Restore ability to have a result view panel with no content view

This commit is contained in:
Richard Cordovano 2018-05-04 17:35:01 -04:00
parent 06b2ce3c7a
commit 7f452ab4ea
2 changed files with 33 additions and 32 deletions

View File

@ -58,18 +58,19 @@ import org.sleuthkit.autopsy.datamodel.NodeSelectionInfo;
* node. A typical result viewer is a JPanel that displays the child nodes of * node. A typical result viewer is a JPanel that displays the child nodes of
* the given node using a NetBeans explorer view child component. * the given node using a NetBeans explorer view child component.
* *
* A result panel should be child components of top components that are explorer * All result view panels should be child components of top components that are
* manager providers. The parent top component is expected to expose a lookup * explorer manager providers. The parent top component is expected to expose a
* maintained by its explorer manager to the actions global context. The child * lookup maintained by its explorer manager to the actions global context. The
* result view panel will then find the parent top component's explorer manager * child result view panel will then find the parent top component's explorer
* at runtime, so that it can act as an explorer manager provider for its child * manager at runtime, so that it can act as an explorer manager provider for
* result viewers. This connects the nodes displayed in the result viewers to * its child result viewers. This connects the nodes displayed in the result
* the actions global context. * viewers to the actions global context.
* *
* All result view panels push single node selections in the child result * Result view panels can be constructed so that they push single node
* viewers to either the "main" content view (DataContentTopComponent) that is * selections in the child result viewers to a content view (implements
* normally docked into the lower right hand side of the main application * DataContent). The content view could be the "main" content view
* window, or to a supplied custom content view (implements DataContent). * (DataContentTopComponent) that is normally docked into the lower right hand
* side of the main application window, or could be a custom content view.
*/ */
public class DataResultPanel extends javax.swing.JPanel implements DataResult, ChangeListener, ExplorerManager.Provider { 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. * @return A result view panel.
*/ */
public static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount) { 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(), Lookup.getDefault().lookup(DataContent.class));
createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel); createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel);
resultPanel.open(); resultPanel.open();
return resultPanel; return resultPanel;
@ -130,7 +131,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
* @return A result view panel. * @return A result view panel.
*/ */
public static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount, Collection<DataResultViewer> viewers) { public static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount, Collection<DataResultViewer> viewers) {
DataResultPanel resultPanel = new DataResultPanel(title, false, viewers, null); DataResultPanel resultPanel = new DataResultPanel(title, false, viewers, Lookup.getDefault().lookup(DataContent.class));
createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel); createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel);
resultPanel.open(); resultPanel.open();
return resultPanel; 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 * contains instances of the result viewers (DataResultViewer) provided by
* the result viewer extension point (service providers that implement * the result viewer extension point (service providers that implement
* DataResultViewer). The result view panel will push single node selections * 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 custom content view, which
* can be null if a content view is not needed.
* *
* @param title The title for the result view panel. * @param title The title for the result view panel.
* @param description Descriptive text about the source of the nodes * @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 * @param customContentView A custom content view to use instead of the
* "main" content view that is normally docked into * "main" content view that is normally docked into
* the lower right hand side of the main * 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. * @return A result view panel.
*/ */
@ -229,11 +232,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
DataResultPanel(String title, boolean isMain, Collection<DataResultViewer> viewers, DataContent customContentView) { DataResultPanel(String title, boolean isMain, Collection<DataResultViewer> viewers, DataContent customContentView) {
this.setTitle(title); this.setTitle(title);
this.isMain = isMain; this.isMain = isMain;
if (customContentView == null) {
this.contentView = Lookup.getDefault().lookup(DataContent.class);
} else {
this.contentView = customContentView; this.contentView = customContentView;
}
this.resultViewers = new ArrayList<>(viewers); this.resultViewers = new ArrayList<>(viewers);
this.explorerManagerListener = new ExplorerManagerListener(); this.explorerManagerListener = new ExplorerManagerListener();
this.rootNodeListener = new RootNodeListener(); this.rootNodeListener = new RootNodeListener();
@ -566,9 +565,11 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
class SetupTabsChildrenWorker extends SwingWorker<Void, Void> { class SetupTabsChildrenWorker extends SwingWorker<Void, Void> {
private final Node childNode; private final Node childNode;
SetupTabsChildrenWorker(Node aChildNode) { SetupTabsChildrenWorker(Node aChildNode) {
childNode = aChildNode; childNode = aChildNode;
} }
@Override @Override
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
setupTabs(childNode); setupTabs(childNode);
@ -580,6 +581,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
setupTabs(childNode); setupTabs(childNode);
} }
} }
/** /**
* Responds to changes in the root node due to asynchronous child node * Responds to changes in the root node due to asynchronous child node
* creation. * creation.

View File

@ -27,6 +27,7 @@ import javax.swing.JComponent;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils; import org.openide.explorer.ExplorerUtils;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.Mode; import org.openide.windows.Mode;
import org.openide.windows.RetainLocation; import org.openide.windows.RetainLocation;
@ -35,6 +36,7 @@ import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.actions.AddBookmarkTagAction; import org.sleuthkit.autopsy.actions.AddBookmarkTagAction;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
@ -96,7 +98,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult,
* @return The result view top component. * @return The result view top component.
*/ */
public static DataResultTopComponent createInstance(String title, String description, Node node, int childNodeCount) { 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); initInstance(description, node, childNodeCount, resultViewTopComponent);
return resultViewTopComponent; return resultViewTopComponent;
} }
@ -121,7 +123,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult,
* @return The result view top component. * @return The result view top component.
*/ */
public static DataResultTopComponent createInstance(String title, String description, Node node, int childNodeCount, Collection<DataResultViewer> viewers) { public static DataResultTopComponent createInstance(String title, String description, Node node, int childNodeCount, Collection<DataResultViewer> 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); initInstance(description, node, childNodeCount, resultViewTopComponent);
return resultViewTopComponent; return resultViewTopComponent;
} }
@ -143,7 +145,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult,
* @return The partially initialized result view top component. * @return The partially initialized result view top component.
*/ */
public static DataResultTopComponent createInstance(String title) { 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; return resultViewTopComponent;
} }
@ -210,7 +212,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult,
* component's tab. * component's tab.
*/ */
public DataResultTopComponent(String title) { public DataResultTopComponent(String title) {
this(true, title, null, Collections.emptyList(), null); this(true, title, null, Collections.emptyList(), DataContentTopComponent.findInstance());
} }
/** /**
@ -229,10 +231,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult,
* the result viewers provided by the results * the result viewers provided by the results
* viewer extension point will be used. * viewer extension point will be used.
* @param contentViewTopComponent A content view to which this result view * @param contentViewTopComponent A content view to which this result view
* will be linked. If null, this result view * will be linked, possibly null.
* will be linked to the content view docked
* into the lower right hand side of the main
* application window,
*/ */
private DataResultTopComponent(boolean isMain, String title, String mode, Collection<DataResultViewer> viewers, DataContentTopComponent contentViewTopComponent) { private DataResultTopComponent(boolean isMain, String title, String mode, Collection<DataResultViewer> viewers, DataContentTopComponent contentViewTopComponent) {
this.isMain = isMain; this.isMain = isMain;
@ -445,7 +444,7 @@ public class DataResultTopComponent extends TopComponent implements DataResult,
*/ */
@Deprecated @Deprecated
public DataResultTopComponent(boolean isMain, String title) { public DataResultTopComponent(boolean isMain, String title) {
this(false, title, null, Collections.emptyList(), null); this(false, title, null, Collections.emptyList(), DataContentTopComponent.findInstance());
} }
/** /**