Merge branch 'master' of https://github.com/sleuthkit/autopsy into ie_bookmark_parsing

This commit is contained in:
Jeff Wallace 2013-12-02 15:45:43 -05:00
commit 1c78e0c896
7 changed files with 267 additions and 266 deletions

View File

@ -362,6 +362,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
this.rootNode.addNodeListener(dummyNodeListener); this.rootNode.addNodeListener(dummyNodeListener);
} }
resetTabs(selectedNode);
setupTabs(selectedNode); setupTabs(selectedNode);
if (selectedNode != null) { if (selectedNode != null) {
@ -369,58 +370,42 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
this.numberMatchLabel.setText(Integer.toString(childrenCount)); this.numberMatchLabel.setText(Integer.toString(childrenCount));
} }
this.numberMatchLabel.setVisible(true); this.numberMatchLabel.setVisible(true);
resetTabs(selectedNode);
// set the display on the current active tab
int currentActiveTab = this.dataResultTabbedPanel.getSelectedIndex();
if (currentActiveTab != -1) {
UpdateWrapper drv = viewers.get(currentActiveTab);
drv.setNode(selectedNode);
}
} }
private void setupTabs(final Node selectedNode) { private void setupTabs(Node selectedNode) {
SwingUtilities.invokeLater(new Runnable() { //update/disable tabs based on if supported for this node
@Override int drvC = 0;
public void run() { for (UpdateWrapper drv : viewers) {
//update/disable tabs based on if supported for this node
int drvC = 0;
for (UpdateWrapper drv : viewers) {
if (drv.isSupported(selectedNode)) { if (drv.isSupported(selectedNode)) {
dataResultTabbedPanel.setEnabledAt(drvC, true); dataResultTabbedPanel.setEnabledAt(drvC, true);
} else { } else {
dataResultTabbedPanel.setEnabledAt(drvC, false); dataResultTabbedPanel.setEnabledAt(drvC, false);
} }
++drvC; ++drvC;
} }
// if the current tab is no longer enabled, then find one that is // if the current tab is no longer enabled, then find one that is
boolean hasViewerEnabled = true; boolean hasViewerEnabled = true;
int currentActiveTab = dataResultTabbedPanel.getSelectedIndex(); int currentActiveTab = dataResultTabbedPanel.getSelectedIndex();
if ((currentActiveTab == -1) || (dataResultTabbedPanel.isEnabledAt(currentActiveTab) == false)) { if ((currentActiveTab == -1) || (dataResultTabbedPanel.isEnabledAt(currentActiveTab) == false)) {
hasViewerEnabled = false; hasViewerEnabled = false;
for (int i = 0; i < dataResultTabbedPanel.getTabCount(); i++) { for (int i = 0; i < dataResultTabbedPanel.getTabCount(); i++) {
if (dataResultTabbedPanel.isEnabledAt(i)) { if (dataResultTabbedPanel.isEnabledAt(i)) {
currentActiveTab = i; currentActiveTab = i;
hasViewerEnabled = true; hasViewerEnabled = true;
break; break;
}
}
if (hasViewerEnabled) {
dataResultTabbedPanel.setSelectedIndex(currentActiveTab);
}
}
if (hasViewerEnabled) {
viewers.get(currentActiveTab).setNode(selectedNode);
} }
} }
});
if (hasViewerEnabled) {
dataResultTabbedPanel.setSelectedIndex(currentActiveTab);
}
}
if (hasViewerEnabled) {
viewers.get(currentActiveTab).setNode(selectedNode);
}
} }
@Override @Override
@ -622,12 +607,22 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
} }
@Override @Override
public void childrenAdded(NodeMemberEvent nme) { public void childrenAdded(final NodeMemberEvent nme) {
Node[] delta = nme.getDelta(); Node[] delta = nme.getDelta();
if (load && containsReal(delta)) { if (load && containsReal(delta)) {
load = false; load = false;
setupTabs(nme.getNode()); if (SwingUtilities.isEventDispatchThread()) {
updateMatches(); setupTabs(nme.getNode());
updateMatches();
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setupTabs(nme.getNode());
updateMatches();
}
});
}
} }
} }
@ -645,14 +640,9 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
* *
*/ */
private void updateMatches() { private void updateMatches() {
SwingUtilities.invokeLater(new Runnable() { if (rootNode != null && rootNode.getChildren() != null) {
@Override setNumMatches(rootNode.getChildren().getNodesCount());
public void run() { }
if (rootNode != null && rootNode.getChildren() != null) {
setNumMatches(rootNode.getChildren().getNodesCount());
}
}
});
} }
@Override @Override

