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");
81 pcs =
new PropertyChangeSupport(
this);
134 newDataResult.
open();
135 return newDataResult;
152 newDataResult.
open();
153 return newDataResult;
172 return newDataResult;
187 newDataResult.
setNode(givenNode);
188 newDataResult.
setPath(pathText);
206 if (null == explorerManager) {
215 explorerManager = ExplorerManager.find(
this);
227 if (totalTabs == 0) {
255 if (rootNode == null) {
260 this.setVisible(
true);
272 if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
273 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
277 if (contentViewer == null) {
278 contentViewer = Lookup.getDefault().lookup(
DataContent.class);
282 if (contentViewer != null) {
283 Node[] selectedNodes = explorerManager.getSelectedNodes();
285 drv.setSelectedNodes(selectedNodes);
291 if (selectedNodes.length == 1) {
292 contentViewer.
setNode(selectedNodes[0]);
295 contentViewer.setNode(null);
307 if (null != this.customContentViewer) {
308 viewerWrapper.setContentViewer(this.customContentViewer);
310 this.viewers.add(viewerWrapper);
321 PropertyChangeListener[] pcl = pcs.getPropertyChangeListeners();
322 for (
int i = 0; i < pcl.length; i++) {
323 pcs.removePropertyChangeListener(pcl[i]);
327 for (UpdateWrapper drv : this.viewers) {
332 for (UpdateWrapper drv : this.viewers) {
333 drv.clearComponent();
341 this.setLayout(null);
344 this.setVisible(
false);
351 logger.log(Level.WARNING,
"Could not add listener to DataResultPanel, "
352 +
"listener support not fully initialized yet, listener: " + listener.toString() );
355 this.pcs.addPropertyChangeListener(listener);
361 this.pcs.removePropertyChangeListener(listener);
371 if (this.rootNode != null) {
372 this.rootNode.removeNodeListener(dummyNodeListener);
376 if (listeningToTabbedPane ==
false) {
378 listeningToTabbedPane =
true;
381 this.rootNode = selectedNode;
382 if (this.rootNode != null) {
383 dummyNodeListener.
reset();
384 this.rootNode.addNodeListener(dummyNodeListener);
390 if (selectedNode != null) {
391 int childrenCount = selectedNode.getChildren().getNodesCount();
402 if (drv.isSupported(selectedNode)) {
411 boolean hasViewerEnabled =
true;
414 hasViewerEnabled =
false;
417 currentActiveTab = i;
418 hasViewerEnabled =
true;
423 if (hasViewerEnabled) {
428 if (hasViewerEnabled) {
429 viewers.get(currentActiveTab).setNode(selectedNode);
451 List<DataResultViewer> ret =
new ArrayList<DataResultViewer>();
453 ret.add(w.getViewer());
465 JTabbedPane pane = (JTabbedPane) e.getSource();
468 int currentTab = pane.getSelectedIndex();
469 if (currentTab != -1) {
476 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
478 drv.setNode(rootNode);
480 this.setCursor(null);
499 drv.resetComponent();
505 drv.setSelectedNodes(selected);
518 @SuppressWarnings(
"unchecked")
527 setMinimumSize(
new java.awt.Dimension(5, 5));
528 setPreferredSize(
new java.awt.Dimension(5, 5));
534 org.openide.awt.Mnemonics.setLocalizedText(
matchLabel,
org.openide.util.NbBundle.getMessage(
DataResultPanel.class,
"DataResultPanel.matchLabel.text"));
536 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
537 this.setLayout(layout);
538 layout.setHorizontalGroup(
539 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
540 .addGroup(layout.createSequentialGroup()
542 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 518, Short.MAX_VALUE)
544 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
548 layout.setVerticalGroup(
549 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
550 .addGroup(layout.createSequentialGroup()
551 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
552 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
574 this.outdated =
true;
581 void setNode(Node selectedNode) {
582 this.wrapped.
setNode(selectedNode);
583 this.outdated =
false;
586 void resetComponent() {
588 this.outdated =
true;
591 void clearComponent() {
593 this.outdated =
true;
596 boolean isOutdated() {
600 void setSelectedNodes(Node[] selected) {
604 boolean isSupported(Node selectedNode) {
608 void setContentViewer(DataContent contentViewer) {
625 private volatile boolean load =
true;
633 Node[] delta = nme.getDelta();
636 if (SwingUtilities.isEventDispatchThread()) {
640 SwingUtilities.invokeLater(
new Runnable() {
652 for (Node n : delta) {
653 if (!n.getDisplayName().equals(DUMMY_NODE_DISPLAY_NAME)) {
665 if (rootNode != null && rootNode.getChildren() != null) {
void setupTabs(Node selectedNode)
static void createInstanceCommon(String pathText, Node givenNode, int totalMatches, DataResultPanel newDataResult)
final DummyNodeListener dummyNodeListener
boolean isSupported(Node selectedNode)
ExplorerManager explorerManager
static boolean existsCurrentCase()
synchronized void addPropertyChangeListener(PropertyChangeListener listener)
static final Logger logger
void childrenRemoved(NodeMemberEvent nme)
DataContent customContentViewer
void setSelectedNodes(Node[] selected)
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)
boolean containsReal(Node[] delta)
List< DataResultViewer > getViewers()
void propertyChange(PropertyChangeEvent evt)
static final String DUMMY_NODE_DISPLAY_NAME
void setContentViewer(DataContent customContentViewer)
javax.swing.JTabbedPane dataResultTabbedPanel
void setNode(Node selectedNode)
void nodeDestroyed(NodeEvent ne)
DataResultViewer createInstance()
void setNode(Node selectedNode)
void addDataResultViewer(DataResultViewer dataResultViewer)
javax.swing.JLabel directoryTablePath
void resetTabs(Node selectedNode)
void childrenAdded(final NodeMemberEvent nme)
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)
static Case getCurrentCase()
javax.swing.JLabel matchLabel
void setContentViewer(DataContent contentViewer)
void setTitle(String title)
void propertyChange(PropertyChangeEvent evt)
void childrenReordered(NodeReorderEvent nre)
static boolean isCaseOpen()
static Logger getLogger(String name)