Clear out ContentNode & subclasses from CoreComponents

This commit is contained in:
Peter J. Martel 2011-12-12 16:06:40 -05:00
parent f66d92ff33
commit 124ed5dfdd
27 changed files with 155 additions and 292 deletions

View File

@ -19,8 +19,8 @@
package org.sleuthkit.autopsy.corecomponentinterfaces;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import java.beans.PropertyChangeListener;
import org.openide.nodes.Node;
import org.openide.windows.TopComponent;
/**
@ -34,7 +34,7 @@ public interface DataContent extends PropertyChangeListener {
* Sets the "selected" node in this class
* @param selectedNode node to use
*/
public void setNode(ContentNode selectedNode);
public void setNode(Node selectedNode);
/**
* Get the TopComponent that is used when displaying this DataContent

View File

@ -19,19 +19,19 @@
package org.sleuthkit.autopsy.corecomponentinterfaces;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import java.awt.Component;
import org.openide.nodes.Node;
/**
* Responsible for a tab in the {@link DataContent} component. Displays the
* contents of the node passed to {@link setNode(ContentNode)}.
* contents of the node passed to {@link setNode(Node)}.
*/
public interface DataContentViewer {
/**
* Sets the node to display in the viewer. When called with null, must
* clear all references to previous nodes.
*/
public void setNode(ContentNode selectedNode);
public void setNode(Node selectedNode);
/**
* Returns the title of this viewer.
@ -62,6 +62,6 @@ public interface DataContentViewer {
* @param node Node to check for support
* @return True if supported, else false
*/
public boolean isSupported(ContentNode node);
public boolean isSupported(Node node);
}

View File

