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;
38 final class AccountDeviceInstanceNode
extends AbstractNode {
40 private final AccountDeviceInstanceKey accountDeviceInstanceKey;
41 private final CommunicationsManager commsManager;
42 private final Account account;
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()));
54 AccountDeviceInstance getAccountDeviceInstance() {
55 return accountDeviceInstanceKey.getAccountDeviceInstance();
58 AccountDeviceInstanceKey getAccountDeviceInstanceKey() {
59 return accountDeviceInstanceKey;
62 CommunicationsManager getCommsManager() {
66 long getMessageCount() {
67 return accountDeviceInstanceKey.getMessageCount();
70 CommunicationsFilter getFilter() {
71 return accountDeviceInstanceKey.getCommunicationsFilter();
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);
83 properties.put(
new NodeProperty<>(
"type",
84 Bundle.AccountNode_accountType(),
86 account.getAccountType().getDisplayName()));
87 properties.put(
new NodeProperty<>(
"count",
88 Bundle.AccountNode_messageCount(),
90 accountDeviceInstanceKey.getMessageCount()));
91 properties.put(
new NodeProperty<>(
"device",
92 Bundle.AccountNode_device(),
94 accountDeviceInstanceKey.getDataSourceName()));
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()]);