line endings

This commit is contained in:
Jeff Wallace 2013-12-12 15:13:48 -05:00
parent d11df43a1d
commit 7290b1f052

View File

@ -1,159 +1,159 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2011 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.sleuthkit.autopsy.directorytree; package org.sleuthkit.autopsy.directorytree;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
import org.openide.nodes.FilterNode; import org.openide.nodes.FilterNode;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ProxyLookup; import org.openide.util.lookup.ProxyLookup;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.datamodel.AbstractContentNode; import org.sleuthkit.autopsy.datamodel.AbstractContentNode;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode; import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
import org.sleuthkit.autopsy.ingest.IngestDialog; import org.sleuthkit.autopsy.ingest.IngestDialog;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.Directory; import org.sleuthkit.datamodel.Directory;
import org.sleuthkit.datamodel.Image; import org.sleuthkit.datamodel.Image;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
/** /**
* This class sets the actions for the nodes in the directory tree and creates * 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. * the children filter so that files and such are hidden from the tree.
* *
*/ */
class DirectoryTreeFilterNode extends FilterNode { class DirectoryTreeFilterNode extends FilterNode {
private static final Action collapseAll = new CollapseAction("Collapse All"); private static final Action collapseAll = new CollapseAction("Collapse All");
private static final Logger logger = Logger.getLogger(DirectoryTreeFilterNode.class.getName()); private static final Logger logger = Logger.getLogger(DirectoryTreeFilterNode.class.getName());
/** /**
* the constructor * the constructor
*/ */
DirectoryTreeFilterNode(Node arg, boolean createChildren) { DirectoryTreeFilterNode(Node arg, boolean createChildren) {
super(arg, DirectoryTreeFilterChildren.createInstance(arg, createChildren), super(arg, DirectoryTreeFilterChildren.createInstance(arg, createChildren),
new ProxyLookup(Lookups.singleton(new OriginalNode(arg)), new ProxyLookup(Lookups.singleton(new OriginalNode(arg)),
arg.getLookup())); arg.getLookup()));
} }
@Override @Override
public String getDisplayName() { public String getDisplayName() {
final Node orig = getOriginal(); final Node orig = getOriginal();
String name = orig.getDisplayName(); String name = orig.getDisplayName();
//do not show children counts for non content nodes //do not show children counts for non content nodes
if (orig instanceof AbstractContentNode) { if (orig instanceof AbstractContentNode) {
//show only for file content nodes //show only for file content nodes
AbstractFile file = getLookup().lookup(AbstractFile.class); AbstractFile file = getLookup().lookup(AbstractFile.class);
if (file != null) { if (file != null) {
try { try {
final int numChildren = file.getChildrenCount(); final int numChildren = file.getChildrenCount();
name = name + " (" + numChildren + ")"; name = name + " (" + numChildren + ")";
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error getting children count to display for file: " + file, ex); logger.log(Level.SEVERE, "Error getting children count to display for file: " + file, ex);
} }
} }
} }
return name; return name;
} }
/** /**
* Right click action for the nodes in the directory tree. * Right click action for the nodes in the directory tree.
* *
* @param popup * @param popup
* @return * @return
*/ */
@Override @Override
public Action[] getActions(boolean popup) { public Action[] getActions(boolean popup) {
List<Action> actions = new ArrayList<Action>(); List<Action> actions = new ArrayList<Action>();
final Content content = this.getLookup().lookup(Content.class); final Content content = this.getLookup().lookup(Content.class);
if (content != null) { if (content != null) {
actions.addAll(DirectoryTreeFilterNode.getDetailActions(content)); actions.addAll(DirectoryTreeFilterNode.getDetailActions(content));
//extract dir action //extract dir action
Directory dir = this.getLookup().lookup(Directory.class); Directory dir = this.getLookup().lookup(Directory.class);
if (dir != null) { if (dir != null) {
actions.add(ExtractAction.getInstance()); actions.add(ExtractAction.getInstance());
} }
// file search action // file search action
final Image img = this.getLookup().lookup(Image.class); final Image img = this.getLookup().lookup(Image.class);
if (img != null) { if (img != null) {
actions.add(new FileSearchAction("Open File Search by Attributes")); actions.add(new FileSearchAction("Open File Search by Attributes"));
} }
//ingest action //ingest action
actions.add(new AbstractAction("Run Ingest Modules") { actions.add(new AbstractAction("Run Ingest Modules") {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final IngestDialog ingestDialog = new IngestDialog(); final IngestDialog ingestDialog = new IngestDialog();
ingestDialog.setContent(Collections.<Content>singletonList(content)); ingestDialog.setContent(Collections.<Content>singletonList(content));
ingestDialog.display(); ingestDialog.display();
} }
}); });
} }
//check if delete actions should be added //check if delete actions should be added
final Node orig = getOriginal(); final Node orig = getOriginal();
//TODO add a mechanism to determine if DisplayableItemNode //TODO add a mechanism to determine if DisplayableItemNode
if (orig instanceof DisplayableItemNode) { if (orig instanceof DisplayableItemNode) {
actions.addAll(getDeleteActions((DisplayableItemNode) orig)); actions.addAll(getDeleteActions((DisplayableItemNode) orig));
} }
actions.add(collapseAll); actions.add(collapseAll);
return actions.toArray(new Action[actions.size()]); return actions.toArray(new Action[actions.size()]);
} }
private static List<Action> getDeleteActions(DisplayableItemNode original) { private static List<Action> getDeleteActions(DisplayableItemNode original) {
List<Action> actions = new ArrayList<Action>(); List<Action> actions = new ArrayList<Action>();
//actions.addAll(original.accept(getDeleteActionVisitor)); //actions.addAll(original.accept(getDeleteActionVisitor));
return actions; return actions;
} }
private static List<Action> getDetailActions(Content c) { private static List<Action> getDetailActions(Content c) {
List<Action> actions = new ArrayList<Action>(); List<Action> actions = new ArrayList<Action>();
actions.addAll(ExplorerNodeActionVisitor.getActions(c)); actions.addAll(ExplorerNodeActionVisitor.getActions(c));
return actions; return actions;
} }
} }
class OriginalNode { class OriginalNode {
private Node original; private Node original;
OriginalNode(Node original) { OriginalNode(Node original) {
this.original = original; this.original = original;
} }
Node getNode() { Node getNode() {
return original; return original;
} }
} }