change to ChildFactory, do CommunicationsManager calls off the EDT

This commit is contained in:
millmanorama 2017-11-20 14:57:44 +01:00
parent 183daff325
commit f47edb131e
6 changed files with 135 additions and 88 deletions

View File

@ -18,17 +18,16 @@
*/ */
package org.sleuthkit.autopsy.communications; package org.sleuthkit.autopsy.communications;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.AccountDeviceInstance;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.CommunicationsFilter; import org.sleuthkit.datamodel.CommunicationsFilter;
import org.sleuthkit.datamodel.CommunicationsManager; import org.sleuthkit.datamodel.CommunicationsManager;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* 'Root' Node for the Account/Messages area. Has children which are all the * 'Root' Node for the Account/Messages area. Has children which are all the
@ -39,37 +38,43 @@ class AccountDetailsNode extends AbstractNode {
private final static Logger logger = Logger.getLogger(AccountDetailsNode.class.getName()); private final static Logger logger = Logger.getLogger(AccountDetailsNode.class.getName());
AccountDetailsNode(Set<AccountDeviceInstance> accountDeviceInstances, CommunicationsFilter filter, CommunicationsManager commsManager) { AccountDetailsNode(Set<BlackboardArtifact> accountDeviceInstances, CommunicationsFilter filter, CommunicationsManager commsManager) {
super(new AccountRelationshipChildren(accountDeviceInstances, commsManager, filter)); super(Children.create(new AccountRelationshipChildren(accountDeviceInstances, commsManager, filter), true));
} }
/** /**
* Children object for the relationships that the accounts are part of. * Children object for the relationships that the accounts are part of.
*/ */
private static class AccountRelationshipChildren extends Children.Keys<BlackboardArtifact> { private static class AccountRelationshipChildren extends ChildFactory<BlackboardArtifact> {
private final Set<AccountDeviceInstance> accountDeviceInstances; private final Set<BlackboardArtifact> accountDeviceInstances;
private final CommunicationsManager commsManager; private final CommunicationsManager commsManager;
private final CommunicationsFilter filter; private final CommunicationsFilter filter;
private AccountRelationshipChildren(Set<AccountDeviceInstance> accountDeviceInstances, CommunicationsManager commsManager, CommunicationsFilter filter) { private AccountRelationshipChildren(Set<BlackboardArtifact> accountDeviceInstances, CommunicationsManager commsManager, CommunicationsFilter filter) {
this.accountDeviceInstances = accountDeviceInstances; this.accountDeviceInstances = accountDeviceInstances;
this.commsManager = commsManager; this.commsManager = commsManager;
this.filter = filter; this.filter = filter;
} }
@Override @Override
protected Node[] createNodes(BlackboardArtifact key) { protected boolean createKeys(List<BlackboardArtifact> list) {
return new Node[]{new RelationShipNode(key)}; list.addAll(accountDeviceInstances);
return true;
} }
@Override @Override
protected void addNotify() { protected Node createNodeForKey(BlackboardArtifact t) {
try { return new RelationShipNode(t); //To change body of generated methods, choose Tools | Templates.
setKeys(commsManager.getCommunications(accountDeviceInstances, filter)); }
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error loading communications for accounts. ", ex); // @Override
} // protected Node[] createNodes(BlackboardArtifact key) {
} // return new Node[]{new RelationShipNode(key)};
// }
// @Override
// protected void addNotify() {
// setKeys(accountDeviceInstances);
// }
} }
} }

View File

