19package org.sleuthkit.autopsy.contentviewers.annotations;
21import com.google.common.collect.ImmutableSet;
22import java.awt.Component;
23import java.beans.PropertyChangeEvent;
24import java.beans.PropertyChangeListener;
25import java.util.EnumSet;
27import java.util.concurrent.ExecutionException;
28import java.util.logging.Level;
29import javax.swing.SwingWorker;
30import org.apache.commons.lang3.tuple.Pair;
32import static org.openide.util.NbBundle.Messages;
33import org.openide.nodes.Node;
34import org.openide.util.lookup.ServiceProvider;
35import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
36import org.sleuthkit.autopsy.coreutils.Logger;
37import org.jsoup.nodes.Document;
38import org.openide.util.WeakListeners;
39import org.sleuthkit.autopsy.casemodule.Case;
40import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent;
41import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagDeletedEvent;
42import org.sleuthkit.autopsy.casemodule.events.CommentChangedEvent;
43import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
44import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
45import org.sleuthkit.autopsy.contentviewers.annotations.AnnotationUtils.DisplayTskItems;
46import org.sleuthkit.autopsy.contentviewers.layout.ContentViewerHtmlStyles;
47import org.sleuthkit.autopsy.contentviewers.utils.ViewerPriority;
48import org.sleuthkit.autopsy.ingest.IngestManager;
49import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
50import org.sleuthkit.datamodel.BlackboardArtifact;
55@SuppressWarnings(
"PMD.SingularField")
58 "AnnotationsContentViewer.title=Annotations",
59 "AnnotationsContentViewer.toolTip=Displays tags and comments associated with the selected content.",
60 "AnnotationsContentViewer.onEmpty=No annotations were found for this particular item."
80 @SuppressWarnings(
"deprecation")
82 BlackboardArtifact.Type.TSK_HASHSET_HIT,
83 BlackboardArtifact.Type.TSK_INTERESTING_FILE_HIT,
84 BlackboardArtifact.Type.TSK_INTERESTING_ITEM
99 ModuleDataEvent moduleDataEvent = (ModuleDataEvent) evt.getOldValue();
102 if (ARTIFACT_TYPES_OF_INTEREST.contains(moduleDataEvent.getBlackboardArtifactType())) {
103 for (BlackboardArtifact artifact : moduleDataEvent.getArtifacts()) {
104 if ((curArtifactId != null && artifact.getArtifactID() == curArtifactId)
105 || (curContentId != null && artifact.getObjectID() == curContentId)) {
125 Long artifactId = artifactContentId.getLeft();
126 Long contentId = artifactContentId.getRight();
177 this.curArtifactId = displayItems.getArtifact() ==
null ? null : displayItems.getArtifact().getArtifactID();
178 this.curContentId = displayItems.getContent() ==
null ? null : displayItems.getContent().getId();
194 eventType =
Case.
Events.valueOf(evt.getPropertyName());
195 }
catch (IllegalArgumentException ex) {
196 logger.log(Level.SEVERE,
"Unknown event type: " + evt.getPropertyName(), ex);
197 return Pair.of(
null,
null);
200 Long artifactId =
null;
201 Long contentId =
null;
204 case BLACKBOARD_ARTIFACT_TAG_ADDED:
207 artifactId = art.getArtifactID();
208 contentId = art.getObjectID();
211 case BLACKBOARD_ARTIFACT_TAG_DELETED:
217 case CONTENT_TAG_ADDED:
222 case CONTENT_TAG_DELETED:
227 case CR_COMMENT_CHANGED:
230 artifactId = commentObjId;
231 contentId = commentObjId;
238 return Pair.of(artifactId, contentId);
245 if (this.isVisible()) {
288 @SuppressWarnings(
"unchecked")
292 javax.swing.JScrollPane scrollPane =
new javax.swing.JScrollPane();
295 setPreferredSize(
new java.awt.Dimension(100, 58));
299 textPanel.setPreferredSize(
new java.awt.Dimension(600, 52));
302 javax.swing.GroupLayout
layout =
new javax.swing.GroupLayout(
this);
304 layout.setHorizontalGroup(
305 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
306 .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 907, Short.MAX_VALUE)
309 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
310 .addComponent(scrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE)
320 return Bundle.AnnotationsContentViewer_title();
325 return Bundle.AnnotationsContentViewer_toolTip();
358 private class AnnotationWorker
extends SwingWorker<String, Void> {
392 if (!isCancelled()) {
402 }
catch (InterruptedException | ExecutionException ex) {
403 logger.log(Level.SEVERE,
"Failed to get annotation information for node", ex);
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
static Document buildDocument(Node node)
static boolean isSupported(Node node)
final boolean resetCaretPosition
final PropertyChangeListener caseEventListener
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
static final Logger logger
boolean isSupported(Node node)
final PropertyChangeListener weakIngestEventListener
static final Set< BlackboardArtifact.Type > ARTIFACT_TYPES_OF_INTEREST
DataContentViewer createInstance()
static Pair< Long, Long > getIdsFromEvent(PropertyChangeEvent evt)
void updateData(Node node, boolean forceReset)
AnnotationsContentViewer()
static final Set< IngestManager.IngestModuleEvent > INGEST_MODULE_EVENTS_OF_INTEREST
final PropertyChangeListener ingestEventListener
javax.swing.JTextPane textPanel
void unregisterListeners()
final PropertyChangeListener weakCaseEventListener
int isPreferred(Node node)
static final long serialVersionUID
static void setupHtmlJTextPane(JTextPane textPane)
static String getMessageClassName()
static void setStyles(JTextPane textPane)
synchronized static Logger getLogger(String name)
static synchronized IngestManager getInstance()
void addIngestModuleEventListener(final PropertyChangeListener listener)
BLACKBOARD_ARTIFACT_TAG_DELETED
BLACKBOARD_ARTIFACT_TAG_ADDED