19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.Cursor;
22 import java.beans.PropertyChangeEvent;
23 import java.beans.PropertyChangeListener;
24 import java.beans.PropertyChangeSupport;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.logging.Level;
28 import javax.swing.JTabbedPane;
29 import javax.swing.SwingUtilities;
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;
60 private PropertyChangeSupport
pcs;
63 private final List<UpdateWrapper>
viewers =
new ArrayList<>();
73 "DataResultPanel.dummyNodeDisplayName");
82 pcs =
new PropertyChangeSupport(
this);
140 newDataResult.
open();
141 return newDataResult;
162 newDataResult.
open();
163 return newDataResult;
185 return newDataResult;
200 newDataResult.
setNode(givenNode);
201 newDataResult.
setPath(pathText);
220 if (null == explorerManager) {
229 explorerManager = ExplorerManager.find(
this);
241 if (totalTabs == 0) {
268 if (rootNode == null) {
273 this.setVisible(
true);
286 if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
287 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
291 if (contentViewer == null) {
292 contentViewer = Lookup.getDefault().lookup(
DataContent.class);
296 if (contentViewer != null) {
297 Node[] selectedNodes = explorerManager.getSelectedNodes();
299 drv.setSelectedNodes(selectedNodes);
305 if (selectedNodes.length == 1) {
306 contentViewer.
setNode(selectedNodes[0]);
308 contentViewer.setNode(null);
320 if (null != this.customContentViewer) {
321 viewerWrapper.setContentViewer(this.customContentViewer);
323 this.viewers.add(viewerWrapper);
334 PropertyChangeListener[] pcl = pcs.getPropertyChangeListeners();
335 for (
int i = 0; i < pcl.length; i++) {
336 pcs.removePropertyChangeListener(pcl[i]);
340 for (UpdateWrapper drv : this.viewers) {
345 for (UpdateWrapper drv : this.viewers) {
346 drv.clearComponent();
354 this.setLayout(null);
357 this.setVisible(
false);
364 logger.log(Level.WARNING,
"Could not add listener to DataResultPanel, "
365 +
"listener support not fully initialized yet, listener: " + listener.toString());
367 this.pcs.addPropertyChangeListener(listener);
373 this.pcs.removePropertyChangeListener(listener);
383 if (this.rootNode != null) {
384 this.rootNode.removeNodeListener(rootNodeListener);
388 if (listeningToTabbedPane ==
false) {
390 listeningToTabbedPane =
true;
393 this.rootNode = selectedNode;
394 if (this.rootNode != null) {
395 rootNodeListener.
reset();
396 this.rootNode.addNodeListener(rootNodeListener);
402 if (selectedNode != null) {
403 int childrenCount = selectedNode.getChildren().getNodesCount();
414 if (drv.isSupported(selectedNode)) {
423 boolean hasViewerEnabled =
true;
426 hasViewerEnabled =
false;
429 currentActiveTab = i;
430 hasViewerEnabled =
true;
435 if (hasViewerEnabled) {
440 if (hasViewerEnabled) {
441 viewers.get(currentActiveTab).setNode(selectedNode);
463 List<DataResultViewer> ret =
new ArrayList<DataResultViewer>();
465 ret.add(w.getViewer());
477 JTabbedPane pane = (JTabbedPane) e.getSource();
480 int currentTab = pane.getSelectedIndex();
481 if (currentTab != -1) {
488 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
490 drv.setNode(rootNode);
492 this.setCursor(null);
511 drv.resetComponent();
517 drv.setSelectedNodes(selected);
530 @SuppressWarnings(
"unchecked")
539 setMinimumSize(
new java.awt.Dimension(5, 5));
540 setPreferredSize(
new java.awt.Dimension(5, 5));
546 org.openide.awt.Mnemonics.setLocalizedText(
matchLabel,
org.openide.util.NbBundle.getMessage(
DataResultPanel.class,
"DataResultPanel.matchLabel.text"));
548 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
549 this.setLayout(layout);
550 layout.setHorizontalGroup(
551 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
552 .addGroup(layout.createSequentialGroup()
554 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 518, Short.MAX_VALUE)
556 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
560 layout.setVerticalGroup(
561 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
562 .addGroup(layout.createSequentialGroup()
563 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
564 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
586 this.outdated =
true;
593 void setNode(Node selectedNode) {
594 this.wrapped.
setNode(selectedNode);
595 this.outdated =
false;
598 void resetComponent() {
600 this.outdated =
true;
603 void clearComponent() {
605 this.outdated =
true;
608 boolean isOutdated() {
612 void setSelectedNodes(Node[] selected) {
616 boolean isSupported(Node selectedNode) {
620 void setContentViewer(DataContent contentViewer) {
641 waitingForData =
true;
646 Node[] delta = nme.getDelta();
656 waitingForData =
false;
657 if (SwingUtilities.isEventDispatchThread()) {
660 SwingUtilities.invokeLater(
new Runnable() {
671 for (Node n : delta) {
672 if (!n.getDisplayName().equals(DUMMY_NODE_DISPLAY_NAME)) {
684 if (rootNode != null && rootNode.getChildren() != null) {
void setupTabs(Node selectedNode)
static void createInstanceCommon(String pathText, Node givenNode, int totalMatches, DataResultPanel newDataResult)
boolean isSupported(Node selectedNode)
void propertyChange(PropertyChangeEvent evt)
ExplorerManager explorerManager
static boolean existsCurrentCase()
synchronized void addPropertyChangeListener(PropertyChangeListener listener)
static final Logger logger
DataContent customContentViewer
volatile boolean waitingForData
void setSelectedNodes(Node[] selected)
void childrenReordered(NodeReorderEvent nre)
synchronized void removePropertyChangeListener(PropertyChangeListener listener)
javax.swing.JLabel numberMatchLabel
final List< UpdateWrapper > viewers
PropertyChangeSupport pcs
static DataResultPanel createInstanceUninitialized(String title, String pathText, Node givenNode, int totalMatches, DataContent dataContent)
static DataResultPanel createInstance(String title, String pathText, Node givenNode, int totalMatches, DataContent dataContent)
void setSelectedNodes(Node[] selected)
void setNode(Node selectedNode)
List< DataResultViewer > getViewers()
static final String DUMMY_NODE_DISPLAY_NAME
void childrenRemoved(NodeMemberEvent nme)
void setContentViewer(DataContent customContentViewer)
javax.swing.JTabbedPane dataResultTabbedPanel
void setNode(Node selectedNode)
DataResultViewer createInstance()
void nodeDestroyed(NodeEvent ne)
void setNode(Node selectedNode)
void addDataResultViewer(DataResultViewer dataResultViewer)
void childrenAdded(final NodeMemberEvent nme)
javax.swing.JLabel directoryTablePath
void resetTabs(Node selectedNode)
void setNumMatches(Integer numMatches)
boolean listeningToTabbedPane
static DataResultPanel createInstance(String title, String pathText, Node givenNode, int totalMatches)
void stateChanged(ChangeEvent e)
void setPath(String pathText)
boolean containsReal(Node[] delta)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
javax.swing.JLabel matchLabel
void setContentViewer(DataContent contentViewer)
final RootNodeListener rootNodeListener
void setTitle(String title)
void propertyChange(PropertyChangeEvent evt)
static boolean isCaseOpen()