View File

@ -278,108 +278,103 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
* @param root The parent Node of the ContentNodes * @param root The parent Node of the ContentNodes
*/ */
private void setupTable(final Node root) { private void setupTable(final Node root) {
SwingUtilities.invokeLater(new Runnable() { //wrap to filter out children
@Override //note: this breaks the tree view mode in this generic viewer,
public void run() { //so wrap nodes earlier if want 1 level view
//wrap to filter out children //if (!(root instanceof TableFilterNode)) {
//note: this breaks the tree view mode in this generic viewer, /// root = new TableFilterNode(root, true);
//so wrap nodes earlier if want 1 level view //}
//if (!(root instanceof TableFilterNode)) {
/// root = new TableFilterNode(root, true);
//}
em.setRootContext(root); em.setRootContext(root);
final OutlineView ov = ((OutlineView) DataResultViewerTable.this.tableScrollPanel); final OutlineView ov = ((OutlineView) DataResultViewerTable.this.tableScrollPanel);
if (ov == null) { if (ov == null) {
return; return;
} }
propertiesAcc.clear(); propertiesAcc.clear();
DataResultViewerTable.this.getAllChildPropertyHeadersRec(root, 100); DataResultViewerTable.this.getAllChildPropertyHeadersRec(root, 100);
List<Node.Property> props = new ArrayList<Node.Property>(propertiesAcc); List<Node.Property> props = new ArrayList<Node.Property>(propertiesAcc);
if (props.size() > 0) { if (props.size() > 0) {
Node.Property prop = props.remove(0); Node.Property prop = props.remove(0);
((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(prop.getDisplayName()); ((DefaultOutlineModel) ov.getOutline().getOutlineModel()).setNodesColumnLabel(prop.getDisplayName());
} }
// *********** Make the TreeTableView to be sortable *************** // *********** Make the TreeTableView to be sortable ***************
//First property column is sortable, but also sorted initially, so //First property column is sortable, but also sorted initially, so
//initially this one will have the arrow icon: //initially this one will have the arrow icon:
if (props.size() > 0) { if (props.size() > 0) {
props.get(0).setValue("TreeColumnTTV", Boolean.TRUE); // Identifies special property representing first (tree) column. props.get(0).setValue("TreeColumnTTV", Boolean.TRUE); // Identifies special property representing first (tree) column.
props.get(0).setValue("SortingColumnTTV", Boolean.TRUE); // TreeTableView should be initially sorted by this property column. props.get(0).setValue("SortingColumnTTV", Boolean.TRUE); // TreeTableView should be initially sorted by this property column.
} }
// The rest of the columns are sortable, but not initially sorted, // The rest of the columns are sortable, but not initially sorted,
// so initially will have no arrow icon: // so initially will have no arrow icon:
String[] propStrings = new String[props.size() * 2]; String[] propStrings = new String[props.size() * 2];
for (int i = 0; i < props.size(); i++) { for (int i = 0; i < props.size(); i++) {
props.get(i).setValue("ComparableColumnTTV", Boolean.TRUE); props.get(i).setValue("ComparableColumnTTV", Boolean.TRUE);
propStrings[2 * i] = props.get(i).getName(); propStrings[2 * i] = props.get(i).getName();
propStrings[2 * i + 1] = props.get(i).getDisplayName(); propStrings[2 * i + 1] = props.get(i).getDisplayName();
} }
ov.setPropertyColumns(propStrings); ov.setPropertyColumns(propStrings);
// ***************************************************************** // *****************************************************************
// // set the first entry // // set the first entry
// Children test = root.getChildren(); // Children test = root.getChildren();
// Node firstEntryNode = test.getNodeAt(0); // Node firstEntryNode = test.getNodeAt(0);
// try { // try {
// this.getExplorerManager().setSelectedNodes(new Node[]{firstEntryNode}); // this.getExplorerManager().setSelectedNodes(new Node[]{firstEntryNode});
// } catch (PropertyVetoException ex) {} // } catch (PropertyVetoException ex) {}
// show the horizontal scroll panel and show all the content & header // show the horizontal scroll panel and show all the content & header
int totalColumns = props.size(); int totalColumns = props.size();
//int scrollWidth = ttv.getWidth(); //int scrollWidth = ttv.getWidth();
int margin = 4; int margin = 4;
int startColumn = 1; int startColumn = 1;
// If there is only one column (which was removed from props above) // If there is only one column (which was removed from props above)
// Just let the table resize itself. // Just let the table resize itself.
ov.getOutline().setAutoResizeMode((props.size() > 0) ? JTable.AUTO_RESIZE_OFF : JTable.AUTO_RESIZE_ALL_COLUMNS); ov.getOutline().setAutoResizeMode((props.size() > 0) ? JTable.AUTO_RESIZE_OFF : JTable.AUTO_RESIZE_ALL_COLUMNS);
// get first 100 rows values for the table // get first 100 rows values for the table
Object[][] content = null; Object[][] content = null;
content = getRowValues(root, 100); content = getRowValues(root, 100);
if (content != null) { if (content != null) {
// get the fontmetrics // get the fontmetrics
final Graphics graphics = ov.getGraphics(); final Graphics graphics = ov.getGraphics();
if (graphics != null) { if (graphics != null) {
final FontMetrics metrics = graphics.getFontMetrics(); final FontMetrics metrics = graphics.getFontMetrics();
// for the "Name" column // for the "Name" column
int nodeColWidth = Math.min(getMaxColumnWidth(0, metrics, margin, 40, firstColumnLabel, content), 250); // Note: 40 is the width of the icon + node lines. Change this value if those values change! int nodeColWidth = Math.min(getMaxColumnWidth(0, metrics, margin, 40, firstColumnLabel, content), 250); // Note: 40 is the width of the icon + node lines. Change this value if those values change!
ov.getOutline().getColumnModel().getColumn(0).setPreferredWidth(nodeColWidth); ov.getOutline().getColumnModel().getColumn(0).setPreferredWidth(nodeColWidth);
// get the max for each other column // get the max for each other column
for (int colIndex = startColumn; colIndex <= totalColumns; colIndex++) { for (int colIndex = startColumn; colIndex <= totalColumns; colIndex++) {
int colWidth = Math.min(getMaxColumnWidth(colIndex, metrics, margin, 8, props, content), 350); int colWidth = Math.min(getMaxColumnWidth(colIndex, metrics, margin, 8, props, content), 350);
ov.getOutline().getColumnModel().getColumn(colIndex).setPreferredWidth(colWidth); ov.getOutline().getColumnModel().getColumn(colIndex).setPreferredWidth(colWidth);
}
}
}
// if there's no content just auto resize all columns
if (!(content.length > 0)) {
// turn on the auto resize
ov.getOutline().setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
} }
} }
}); }
// if there's no content just auto resize all columns
if (!(content.length > 0)) {
// turn on the auto resize
ov.getOutline().setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
}
} }
private static Object[][] getRowValues(Node node, int rows) { private static Object[][] getRowValues(Node node, int rows) {
@ -492,11 +487,20 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
} }
@Override @Override
public void childrenAdded(NodeMemberEvent nme) { public void childrenAdded(final NodeMemberEvent nme) {
Node[] delta = nme.getDelta(); Node[] delta = nme.getDelta();
if (load && containsReal(delta)) { if (load && containsReal(delta)) {
load = false; load = false;
setupTable(nme.getNode()); if (SwingUtilities.isEventDispatchThread()) {
setupTable(nme.getNode());
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setupTable(nme.getNode());
}
});
}
} }
} }

