mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
refactor and cleanup slightly
This commit is contained in:
parent
ca36a50b16
commit
974bf77fc8
@ -39,7 +39,7 @@ class AccountDetailsNode extends AbstractNode {
|
||||
private final CommunicationsFilter filter; //TODO: Use this
|
||||
|
||||
AccountDetailsNode(Set<Account> accounts,CommunicationsFilter filter, CommunicationsManager commsManager) {
|
||||
super(new AccountRelationshipChildren(accounts, commsManager));
|
||||
super(new AccountRelationshipChildren(accounts, commsManager, filter));
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@ -50,10 +50,12 @@ class AccountDetailsNode extends AbstractNode {
|
||||
|
||||
private final Set<Account> accounts;
|
||||
private final CommunicationsManager commsManager;
|
||||
private final CommunicationsFilter filter;//TODO: Use this
|
||||
|
||||
private AccountRelationshipChildren(Set<Account> accounts, CommunicationsManager commsManager) {
|
||||
private AccountRelationshipChildren(Set<Account> accounts, CommunicationsManager commsManager, CommunicationsFilter filter) {
|
||||
this.accounts = accounts;
|
||||
this.commsManager = commsManager;
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -67,14 +69,14 @@ class AccountDetailsNode extends AbstractNode {
|
||||
for (Account account : accounts) {
|
||||
List<Account> accountsWithRelationship = new ArrayList<>();
|
||||
try {
|
||||
accountsWithRelationship.addAll(commsManager.getAccountsWithRelationship(account)); //TODO: Use filter
|
||||
accountsWithRelationship.addAll(commsManager.getAccountsWithRelationship(account)); //TODO: Use filter here
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.WARNING, "Error loading with relationships to " + account, ex);
|
||||
}
|
||||
|
||||
accountsWithRelationship.forEach(otherAcount -> {
|
||||
try {
|
||||
keys.addAll(commsManager.getRelationships(account, otherAcount)); //TODO:Use filter
|
||||
keys.addAll(commsManager.getRelationships(account, otherAcount)); //TODO:Use filter here
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.WARNING, "Error loading relationships between " + account + " and " + otherAcount, ex);
|
||||
}
|
||||
@ -83,5 +85,4 @@ class AccountDetailsNode extends AbstractNode {
|
||||
setKeys(keys);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,13 +18,16 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.communications;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.explorer.ExplorerManager;
|
||||
import org.openide.nodes.Node;
|
||||
import org.sleuthkit.autopsy.communications.AccountsRootChildren.AccountDeviceInstanceNode;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
|
||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.Account;
|
||||
import org.sleuthkit.datamodel.CommunicationsFilter;
|
||||
import org.sleuthkit.datamodel.CommunicationsManager;
|
||||
@ -35,6 +38,8 @@ import org.sleuthkit.datamodel.CommunicationsManager;
|
||||
*/
|
||||
final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager.Provider {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MessageBrowser.class.getName());
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ExplorerManager parentExplorereManager;
|
||||
@ -59,32 +64,37 @@ final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager
|
||||
parentExplorereManager.addPropertyChangeListener(pce -> {
|
||||
if (pce.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
|
||||
final Node[] selectedNodes = parentExplorereManager.getSelectedNodes();
|
||||
switch (selectedNodes.length) {
|
||||
case 0:
|
||||
messagesResultPanel.setNode(null);
|
||||
break;
|
||||
default:
|
||||
Set<Account> accounts = new HashSet<>();
|
||||
CommunicationsFilter filter = null;
|
||||
CommunicationsManager commsManager = null;
|
||||
for (Node n : selectedNodes) {
|
||||
if (n instanceof AccountDeviceInstanceNode) {
|
||||
final AccountDeviceInstanceNode adiNode = (AccountDeviceInstanceNode) n;
|
||||
accounts.add(adiNode.getAccountDeviceInstance().getAccount());
|
||||
if (commsManager == null) {
|
||||
commsManager = adiNode.getCommsManager();
|
||||
}
|
||||
if (filter == null) {
|
||||
filter = adiNode.getFilter();
|
||||
} else if (filter != adiNode.getFilter()) {
|
||||
//different filters ..... exception?
|
||||
}
|
||||
} else {
|
||||
///this should never happen...
|
||||
if (selectedNodes.length == 0) {
|
||||
messagesResultPanel.setNode(null);
|
||||
messagesResultPanel.setPath("");
|
||||
} else {
|
||||
Set<Account> accounts = new HashSet<>();
|
||||
CommunicationsFilter filter = null;
|
||||
CommunicationsManager commsManager = null;
|
||||
for (Node n : selectedNodes) {
|
||||
if (n instanceof AccountDeviceInstanceNode) {
|
||||
final AccountDeviceInstanceNode adiNode = (AccountDeviceInstanceNode) n;
|
||||
accounts.add(adiNode.getAccountDeviceInstance().getAccount());
|
||||
if (commsManager == null) {
|
||||
commsManager = adiNode.getCommsManager();
|
||||
}
|
||||
if (filter == null) {
|
||||
filter = adiNode.getFilter();
|
||||
} else if (filter != adiNode.getFilter()) {
|
||||
///this should never happen...
|
||||
logger.log(Level.WARNING, "Not all AccountDeviceInstanceNodes have the same filter. Using the first.");
|
||||
}
|
||||
} else {
|
||||
///this should never happen...
|
||||
logger.log(Level.WARNING, "Unexpected Node encountered: " + n.toString());
|
||||
}
|
||||
messagesResultPanel.setNode(new TableFilterNode(new AccountDetailsNode(accounts, filter, commsManager), true));
|
||||
break;
|
||||
}
|
||||
messagesResultPanel.setNode(new TableFilterNode(new AccountDetailsNode(accounts, filter, commsManager), true));
|
||||
if (accounts.size() == 1) {
|
||||
messagesResultPanel.setPath(Iterables.getOnlyElement(accounts).getAccountUniqueID());
|
||||
} else {
|
||||
messagesResultPanel.setPath(accounts.size() + " accounts");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user