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
* 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 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(), Lookup.getDefault().lookup(DataContent.class));
createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel);
resultPanel.open();
return resultPanel;
@ -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<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);
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 custom 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.
*/
@ -229,11 +232,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
DataResultPanel(String title, boolean isMain, Collection<DataResultViewer> viewers, DataContent customContentView) {
this.setTitle(title);
this.isMain = isMain;
if (customContentView == null) {
this.contentView = Lookup.getDefault().lookup(DataContent.class);
} else {
this.contentView = customContentView;
}
this.resultViewers = new ArrayList<>(viewers);
this.explorerManagerListener = new ExplorerManagerListener();
this.rootNodeListener = new RootNodeListener();
@ -566,9 +565,11 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
class SetupTabsChildrenWorker extends SwingWorker<Void, Void> {
private final Node childNode;
SetupTabsChildrenWorker(Node aChildNode) {
childNode = aChildNode;
}
@Override
protected Void doInBackground() throws Exception {
setupTabs(childNode);
@ -580,6 +581,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.

View File

@ -27,6 +27,7 @@ import javax.swing.JComponent;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.Mode;
import org.openide.windows.RetainLocation;
@ -35,6 +36,7 @@ import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.actions.AddBookmarkTagAction;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResult;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -96,7 +98,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 +123,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<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);
return resultViewTopComponent;
}
@ -143,7 +145,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 +212,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 +231,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<DataResultViewer> viewers, DataContentTopComponent contentViewTopComponent) {
this.isMain = isMain;
@ -445,7 +444,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());
}
/**