From 806eb76f7fd0933ba98b93cba41912f902cdfda7 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Thu, 2 May 2019 11:43:04 -0400 Subject: [PATCH] inital commit with a message of a merge from my other branch --- ...hildren.java => AttachementsChildren.java} | 44 ++++++++++--------- ...{ThumbnailViewer.form => MediaViewer.form} | 0 ...{ThumbnailViewer.java => MediaViewer.java} | 12 ++--- .../communications/RelationshipBrowser.java | 4 +- .../contentviewers/MessageContentViewer.java | 2 +- .../directorytree/DataResultFilterNode.java | 25 ++++++++++- 6 files changed, 55 insertions(+), 32 deletions(-) rename Core/src/org/sleuthkit/autopsy/communications/{ThumbnailChildren.java => AttachementsChildren.java} (83%) rename Core/src/org/sleuthkit/autopsy/communications/{ThumbnailViewer.form => MediaViewer.form} (100%) rename Core/src/org/sleuthkit/autopsy/communications/{ThumbnailViewer.java => MediaViewer.java} (95%) diff --git a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java b/Core/src/org/sleuthkit/autopsy/communications/AttachementsChildren.java similarity index 83% rename from Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java rename to Core/src/org/sleuthkit/autopsy/communications/AttachementsChildren.java index 30a95f35aa..429e44d2e7 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AttachementsChildren.java @@ -27,7 +27,6 @@ import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode; import org.sleuthkit.autopsy.datamodel.FileNode; @@ -44,11 +43,11 @@ import org.sleuthkit.datamodel.TskCoreException; * the addNotify function in ThumbnailChildNode ends up wtih a list containing * just the wait node and the thumbanils never appear. */ -final class ThumbnailChildren extends Children.Keys { +final class AttachementsChildren extends Children.Keys { - private static final Logger logger = Logger.getLogger(ThumbnailChildren.class.getName()); + private static final Logger logger = Logger.getLogger(AttachementsChildren.class.getName()); - private final Set thumbnails; + private final Set artifacts; /* * Creates the list of thumbnails from the given list of @@ -57,9 +56,21 @@ final class ThumbnailChildren extends Children.Keys { * The thumbnails will be initialls sorted by size, then name so that they * appear sorted by size by default. */ - ThumbnailChildren(Set artifacts) { + AttachementsChildren(Set artifacts) { super(false); - thumbnails = new TreeSet<>((AbstractFile file1, AbstractFile file2) -> { + this.artifacts = artifacts; + } + + @Override + protected Node[] createNodes(AbstractFile t) { + return new Node[]{new AttachmentNode(t)}; + } + + @Override + protected void addNotify() { + super.addNotify(); + + Set attachments = new TreeSet<>((AbstractFile file1, AbstractFile file2) -> { int result = Long.compare(file1.getSize(), file2.getSize()); if (result == 0) { result = file1.getName().compareTo(file2.getName()); @@ -71,33 +82,24 @@ final class ThumbnailChildren extends Children.Keys { artifacts.forEach((bba) -> { try { for (Content childContent : bba.getChildren()) { - if (childContent instanceof AbstractFile && ImageUtils.thumbnailSupported((AbstractFile) childContent)) { - thumbnails.add((AbstractFile) childContent); + if (childContent instanceof AbstractFile) { + attachments.add((AbstractFile) childContent); } } } catch (TskCoreException ex) { logger.log(Level.WARNING, "Unable to get children from artifact.", ex); //NON-NLS } }); - } - @Override - protected Node[] createNodes(AbstractFile t) { - return new Node[]{new ThumbnailNode(t)}; - } - - @Override - protected void addNotify() { - super.addNotify(); - setKeys(thumbnails); + setKeys(attachments); } /** - * A node for representing a thumbnail. + * A node for representing a attachememt. */ - static class ThumbnailNode extends FileNode { + static class AttachmentNode extends FileNode { - ThumbnailNode(AbstractFile file) { + AttachmentNode(AbstractFile file) { super(file, false); } diff --git a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.form b/Core/src/org/sleuthkit/autopsy/communications/MediaViewer.form similarity index 100% rename from Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.form rename to Core/src/org/sleuthkit/autopsy/communications/MediaViewer.form diff --git a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java b/Core/src/org/sleuthkit/autopsy/communications/MediaViewer.java similarity index 95% rename from Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java rename to Core/src/org/sleuthkit/autopsy/communications/MediaViewer.java index a4dea6493f..775f9c5f09 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java +++ b/Core/src/org/sleuthkit/autopsy/communications/MediaViewer.java @@ -46,11 +46,11 @@ import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.TskCoreException; /** - * + * This panel is a RelationshipsViewer panel */ -public class ThumbnailViewer extends JPanel implements RelationshipsViewer, ExplorerManager.Provider, Lookup.Provider { +public class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerManager.Provider, Lookup.Provider { - private static final Logger logger = Logger.getLogger(ThumbnailChildren.class.getName()); + private static final Logger logger = Logger.getLogger(MediaViewer.class.getName()); private final ExplorerManager tableEM = new ExplorerManager(); private final PropertyChangeListener focusPropertyListener; @@ -63,7 +63,7 @@ public class ThumbnailViewer extends JPanel implements RelationshipsViewer, Expl /** * Creates new form ThumbnailViewer */ - public ThumbnailViewer() { + public MediaViewer() { proxyLookup = new ModifiableProxyLookup(createLookup(tableEM, getActionMap())); // See org.sleuthkit.autopsy.timeline.TimeLineTopComponent for a detailed @@ -78,7 +78,7 @@ public class ThumbnailViewer extends JPanel implements RelationshipsViewer, Expl if (isDescendingFrom(newFocusOwner, contentViewer)) { //if the focus owner is within the MessageContentViewer (the attachments table) proxyLookup.setNewLookups(createLookup(((MessageDataContent) contentViewer).getExplorerManager(), getActionMap())); - } else if (isDescendingFrom(newFocusOwner, ThumbnailViewer.this)) { + } else if (isDescendingFrom(newFocusOwner, MediaViewer.this)) { //... or if it is within the Results table. proxyLookup.setNewLookups(createLookup(tableEM, getActionMap())); @@ -130,7 +130,7 @@ public class ThumbnailViewer extends JPanel implements RelationshipsViewer, Expl thumbnailViewer.resetComponent(); } - thumbnailViewer.setNode(new TableFilterNode(new DataResultFilterNode(new AbstractNode(new ThumbnailChildren(artifactList)), tableEM), true)); + thumbnailViewer.setNode(new TableFilterNode(new DataResultFilterNode(new AbstractNode(new AttachementsChildren(artifactList)), tableEM), true)); } @Override diff --git a/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java b/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java index 432f5e1dd7..49275e4b22 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java +++ b/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java @@ -33,7 +33,7 @@ final class RelationshipBrowser extends JPanel implements Lookup.Provider { private final MessagesViewer messagesViewer; private final ContactsViewer contactsViewer; - private final ThumbnailViewer thumbnailsViewer; + private final MediaViewer thumbnailsViewer; private final ModifiableProxyLookup proxyLookup; @@ -43,7 +43,7 @@ final class RelationshipBrowser extends JPanel implements Lookup.Provider { public RelationshipBrowser() { messagesViewer = new MessagesViewer(); contactsViewer = new ContactsViewer(); - thumbnailsViewer = new ThumbnailViewer(); + thumbnailsViewer = new MediaViewer(); proxyLookup = new ModifiableProxyLookup(messagesViewer.getLookup()); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java index 00c87b3417..92efe43891 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java @@ -561,7 +561,7 @@ public class MessageContentViewer extends javax.swing.JPanel implements DataCont msgbodyTabbedPane.setEnabledAt(ATTM_TAB_INDEX, numberOfAttachments > 0); msgbodyTabbedPane.setTitleAt(ATTM_TAB_INDEX, "Attachments (" + numberOfAttachments + ")"); drp.setNode(new TableFilterNode(new DataResultFilterNode(new AbstractNode( - new AttachmentsChildren(attachments)), null), true)); + new AttachmentsChildren(attachments))), true)); } private static String wrapInHtmlBody(String htmlText) { diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java index c375c7f02b..ef209beee5 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java @@ -125,9 +125,23 @@ public class DataResultFilterNode extends FilterNode { static private final DisplayableItemNodeVisitor> getActionsDIV = new GetPopupActionsDisplayableItemNodeVisitor(); private final DisplayableItemNodeVisitor getPreferredActionsDIV = new GetPreferredActionsDisplayableItemNodeVisitor(); + + // In GetPreferredActionsDisplayableItemNodeVisitor this is expected + // to be the directory tree explorer manager + private final ExplorerManager sourceEm; - private final ExplorerManager sourceEm; - + /** + * Constructs a node used to wrap another node before passing it to the + * result viewers. The wrapper node defines the actions associated with the + * wrapped node and may filter out some of its children. + * + * @param node The node to wrap. + */ + public DataResultFilterNode(Node node) { + super(node, null); + this.sourceEm = null; + } + /** * Constructs a node used to wrap another node before passing it to the * result viewers. The wrapper node defines the actions associated with the @@ -635,6 +649,10 @@ public class DataResultFilterNode extends FilterNode { // is a DirectoryTreeFilterNode that wraps the dataModelNode. We need // to set that wrapped node as the selection and root context of the // directory tree explorer manager (sourceEm) + if(sourceEm == null) { + return null; + } + final Node currentSelectionInDirectoryTree = sourceEm.getSelectedNodes()[0]; return new AbstractAction() { @@ -675,6 +693,9 @@ public class DataResultFilterNode extends FilterNode { * @return */ private AbstractAction openParent(AbstractNode node) { + if(sourceEm == null) { + return null; + } // @@@ Why do we ignore node? Node[] selectedFilterNodes = sourceEm.getSelectedNodes(); Node selectedFilterNode = selectedFilterNodes[0];