diff --git a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java index 671f5ed8a2..37f2df996c 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java @@ -35,6 +35,7 @@ import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.Lookup; +import org.openide.util.lookup.ProxyLookup; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.coreutils.Logger; @@ -60,7 +61,6 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro private final Outline outline; - private final ExplorerManager messageBrowserEM = new ExplorerManager(); private final ExplorerManager accountsTableEM = new ExplorerManager(); final RelationshipBrowser relationshipBrowser; @@ -69,7 +69,7 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro * This lookup proxies the selection lookup of both he accounts table and * the messages table. */ - private final Lookup lookup; + private final ProxyLookup proxyLookup; public AccountsBrowser() { initComponents(); @@ -106,7 +106,8 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro } }); - lookup = ExplorerUtils.createLookup(accountsTableEM, getActionMap()); + proxyLookup = new ProxyLookup(relationshipBrowser.getLookup(), + ExplorerUtils.createLookup(accountsTableEM, getActionMap())); } private void setColumnWidths() { @@ -178,6 +179,6 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro @Override public Lookup getLookup() { - return lookup; + return proxyLookup; } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/communications/Bundle.properties-MERGED index 22bc2cdd10..7c5889eada 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/communications/Bundle.properties-MERGED @@ -51,7 +51,7 @@ PinAccountsAction.singularText=Add Selected Account to Visualization refreshText=Refresh Results ResetAndPinAccountsAction.pluralText=Visualize Only Selected Accounts ResetAndPinAccountsAction.singularText=Visualize Only Selected Account -ThumbnailViewer_Name=Thumbnails +ThumbnailViewer_Name=Media UnpinAccountsAction.pluralText=Remove Selected Accounts UnpinAccountsAction.singularText=Remove Selected Account VisalizationPanel.paintingError=Problem painting visualization. diff --git a/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java b/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java index 85695e2eb7..432f5e1dd7 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java +++ b/Core/src/org/sleuthkit/autopsy/communications/RelationshipBrowser.java @@ -18,33 +18,42 @@ */ package org.sleuthkit.autopsy.communications; +import java.awt.Component; import javax.swing.JPanel; +import org.openide.util.Lookup; +import org.openide.util.lookup.ProxyLookup; /** * Displays the Relationship information for the currently selected accounts. * */ -final class RelationshipBrowser extends JPanel { +final class RelationshipBrowser extends JPanel implements Lookup.Provider { private SelectionInfo currentSelection; private final MessagesViewer messagesViewer; private final ContactsViewer contactsViewer; - private final ThumbnailViewer thumbnailViewer; + private final ThumbnailViewer thumbnailsViewer; + + private final ModifiableProxyLookup proxyLookup; /** * Creates new form RelationshipBrowser */ public RelationshipBrowser() { - initComponents(); - messagesViewer = new MessagesViewer(); contactsViewer = new ContactsViewer(); - thumbnailViewer = new ThumbnailViewer(); + thumbnailsViewer = new ThumbnailViewer(); + + proxyLookup = new ModifiableProxyLookup(messagesViewer.getLookup()); + + initComponents(); tabPane.add(messagesViewer.getDisplayName(), messagesViewer); tabPane.add(contactsViewer.getDisplayName(), contactsViewer); - tabPane.add(thumbnailViewer.getDisplayName(), thumbnailViewer); + tabPane.add(thumbnailsViewer.getDisplayName(), thumbnailsViewer); + + } /** @@ -99,6 +108,12 @@ final class RelationshipBrowser extends JPanel { if(currentSelection != null) { ((RelationshipsViewer) tabPane.getSelectedComponent()).setSelectionInfo(currentSelection); } + + Component selectedComponent = tabPane.getSelectedComponent(); + if(selectedComponent instanceof Lookup.Provider) { + Lookup lookup = ((Lookup.Provider)selectedComponent).getLookup(); + proxyLookup.setNewLookups(lookup); + } }//GEN-LAST:event_tabPaneStateChanged @@ -106,4 +121,9 @@ final class RelationshipBrowser extends JPanel { private javax.swing.JScrollPane scrollPane; private javax.swing.JTabbedPane tabPane; // End of variables declaration//GEN-END:variables + + @Override + public Lookup getLookup() { + return proxyLookup; + } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/RelationshipsViewer.java b/Core/src/org/sleuthkit/autopsy/communications/RelationshipsViewer.java index 395182f5d6..ed2accee07 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/RelationshipsViewer.java +++ b/Core/src/org/sleuthkit/autopsy/communications/RelationshipsViewer.java @@ -19,11 +19,12 @@ package org.sleuthkit.autopsy.communications; import javax.swing.JPanel; +import org.openide.util.Lookup; /** * Interface for Controls wishing to appear in the RelationshipBrowser tabPane. */ -public interface RelationshipsViewer { +public interface RelationshipsViewer extends Lookup.Provider { /** * Returns the value to be displayed on the "tab" diff --git a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java b/Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java index fb23d94eb7..30a95f35aa 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java +++ b/Core/src/org/sleuthkit/autopsy/communications/ThumbnailChildren.java @@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.communications; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import java.util.TreeSet; import java.util.logging.Level; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -38,32 +39,48 @@ import org.sleuthkit.datamodel.TskCoreException; /** * Factory for creating thumbnail children nodes. * + * Given the current way that DataResultViewerThumbnail works this class must + * extend Children.Keys not ChildNodeFactory. When a ChildNodeFactory is used + * the addNotify function in ThumbnailChildNode ends up wtih a list containing + * just the wait node and the thumbanils never appear. */ -public class ThumbnailChildren extends Children.Keys { +final class ThumbnailChildren extends Children.Keys { + private static final Logger logger = Logger.getLogger(ThumbnailChildren.class.getName()); - + private final Set thumbnails; - + /* - * Creates the list of thumbnails from the given list of BlackboardArtifacts. + * Creates the list of thumbnails from the given list of + * BlackboardArtifacts. + * + * The thumbnails will be initialls sorted by size, then name so that they + * appear sorted by size by default. */ ThumbnailChildren(Set artifacts) { super(false); - thumbnails = new HashSet<>(); - + thumbnails = new TreeSet<>((AbstractFile file1, AbstractFile file2) -> { + int result = Long.compare(file1.getSize(), file2.getSize()); + if (result == 0) { + result = file1.getName().compareTo(file2.getName()); + } + + return result; + }); + artifacts.forEach((bba) -> { - try{ - for(Content childContent: bba.getChildren()) { - if(childContent instanceof AbstractFile && ImageUtils.thumbnailSupported((AbstractFile)childContent)) { - thumbnails.add((AbstractFile)childContent); + try { + for (Content childContent : bba.getChildren()) { + if (childContent instanceof AbstractFile && ImageUtils.thumbnailSupported((AbstractFile) childContent)) { + thumbnails.add((AbstractFile) childContent); } } - } catch(TskCoreException ex) { + } 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)}; @@ -74,13 +91,13 @@ public class ThumbnailChildren extends Children.Keys { super.addNotify(); setKeys(thumbnails); } - + /** * A node for representing a thumbnail. */ - private static class ThumbnailNode extends FileNode { - - ThumbnailNode(AbstractFile file) { + static class ThumbnailNode extends FileNode { + + ThumbnailNode(AbstractFile file) { super(file, false); } @@ -88,18 +105,18 @@ public class ThumbnailChildren extends Children.Keys { protected Sheet createSheet() { Sheet sheet = super.createSheet(); Set keepProps = new HashSet<>(Arrays.asList( - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"), - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"), - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"), - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.sizeColLbl"), - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), - NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.knownColLbl"))); - + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"), + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"), + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"), + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.sizeColLbl"), + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), + NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.knownColLbl"))); + //Remove all other props except for the ones above Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES); - for(Node.Property p : sheetSet.getProperties()) { - if(!keepProps.contains(p.getName())){ + for (Node.Property p : sheetSet.getProperties()) { + if (!keepProps.contains(p.getName())) { sheetSet.remove(p.getName()); } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java b/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java index e6029cba92..a4dea6493f 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java +++ b/Core/src/org/sleuthkit/autopsy/communications/ThumbnailViewer.java @@ -58,7 +58,7 @@ public class ThumbnailViewer extends JPanel implements RelationshipsViewer, Expl private final ModifiableProxyLookup proxyLookup; @Messages({ - "ThumbnailViewer_Name=Thumbnails" + "ThumbnailViewer_Name=Media" }) /** * Creates new form ThumbnailViewer @@ -93,6 +93,8 @@ public class ThumbnailViewer extends JPanel implements RelationshipsViewer, Expl handleNodeSelectionChange(); } }); + + thumbnailViewer.resetComponent(); } @Override @@ -121,7 +123,11 @@ public class ThumbnailViewer extends JPanel implements RelationshipsViewer, Expl }); } catch (TskCoreException | NoCurrentCaseException ex) { - + logger.log(Level.WARNING, "Unable to update selection." , ex); + } + + if(artifactList.size() == 0) { + thumbnailViewer.resetComponent(); } thumbnailViewer.setNode(new TableFilterNode(new DataResultFilterNode(new AbstractNode(new ThumbnailChildren(artifactList)), tableEM), true));