Merge pull request #3742 from rcordovano/3812-content-panel-stack-overflow

3812 content panel stack overflow
This commit is contained in:
Richard Cordovano 2018-05-07 10:09:54 -04:00 committed by GitHub
commit b7fd3cfef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 48 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 it 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(), DataContentTopComponent.findInstance());
createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel); createInstanceCommon(title, description, currentRootNode, childNodeCount, resultPanel);
resultPanel.open(); resultPanel.open();
return resultPanel; 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 * of the result viewers provided by the results viewer extension point. The
* result view panel will push single node selections from its child result * 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 * 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 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
@ -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, DataContentTopComponent.findInstance());
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 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.
*/ */
@ -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 * contains a collection of result viewers that is either supplied or
* provided by the result viewer extension point. * provided by the result viewer extension point.
* *
* @param title The title of the result view panel. * @param title The title of the result view panel.
* @param isMain Whether or not the result view panel is the * @param isMain Whether or not the result view panel is the "main"
* "main" instance of the panel that resides in the * instance of the panel that resides in the "main"
* "main" results view (DataResultTopComponent) * results view (DataResultTopComponent) that is normally
* that is normally docked into the upper right * docked into the upper right hand side of the main
* hand side of the main application window. * application window.
* @param viewers A collection of result viewers to use instead of * @param viewers A collection of result viewers to use instead of the
* the result viewers provided by the results * result viewers provided by the results viewer
* viewer extension point, may be empty. * extension point, may be empty.
* @param customContentView A custom content view to use instead of the * @param contentView A content view to into which to push single node
* "main" content view that is normally docked into * selections in the child result viewers, may be null.
* the lower right hand side of the main
* application window, may be null.
*/ */
DataResultPanel(String title, boolean isMain, Collection<DataResultViewer> viewers, DataContent customContentView) { DataResultPanel(String title, boolean isMain, Collection<DataResultViewer> viewers, DataContent contentView) {
this.setTitle(title); this.setTitle(title);
this.isMain = isMain; this.isMain = isMain;
if (customContentView == null) { this.contentView = contentView;
this.contentView = Lookup.getDefault().lookup(DataContent.class);
} else {
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();
@ -562,16 +559,18 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
/** /**
* Worker for RootNodeListener childrenAdded. * Worker for RootNodeListener childrenAdded.
*/ */
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);
return null; return null;
} }
@ -580,6 +579,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

@ -68,7 +68,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
* viewers to the actions global context. * viewers to the actions global context.
*/ */
@RetainLocation("editor") @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 Logger logger = Logger.getLogger(DataResultTopComponent.class.getName());
private static final List<String> activeComponentIds = Collections.synchronizedList(new ArrayList<String>()); private static final List<String> activeComponentIds = Collections.synchronizedList(new ArrayList<String>());
@ -96,7 +96,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 +121,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 +143,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 +210,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 +229,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 +442,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());
} }
/** /**