@ -18,7 +18,7 @@
*/
package org.sleuthkit.autopsy.corecomponentinterfaces;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.openide.nodes.Node;
/**
* The interface for the "top right component" window.
@ -30,7 +30,7 @@ public interface DataResult {
/**
* Sets the "selected" node in this class.
*/
public void setNode(ContentNode selectedNode);
public void setNode(Node selectedNode);
/**
* Gets the unique TopComponent ID of this class.

View File

@ -20,8 +20,8 @@
package org.sleuthkit.autopsy.corecomponentinterfaces;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import java.awt.Component;
import org.openide.nodes.Node;
/**
* Interface for the different viewers that show a set of nodes in the DataResult area.
@ -34,7 +34,7 @@ public interface DataResultViewer {
* Set the root node to display in this viewer. When called with null, must
* clear all references to previous nodes.
*/
public void setNode(ContentNode selectedNode);
public void setNode(Node selectedNode);
/**
* Gets the title of this viewer

View File

@ -6,7 +6,7 @@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obt ain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ -28,15 +28,16 @@ import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
import org.sleuthkit.autopsy.datamodel.ContentNode;
/**
* Holds commonalities between all DataResultViewers
*/
public abstract class AbstractDataResultViewer extends JPanel implements DataResultViewer, Provider, PropertyChangeListener {
public abstract class AbstractDataResultViewer extends JPanel implements
DataResultViewer, Provider, PropertyChangeListener {
/**
* Propagates changes in the current select node from the DataResultViewer to the DataContentTopComponent
* Propagates changes in the current select node from the DataResultViewer
* to the DataContentTopComponent
*
* @param evt
*/
@ -53,14 +54,14 @@ public abstract class AbstractDataResultViewer extends JPanel implements DataRes
// change the cursor to "waiting cursor" for this operation
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
Node originalSelectedNode = this.getOriginalSelectedNode();
Node selectedNode = this.getSelectedNode();
// DataContent is designed to return only the default viewer
DataContent dataContent = Lookup.getDefault().lookup(DataContent.class);
if (originalSelectedNode != null && originalSelectedNode instanceof ContentNode) {
if (selectedNode != null) {
// there's a new/changed node to display
ContentNode newSelectedNode = (ContentNode) originalSelectedNode; // get the selected Node on the table
Node newSelectedNode = selectedNode; // get the selected Node on the table
// push the node to default "DataContent"
dataContent.setNode(newSelectedNode);
} else {
@ -74,9 +75,8 @@ public abstract class AbstractDataResultViewer extends JPanel implements DataRes
}
/**
* Gets the current node, stripping off any FilterNode that this class might
* have wrapped it in.
* Gets the current node selected node
* @return
*/
public abstract Node getOriginalSelectedNode();
public abstract Node getSelectedNode();
}

View File

@ -32,7 +32,6 @@ import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.datamodel.ContentUtils;
@ -48,7 +47,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
// reference to the "default" TC that always stays open
private static DataContentTopComponent defaultInstance;
private ContentNode currentNode;
private Node currentNode;
// set to true if this is the TC that always stays open and is the default place to display content
private boolean isDefault;
// Different DataContentViewers
@ -81,7 +80,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
this.outdated = true;
}
void setNode(ContentNode selectedNode) {
void setNode(Node selectedNode) {
this.wrapped.setNode(selectedNode);
this.outdated = false;
}
@ -95,7 +94,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
return this.outdated;
}
boolean isSupported(ContentNode node) {
boolean isSupported(Node node) {
return this.wrapped.isSupported(node);
}
}
@ -107,7 +106,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
* @param givenNode node to view content of
* @return newly undocked instance
*/
public static DataContentTopComponent createUndocked(String filePath, ContentNode givenNode) {
public static DataContentTopComponent createUndocked(String filePath, Node givenNode) {
DataContentTopComponent dctc = new DataContentTopComponent(false, filePath);
dctc.componentOpened();
@ -222,7 +221,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
}
@Override
public void setNode(ContentNode selectedNode) {
public void setNode(Node selectedNode) {
// change the cursor to "waiting cursor" for this operation
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
@ -230,7 +229,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
if (selectedNode == null) {
setName(NbBundle.getMessage(DataContentTopComponent.class, "CTL_DataContentTopComponent"));
} else {
String path = DataConversion.getformattedPath(ContentUtils.getDisplayPath(((Node) selectedNode).getLookup().lookup(Content.class)), 0);
String path = DataConversion.getformattedPath(ContentUtils.getDisplayPath(selectedNode.getLookup().lookup(Content.class)), 0);
setName(path);
}
@ -284,7 +283,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC
*
* @param selectedNode the selected content Node
*/
public void resetTabs(ContentNode selectedNode) {
public void resetTabs(Node selectedNode) {
int totalTabs = dataContentTabbedPane.getTabCount();

View File

@ -25,7 +25,6 @@ import java.util.logging.Logger;
import javax.swing.JTextPane;
import org.openide.nodes.Node;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.datamodel.DataConversion;
import org.sleuthkit.datamodel.Content;
@ -273,7 +272,7 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
}
@Override
public void setNode(ContentNode selectedNode) {
public void setNode(Node selectedNode) {
if (selectedNode != null) {
Content content = ((Node) selectedNode).getLookup().lookup(Content.class);
if (content != null) {
@ -322,7 +321,7 @@ public class DataContentViewerHex extends javax.swing.JPanel implements DataCont
}
@Override
public boolean isSupported(ContentNode node) {
public boolean isSupported(Node node) {
return true;
}

View File

@ -29,7 +29,6 @@ import javax.imageio.ImageIO;
import javax.swing.JPanel;
import org.openide.nodes.Node;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.TskException;
@ -84,7 +83,7 @@ public class DataContentViewerPicture extends javax.swing.JPanel implements Data
// End of variables declaration//GEN-END:variables
@Override
public void setNode(ContentNode selectedNode) {
public void setNode(Node selectedNode) {
// change the cursor to "waiting cursor" for this operation
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
@ -92,8 +91,7 @@ public class DataContentViewerPicture extends javax.swing.JPanel implements Data
try {
// read the byte of the image file
// TODO: ContentNode fix - get rid of cast to Node
Content content = ((Node) selectedNode).getLookup().lookup(Content.class);
Content content = selectedNode.getLookup().lookup(Content.class);
byte[] dataSource = content.read(0, content.getSize());
// create the input stream for the content
@ -133,7 +131,7 @@ public class DataContentViewerPicture extends javax.swing.JPanel implements Data
}
@Override
public boolean isSupported(ContentNode cNode) {
public boolean isSupported(Node cNode) {
Node node = (Node) cNode;
if (node != null) {

View File

@ -24,7 +24,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.nodes.Node;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.datamodel.DataConversion;
import org.sleuthkit.datamodel.Content;
@ -267,7 +266,7 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
}
@Override
public void setNode(ContentNode selectedNode) {
public void setNode(Node selectedNode) {
if (selectedNode != null) {
Content content = ((Node) selectedNode).getLookup().lookup(Content.class);
if (content != null) {
@ -301,7 +300,7 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
}
@Override
public boolean isSupported(ContentNode node) {
public boolean isSupported(Node node) {
return true;
}

View File

@ -32,18 +32,14 @@ import org.openide.windows.TopComponent;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
import org.sleuthkit.autopsy.datamodel.ContentUtils;
import org.sleuthkit.autopsy.datamodel.DataConversion;
import org.sleuthkit.datamodel.Content;
/**
* Top component which displays something.
*/
public final class DataResultTopComponent extends TopComponent implements DataResult, ChangeListener {
private ContentNode rootNode;
private Node rootNode;
private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private boolean isMain;
/** path to the icon used by the component and its open action */
@ -77,7 +73,7 @@ public final class DataResultTopComponent extends TopComponent implements DataRe
this.outdated = true;
}
void setNode(ContentNode selectedNode) {
void setNode(Node selectedNode) {
this.wrapped.setNode(selectedNode);
this.outdated = false;
}
@ -114,7 +110,7 @@ public final class DataResultTopComponent extends TopComponent implements DataRe
newDataResult.open(); // open it first so the component can be initialized
// set the tree table view
newDataResult.setNode((ContentNode) givenNode);
newDataResult.setNode(givenNode);
newDataResult.directoryTablePath.setText(pathText);
return newDataResult;
@ -285,20 +281,19 @@ public final class DataResultTopComponent extends TopComponent implements DataRe
}
@Override
public void setNode(ContentNode selectedNode) {
public void setNode(Node selectedNode) {
this.rootNode = selectedNode;
String path = "";
if (selectedNode != null) {
path = DataConversion.getformattedPath(ContentUtils.getDisplayPath(((Node) selectedNode).getLookup().lookup(Content.class)), 0);
//path = DataConversion.getformattedPath(ContentUtils.getDisplayPath(selectedNode.getLookup().lookup(Content.class)), 0);
int childrenCount = ((Node) selectedNode).getChildren().getNodesCount(true);
int childrenCount = selectedNode.getChildren().getNodesCount(true);
this.numberMatchLabel.setText(Integer.toString(childrenCount));
}
this.numberMatchLabel.setVisible(true);
this.matchLabel.setVisible(true);
this.directoryTablePath.setText(path); // set the node path
this.directoryTablePath.setText("TEST"); // set the node path
resetTabs(selectedNode);
@ -351,7 +346,7 @@ public final class DataResultTopComponent extends TopComponent implements DataRe
*
* @param selectedNode the selected content Node
*/
public void resetTabs(ContentNode selectedNode) {
public void resetTabs(Node selectedNode) {
for (UpdateWrapper drv : this.viewers) {
drv.resetComponent();

View File

@ -37,7 +37,6 @@ import org.openide.nodes.Node.Property;
import org.openide.nodes.Node.PropertySet;
import org.openide.nodes.Sheet;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
// TODO We should not have anything specific to Image in here...
@ -107,14 +106,11 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
}
@Override
public Node getOriginalSelectedNode() {
public Node getSelectedNode() {
Node result = null;
Node[] selectedNodes = this.getExplorerManager().getSelectedNodes();
if (selectedNodes.length > 0) {
result = selectedNodes[0];
if (result != null && result instanceof TableFilterNode) {
result = ((TableFilterNode) result).getOriginal();
}
}
return result;
}
@ -141,7 +137,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
}
@Override
public void setNode(ContentNode selectedNode) {
public void setNode(Node selectedNode) {
// change the cursor to "waiting cursor" for this operation
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
@ -157,9 +153,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
if (hasChildren) {
Node root = (Node) selectedNode;
if (root instanceof TableFilterNode) {
root = ((TableFilterNode) root).getOriginal();
} else {
if (!(root instanceof TableFilterNode)) {
root = new TableFilterNode(root, true);
}
@ -218,8 +212,7 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
// get first 100 rows values for the table
Object[][] content = null;
//TODO: ContentNode fix - remove cast to node
content = getRowValues((Node) selectedNode, 100);
content = getRowValues(selectedNode, 100);
if (content != null) {

View File

@ -29,7 +29,6 @@ import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer;
/**
@ -82,34 +81,23 @@ public class DataResultViewerThumbnail extends AbstractDataResultViewer {
}
@Override
public Node getOriginalSelectedNode() {
public Node getSelectedNode() {
Node result = null;
Node[] selectedNodes = this.getExplorerManager().getSelectedNodes();
if (selectedNodes.length > 0) {
result = selectedNodes[0];
if (result != null && result instanceof ThumbnailViewNode) {
result = ((ThumbnailViewNode) result).getOriginal();
}
}
return result;
}
@Override
public void setNode(ContentNode givenNode) {
public void setNode(Node givenNode) {
// change the cursor to "waiting cursor" for this operation
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
if (givenNode != null) {
Node root = (Node) givenNode;
if (root instanceof ThumbnailViewNode) {
root = ((ThumbnailViewNode) root).getOriginal();
} else {
Node temp = new AbstractNode(new ThumbnailViewChildren((ContentNode) root));
root = temp;
}
Node root = new AbstractNode(new ThumbnailViewChildren(givenNode));
em.setRootContext(root);
} else {
Node emptyNode = new AbstractNode(Children.LEAF);

View File

@ -37,11 +37,6 @@ class TableFilterNode extends FilterNode {
this.createChild = crChild;
}
@Override
public Node getOriginal() {
return super.getOriginal();
}
/**
* Override the display name / header for the first (tree) column on the
* "TreeTableView".

View File

@ -20,17 +20,21 @@ package org.sleuthkit.autopsy.corecomponents;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.ContentVisitor;
import org.sleuthkit.datamodel.File;
/**
* Complementary class to ThumbnailViewNode
*/
class ThumbnailViewChildren extends FilterNode.Children {
private static final IsSupportedContentVisitor isSupportedVisitor = new IsSupportedContentVisitor();
private int totalChildren;
/** the constructor */
ThumbnailViewChildren(ContentNode arg) {
ThumbnailViewChildren(Node arg) {
super((Node) arg);
this.totalChildren = 1;
}
@ -42,9 +46,7 @@ class ThumbnailViewChildren extends FilterNode.Children {
@Override
protected Node[] createNodes(Node arg0) {
// filter out the FileNode and the "." and ".." directories
if (arg0 != null && //(arg0 instanceof FileNode &&
isSupported(arg0)) {
if (arg0 != null && isSupported(arg0)) {
totalChildren++;
return new Node[]{this.copyNode(arg0)};
} else {
@ -58,7 +60,20 @@ class ThumbnailViewChildren extends FilterNode.Children {
public static boolean isSupported(Node node) {
if (node != null) {
String lowerName = node.getDisplayName().toLowerCase();
Content content = node.getLookup().lookup(Content.class);
if (content != null) {
return content.accept(isSupportedVisitor);
}
}
return false;
}
private static class IsSupportedContentVisitor extends ContentVisitor.Default<Boolean> {
@Override
public Boolean visit(File f) {
String lowerName = f.getName().toLowerCase();
// Note: only supports JPG, GIF, and PNG for now
// TODO: replace giant OR with check if in list
return lowerName.endsWith(".jpg")
@ -71,8 +86,11 @@ class ThumbnailViewChildren extends FilterNode.Children {
//node.getName().toLowerCase().endsWith(".tiff") ||
//node.getName().toLowerCase().endsWith(".tga") ||
lowerName.endsWith(".png");
} else {
}
@Override
protected Boolean defaultVisit(Content cntnt) {
return false;
}
}
}
}

View File

@ -49,11 +49,6 @@ class ThumbnailViewNode extends FilterNode {
super(arg, Children.LEAF);
}
@Override
public Node getOriginal() {
return super.getOriginal();
}
@Override
public Image getIcon(int type) {
Image icon = null;

View File

@ -1,43 +0,0 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.datamodel;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
public class ContentFilterNode extends FilterNode implements ContentNode {
public ContentFilterNode(ContentNode original) {
super((Node) original);
}
public ContentFilterNode(ContentNode original, Children children) {
super((Node) original, children);
}
public ContentFilterNode(ContentNode original, Children children, Lookup lookup) {
super((Node) original, children, lookup);
}
@Override
public <T> T accept(ContentNodeVisitor<T> v) {
return ((ContentNode) super.getOriginal()).accept(v);
}
}

View File

@ -22,7 +22,8 @@ package org.sleuthkit.autopsy.datamodel;
* Interface class that all Data nodes inherit from.
* Provides basic information such as ID, parent ID, etc.
*/
public interface ContentNode {
interface ContentNode {
/**
* Visitor pattern support.
@ -31,5 +32,5 @@ public interface ContentNode {
* @param v visitor
* @return visitor return value
*/
public <T> T accept(ContentNodeVisitor<T> v);
<T> T accept(ContentNodeVisitor<T> v);
}

View File

@ -22,7 +22,7 @@ package org.sleuthkit.autopsy.datamodel;
* Interface for visitor pattern on ContentNodes
* @param <T> visit method return type
*/
public interface ContentNodeVisitor<T> {
interface ContentNodeVisitor<T> {
T visit(DirectoryNode dn);
@ -37,7 +37,7 @@ public interface ContentNodeVisitor<T> {
* specific visit types to not use the default behavior.
* @param <T>
*/
static abstract public class Default<T> implements ContentNodeVisitor<T> {
static abstract class Default<T> implements ContentNodeVisitor<T> {
/**
* Default visit for all types

View File

@ -67,32 +67,6 @@ public class FileNode extends AbstractFsContentNode<File> {
return new Action[]{};
}
// TODO: check if there's anything important in here
// @Override
// public Object[][] getRowValues(int rows) throws SQLException {
// FsContent con = content;
// Object[][] objs = new Object[1][16];
// Arrays.fill(objs, 0, 1, new Object[]{
// con.getName(),
// con.getMtimeAsDate(),
// con.getCtimeAsDate(),
// con.getAtimeAsDate(),
// con.getCrtimeAsDate(),
// con.getSize(),
// con.getDirFlagsAsString(),
// con.getMetaFlagsAsString(),
// con.getModeAsString(),
// con.getUid(),
// con.getGid(),
// con.getMeta_addr(),
// con.getAttr_type() + "-" + con.getAttr_id(),
// con.getDirTypeAsString(),
// con.getMetaTypeAsString(),
// con.getKnown().getName()
// });
// return objs;
// }
@Override
public <T> T accept(ContentNodeVisitor<T> v) {
return v.visit(this);

View File

@ -18,11 +18,11 @@
*/
package org.sleuthkit.autopsy.directorytree;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import org.openide.nodes.Node;
import org.openide.util.actions.Presenter;
import org.sleuthkit.autopsy.corecomponents.DataContentTopComponent;
import org.sleuthkit.autopsy.corecomponents.DataContentViewerHex;
@ -37,10 +37,10 @@ import org.sleuthkit.autopsy.logging.Log;
public class ChangeViewAction extends AbstractAction implements Presenter.Popup {
private int type; // type 1 = hex view, 2 = string view
private ContentNode node;
private Node node;
/** the constructor */
public ChangeViewAction(String title, int viewType, ContentNode node) {
public ChangeViewAction(String title, int viewType, Node node) {
super(title);
this.type = viewType;
this.node = node;

View File

@ -18,6 +18,7 @@
*/
package org.sleuthkit.autopsy.directorytree;
import org.openide.explorer.ExplorerManager;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
@ -28,19 +29,17 @@ import org.openide.nodes.Node;
* @author jantonius
*/
public class DataResultFilterChildren extends FilterNode.Children {
ExplorerManager sourceEm;
/** the constructor */
public DataResultFilterChildren(Node arg) {
public DataResultFilterChildren(Node arg, ExplorerManager sourceEm) {
super(arg);
this.sourceEm = sourceEm;
}
@Override
protected Node copyNode(Node arg0) {
return new DataResultFilterNode(arg0);
}
@Override
protected Node[] createNodes(Node arg0) {
return new Node[]{this.copyNode(arg0)};
return new DataResultFilterNode(arg0, sourceEm);
}
}

View File

@ -23,7 +23,6 @@ import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.List;
import org.sleuthkit.autopsy.datamodel.ImageNode;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.datamodel.VolumeNode;
import org.sleuthkit.autopsy.datamodel.FileNode;
import org.sleuthkit.autopsy.datamodel.DirectoryNode;
@ -31,34 +30,24 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JPanel;
import org.openide.explorer.ExplorerManager;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.openide.nodes.Sheet;
import org.sleuthkit.autopsy.datamodel.ContentNodeVisitor;
import org.sleuthkit.datamodel.Content;
/**
* This class wraps nodes as they are passed to the DataResult viewers. It
* defines the actions that the node should have.
*/
public class DataResultFilterNode extends FilterNode implements ContentNode {
public class DataResultFilterNode extends FilterNode{
private Node currentNode;
// for error handling
private JPanel caller;
private String className = this.getClass().toString();
private ExplorerManager sourceEm;
/** the constructor */
public DataResultFilterNode(Node arg) {
super(arg, new DataResultFilterChildren(arg));
this.currentNode = arg;
}
@Override
public Node getOriginal() {
return super.getOriginal();
public DataResultFilterNode(Node arg, ExplorerManager em) {
super(arg, new DataResultFilterChildren(arg, em));
this.sourceEm = em;
}
/**
@ -66,7 +55,7 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
* table and the output view.
*
* @param popup
* @return actionss
* @return actions
*/
@Override
public Action[] getActions(boolean popup) {
@ -76,32 +65,33 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
// TODO: ContentNode fix - restore right-click actions
// TODO: ContentVisitor instead of instanceof
Content nodeContent = this.currentNode.getLookup().lookup(Content.class);
Content nodeContent = this.getOriginal().getLookup().lookup(Content.class);
Node originalNode = this.getOriginal();
// right click action(s) for image node
if (this.currentNode instanceof ImageNode) {
actions.add(new NewWindowViewAction("View in New Window", (ImageNode) this.currentNode));
if (originalNode instanceof ImageNode) {
actions.add(new NewWindowViewAction("View in New Window", (ImageNode) originalNode));
actions.addAll(ShowDetailActionVisitor.getActions(nodeContent));
} // right click action(s) for volume node
else if (this.currentNode instanceof VolumeNode) {
actions.add(new NewWindowViewAction("View in New Window", (VolumeNode) this.currentNode));
else if (originalNode instanceof VolumeNode) {
actions.add(new NewWindowViewAction("View in New Window", (VolumeNode) originalNode));
//new ShowDetailActionVisitor("Volume Details", this.currentNode.getName(), (VolumeNode) this.currentNode),
actions.addAll(ShowDetailActionVisitor.getActions(nodeContent));
actions.add(new ChangeViewAction("View", 0, (ContentNode) currentNode));
actions.add(new ChangeViewAction("View", 0, this.getOriginal()));
} // right click action(s) for directory node
else if (this.currentNode instanceof DirectoryNode) {
actions.add(new NewWindowViewAction("View in New Window", (DirectoryNode) this.currentNode));
actions.add(new ChangeViewAction("View", 0, (ContentNode) currentNode));
else if (originalNode instanceof DirectoryNode) {
actions.add(new NewWindowViewAction("View in New Window", (DirectoryNode) originalNode));
actions.add(new ChangeViewAction("View", 0, originalNode));
// TODO: ContentNode fix - reimplement ExtractAction
//actions.add(new ExtractAction("Extract Directory", (DirectoryNode) this.currentNode));
} // right click action(s) for the file node
else if (this.currentNode instanceof FileNode) {
actions.add(new ExternalViewerAction("Open File in External Viewer", (FileNode) this.currentNode));
actions.add(new NewWindowViewAction("View in New Window", (FileNode) this.currentNode));
else if (originalNode instanceof FileNode) {
actions.add(new ExternalViewerAction("Open File in External Viewer", (FileNode) originalNode));
actions.add(new NewWindowViewAction("View in New Window", (FileNode) originalNode));
// TODO: ContentNode fix - reimplement ExtractAction
//actions.add(new ExtractAction("Extract", (FileNode) this.currentNode));
actions.add(new ChangeViewAction("View", 0, (ContentNode) currentNode));
actions.add(new ChangeViewAction("View", 0, originalNode));
}
return actions.toArray(new Action[actions.size()]);
@ -116,9 +106,12 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
@Override
public Action getPreferredAction() {
// double click action(s) for volume node or directory node
if (this.currentNode instanceof VolumeNode || (this.currentNode instanceof DirectoryNode && !this.currentNode.getDisplayName().equals("."))) {
final Node originalNode = this.getOriginal();
if (originalNode instanceof VolumeNode || (originalNode instanceof DirectoryNode && !originalNode.getDisplayName().equals("."))) {
if (this.currentNode instanceof DirectoryNode && this.currentNode.getDisplayName().equals("..")) {
if (originalNode instanceof DirectoryNode && originalNode.getDisplayName().equals("..")) {
ExplorerManager em = DirectoryTreeTopComponent.findInstance().getExplorerManager();
Node[] selectedNode = em.getSelectedNodes();
Node selectedContext = selectedNode[0];
@ -149,7 +142,7 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
ExplorerManager em = DirectoryTreeTopComponent.findInstance().getExplorerManager();
for (int i = 0; i < parentContext.getChildren().getNodesCount(); i++) {
Node selectedNode = parentContext.getChildren().getNodeAt(i);
if (selectedNode != null && selectedNode.getName().equals(currentNode.getName())) {
if (selectedNode != null && selectedNode.getName().equals(originalNode.getName())) {
try {
em.setExploredContextAndSelection(selectedNode, new Node[]{selectedNode});
} catch (PropertyVetoException ex) {
@ -194,10 +187,4 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
return propertySets;
}
@Override
public <T> T accept(ContentNodeVisitor<T> v) {
// TODO: Figure out how visitors should be delegated
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -23,29 +23,24 @@ import java.util.List;
import javax.swing.Action;
import org.openide.nodes.FilterNode;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.casemodule.Case;
import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ProxyLookup;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.Volume;
/**
* This class sets the actions for the nodes in the directory tree and creates
* the children filter so that files and such are hidden from the tree.
*
*/
public class DirectoryTreeFilterNode extends FilterNode {
class DirectoryTreeFilterNode extends FilterNode {
private static final Action collapseAll = new CollapseAction("Collapse All");
/** the constructor */
public DirectoryTreeFilterNode(Node arg) {
super(arg, DirectoryTreeFilterChildren.createInstance(arg));
}
// TODO This seems bad. We should have this return the real original and modify code somewhere else to wrap it
@Override
public Node getOriginal() {
return new DataResultFilterNode(super.getOriginal());
DirectoryTreeFilterNode(Node arg) {
super(arg, DirectoryTreeFilterChildren.createInstance(arg),
new ProxyLookup(Lookups.singleton(new OriginalNode(arg)),
arg.getLookup()));
}
/**
@ -58,7 +53,7 @@ public class DirectoryTreeFilterNode extends FilterNode {
public Action[] getActions(boolean popup) {
List<Action> actions = new ArrayList<Action>();
Content content = super.getOriginal().getLookup().lookup(Content.class);
Content content = this.getLookup().lookup(Content.class);
if (content != null) {
actions.addAll(DirectoryTreeFilterNode.getActions(content));
actions.add(collapseAll);
@ -74,4 +69,17 @@ public class DirectoryTreeFilterNode extends FilterNode {
return actions;
}
static class OriginalNode {
private Node original;
private OriginalNode(Node original) {
this.original = original;
}
Node getNode() {
return original;
}
}
}

View File

@ -44,9 +44,9 @@ import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
import org.sleuthkit.autopsy.datamodel.RootContentChildren;
import org.sleuthkit.autopsy.directorytree.DirectoryTreeFilterNode.OriginalNode;
/**
* Top component which displays something.
@ -332,24 +332,10 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
};
}
};
/*try {
root = new DirectoryTreeFilterNode(root);
} catch (SQLException ex) {
JOptionPane.showMessageDialog(caller, "Error: problem making directory filter node.\n \nDetail: \n" + ex.getMessage() + " (at " + className + ").", "Error", JOptionPane.ERROR_MESSAGE);
}*/
// TODO It seems that we can get rid of the first condition. root is an abstract node
if (root instanceof DirectoryTreeFilterNode) {
root = ((DirectoryTreeFilterNode) root).getOriginal();
} else {
// try {
root = new DirectoryTreeFilterNode(root);
// } catch (SQLException ex) {
// JOptionPane.showMessageDialog(caller, "Error: problem making directory filter node.\n \nDetail: \n" + ex.getMessage() + " (at " + className + ").", "Error", JOptionPane.ERROR_MESSAGE);
// }
}
em.setRootContext(root);
em.getRootContext().setName(currentCase.getName());
em.getRootContext().setDisplayName(currentCase.getName());
@ -460,16 +446,12 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
*
* @return node the original selected Node
*/
// TODO Rename or get rid of it entirely.
public Node getOriginalSelectedNode() {
public Node getSelectedNode() {
Node result = null;
Node[] selectedNodes = this.getExplorerManager().getSelectedNodes();
if (selectedNodes.length > 0) {
result = selectedNodes[0];
if (result != null && result instanceof DirectoryTreeFilterNode) {
result = ((DirectoryTreeFilterNode) result).getOriginal();
}
}
return result;
}
@ -500,10 +482,10 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
em.getRootContext().setDisplayName(newCaseName);
}
}
// changed current case
if (changed.equals(Case.CASE_CURRENT_CASE)) {
// case opened
if (newValue != null) {
resetHistoryListAndButtons();
@ -546,8 +528,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
// change in node selection
if (changed.equals(ExplorerManager.PROP_SELECTED_NODES)) {
// Some lock that prevents certian Node operations is set during the
// Some lock that prevents certain Node operations is set during the
// ExplorerManager selection-change, so we must handle changes after the
// selection-change event is processed.
EventQueue.invokeLater(new Runnable() {
@ -561,18 +542,18 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
// make sure dataResult is open
dataResult.open();
ContentNode node = (ContentNode) DirectoryTreeTopComponent.this.getOriginalSelectedNode();
if (node != null) {
Node treeNode = DirectoryTreeTopComponent.this.getSelectedNode();
if (treeNode != null) {
Node originNode = treeNode.getLookup().lookup(DirectoryTreeFilterNode.OriginalNode.class).getNode();
//pcs.firePropertyChange(DataExplorer.EXPLORER_NODE_SELECTION_CHANGED, "", node);
int count = ((Node) node).getChildren().getNodesCount(true);
int count = originNode.getChildren().getNodesCount(true);
if (count > 1000) {
DirectoryTreeTopComponent.this.setCursor(null);
JOptionPane.showMessageDialog(caller, "Note: The selected directory contains " + count + " child files and folders. It may take some time to display them.\n\nAlso note that in the current version of Autopsy this will also make certain functions very slow (thumbnail view in particular, should be fixed in a future version)", "Large Data", JOptionPane.INFORMATION_MESSAGE);
DirectoryTreeTopComponent.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
DirectoryTreeTopComponent.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
DirectoryTreeTopComponent.this.dataResult.setNode(node);
DirectoryTreeTopComponent.this.dataResult.setNode(new DataResultFilterNode(originNode, DirectoryTreeTopComponent.this.em));
}
// set the directory listing to be active

View File

@ -25,7 +25,6 @@ import javax.swing.AbstractAction;
import org.openide.nodes.Node;
import org.openide.windows.Mode;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.datamodel.DataConversion;
import org.sleuthkit.autopsy.corecomponents.DataContentTopComponent;
import org.sleuthkit.autopsy.datamodel.ContentUtils;
@ -37,9 +36,9 @@ import org.sleuthkit.datamodel.Content;
*/
class NewWindowViewAction extends AbstractAction{
private ContentNode contentNode ;
private Node contentNode ;
NewWindowViewAction(String title, ContentNode contentNode){
NewWindowViewAction(String title, Node contentNode){
super(title);
this.contentNode = contentNode;
}

View File

@ -18,9 +18,7 @@
*/
package org.sleuthkit.autopsy.filesearch;
import org.sleuthkit.autopsy.datamodel.ContentNodeVisitor;
import org.sleuthkit.autopsy.datamodel.ImageNode;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.datamodel.VolumeNode;
import org.sleuthkit.autopsy.datamodel.FileNode;
import org.sleuthkit.autopsy.datamodel.DirectoryNode;
@ -35,7 +33,7 @@ import org.sleuthkit.datamodel.Content;
* This class wraps nodes as they are passed to the DataResult viewers. It
* defines the actions that the node should have.
*/
public class DataResultFilterNode extends FilterNode implements ContentNode {
public class DataResultFilterNode extends FilterNode {
private Node currentNode;
@ -45,11 +43,6 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
this.currentNode = arg;
}
@Override
public Node getOriginal() {
return super.getOriginal();
}
/**
* Right click action for the nodes that we want to pass to the directory
* table and the output view.
@ -68,16 +61,16 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
} // right click action(s) for directory node
else if (this.currentNode instanceof DirectoryNode) {
return new Action[]{
new ChangeViewAction("View", 0, (ContentNode) currentNode),
new OpenParentFolderAction("Open Parent Directory", ContentUtils.getSystemPath((currentNode).getLookup().lookup(Content.class)))
new ChangeViewAction("View", 0, currentNode),
new OpenParentFolderAction("Open Parent Directory", ContentUtils.getSystemPath(currentNode.getLookup().lookup(Content.class)))
};
} // right click action(s) for the file node
else if (this.currentNode instanceof FileNode) {
return new Action[]{
// TODO: ContentNode fix - reimplement ExtractAction
// new ExtractAction("Extract", (FileNode) this.currentNode),
new ChangeViewAction("View", 0, (ContentNode) currentNode),
new OpenParentFolderAction("Open Parent Directory", ContentUtils.getSystemPath((currentNode).getLookup().lookup(Content.class)))
new ChangeViewAction("View", 0, currentNode),
new OpenParentFolderAction("Open Parent Directory", ContentUtils.getSystemPath(currentNode.getLookup().lookup(Content.class)))
};
} else {
return new Action[]{};
@ -94,10 +87,4 @@ public class DataResultFilterNode extends FilterNode implements ContentNode {
public Action getPreferredAction() {
return null;
}
@Override
public <T> T accept(ContentNodeVisitor<T> v) {
//TODO: figure out how to deal with visitors
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -21,15 +21,13 @@ package org.sleuthkit.autopsy.filesearch;
import java.util.ArrayList;
import org.openide.nodes.AbstractNode;
import org.sleuthkit.autopsy.datamodel.ContentNode;
import org.sleuthkit.autopsy.datamodel.ContentNodeVisitor;
import org.sleuthkit.datamodel.FsContent;
/**
*
* @author jantonius
*/
class SearchNode extends AbstractNode implements ContentNode {
class SearchNode extends AbstractNode {
private SearchChildren children;
@ -42,11 +40,4 @@ class SearchNode extends AbstractNode implements ContentNode {
public String getName() {
return "Search Result";
}
@Override
public <T> T accept(ContentNodeVisitor<T> v) {
//TODO: figure out how to deal with visitors
throw new UnsupportedOperationException("Not supported yet.");
}
}