Further improve indexed text content viewer behavior

This commit is contained in:
Richard Cordovano 2016-05-25 12:08:52 -04:00
parent 549d033a47
commit 7bf7a3cfd8

View File

@ -30,6 +30,7 @@ import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.lookup.ServiceProvider; import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
@ -112,10 +113,6 @@ public class ExtractedContentViewer implements DataContentViewer {
if (null != content && solrHasContent(content.getId())) { if (null != content && solrHasContent(content.getId())) {
rawContentText = new RawText(content, content.getId()); rawContentText = new RawText(content, content.getId());
sources.add(rawContentText); sources.add(rawContentText);
int currentPage = rawContentText.getCurrentPage();
if (currentPage == 0 && rawContentText.hasNextPage()) {
rawContentText.nextPage();
}
} }
/* /*
@ -124,17 +121,22 @@ public class ExtractedContentViewer implements DataContentViewer {
*/ */
BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class); BlackboardArtifact artifact = node.getLookup().lookup(BlackboardArtifact.class);
if (null != artifact) { if (null != artifact) {
/*
* For keyword hit artifacts, add the text of the artifact that hit,
* not the hit artifact; otherwise add the text for the artifact.
*/
if (artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) { if (artifact.getArtifactTypeID() != BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
rawArtifactText = new RawText(artifact, artifact.getArtifactID()); rawArtifactText = new RawText(artifact, artifact.getArtifactID());
sources.add(rawArtifactText); sources.add(rawArtifactText);
} else { } else {
try { try {
// Get the associated artifact attribute and return its value as the ID
BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT)); BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
if (attribute != null) { if (attribute != null) {
rawArtifactText = new RawText(artifact, attribute.getValueLong()); // RJCTODO: The artifact is just a flag for RawText, that's why this works long artifactId = attribute.getValueLong();
BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(artifactId);
rawArtifactText = new RawText(associatedArtifact, associatedArtifact.getArtifactID());
sources.add(rawArtifactText); sources.add(rawArtifactText);
} }
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error getting associated artifact attributes", ex); //NON-NLS logger.log(Level.SEVERE, "Error getting associated artifact attributes", ex); //NON-NLS
} }
@ -142,27 +144,25 @@ public class ExtractedContentViewer implements DataContentViewer {
} }
/* /*
* Now set the default text to be displayed. RJCTODO: Correct this. * Now set the default source to be displayed.
*/ */
if (null != highlightedHitText) { if (null != highlightedHitText) {
/*
* Default to highlight hit text, if present.
*/
currentSource = highlightedHitText; currentSource = highlightedHitText;
} else if (null != rawContentText) { } else if (null != rawContentText) {
/*
* Default to the raw content text for content nodes and artifact
* nodes that are not keyword hits.
*/
currentSource = rawContentText; currentSource = rawContentText;
} else { } else {
/*
* Handle the artifacts associated with a data source, for which
* there is no content text.
*/
currentSource = rawArtifactText; currentSource = rawArtifactText;
} }
/*
* Push the text sources into the panel.
*/
for (IndexedText source : sources) {
int currentPage = source.getCurrentPage();
if (currentPage == 0 && source.hasNextPage()) {
source.nextPage();
}
}
updatePageControls(); updatePageControls();
setPanel(sources); setPanel(sources);
} }