mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
fix DataResultViewerTable to support tree view. Wrapping of nodes needs to happen earlier if want to filter children out from the view.
This commit is contained in:
parent
c33608d61f
commit
0388bfd065
@ -152,9 +152,12 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
|
||||
if (hasChildren) {
|
||||
Node root = selectedNode;
|
||||
|
||||
if (!(root instanceof TableFilterNode)) {
|
||||
root = new TableFilterNode(root, true);
|
||||
}
|
||||
//wrap to filter out children
|
||||
//note: this breaks the tree view mode in this generic viewer,
|
||||
//so wrap nodes earlier if want 1 level view
|
||||
//if (!(root instanceof TableFilterNode)) {
|
||||
/// root = new TableFilterNode(root, true);
|
||||
//}
|
||||
|
||||
em.setRootContext(root);
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.openide.nodes.Node;
|
||||
*
|
||||
* @author jantonius
|
||||
*/
|
||||
class TableFilterNode extends FilterNode {
|
||||
public class TableFilterNode extends FilterNode {
|
||||
|
||||
private boolean createChild;
|
||||
|
||||
|
@ -45,6 +45,7 @@ import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Node;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
|
||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
||||
import org.sleuthkit.autopsy.datamodel.DataConversion;
|
||||
import org.sleuthkit.autopsy.datamodel.RootContentChildren;
|
||||
@ -555,7 +556,9 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
|
||||
DirectoryTreeTopComponent.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
}
|
||||
DirectoryTreeTopComponent.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
DirectoryTreeTopComponent.this.dataResult.setNode(new DataResultFilterNode(originNode, DirectoryTreeTopComponent.this.em));
|
||||
//set node, wrap in filter node first to filter out children
|
||||
Node drfn = new DataResultFilterNode(originNode, DirectoryTreeTopComponent.this.em);
|
||||
DirectoryTreeTopComponent.this.dataResult.setNode(new TableFilterNode(drfn, true));
|
||||
|
||||
String path = DataConversion.getformattedPath(ContentUtils.getDisplayPath(originNode.getLookup().lookup(Content.class)), 0);
|
||||
DirectoryTreeTopComponent.this.dataResult.setPath(path);
|
||||
|
@ -97,7 +97,7 @@ public class KeywordSearchDataExplorer implements DataExplorer {
|
||||
if (rq.validate()) {
|
||||
rq.execute();
|
||||
} else {
|
||||
displayErrorDialog("Invalid RegEx query: " + regexQuery);
|
||||
displayErrorDialog("Invalid RegEx query syntax: " + regexQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,15 +101,14 @@ public class RegexQuery implements KeywordSearchQuery {
|
||||
Collection<KeyValueThing> things = new ArrayList<KeyValueThing>();
|
||||
|
||||
Iterator<Term> it = terms.iterator();
|
||||
int termID = 1;
|
||||
int termID = 0;
|
||||
long totalMatches = 0;
|
||||
while (it.hasNext()) {
|
||||
Term term = it.next();
|
||||
Map<String, Object> kvs = new LinkedHashMap<String, Object>();
|
||||
//kvs.put("RegEx Match", term.getTerm());
|
||||
long matches = term.getFrequency();
|
||||
kvs.put("#files", matches);
|
||||
things.add(new KeyValueThing(term.getTerm(), kvs, termID));
|
||||
kvs.put("#hits", matches);
|
||||
things.add(new KeyValueThing(term.getTerm(), kvs, ++termID));
|
||||
totalMatches += matches;
|
||||
}
|
||||
|
||||
@ -145,7 +144,42 @@ public class RegexQuery implements KeywordSearchQuery {
|
||||
|
||||
@Override
|
||||
protected Node createNodeForKey(KeyValueThing thing) {
|
||||
return new KeyValueNode(thing, Children.LEAF);
|
||||
//return new KeyValueNode(thing, Children.LEAF);
|
||||
return new KeyValueNode(thing, Children.create(new RegexResultDetailsChildFactory(thing), true));
|
||||
}
|
||||
|
||||
|
||||
class RegexResultDetailsChildFactory extends ChildFactory<KeyValueThing> {
|
||||
|
||||
private KeyValueThing thing;
|
||||
RegexResultDetailsChildFactory(KeyValueThing thing) {
|
||||
this.thing = thing;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean createKeys(List<KeyValueThing> toPopulate) {
|
||||
//query
|
||||
Map<String,Object> map = new LinkedHashMap<String,Object>();
|
||||
map.put("#hits", -1);
|
||||
KeyValueThing t = new KeyValueThing("TEST", map, 1);
|
||||
//return toPopulate.addAll(things);
|
||||
toPopulate.add(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Node createNodeForKey(KeyValueThing thing) {
|
||||
return new KeyValueNode(thing, Children.LEAF);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Node[] createNodesForKey(KeyValueThing thing) {
|
||||
Node [] nodes = new Node[1];
|
||||
nodes[0] = new KeyValueNode(thing, Children.LEAF);
|
||||
return nodes;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user