View File

@ -24,12 +24,14 @@ import java.beans.PropertyVetoException;
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.concurrent.ExecutionException;
import java.util.logging.Level; import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.SwingWorker;
import org.openide.nodes.AbstractNode;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.explorer.view.TreeView; import org.openide.explorer.view.TreeView;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent; import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
@ -44,7 +46,14 @@ import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.VolumeSystem; import org.sleuthkit.datamodel.VolumeSystem;
/** /**
* View the directory content associated with the given Artifact * View the directory content associated with the given Artifact in the DataResultViewer.
*
* 1. Expands the Directory Tree to the location of the parent Node of the
* associated Content.
* 2. Selects the parent Node of the associated Content in the Directory Tree,
* which causes the parent Node's Children to be visible in the DataResultViewer.
* 3. Waits for all the Children to be contentNode in the DataResultViewer and
* selects the Node that represents the Content.
*/ */
public class ViewContextAction extends AbstractAction { public class ViewContextAction extends AbstractAction {
@ -81,62 +90,117 @@ public class ViewContextAction extends AbstractAction {
Node generated = new DirectoryTreeFilterNode(new AbstractNode(new RootContentChildren(hierarchy)), true); Node generated = new DirectoryTreeFilterNode(new AbstractNode(new RootContentChildren(hierarchy)), true);
Children genChilds = generated.getChildren(); Children genChilds = generated.getChildren();
final DirectoryTreeTopComponent directoryTree = DirectoryTreeTopComponent.findInstance(); final DirectoryTreeTopComponent dirTree = DirectoryTreeTopComponent.findInstance();
TreeView tree = directoryTree.getTree(); TreeView dirTreeView = dirTree.getTree();
ExplorerManager man = directoryTree.getExplorerManager(); ExplorerManager dirTreeExplorerManager = dirTree.getExplorerManager();
Node dirRoot = man.getRootContext(); Node dirTreeRootNode = dirTreeExplorerManager.getRootContext();
Children dirChilds = dirRoot.getChildren(); Children dirChilds = dirTreeRootNode.getChildren();
Node imagesRoot = dirChilds.findChild(DataSourcesNode.NAME); Children currentChildren = dirChilds.findChild(DataSourcesNode.NAME).getChildren();
dirChilds = imagesRoot.getChildren();
Node dirExplored = null; Node dirExplored = null;
// Find the parent node of the content in the directory tree
for (int i = 0; i < genChilds.getNodesCount() - 1; i++) { for (int i = 0; i < genChilds.getNodesCount() - 1; i++) {
Node currentGeneratedNode = genChilds.getNodeAt(i); Node currentGeneratedNode = genChilds.getNodeAt(i);
for (int j = 0; j < dirChilds.getNodesCount(); j++) { for (int j = 0; j < currentChildren.getNodesCount(); j++) {
Node currentDirectoryTreeNode = dirChilds.getNodeAt(j); Node currentDirectoryTreeNode = currentChildren.getNodeAt(j);
if (currentGeneratedNode.getDisplayName().equals(currentDirectoryTreeNode.getDisplayName())) { if (currentGeneratedNode.getDisplayName().equals(currentDirectoryTreeNode.getDisplayName())) {
dirExplored = currentDirectoryTreeNode; dirExplored = currentDirectoryTreeNode;
tree.expandNode(dirExplored); dirTreeView.expandNode(dirExplored);
dirChilds = currentDirectoryTreeNode.getChildren(); currentChildren = currentDirectoryTreeNode.getChildren();
break; break;
} }
} }
} }
// Set the parent node of the content as the selection in the
// directory tree
try { try {
if (dirExplored != null) { if (dirExplored != null) {
tree.expandNode(dirExplored); dirTreeView.expandNode(dirExplored);
man.setExploredContextAndSelection(dirExplored, new Node[]{dirExplored}); dirTreeExplorerManager.setExploredContextAndSelection(dirExplored, new Node[]{dirExplored});
} }
} catch (PropertyVetoException ex) { } catch (PropertyVetoException ex) {
logger.log(Level.WARNING, "Couldn't set selected node", ex); logger.log(Level.WARNING, "Couldn't set selected node", ex);
} }
// Another thread is needed because we have to wait for dataResult to populate
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
DataResultTopComponent dataResult = directoryTree.getDirectoryListing(); DataResultTopComponent dataResultTC = dirTree.getDirectoryListing();
Node resultRoot = dataResult.getRootNode(); Node currentRootNodeOfDataResultTC = dataResultTC.getRootNode();
Children resultChilds = resultRoot.getChildren(); Node contentNode = content.accept(new RootContentChildren.CreateSleuthkitNodeVisitor());
Node generated = content.accept(new RootContentChildren.CreateSleuthkitNodeVisitor()); new SelectionWorker(dataResultTC, contentNode.getName(), currentRootNodeOfDataResultTC).execute();
for (int i = 0; i < resultChilds.getNodesCount(); i++) {
Node current = resultChilds.getNodeAt(i);
if (generated.getName().equals(current.getName())) {
dataResult.requestActive();
dataResult.setSelectedNodes(new Node[]{current});
DirectoryTreeTopComponent.getDefault().fireViewerComplete();
break;
}
}
} }
}); });
} }
}); });
} }
/**
* Waits for a Node's children to be generated, regardless of whether they
* are lazily loaded, then sets the correct selection in a specified
* DataResultTopComponent.
*/
private class SelectionWorker extends SwingWorker<Node[], Integer> {
DataResultTopComponent dataResultTC;
String nameOfNodeToSelect;
Node originalRootNodeOfDataResultTC;
SelectionWorker(DataResultTopComponent dataResult, String nameToSelect, Node originalRoot) {
this.dataResultTC = dataResult;
this.nameOfNodeToSelect = nameToSelect;
this.originalRootNodeOfDataResultTC = originalRoot;
}
@Override
protected Node[] doInBackground() throws Exception {
// Calls to Children::getNodes(true) block until all child Nodes have
// been created, regardless of whether they are created lazily.
// This means that this call will return the actual child Nodes
// and will *NEVER* return a proxy wait Node. This is done on the
// background thread to ensure we are not hanging the ui as it could
// be a lengthy operation.
return originalRootNodeOfDataResultTC.getChildren().getNodes(true);
}
@Override
protected void done() {
Node[] nodesDisplayedInDataResultViewer;
try {
nodesDisplayedInDataResultViewer = get();
} catch (InterruptedException | ExecutionException ex) {
logger.log(Level.WARNING, "Failed to get nodes in selection worker.", ex);
return;
}
// It is possible the user selected a different Node to be displayed
// in the DataResultViewer while the child Nodes were being generated.
// In that case, we don't want to set the selection because it the
// nodes returned from get() won't be in the DataResultTopComponent's
// ExplorerManager. If we did call setSelectedNodes, it would clear
// the current selection, which is not good.
if (dataResultTC.getRootNode().equals(originalRootNodeOfDataResultTC) == false) {
return;
}
// Find the correct node to select from the nodes that are displayed
// in the data result viewer and set it as the selection of the
// DataResultTopComponent.
for (Node node : nodesDisplayedInDataResultViewer) {
if (nameOfNodeToSelect.equals(node.getName())) {
dataResultTC.requestActive();
dataResultTC.setSelectedNodes(new Node[]{node});
DirectoryTreeTopComponent.getDefault().fireViewerComplete();
break;
}
}
}
}
/** /**
* The ReverseHierarchyVisitor class is designed to return a list of Content * The ReverseHierarchyVisitor class is designed to return a list of Content
* objects starting with the one the user calls 'accept' with and ending at * objects starting with the one the user calls 'accept' with and ending at

View File

@ -38,7 +38,6 @@ KeywordSearchPanel.settingsLabel.text=
KeywordSearchListsViewerPanel.searchAddButton.text=Search KeywordSearchListsViewerPanel.searchAddButton.text=Search
KeywordSearchListsViewerPanel.manageListsButton.text=Manage Lists KeywordSearchListsViewerPanel.manageListsButton.text=Manage Lists
KeywordSearchListsViewerPanel.ingestIndexLabel.text=Files Indexed: KeywordSearchListsViewerPanel.ingestIndexLabel.text=Files Indexed:
KeywordSearchEditListPanel.selectorsCombo.toolTipText=Regular Expression selector type (optional)
KeywordSearchPanel.searchButton.text= KeywordSearchPanel.searchButton.text=
KeywordSearchPanel.cutMenuItem.text=Cut KeywordSearchPanel.cutMenuItem.text=Cut
KeywordSearchPanel.copyMenuItem.text=Copy KeywordSearchPanel.copyMenuItem.text=Copy

View File

@ -26,10 +26,10 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import net.htmlparser.jericho.Attributes; import net.htmlparser.jericho.Attributes;
import net.htmlparser.jericho.Renderer;
import net.htmlparser.jericho.Source; import net.htmlparser.jericho.Source;
import net.htmlparser.jericho.StartTag; import net.htmlparser.jericho.StartTag;
import net.htmlparser.jericho.StartTagType; import net.htmlparser.jericho.StartTagType;
import net.htmlparser.jericho.TextExtractor;
/** /**
* Uses Jericho HTML Parser to create a Reader for output, consisting of * Uses Jericho HTML Parser to create a Reader for output, consisting of
@ -46,6 +46,15 @@ public class JerichoParserWrapper {
this.in = in; this.in = in;
} }
/**
* Returns the reader, initialized in parse(), which will be
* null if parse() is not called or if parse() throws an error.
* @return Reader
*/
public Reader getReader() {
return reader;
}
/** /**
* Initialize the reader by parsing the InputStream, adding it to StringBuilder, * Initialize the reader by parsing the InputStream, adding it to StringBuilder,
* and creating a StringReader from it. * and creating a StringReader from it.
@ -57,7 +66,7 @@ public class JerichoParserWrapper {
Source source = new Source(in); Source source = new Source(in);
source.fullSequentialParse(); source.fullSequentialParse();
StringBuilder text = new StringBuilder(); String text;
StringBuilder scripts = new StringBuilder(); StringBuilder scripts = new StringBuilder();
StringBuilder links = new StringBuilder(); StringBuilder links = new StringBuilder();
StringBuilder images = new StringBuilder(); StringBuilder images = new StringBuilder();
@ -69,13 +78,7 @@ public class JerichoParserWrapper {
int numComments = 1; int numComments = 1;
int numOthers = 1; int numOthers = 1;
// Extract text from the source text = renderHTMLAsPlainText(source);
TextExtractor extractor = new TextExtractor(source);
// Split it at every ". " but keep the .
String[] lines = extractor.toString().split("(?<=\\. )");
for(String s : lines) {
text.append(s).append("\n");
}
// Get all the tags in the source // Get all the tags in the source
List<StartTag> tags = source.getAllStartTags(); List<StartTag> tags = source.getAllStartTags();
@ -113,7 +116,7 @@ public class JerichoParserWrapper {
} }
} }
out.append(text.toString()).append("\n"); out.append(text).append("\n\n");
out.append("----------NONVISIBLE TEXT----------\n\n"); out.append("----------NONVISIBLE TEXT----------\n\n");
if(numScripts>1) { if(numScripts>1) {
@ -139,13 +142,14 @@ public class JerichoParserWrapper {
} }
} }
/** // Extract text from the source, nicely formatted with whitespace and
* Returns the reader, initialized in parse(), which will be // newlines where appropriate.
* null if parse() is not called or if parse() throws an error. private String renderHTMLAsPlainText(Source source) {
* @return Reader Renderer renderer = source.getRenderer();
*/ renderer.setNewLine("\n");
public Reader getReader() { renderer.setIncludeHyperlinkURLs(false);
return reader; renderer.setDecorateFontStyles(false);
renderer.setIncludeAlternateText(false);
return renderer.toString();
} }
} }