@ -26,14 +26,18 @@ import org.sleuthkit.datamodel.CommunicationsFilter;
* *
* Encapsulates a AccountDeviceInstance, and CommunicationsFilter. * Encapsulates a AccountDeviceInstance, and CommunicationsFilter.
*/ */
public class AccountDeviceInstanceKey { class AccountDeviceInstanceKey {
private final AccountDeviceInstance accountDeviceInstance; private final AccountDeviceInstance accountDeviceInstance;
private final CommunicationsFilter filter; private final CommunicationsFilter filter;
private final long messageCount;
AccountDeviceInstanceKey(AccountDeviceInstance accountDeviceInstance, CommunicationsFilter filter) {
AccountDeviceInstanceKey(AccountDeviceInstance accountDeviceInstance, CommunicationsFilter filter, long msgCount) {
this.accountDeviceInstance = accountDeviceInstance; this.accountDeviceInstance = accountDeviceInstance;
this.filter = filter; this.filter = filter;
this.messageCount = msgCount;
} }
AccountDeviceInstance getAccountDeviceInstance() { AccountDeviceInstance getAccountDeviceInstance() {
@ -43,4 +47,8 @@ public class AccountDeviceInstanceKey {
CommunicationsFilter getCommunicationsFilter() { CommunicationsFilter getCommunicationsFilter() {
return filter; return filter;
} }
long getMessageCount() {
return messageCount;
}
} }

View File

@ -18,59 +18,59 @@
*/ */
package org.sleuthkit.autopsy.communications; package org.sleuthkit.autopsy.communications;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.datamodel.NodeProperty; import org.sleuthkit.autopsy.datamodel.NodeProperty;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.AccountDeviceInstance; import org.sleuthkit.datamodel.AccountDeviceInstance;
import org.sleuthkit.datamodel.CommunicationsFilter; import org.sleuthkit.datamodel.CommunicationsFilter;
import org.sleuthkit.datamodel.CommunicationsManager; import org.sleuthkit.datamodel.CommunicationsManager;
import org.sleuthkit.datamodel.TskCoreException;
class AccountsRootChildren extends Children.Keys<AccountDeviceInstanceKey> { class AccountsRootChildren extends ChildFactory<AccountDeviceInstanceKey> {
private final List<AccountDeviceInstanceKey> accountDeviceInstanceKeys; private final List<AccountDeviceInstanceKey> accountDeviceInstanceKeys;
private final CommunicationsManager commsManager; private final CommunicationsManager commsManager;
AccountsRootChildren(List<AccountDeviceInstanceKey> accountDeviceInstanceKeys, CommunicationsManager commsManager) { AccountsRootChildren(List<AccountDeviceInstanceKey> accountDeviceInstanceKeys, CommunicationsManager commsManager) {
super(true); super();
this.accountDeviceInstanceKeys = accountDeviceInstanceKeys; this.accountDeviceInstanceKeys = accountDeviceInstanceKeys;
this.commsManager = commsManager; this.commsManager = commsManager;
} }
//these are the methods for Children.Keys
@Override
protected void removeNotify() {
super.removeNotify();
setKeys(Collections.emptySet());
}
@Override
protected void addNotify() {
super.addNotify();
setKeys(accountDeviceInstanceKeys);
}
//These are the methods for ChildFactory. I am going to keep them around but commented until we make a final descision.
// @Override // @Override
// protected boolean createKeys(List<Account> list) { // protected void removeNotify() {
// list.addAll(accounts); // super.removeNotify();
// return true; // setKeys(Collections.emptySet());
// } // }
// //
// @Override // @Override
// protected Node createNodeForKey(Account key) { // protected void addNotify() {
// return new AccountDeviceInstanceNode(key); // super.addNotify();
// setKeys(accountDeviceInstanceKeys);
// } // }
// @Override
// protected Node[] createNodes(AccountDeviceInstanceKey key) {
// return new Node[]{new AccountDeviceInstanceNode(key, commsManager)};
// }
//These are the methods for ChildFactory. I am going to keep them around but commented until we make a final descision.
@Override @Override
protected Node[] createNodes(AccountDeviceInstanceKey key) { protected boolean createKeys(List<AccountDeviceInstanceKey> list) {
return new Node[]{new AccountDeviceInstanceNode(key, commsManager)}; list.addAll(accountDeviceInstanceKeys);
return true;
}
@Override
protected Node createNodeForKey(AccountDeviceInstanceKey key) {
return new AccountDeviceInstanceNode(key, commsManager);
} }
/** /**
@ -79,21 +79,21 @@ class AccountsRootChildren extends Children.Keys<AccountDeviceInstanceKey> {
static class AccountDeviceInstanceNode extends AbstractNode { static class AccountDeviceInstanceNode extends AbstractNode {
private static final Logger LOGGER = Logger.getLogger(AccountDeviceInstanceNode.class.getName()); private static final Logger LOGGER = Logger.getLogger(AccountDeviceInstanceNode.class.getName());
private final AccountDeviceInstance accountDeviceInstance; private final AccountDeviceInstanceKey accountDeviceInstanceKey;
private final CommunicationsManager commsManager; private final CommunicationsManager commsManager;
private final CommunicationsFilter filter; private final Account account;
private AccountDeviceInstanceNode(AccountDeviceInstanceKey accountDeviceInstanceKey, CommunicationsManager commsManager) { private AccountDeviceInstanceNode(AccountDeviceInstanceKey accountDeviceInstanceKey, CommunicationsManager commsManager) {
super(Children.LEAF, Lookups.fixed(accountDeviceInstanceKey, commsManager)); super(Children.LEAF, Lookups.fixed(accountDeviceInstanceKey, commsManager));
this.accountDeviceInstance = accountDeviceInstanceKey.getAccountDeviceInstance(); this.accountDeviceInstanceKey = accountDeviceInstanceKey;
this.commsManager = commsManager; this.commsManager = commsManager;
this.filter = accountDeviceInstanceKey.getCommunicationsFilter(); this.account = accountDeviceInstanceKey.getAccountDeviceInstance().getAccount();
setName(accountDeviceInstance.getAccount().getAccountUniqueID()); setName(account.getAccountUniqueID());
setIconBaseWithExtension("org/sleuthkit/autopsy/communications/images/" + Utils.getIconFileName(accountDeviceInstance.getAccount().getAccountType())); setIconBaseWithExtension("org/sleuthkit/autopsy/communications/images/" + Utils.getIconFileName(account.getAccountType()));
} }
public AccountDeviceInstance getAccountDeviceInstance() { public AccountDeviceInstance getAccountDeviceInstance() {
return accountDeviceInstance; return accountDeviceInstanceKey.getAccountDeviceInstance();
} }
public CommunicationsManager getCommsManager() { public CommunicationsManager getCommsManager() {
@ -101,7 +101,7 @@ class AccountsRootChildren extends Children.Keys<AccountDeviceInstanceKey> {
} }
public CommunicationsFilter getFilter() { public CommunicationsFilter getFilter() {
return filter; return accountDeviceInstanceKey.getCommunicationsFilter();
} }
@Override @Override
@ -116,15 +116,13 @@ class AccountsRootChildren extends Children.Keys<AccountDeviceInstanceKey> {
properties = Sheet.createPropertiesSet(); properties = Sheet.createPropertiesSet();
s.put(properties); s.put(properties);
} }
long msgCount = 0;
try { properties.put(new NodeProperty<>("type", Bundle.AccountNode_accountType(), "type",
msgCount = commsManager.getCommunicationsCount(accountDeviceInstance, filter ); account.getAccountType().getDisplayName())); // NON-NLS
} catch (TskCoreException ex) { properties.put(new NodeProperty<>("count", Bundle.AccountNode_messageCount(), "count",
LOGGER.log(Level.WARNING, "Failed to get message count for account", ex); //NON-NLS accountDeviceInstanceKey.getMessageCount())); // NON-NLS
} properties.put(new NodeProperty<>("device", Bundle.AccountNode_device(), "device",
properties.put(new NodeProperty<>("type", Bundle.AccountNode_accountType(), "type", accountDeviceInstance.getAccount().getAccountType().getDisplayName())); // NON-NLS accountDeviceInstanceKey.getAccountDeviceInstance().getDeviceId())); // NON-NLS
properties.put(new NodeProperty<>("count", Bundle.AccountNode_messageCount(), "count", msgCount)); // NON-NLS
properties.put(new NodeProperty<>("device", Bundle.AccountNode_device(), "device", accountDeviceInstance.getDeviceId())); // NON-NLS
return s; return s;
} }
} }

View File

@ -68,15 +68,15 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="filtersTitleLabel"> <Component class="javax.swing.JLabel" name="filtersTitleLabel">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="16" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/sleuthkit/autopsy/communications/images/funnel.png"/> <Image iconType="3" name="/org/sleuthkit/autopsy/communications/images/funnel.png"/>
</Property> </Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/communications/Bundle.properties" key="FiltersPanel.filtersTitleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/communications/Bundle.properties" key="FiltersPanel.filtersTitleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="16" style="0"/>
</Property>
</Properties> </Properties>
</Component> </Component>
<Container class="javax.swing.JPanel" name="jPanel2"> <Container class="javax.swing.JPanel" name="jPanel2">
@ -271,13 +271,13 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="startDatePicker" min="-2" pref="162" max="-2" attributes="0"/> <Component id="startDatePicker" min="-2" pref="162" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="endCheckBox" min="-2" max="-2" attributes="0"/> <Component id="endCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="endDatePicker" min="-2" pref="161" max="-2" attributes="0"/> <Component id="endDatePicker" min="-2" pref="163" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>

View File

@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.communications;
import java.awt.Cursor; import java.awt.Cursor;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -32,10 +33,12 @@ import javax.swing.JCheckBox;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ThreadConfined; import org.sleuthkit.autopsy.coreutils.ThreadConfined;
import org.sleuthkit.datamodel.Account; import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.AccountDeviceInstance;
import org.sleuthkit.datamodel.AccountTypeFilter; import org.sleuthkit.datamodel.AccountTypeFilter;
import org.sleuthkit.datamodel.CommunicationsFilter; import org.sleuthkit.datamodel.CommunicationsFilter;
import org.sleuthkit.datamodel.CommunicationsManager; import org.sleuthkit.datamodel.CommunicationsManager;
@ -53,7 +56,6 @@ final public class FiltersPanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName()); private static final Logger logger = Logger.getLogger(FiltersPanel.class.getName());
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy");
private ExplorerManager em; private ExplorerManager em;
@ThreadConfined(type = ThreadConfined.ThreadType.AWT) @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
@ -67,8 +69,6 @@ final public class FiltersPanel extends javax.swing.JPanel {
endDatePicker.setDateToToday(); endDatePicker.setDateToToday();
startDatePicker.getSettings().setVetoPolicy( startDatePicker.getSettings().setVetoPolicy(
//no end date, or start is before end //no end date, or start is before end
startDate -> endCheckBox.isSelected() == false startDate -> endCheckBox.isSelected() == false
|| startDate.compareTo(endDatePicker.getDate()) <= 0 || startDate.compareTo(endDatePicker.getDate()) <= 0
); );
@ -77,16 +77,15 @@ final public class FiltersPanel extends javax.swing.JPanel {
endDate -> startCheckBox.isSelected() == false endDate -> startCheckBox.isSelected() == false
|| endDate.compareTo(startDatePicker.getDate()) >= 0 || endDate.compareTo(startDatePicker.getDate()) >= 0
); );
applyFiltersButton.addActionListener(actionEvent -> applyFilters());
applyFiltersButton.addActionListener(actionEvent -> applyFilters());
} }
/** /**
* Update the filter widgets, and apply them. * Update the filter widgets, and apply them.
*/ */
void updateAndApplyFilters() { void updateAndApplyFilters() {
updateAccountTypeFilter(); updateFilters();
updateDeviceFilter();
if (em != null) { if (em != null) {
applyFilters(); applyFilters();
} }
@ -94,6 +93,11 @@ final public class FiltersPanel extends javax.swing.JPanel {
dateRangeLabel.setText("Date Range ( " + Utils.getUserPreferredZoneId().getId() + "):"); dateRangeLabel.setText("Date Range ( " + Utils.getUserPreferredZoneId().getId() + "):");
} }
private void updateFilters() {
updateAccountTypeFilter();
updateDeviceFilter();
}
@Override @Override
public void addNotify() { public void addNotify() {
super.addNotify(); super.addNotify();
@ -312,10 +316,10 @@ final public class FiltersPanel extends javax.swing.JPanel {
.addComponent(startCheckBox) .addComponent(startCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(startDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel4Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addComponent(endCheckBox) .addComponent(endCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(endDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
jPanel4Layout.setVerticalGroup( jPanel4Layout.setVerticalGroup(
@ -377,16 +381,18 @@ final public class FiltersPanel extends javax.swing.JPanel {
try { try {
final CommunicationsManager commsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager(); final CommunicationsManager commsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
getRootPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
new SwingWorker<AbstractNode, Void>() { new SwingWorker<AbstractNode, Void>() {
@Override @Override
protected AbstractNode doInBackground() throws Exception { protected AbstractNode doInBackground() throws Exception {
List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = new ArrayList<>();
commsManager.getAccountDeviceInstancesWithCommunications(commsFilter) for (AccountDeviceInstance adi : commsManager.getAccountDeviceInstancesWithCommunications(commsFilter)) {
.stream() long communicationsCount = commsManager.getCommunicationsCount(adi, commsFilter);
.map(adi -> new AccountDeviceInstanceKey(adi, commsFilter)) accountDeviceInstanceKeys.add(new AccountDeviceInstanceKey(adi, commsFilter, communicationsCount));
.collect(Collectors.toList()); };
return new AbstractNode(new AccountsRootChildren(accountDeviceInstanceKeys, commsManager)); return new AbstractNode(Children.create(new AccountsRootChildren(accountDeviceInstanceKeys, commsManager), true));
} }
@Override @Override
@ -394,6 +400,7 @@ final public class FiltersPanel extends javax.swing.JPanel {
super.done(); //To change body of generated methods, choose Tools | Templates. super.done(); //To change body of generated methods, choose Tools | Templates.
setCursor(Cursor.getDefaultCursor()); setCursor(Cursor.getDefaultCursor());
getRootPane().setCursor(Cursor.getDefaultCursor());
try { try {
em.setRootContext(get()); em.setRootContext(get());
} catch (InterruptedException | ExecutionException ex) { } catch (InterruptedException | ExecutionException ex) {

View File

@ -18,17 +18,23 @@
*/ */
package org.sleuthkit.autopsy.communications; package org.sleuthkit.autopsy.communications;
import java.awt.Cursor;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.swing.SwingWorker;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.sleuthkit.autopsy.communications.AccountsRootChildren.AccountDeviceInstanceNode; import org.sleuthkit.autopsy.communications.AccountsRootChildren.AccountDeviceInstanceNode;
import org.sleuthkit.autopsy.corecomponents.DataResultPanel; import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.corecomponents.TableFilterNode; import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.AccountDeviceInstance; import org.sleuthkit.datamodel.AccountDeviceInstance;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.CommunicationsFilter; import org.sleuthkit.datamodel.CommunicationsFilter;
import org.sleuthkit.datamodel.CommunicationsManager; import org.sleuthkit.datamodel.CommunicationsManager;
@ -40,6 +46,8 @@ final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(MessageBrowser.class.getName());
private final DataResultPanel messagesResultPanel; private final DataResultPanel messagesResultPanel;
private final ExplorerManager explorerManager = new ExplorerManager(); private final ExplorerManager explorerManager = new ExplorerManager();
private final DataResultViewerTable dataResultViewerTable = new DataResultViewerTable(explorerManager, "Messages"); private final DataResultViewerTable dataResultViewerTable = new DataResultViewerTable(explorerManager, "Messages");
@ -84,8 +92,29 @@ final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager
.collect(Collectors.toSet()); .collect(Collectors.toSet());
messagesResultPanel.setPath(selectedNodes.length + " accounts"); messagesResultPanel.setPath(selectedNodes.length + " accounts");
} }
messagesResultPanel.setNumMatches(0);
messagesResultPanel.setNode(null);
getRootPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
new SwingWorker<Set<BlackboardArtifact>, Void>() {
@Override
protected Set<BlackboardArtifact> doInBackground() throws Exception {
return commsManager.getCommunications(collect, filter);
}
@Override
protected void done() {
super.done(); //To change body of generated methods, choose Tools | Templates.
try {
messagesResultPanel.setNode(new TableFilterNode( messagesResultPanel.setNode(new TableFilterNode(
new AccountDetailsNode(collect, filter, commsManager), true)); new AccountDetailsNode(get(), filter, commsManager), true));
} catch (InterruptedException | ExecutionException ex) {
logger.log(Level.SEVERE, "Error getting relationships", ex);
}
getRootPane().setCursor(Cursor.getDefaultCursor());
}
}.execute();
} }
} }
}); });