19 package org.sleuthkit.autopsy.communications;
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;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME;
42 final class AccountDeviceInstanceNode
extends AbstractNode {
44 private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNode.class.getName());
46 private final AccountDeviceInstanceKey accountDeviceInstanceKey;
47 private final CommunicationsManager commsManager;
48 private final Account account;
50 private static final BlackboardAttribute.Type NAME_ATTRIBUTE =
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_NAME.getTypeID()));
52 AccountDeviceInstanceNode(AccountDeviceInstanceKey accountDeviceInstanceKey, CommunicationsManager commsManager) {
53 super(Children.LEAF, Lookups.fixed(accountDeviceInstanceKey, commsManager));
54 this.accountDeviceInstanceKey = accountDeviceInstanceKey;
55 this.commsManager = commsManager;
56 this.account = accountDeviceInstanceKey.getAccountDeviceInstance().getAccount();
57 setName(account.getTypeSpecificID());
58 setDisplayName(getName());
59 String iconPath = Utils.getIconFilePath(account.getAccountType());
60 this.setIconBaseWithExtension(iconPath != null && iconPath.charAt(0) ==
'/' ? iconPath.substring(1) : iconPath);
63 AccountDeviceInstance getAccountDeviceInstance() {
64 return accountDeviceInstanceKey.getAccountDeviceInstance();
67 AccountDeviceInstanceKey getAccountDeviceInstanceKey() {
68 return accountDeviceInstanceKey;
71 CommunicationsManager getCommsManager() {
75 long getMessageCount() {
76 return accountDeviceInstanceKey.getMessageCount();
79 CommunicationsFilter getFilter() {
80 return accountDeviceInstanceKey.getCommunicationsFilter();
84 @NbBundle.Messages(value = {
"AccountNode.device=Device",
"AccountNode.accountName=Account",
"AccountNode.accountType=Type",
"AccountNode.messageCount=Items"})
85 protected Sheet createSheet() {
86 Sheet sheet = super.createSheet();
87 Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
88 if (properties == null) {
89 properties = Sheet.createPropertiesSet();
90 sheet.put(properties);
92 properties.put(
new NodeProperty<>(
"type",
93 Bundle.AccountNode_accountType(),
95 account.getAccountType().getDisplayName()));
96 properties.put(
new NodeProperty<>(
"count",
97 Bundle.AccountNode_messageCount(),
99 accountDeviceInstanceKey.getMessageCount()));
100 properties.put(
new NodeProperty<>(
"device",
101 Bundle.AccountNode_device(),
103 accountDeviceInstanceKey.getDataSourceName()));
108 public Action[] getActions(
boolean context) {
109 ArrayList<Action> actions =
new ArrayList<>();
110 actions.add(PinAccountsAction.getInstance());
111 actions.add(ResetAndPinAccountsAction.getInstance());
113 actions.addAll(Arrays.asList(super.getActions(context)));
114 return actions.toArray(
new Action[actions.size()]);
118 public String getShortDescription() {
119 return RelationshipsNodeUtilities.getAccoutToolTipText(getDisplayName(), account);