Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AccountDeviceInstanceNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-18 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications;
20 
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import javax.swing.Action;
24 import org.openide.nodes.AbstractNode;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
28 import org.openide.util.lookup.Lookups;
30 import org.sleuthkit.datamodel.Account;
31 import org.sleuthkit.datamodel.AccountDeviceInstance;
32 import org.sleuthkit.datamodel.CommunicationsFilter;
33 import org.sleuthkit.datamodel.CommunicationsManager;
34 
38 final class AccountDeviceInstanceNode extends AbstractNode {
39 
40  private final AccountDeviceInstanceKey accountDeviceInstanceKey;
41  private final CommunicationsManager commsManager;
42  private final Account account;
43 
44  AccountDeviceInstanceNode(AccountDeviceInstanceKey accountDeviceInstanceKey, CommunicationsManager commsManager) {
45  super(Children.LEAF, Lookups.fixed(accountDeviceInstanceKey, commsManager));
46  this.accountDeviceInstanceKey = accountDeviceInstanceKey;
47  this.commsManager = commsManager;
48  this.account = accountDeviceInstanceKey.getAccountDeviceInstance().getAccount();
49  setName(account.getTypeSpecificID());
50  setDisplayName(getName());
51  setIconBaseWithExtension(Utils.getIconFilePath(account.getAccountType()));
52  }
53 
54  AccountDeviceInstance getAccountDeviceInstance() {
55  return accountDeviceInstanceKey.getAccountDeviceInstance();
56  }
57 
58  AccountDeviceInstanceKey getAccountDeviceInstanceKey() {
59  return accountDeviceInstanceKey;
60  }
61 
62  CommunicationsManager getCommsManager() {
63  return commsManager;
64  }
65 
66  long getMessageCount() {
67  return accountDeviceInstanceKey.getMessageCount();
68  }
69 
70  CommunicationsFilter getFilter() {
71  return accountDeviceInstanceKey.getCommunicationsFilter();
72  }
73 
74  @Override
75  @NbBundle.Messages(value = {"AccountNode.device=Device", "AccountNode.accountName=Account", "AccountNode.accountType=Type", "AccountNode.messageCount=Msgs"})
76  protected Sheet createSheet() {
77  Sheet sheet = super.createSheet();
78  Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
79  if (properties == null) {
80  properties = Sheet.createPropertiesSet();
81  sheet.put(properties);
82  }
83  properties.put(new NodeProperty<>("type",
84  Bundle.AccountNode_accountType(),
85  "type",
86  account.getAccountType().getDisplayName())); // NON-NLS
87  properties.put(new NodeProperty<>("count",
88  Bundle.AccountNode_messageCount(),
89  "count",
90  accountDeviceInstanceKey.getMessageCount())); // NON-NLS
91  properties.put(new NodeProperty<>("device",
92  Bundle.AccountNode_device(),
93  "device",
94  accountDeviceInstanceKey.getDataSourceName())); // NON-NLS
95  return sheet;
96  }
97 
98  @Override
99  public Action[] getActions(boolean context) {
100  ArrayList<Action> actions = new ArrayList<>(Arrays.asList(super.getActions(context)));
101  actions.add(PinAccountsAction.getInstance());
102  actions.add(ResetAndPinAccountsAction.getInstance());
103  return actions.toArray(new Action[actions.size()]);
104  }
105 }

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.