1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-09-06 02:24:30 +00:00

Fixed DRVT node expansion bug and added selection logic for node deletion

This commit is contained in:
Richard Cordovano
2013-10-22 13:32:49 -04:00
parent d992fbe2f7
commit ff54c75cfd
7 changed files with 79 additions and 56 deletions

View File

@@ -50,7 +50,7 @@ public class ContentTagTypeNode extends DisplayableItemNode {
Logger.getLogger(ContentTagTypeNode.class.getName()).log(Level.SEVERE, "Failed to get content tags count for " + tagName.getDisplayName() + " tag name", ex);
}
super.setName(DISPLAY_NAME + " (" + tagsCount + ")");
super.setName(DISPLAY_NAME);
super.setDisplayName(DISPLAY_NAME + " (" + tagsCount + ")");
this.setIconBaseWithExtension(ICON_PATH);
}

View File

@@ -53,7 +53,7 @@ public class TagNameNode extends DisplayableItemNode {
Logger.getLogger(TagNameNode.class.getName()).log(Level.SEVERE, "Failed to get tags count for " + tagName.getDisplayName() + " tag name", ex);
}
super.setName(tagName.getDisplayName() + " (" + tagsCount + ")");
super.setName(tagName.getDisplayName());
super.setDisplayName(tagName.getDisplayName() + " (" + tagsCount + ")");
if (tagName.getDisplayName().equals("Bookmark")) {
setIconBaseWithExtension(BOOKMARK_TAG_ICON_PATH);

View File

@@ -46,10 +46,6 @@ public class TagsNode extends DisplayableItemNode {
this.setIconBaseWithExtension(ICON_PATH);
}
public static String getNodeName() {
return DISPLAY_NAME;
}
@Override
public boolean isLeafTypeNode() {
return false;
@@ -78,7 +74,7 @@ public class TagsNode extends DisplayableItemNode {
@Override
protected boolean createKeys(List<TagName> keys) {
try {
Case.getCurrentCase().getServices().getTagsManager().getAllTagNames(keys);
Case.getCurrentCase().getServices().getTagsManager().getTagNamesInUse(keys);
}
catch (TskCoreException ex) {
Logger.getLogger(TagNameNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex);

View File

@@ -55,7 +55,7 @@ public class BlackboardArtifactTagTypeNode extends DisplayableItemNode {
Logger.getLogger(BlackboardArtifactTagTypeNode.class.getName()).log(Level.SEVERE, "Failed to get blackboard artifact tags count for " + tagName.getDisplayName() + " tag name", ex);
}
super.setName(DISPLAY_NAME + " (" + tagsCount + ")");
super.setName(DISPLAY_NAME);
super.setDisplayName(DISPLAY_NAME + " (" + tagsCount + ")");
this.setIconBaseWithExtension(ICON_PATH);
}

View File

@@ -39,6 +39,7 @@ import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode.AbstractFileProp
import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode;
import org.sleuthkit.autopsy.datamodel.ArtifactTypeNode;
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
import org.sleuthkit.autopsy.datamodel.ContentTagTypeNode;
import org.sleuthkit.autopsy.datamodel.LocalFileNode;
import org.sleuthkit.autopsy.datamodel.DeletedContent.DeletedContentsChildren.DeletedContentNode;
import org.sleuthkit.autopsy.datamodel.DeletedContent.DeletedContentsNode;
@@ -63,6 +64,7 @@ import org.sleuthkit.autopsy.datamodel.LayoutFileNode;
import org.sleuthkit.autopsy.datamodel.RecentFilesFilterNode;
import org.sleuthkit.autopsy.datamodel.RecentFilesNode;
import org.sleuthkit.autopsy.datamodel.FileTypesNode;
import org.sleuthkit.autopsy.datamodel.TagNameNode;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute;
@@ -403,6 +405,21 @@ public class DataResultFilterNode extends FilterNode {
return openChild(atn);
}
@Override
public AbstractAction visit(TagNameNode node) {
return openChild(node);
}
@Override
public AbstractAction visit(ContentTagTypeNode node) {
return openChild(node);
}
@Override
public AbstractAction visit(BlackboardArtifactTagTypeNode node) {
return openChild(node);
}
@Override
public AbstractAction visit(DirectoryNode dn) {
if (dn.getDisplayName().equals(DirectoryNode.DOTDOTDIR)) {

View File

@@ -27,6 +27,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
@@ -856,38 +857,53 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
}
/**
* Set selected node using the previously saved selection path to the
* selected node
* Set the selected node using a path to a previously selected node.
*
* @param path node path with node names
* @param rootNodeName name of the root node to match or null if any
* @param previouslySelectedNodePath Path to a previously selected node.
* @param rootNodeName Name of the root node to match, may be null.
*/
private void setSelectedNode(final String[] path, final String rootNodeName) {
if (path == null) {
private void setSelectedNode(final String[] previouslySelectedNodePath, final String rootNodeName) {
if (previouslySelectedNodePath == null) {
return;
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (path.length > 0 && (rootNodeName == null || path[0].equals(rootNodeName))) {
try {
Node newSelection = NodeOp.findPath(em.getRootContext(), path);
if (newSelection != null) {
if (rootNodeName != null) {
//called from tree auto refresh context
//remove last from backlist, because auto select will result in duplication
backList.pollLast();
}
em.setExploredContextAndSelection(newSelection, new Node[]{newSelection});
if (previouslySelectedNodePath.length > 0 && (rootNodeName == null || previouslySelectedNodePath[0].equals(rootNodeName))) {
Node selectedNode = null;
ArrayList<String> selectedNodePath = new ArrayList<>(Arrays.asList(previouslySelectedNodePath));
while (null == selectedNode && !selectedNodePath.isEmpty()) {
try {
selectedNode = NodeOp.findPath(em.getRootContext(), selectedNodePath.toArray(new String[0]));
}
catch (NodeNotFoundException ex) {
// The selected node may have been deleted (e.g., a deleted tag), so truncate the path and try again.
if (selectedNodePath.size() > 1) {
selectedNodePath.remove(selectedNodePath.size() - 1);
}
else {
StringBuilder nodePath = new StringBuilder();
for (int i = 0; i < previouslySelectedNodePath.length; ++i) {
nodePath.append(previouslySelectedNodePath[i]).append("/");
}
logger.log(Level.WARNING, "Failed to find any nodes to select on path " + nodePath.toString(), ex);
break;
}
}
}
if (null != selectedNode) {
if (rootNodeName != null) {
//called from tree auto refresh context
//remove last from backlist, because auto select will result in duplication
backList.pollLast();
}
try {
em.setExploredContextAndSelection(selectedNode, new Node[]{selectedNode});
}
catch (PropertyVetoException ex) {
logger.log(Level.WARNING, "Property veto from ExplorerManager setting selection to " + selectedNode.getName(), ex);
}
// We need to set the selection, which will refresh dataresult and get rid of the oob exception
} catch (NodeNotFoundException ex) {
logger.log(Level.WARNING, "Node not found", ex);
} catch (PropertyVetoException ex) {
logger.log(Level.WARNING, "Property Veto", ex);
}
}
}

View File

@@ -494,24 +494,19 @@ public class ReportGenerator {
// Give the modules the rows for the content tags.
for (ContentTag tag : tags) {
// Apply the tag names filter.
if (!tagNamesFilter.isEmpty()) {
if (tagNamesFilter.contains(tag.getName().getDisplayName())) {
continue;
if (passesTagNamesFilter(tag.getName().getDisplayName())) {
ArrayList<String> rowData = new ArrayList<>(Arrays.asList(tag.getContent().getName(), tag.getName().getDisplayName(), tag.getComment()));
for (TableReportModule module : tableModules) {
// @@@ This casting is a tricky little workaround to allow the HTML report module to slip in a content hyperlink.
if (module instanceof ReportHTML) {
ReportHTML htmlReportModule = (ReportHTML)module;
htmlReportModule.addRowWithTaggedContentHyperlink(rowData, tag);
}
else {
module.addRow(rowData);
}
}
}
ArrayList<String> rowData = new ArrayList<>(Arrays.asList(tag.getContent().getName(), tag.getName().getDisplayName(), tag.getComment()));
for (TableReportModule module : tableModules) {
// @@@ This casting is a tricky little workaround to allow the HTML report module to slip in a content hyperlink.
if (module instanceof ReportHTML) {
ReportHTML htmlReportModule = (ReportHTML)module;
htmlReportModule.addRowWithTaggedContentHyperlink(rowData, tag);
}
else {
module.addRow(rowData);
}
}
}
// The the modules content tags reporting is ended.
@@ -553,16 +548,11 @@ public class ReportGenerator {
// Give the modules the rows for the content tags.
for (BlackboardArtifactTag tag : tags) {
// Apply the tag names filter.
if (!tagNamesFilter.isEmpty()) {
if (tagNamesFilter.contains(tag.getName().getDisplayName())) {
continue;
if (passesTagNamesFilter(tag.getName().getDisplayName())) {
for (TableReportModule module : tableModules) {
module.addRow(new ArrayList<>(Arrays.asList(tag.getArtifact().getArtifactTypeName(), tag.getName().getDisplayName(), tag.getComment(), tag.getContent().getName())));
}
}
for (TableReportModule module : tableModules) {
module.addRow(new ArrayList<>(Arrays.asList(tag.getArtifact().getArtifactTypeName(), tag.getName().getDisplayName(), tag.getComment(), tag.getContent().getName())));
}
}
// The the modules blackboard artifact tags reporting is ended.
@@ -573,6 +563,10 @@ public class ReportGenerator {
}
}
boolean passesTagNamesFilter(String tagName) {
return tagNamesFilter.isEmpty() || tagNamesFilter.contains(tagName);
}
void removeCancelledTableReportModules() {
Iterator<TableReportModule> iter = tableModules.iterator();
while (iter.hasNext()) {