View File

@ -206,20 +206,16 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="addWordField" max="32767" attributes="0"/> <Component id="addWordField" min="-2" pref="216" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="addWordButton" min="-2" max="-2" attributes="0"/> <Component id="addWordButton" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="deleteWordButton" min="-2" max="-2" attributes="0"/> <Component id="deleteWordButton" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Component id="chRegex" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="chRegex" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="selectorsCombo" min="-2" pref="154" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
</Group> </Group>
@ -234,10 +230,7 @@
<Component id="addWordButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="addWordButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/> <EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Component id="chRegex" min="-2" max="-2" attributes="0"/>
<Component id="selectorsCombo" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chRegex" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/> <EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
<Component id="deleteWordButton" min="-2" max="-2" attributes="0"/> <Component id="deleteWordButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="32767" attributes="0"/>
@ -276,19 +269,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chRegexActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chRegexActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="selectorsCombo">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchEditListPanel.selectorsCombo.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox&lt;String&gt;()"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="deleteWordButton"> <Component class="javax.swing.JButton" name="deleteWordButton">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">

View File

@ -126,18 +126,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
break; break;
} }
} }
if (selected > -1 && selected < keywords.size()) {
Keyword k = keywords.get(selected);
BlackboardAttribute.ATTRIBUTE_TYPE selType = k.getType();
if (selType != null) {
selectorsCombo.setSelectedIndex(selType.ordinal());
} else {
//set to none (last item)
selectorsCombo.setSelectedIndex(selectorsCombo.getItemCount() - 1);
}
}
} }
} }
}); });
@ -195,15 +183,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
} }
} }
}); });
//selectors
selectorsCombo.setEnabled(false);
for (BlackboardAttribute.ATTRIBUTE_TYPE type : BlackboardAttribute.ATTRIBUTE_TYPE.values()) {
selectorsCombo.<String>addItem(type.getDisplayName());
}
selectorsCombo.<String>addItem("<none>");
selectorsCombo.setSelectedIndex(selectorsCombo.getItemCount() - 1);
} }
/** /**
@ -251,7 +230,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
chRegex.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked); chRegex.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked);
keywordOptionsLabel.setEnabled(addWordButton.isEnabled() || chRegex.isEnabled()); keywordOptionsLabel.setEnabled(addWordButton.isEnabled() || chRegex.isEnabled());
keywordOptionsSeparator.setEnabled(addWordButton.isEnabled() || chRegex.isEnabled()); keywordOptionsSeparator.setEnabled(addWordButton.isEnabled() || chRegex.isEnabled());
selectorsCombo.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked && chRegex.isSelected());
useForIngestCheckbox.setEnabled(listSet && (!ingestOngoing || !inIngest)); useForIngestCheckbox.setEnabled(listSet && (!ingestOngoing || !inIngest));
useForIngestCheckbox.setSelected(useForIngest); useForIngestCheckbox.setSelected(useForIngest);
ingestMessagesCheckbox.setEnabled(useForIngestCheckbox.isEnabled() && useForIngestCheckbox.isSelected()); ingestMessagesCheckbox.setEnabled(useForIngestCheckbox.isEnabled() && useForIngestCheckbox.isSelected());
@ -295,7 +273,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
addWordButton = new javax.swing.JButton(); addWordButton = new javax.swing.JButton();
addWordField = new javax.swing.JTextField(); addWordField = new javax.swing.JTextField();
chRegex = new javax.swing.JCheckBox(); chRegex = new javax.swing.JCheckBox();
selectorsCombo = new javax.swing.JComboBox<String>();
deleteWordButton = new javax.swing.JButton(); deleteWordButton = new javax.swing.JButton();
ingestMessagesCheckbox = new javax.swing.JCheckBox(); ingestMessagesCheckbox = new javax.swing.JCheckBox();
keywordsLabel = new javax.swing.JLabel(); keywordsLabel = new javax.swing.JLabel();
@ -359,8 +336,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
} }
}); });
selectorsCombo.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.selectorsCombo.toolTipText")); // NOI18N
deleteWordButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.deleteWordButton.text")); // NOI18N deleteWordButton.setText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.deleteWordButton.text")); // NOI18N
deleteWordButton.addActionListener(new java.awt.event.ActionListener() { deleteWordButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -373,17 +348,14 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
addKeywordPanelLayout.setHorizontalGroup( addKeywordPanelLayout.setHorizontalGroup(
addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(addKeywordPanelLayout.createSequentialGroup() .addGroup(addKeywordPanelLayout.createSequentialGroup()
.addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(addKeywordPanelLayout.createSequentialGroup() .addGroup(addKeywordPanelLayout.createSequentialGroup()
.addComponent(addWordField) .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(addWordButton)) .addComponent(addWordButton))
.addComponent(deleteWordButton)) .addComponent(deleteWordButton))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, addKeywordPanelLayout.createSequentialGroup() .addComponent(chRegex, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(chRegex)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(selectorsCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
addKeywordPanelLayout.setVerticalGroup( addKeywordPanelLayout.setVerticalGroup(
@ -394,9 +366,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
.addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(addWordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addWordButton)) .addComponent(addWordButton))
.addGap(7, 7, 7) .addGap(7, 7, 7)
.addGroup(addKeywordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(chRegex)
.addComponent(selectorsCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chRegex))
.addGap(7, 7, 7) .addGap(7, 7, 7)
.addComponent(deleteWordButton) .addComponent(deleteWordButton)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
@ -515,14 +485,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
String newWord = addWordField.getText().trim(); String newWord = addWordField.getText().trim();
boolean isLiteral = !chRegex.isSelected(); boolean isLiteral = !chRegex.isSelected();
final Keyword keyword = new Keyword(newWord, isLiteral); final Keyword keyword = new Keyword(newWord, isLiteral);
if (!isLiteral) {
//get selector
int selI = this.selectorsCombo.getSelectedIndex();
if (selI < this.selectorsCombo.getItemCount() - 1) {
BlackboardAttribute.ATTRIBUTE_TYPE selector = BlackboardAttribute.ATTRIBUTE_TYPE.values()[selI];
keyword.setType(selector);
}
}
if (newWord.equals("")) { if (newWord.equals("")) {
return; return;
@ -620,7 +582,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
}//GEN-LAST:event_exportButtonActionPerformed }//GEN-LAST:event_exportButtonActionPerformed
private void chRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chRegexActionPerformed private void chRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chRegexActionPerformed
selectorsCombo.setEnabled(chRegex.isEnabled() && chRegex.isSelected());
}//GEN-LAST:event_chRegexActionPerformed }//GEN-LAST:event_chRegexActionPerformed
private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useForIngestCheckboxActionPerformed private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useForIngestCheckboxActionPerformed
@ -659,7 +620,6 @@ private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt)
private javax.swing.JPopupMenu rightClickMenu; private javax.swing.JPopupMenu rightClickMenu;
private javax.swing.JButton saveListButton; private javax.swing.JButton saveListButton;
private javax.swing.JMenuItem selectAllMenuItem; private javax.swing.JMenuItem selectAllMenuItem;
private javax.swing.JComboBox selectorsCombo;
private javax.swing.JCheckBox useForIngestCheckbox; private javax.swing.JCheckBox useForIngestCheckbox;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables