mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 19:14:55 +00:00
initial commit wiring up MessageBrowser
This commit is contained in:
parent
1aaa76efc6
commit
dd948ea878
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2017 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.communications;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.openide.nodes.FilterNode;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
|
||||
import org.sleuthkit.datamodel.Account;
|
||||
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.CommunicationsManager;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
class AccountDetailsNode extends FilterNode {
|
||||
|
||||
/**
|
||||
* @param wrappedNode the value of selectedNode
|
||||
*/
|
||||
AccountDetailsNode(AccountDeviceInstanceNode wrappedNode) throws TskCoreException {
|
||||
super(wrappedNode, new AccountRelationshipChildren(wrappedNode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Children object for the relationships that the account is a member of.
|
||||
*/
|
||||
private static class AccountRelationshipChildren extends Children.Keys<BlackboardArtifact> {
|
||||
|
||||
private final AccountDeviceInstanceNode wrappedNode;
|
||||
|
||||
private AccountRelationshipChildren(AccountDeviceInstanceNode wrappedNode) {
|
||||
this.wrappedNode = wrappedNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Node[] createNodes(BlackboardArtifact t) {
|
||||
|
||||
final RelationShipFilterNode blackboardArtifactNode = new RelationShipFilterNode(new BlackboardArtifactNode(t));
|
||||
return new Node[]{blackboardArtifactNode};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addNotify() {
|
||||
try {
|
||||
AccountDeviceInstance adi = wrappedNode.getLookup().lookup(AccountDeviceInstance.class);
|
||||
CommunicationsManager communicationsManager = wrappedNode.getLookup().lookup(CommunicationsManager.class);
|
||||
List<Account> accountsWithRelationship = communicationsManager.getAccountsWithRelationship(adi.getAccount());
|
||||
Set<BlackboardArtifact> keys = new HashSet<>();
|
||||
|
||||
accountsWithRelationship.forEach(account -> {
|
||||
try {
|
||||
keys.addAll(communicationsManager.getRelationships(adi.getAccount(), account));
|
||||
} catch (TskCoreException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
}
|
||||
});
|
||||
|
||||
setKeys(keys);
|
||||
} catch (TskCoreException ex) {
|
||||
//TODO: proper logging
|
||||
Exceptions.printStackTrace(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -25,10 +25,10 @@ import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.lookup.Lookups;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||
import org.sleuthkit.datamodel.CommunicationsFilter;
|
||||
import org.sleuthkit.datamodel.CommunicationsManager;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
@ -38,10 +38,12 @@ class AccountDeviceInstanceNode extends AbstractNode {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(AccountDeviceInstanceNode.class.getName());
|
||||
private final AccountDeviceInstance accountDeviceInstance;
|
||||
private final CommunicationsManager commsManager;
|
||||
|
||||
AccountDeviceInstanceNode(AccountDeviceInstance accountDeviceInstance) {
|
||||
super(Children.LEAF, Lookups.fixed(accountDeviceInstance));
|
||||
AccountDeviceInstanceNode(AccountDeviceInstance accountDeviceInstance, CommunicationsManager commsManager) {
|
||||
super(Children.LEAF, Lookups.fixed(accountDeviceInstance, commsManager));
|
||||
this.accountDeviceInstance = accountDeviceInstance;
|
||||
this.commsManager = commsManager;
|
||||
setName(accountDeviceInstance.getAccount().getAccountUniqueID());
|
||||
setIconBaseWithExtension("org/sleuthkit/autopsy/communications/images/"
|
||||
+ AccountUtils.getIconFileName(accountDeviceInstance.getAccount().getAccountType()));
|
||||
@ -67,7 +69,7 @@ class AccountDeviceInstanceNode extends AbstractNode {
|
||||
long msgCount = 0;
|
||||
try {
|
||||
CommunicationsFilter filter = null;
|
||||
msgCount = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager().getRelationshipsCount(filter, accountDeviceInstance);
|
||||
msgCount = commsManager.getRelationshipsCount(filter, accountDeviceInstance);
|
||||
} catch (TskCoreException ex) {
|
||||
LOGGER.log(Level.WARNING, "Failed to get message count for account", ex); //NON-NLS
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2017 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.communications;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Node;
|
||||
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||
|
||||
class AccountDeviceInstancesNodeChildren extends Children.Keys<AccountDeviceInstance> {
|
||||
|
||||
private final List<AccountDeviceInstance> accountDeviceInstances;
|
||||
|
||||
AccountDeviceInstancesNodeChildren(List<AccountDeviceInstance> accountDeviceInstances) {
|
||||
super(true);
|
||||
this.accountDeviceInstances = accountDeviceInstances;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeNotify() {
|
||||
super.removeNotify();
|
||||
setKeys(Collections.emptySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addNotify() {
|
||||
super.addNotify();
|
||||
setKeys(accountDeviceInstances);
|
||||
}
|
||||
|
||||
//These are the methods for ChildFactory. I am going to keep them around but commented until we make a final descision.
|
||||
// @Override
|
||||
// protected boolean createKeys(List<Account> list) {
|
||||
// list.addAll(accounts);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected Node createNodeForKey(Account key) {
|
||||
// return new AccountDeviceInstanceNode(key);
|
||||
// }
|
||||
@Override
|
||||
protected Node[] createNodes(AccountDeviceInstance key) {
|
||||
return new Node[]{new AccountDeviceInstanceNode(key)};
|
||||
}
|
||||
}
|
@ -23,14 +23,17 @@ import java.util.List;
|
||||
import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Node;
|
||||
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||
import org.sleuthkit.datamodel.CommunicationsManager;
|
||||
|
||||
class AccountsDeviceInstanceChildren extends Children.Keys<AccountDeviceInstance> {
|
||||
|
||||
private final List<AccountDeviceInstance> accountDeviceInstances;
|
||||
private final CommunicationsManager commsManager;
|
||||
|
||||
AccountsDeviceInstanceChildren(List<AccountDeviceInstance> accountDeviceInstances) {
|
||||
AccountsDeviceInstanceChildren(List<AccountDeviceInstance> accountDeviceInstances, CommunicationsManager commsManager) {
|
||||
super(true);
|
||||
this.accountDeviceInstances = accountDeviceInstances;
|
||||
this.commsManager = commsManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,6 +61,6 @@ class AccountsDeviceInstanceChildren extends Children.Keys<AccountDeviceInstance
|
||||
// }
|
||||
@Override
|
||||
protected Node[] createNodes(AccountDeviceInstance key) {
|
||||
return new Node[]{new AccountDeviceInstanceNode(key)};
|
||||
return new Node[]{new AccountDeviceInstanceNode(key, commsManager)};
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.communications;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.openide.explorer.ExplorerManager;
|
||||
@ -45,20 +44,12 @@ public final class CVTTopComponent extends TopComponent implements ExplorerManag
|
||||
|
||||
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
||||
private final ExplorerManager em = new ExplorerManager();
|
||||
private final ExplorerManager messageExplorerManager;
|
||||
|
||||
public CVTTopComponent() {
|
||||
|
||||
initComponents();
|
||||
setName(Bundle.CVTTopComponent_name());
|
||||
messageExplorerManager = new ExplorerManager();
|
||||
splitPane.setRightComponent(new MessageBrowser(messageExplorerManager));
|
||||
|
||||
em.addPropertyChangeListener((PropertyChangeEvent evt) -> {
|
||||
if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
|
||||
|
||||
messageExplorerManager.setRootContext(em.getSelectedNodes()[0]);
|
||||
}
|
||||
});
|
||||
splitPane.setRightComponent(new MessageBrowser());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,11 +33,11 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
|
||||
import org.sleuthkit.datamodel.Account;
|
||||
import org.sleuthkit.datamodel.AccountDeviceInstance;
|
||||
import org.sleuthkit.datamodel.AccountTypeFilter;
|
||||
import org.sleuthkit.datamodel.CommunicationsFilter;
|
||||
import org.sleuthkit.datamodel.CommunicationsManager;
|
||||
import org.sleuthkit.datamodel.DataSource;
|
||||
import org.sleuthkit.datamodel.DeviceFilter;
|
||||
import org.sleuthkit.datamodel.AccountTypeFilter;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
@ -307,7 +307,7 @@ final public class FiltersPanel extends javax.swing.JPanel {
|
||||
final CommunicationsManager communicationsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
|
||||
accountDeviceInstances.addAll(communicationsManager.getAccountDeviceInstancesWithRelationships(commsFilter));
|
||||
|
||||
em.setRootContext(new AbstractNode(new AccountsDeviceInstanceChildren(accountDeviceInstances)));
|
||||
em.setRootContext(new AbstractNode(new AccountsDeviceInstanceChildren(accountDeviceInstances, communicationsManager)));
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.SEVERE, "There was a error loading the accounts.", ex);
|
||||
}
|
||||
|
@ -1,20 +1,89 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2017 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obt ain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.communications;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import org.openide.explorer.ExplorerManager;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataContentPanel;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
|
||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* The right hand side of the CVT. Has a DataResultPanel to show messages and
|
||||
* account details, and a Content viewer to show individual
|
||||
*/
|
||||
final class MessageBrowser extends javax.swing.JPanel implements ExplorerManager.Provider {
|
||||
|
||||
private final ExplorerManager em;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
MessageBrowser(ExplorerManager em) {
|
||||
this.em = em;
|
||||
private ExplorerManager parentExplorereManager;
|
||||
private final DataContentPanel customContentView;
|
||||
private final DataResultPanel messagesResultPanel;
|
||||
private ExplorerManager internalExplorerManager;
|
||||
|
||||
splitPane }
|
||||
MessageBrowser() {
|
||||
initComponents();
|
||||
customContentView = DataContentPanel.createInstance();
|
||||
messagesResultPanel = DataResultPanel.createInstanceUninitialized("Account", "", Node.EMPTY, 0, customContentView);
|
||||
splitPane.setTopComponent(messagesResultPanel);
|
||||
splitPane.setBottomComponent(customContentView);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
this.parentExplorereManager = ExplorerManager.find(this);
|
||||
|
||||
internalExplorerManager = new ExplorerManager();
|
||||
|
||||
parentExplorereManager.addPropertyChangeListener((PropertyChangeEvent evt) -> {
|
||||
if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
|
||||
final Node[] selectedNodes = parentExplorereManager.getSelectedNodes();
|
||||
switch (selectedNodes.length) {
|
||||
case 0:
|
||||
messagesResultPanel.setNode(null);
|
||||
break;
|
||||
case 1:
|
||||
final Node selectedNode = selectedNodes[0];
|
||||
if (selectedNode instanceof AccountDeviceInstanceNode) {
|
||||
try {
|
||||
final AccountDetailsNode accountDetailsNode = new AccountDetailsNode((AccountDeviceInstanceNode) selectedNode);
|
||||
messagesResultPanel.setNode(new TableFilterNode(accountDetailsNode, true));
|
||||
} catch (TskCoreException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
}
|
||||
} else {
|
||||
internalExplorerManager.setRootContext(selectedNode);
|
||||
}
|
||||
break;
|
||||
// TODO: fill in multiseelct support
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
messagesResultPanel.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@ -53,6 +122,6 @@ splitPane }
|
||||
|
||||
@Override
|
||||
public ExplorerManager getExplorerManager() {
|
||||
return em;
|
||||
return internalExplorerManager;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.communications;
|
||||
|
||||
import org.openide.nodes.FilterNode;
|
||||
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class RelationShipFilterNode extends FilterNode {
|
||||
|
||||
private final BlackboardArtifactNode wrappedNode;
|
||||
|
||||
public RelationShipFilterNode(BlackboardArtifactNode wrappedNode) {
|
||||
super(wrappedNode, Children.LEAF);
|
||||
this.wrappedNode = wrappedNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertySet[] getPropertySets() {
|
||||
PropertySet[] propertySets = super.getPropertySets();
|
||||
for (PropertySet set : propertySets) {
|
||||
for (Property<?> p : set.getProperties()) {
|
||||
// p.getName().equals();
|
||||
}
|
||||
}
|
||||
return propertySets;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user