diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java index d33360d4f7..02bf1f4907 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java @@ -58,18 +58,19 @@ import org.sleuthkit.autopsy.datamodel.NodeSelectionInfo; * node. A typical result viewer is a JPanel that displays the child nodes of * the given node using a NetBeans explorer view child component. * - * A result panel should be child components of top components that are explorer - * manager providers. The parent top component is expected to expose a lookup - * maintained by its explorer manager to the actions global context. The child - * result view panel will then find the parent top component's explorer manager - * at runtime, so that it can act as an explorer manager provider for its child - * result viewers. This connects the nodes displayed in the result viewers to - * the actions global context. + * All result view panels should be child components of top components that are + * explorer manager providers. The parent top component is expected to expose a + * lookup maintained by its explorer manager to the actions global context. The + * child result view panel will then find the parent top component's explorer + * manager at runtime, so that it can act as an explorer manager provider for + * its child result viewers. This connects the nodes displayed in the result + * viewers to the actions global context. * - * All result view panels push single node selections in the child result - * viewers to either the "main" content view (DataContentTopComponent) that is - * normally docked into the lower right hand side of the main application - * window, or to a supplied custom content view (implements DataContent). + * Result view panels can be constructed so that they push single node + * selections in the child result viewers to a content view (implements + * DataContent). The content view could be the "main" content view + * (DataContentTopComponent) that is normally docked into the lower right hand + * side of the main application window, or it could be a custom content view. */ public class DataResultPanel extends javax.swing.JPanel implements DataResult, ChangeListener, ExplorerManager.Provider { @@ -103,7 +104,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * @return A result view panel. */ public static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount) { - DataResultPanel resultPanel = new DataResultPanel(title, false, Collections.emptyList(), null); + DataResultPanel resultPanel = new DataResultPanel(title, false, Collections.emptyList(), DataContentTopComponent.findInstance()); createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel); resultPanel.open(); return resultPanel; @@ -115,7 +116,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * of the result viewers provided by the results viewer extension point. The * result view panel will push single node selections from its child result * viewers to the "main" content view that is normally docked into the lower - * right hand side of the main application window.. + * right hand side of the main application window. * * @param title The title for the result view panel. * @param description Descriptive text about the source of the nodes @@ -130,7 +131,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * @return A result view panel. */ public static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount, Collection viewers) { - DataResultPanel resultPanel = new DataResultPanel(title, false, viewers, null); + DataResultPanel resultPanel = new DataResultPanel(title, false, viewers, DataContentTopComponent.findInstance()); createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel); resultPanel.open(); return resultPanel; @@ -141,7 +142,8 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * contains instances of the result viewers (DataResultViewer) provided by * the result viewer extension point (service providers that implement * DataResultViewer). The result view panel will push single node selections - * from its child result viewers to the supplied custom content view. + * from its child result viewers to the supplied content view, which can be + * null if a content view is not needed. * * @param title The title for the result view panel. * @param description Descriptive text about the source of the nodes @@ -152,7 +154,8 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * @param customContentView A custom content view to use instead of the * "main" content view that is normally docked into * the lower right hand side of the main - * application window. + * application window. May be null, if no content + * view is needed. * * @return A result view panel. */ @@ -212,28 +215,22 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * contains a collection of result viewers that is either supplied or * provided by the result viewer extension point. * - * @param title The title of the result view panel. - * @param isMain Whether or not the result view panel is the - * "main" instance of the panel that resides in the - * "main" results view (DataResultTopComponent) - * that is normally docked into the upper right - * hand side of the main application window. - * @param viewers A collection of result viewers to use instead of - * the result viewers provided by the results - * viewer extension point, may be empty. - * @param customContentView A custom content view to use instead of the - * "main" content view that is normally docked into - * the lower right hand side of the main - * application window, may be null. + * @param title The title of the result view panel. + * @param isMain Whether or not the result view panel is the "main" + * instance of the panel that resides in the "main" + * results view (DataResultTopComponent) that is normally + * docked into the upper right hand side of the main + * application window. + * @param viewers A collection of result viewers to use instead of the + * result viewers provided by the results viewer + * extension point, may be empty. + * @param contentView A content view to into which to push single node + * selections in the child result viewers, may be null. */ - DataResultPanel(String title, boolean isMain, Collection viewers, DataContent customContentView) { + DataResultPanel(String title, boolean isMain, Collection viewers, DataContent contentView) { this.setTitle(title); this.isMain = isMain; - if (customContentView == null) { - this.contentView = Lookup.getDefault().lookup(DataContent.class); - } else { - this.contentView = customContentView; - } + this.contentView = contentView; this.resultViewers = new ArrayList<>(viewers); this.explorerManagerListener = new ExplorerManagerListener(); this.rootNodeListener = new RootNodeListener(); @@ -562,16 +559,18 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C /** * Worker for RootNodeListener childrenAdded. - */ + */ class SetupTabsChildrenWorker extends SwingWorker { - + private final Node childNode; + SetupTabsChildrenWorker(Node aChildNode) { childNode = aChildNode; } + @Override protected Void doInBackground() throws Exception { - setupTabs(childNode); + setupTabs(childNode); return null; } @@ -580,6 +579,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C setupTabs(childNode); } } + /** * Responds to changes in the root node due to asynchronous child node * creation. diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java index 47982bb059..c6b0037a85 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java @@ -68,7 +68,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; * viewers to the actions global context. */ @RetainLocation("editor") -public class DataResultTopComponent extends TopComponent implements DataResult, ExplorerManager.Provider { +public final class DataResultTopComponent extends TopComponent implements DataResult, ExplorerManager.Provider { private static final Logger logger = Logger.getLogger(DataResultTopComponent.class.getName()); private static final List activeComponentIds = Collections.synchronizedList(new ArrayList()); @@ -96,7 +96,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult, * @return The result view top component. */ public static DataResultTopComponent createInstance(String title, String description, Node node, int childNodeCount) { - DataResultTopComponent resultViewTopComponent = new DataResultTopComponent(false, title, null, Collections.emptyList(), null); + DataResultTopComponent resultViewTopComponent = new DataResultTopComponent(false, title, null, Collections.emptyList(), DataContentTopComponent.findInstance()); initInstance(description, node, childNodeCount, resultViewTopComponent); return resultViewTopComponent; } @@ -121,7 +121,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult, * @return The result view top component. */ public static DataResultTopComponent createInstance(String title, String description, Node node, int childNodeCount, Collection viewers) { - DataResultTopComponent resultViewTopComponent = new DataResultTopComponent(false, title, null, viewers, null); + DataResultTopComponent resultViewTopComponent = new DataResultTopComponent(false, title, null, viewers, DataContentTopComponent.findInstance()); initInstance(description, node, childNodeCount, resultViewTopComponent); return resultViewTopComponent; } @@ -143,7 +143,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult, * @return The partially initialized result view top component. */ public static DataResultTopComponent createInstance(String title) { - DataResultTopComponent resultViewTopComponent = new DataResultTopComponent(false, title, null, Collections.emptyList(), null); + DataResultTopComponent resultViewTopComponent = new DataResultTopComponent(false, title, null, Collections.emptyList(), DataContentTopComponent.findInstance()); return resultViewTopComponent; } @@ -210,7 +210,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult, * component's tab. */ public DataResultTopComponent(String title) { - this(true, title, null, Collections.emptyList(), null); + this(true, title, null, Collections.emptyList(), DataContentTopComponent.findInstance()); } /** @@ -229,10 +229,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult, * the result viewers provided by the results * viewer extension point will be used. * @param contentViewTopComponent A content view to which this result view - * will be linked. If null, this result view - * will be linked to the content view docked - * into the lower right hand side of the main - * application window, + * will be linked, possibly null. */ private DataResultTopComponent(boolean isMain, String title, String mode, Collection viewers, DataContentTopComponent contentViewTopComponent) { this.isMain = isMain; @@ -445,7 +442,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult, */ @Deprecated public DataResultTopComponent(boolean isMain, String title) { - this(false, title, null, Collections.emptyList(), null); + this(false, title, null, Collections.emptyList(), DataContentTopComponent.findInstance()); } /**