19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.Cursor;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.List;
28 import javax.swing.JTabbedPane;
29 import javax.swing.SwingWorker;
30 import javax.swing.event.ChangeEvent;
31 import javax.swing.event.ChangeListener;
32 import org.openide.explorer.ExplorerManager;
33 import org.openide.nodes.Node;
34 import org.openide.nodes.NodeEvent;
35 import org.openide.nodes.NodeListener;
36 import org.openide.nodes.NodeMemberEvent;
37 import org.openide.nodes.NodeReorderEvent;
38 import org.openide.util.Lookup;
39 import org.openide.util.NbBundle;
132 public static DataResultPanel createInstance(String title, String description, Node currentRootNode,
int childNodeCount, Collection<DataResultViewer> viewers) {
204 resultViewPanel.setName(title);
206 resultViewPanel.
setNode(currentRootNode);
207 resultViewPanel.
setPath(description);
232 if (customContentView == null) {
233 this.contentView = Lookup.getDefault().lookup(
DataContent.class);
235 this.contentView = customContentView;
237 this.resultViewers =
new ArrayList<>(viewers);
238 this.explorerManagerListener =
new ExplorerManagerListener();
239 this.rootNodeListener =
new RootNodeListener();
281 resultViewers.add(resultViewer);
292 return Collections.unmodifiableList(resultViewers);
303 this.contentView = customContentView;
320 if (this.explorerManager == null) {
321 this.explorerManager = ExplorerManager.find(
this);
322 this.explorerManager.addPropertyChangeListener(this.explorerManagerListener);
332 if (this.resultViewers.isEmpty()) {
335 this.resultViewers.add(resultViewer);
337 this.resultViewers.add(resultViewer.createInstance());
341 this.resultViewers.forEach((resultViewer) ->
resultViewerTabs.addTab(resultViewer.getTitle(), resultViewer.getComponent()));
344 this.setVisible(
true);
359 if (this.currentRootNode != null) {
360 this.currentRootNode.removeNodeListener(rootNodeListener);
368 if (listeningToTabbedPane ==
false) {
370 listeningToTabbedPane =
true;
373 this.currentRootNode = rootNode;
374 if (this.currentRootNode != null) {
375 rootNodeListener.
reset();
376 this.currentRootNode.addNodeListener(rootNodeListener);
379 this.resultViewers.forEach((viewer) -> {
380 viewer.resetComponent();
384 if (this.currentRootNode != null) {
385 int childrenCount = this.currentRootNode.getChildren().getNodesCount();
419 this.resultViewers.forEach((viewer) -> viewer.setSelectedNodes(selectedNodes));
434 if (resultViewers.get(i).isSupported(selectedNode)) {
449 NodeSelectionInfo selectedChildInfo = ((TableFilterNode) selectedNode).getChildNodeSelectionInfo();
450 if (null != selectedChildInfo) {
451 for (
int i = 0; i < resultViewers.size(); ++i) {
458 if (tabToSelect == NO_TAB_SELECTED) {
460 if ((tabToSelect == NO_TAB_SELECTED) || (!
resultViewerTabs.isEnabledAt(tabToSelect))) {
474 if (tabToSelect != NO_TAB_SELECTED) {
476 resultViewers.get(tabToSelect).setNode(selectedNode);
488 JTabbedPane pane = (JTabbedPane) event.getSource();
489 int currentTab = pane.getSelectedIndex();
492 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
494 currentViewer.
setNode(currentRootNode);
496 this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
506 if (explorerManager != null && explorerManagerListener != null) {
507 explorerManager.removePropertyChangeListener(explorerManagerListener);
508 explorerManager = null;
511 this.resultViewers.forEach((viewer) -> viewer.setNode(null));
518 this.setLayout(null);
520 this.setVisible(
false);
544 if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES) && contentView != null) {
553 Node[] selectedNodes = explorerManager.getSelectedNodes();
554 if (1 == selectedNodes.length) {
555 contentView.
setNode(selectedNodes[0]);
566 class SetupTabsChildrenWorker
extends SwingWorker<Void, Void> {
568 private final Node childNode;
569 SetupTabsChildrenWorker(Node aChildNode) {
570 childNode = aChildNode;
573 protected Void doInBackground() throws Exception {
579 protected void done() {
593 waitingForData =
true;
598 Node[] delta = nme.getDelta();
608 waitingForData =
false;
609 Node childNode = nme.getNode();
610 new SetupTabsChildrenWorker(childNode).execute();
615 for (Node n : delta) {
616 if (!n.getDisplayName().equals(PLEASE_WAIT_NODE_DISPLAY_NAME)) {
628 if (currentRootNode != null && currentRootNode.getChildren() != null) {
629 setNumMatches(currentRootNode.getChildren().getNodesCount());
656 @SuppressWarnings(
"unchecked")
665 setMinimumSize(
new java.awt.Dimension(0, 5));
666 setPreferredSize(
new java.awt.Dimension(5, 5));
673 org.openide.awt.Mnemonics.setLocalizedText(
matchLabel,
org.openide.util.NbBundle.getMessage(
DataResultPanel.class,
"DataResultPanel.matchLabel.text"));
677 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
678 this.setLayout(layout);
679 layout.setHorizontalGroup(
680 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
681 .addGroup(layout.createSequentialGroup()
682 .addComponent(
descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
683 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
685 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
687 .addComponent(
resultViewerTabs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
689 layout.setVerticalGroup(
690 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
691 .addGroup(layout.createSequentialGroup()
692 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
693 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
696 .addComponent(
descriptionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
698 .addComponent(
resultViewerTabs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
void setupTabs(Node selectedNode)
void propertyChange(PropertyChangeEvent evt)
void setNumberOfChildNodes(Integer numberOfChildNodes)
static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount, Collection< DataResultViewer > viewers)
static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount, DataContent customContentView)
javax.swing.JLabel numberOfChildNodesLabel
static void createInstanceCommon(String title, String description, Node currentRootNode, int childNodeCount, DataResultPanel resultViewPanel)
javax.swing.JTabbedPane resultViewerTabs
void propertyChange(PropertyChangeEvent evt)
static final long serialVersionUID
ExplorerManager explorerManager
final ExplorerManagerListener explorerManagerListener
static final int NO_TAB_SELECTED
volatile boolean waitingForData
void setNumMatches(Integer numberOfChildNodes)
void childrenReordered(NodeReorderEvent nre)
void setPath(String description)
ExplorerManager getExplorerManager()
void setNode(Node rootNode)
List< DataResultViewer > getViewers()
void stateChanged(ChangeEvent event)
void childrenRemoved(NodeMemberEvent nme)
void setSelectedNodes(Node[] selectedNodes)
static DataResultPanel createInstanceUninitialized(String title, String description, Node currentRootNode, int childNodeCount, DataContent customContentView)
void setContentViewer(DataContent customContentView)
final List< DataResultViewer > resultViewers
void addResultViewer(DataResultViewer resultViewer)
void nodeDestroyed(NodeEvent ne)
void setNode(Node selectedNode)
default void clearComponent()
void childrenAdded(final NodeMemberEvent nme)
static final String PLEASE_WAIT_NODE_DISPLAY_NAME
static DataResultPanel createInstance(String title, String description, Node currentRootNode, int childNodeCount)
boolean listeningToTabbedPane
javax.swing.JLabel descriptionLabel
boolean containsReal(Node[] delta)
javax.swing.JLabel matchLabel
final RootNodeListener rootNodeListener
void setTitle(String title)
void resetTabs(Node unusedSelectedNode)