19package org.sleuthkit.autopsy.discovery.ui;
21import org.sleuthkit.autopsy.contentviewers.artifactviewers.GeneralPurposeArtifactViewer;
22import com.google.common.eventbus.Subscribe;
23import java.awt.Dimension;
24import java.beans.PropertyChangeEvent;
25import java.beans.PropertyChangeListener;
26import java.util.logging.Level;
27import javax.swing.JPanel;
28import javax.swing.JSplitPane;
29import javax.swing.SwingUtilities;
30import javax.swing.event.ListSelectionEvent;
31import javax.swing.event.ListSelectionListener;
32import org.sleuthkit.autopsy.contentviewers.artifactviewers.DefaultTableArtifactContentViewer;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.autopsy.coreutils.ThreadConfined;
35import org.sleuthkit.autopsy.discovery.search.DiscoveryEventUtils;
36import org.sleuthkit.datamodel.BlackboardArtifact;
41final class DomainArtifactsTabPanel
extends JPanel {
43 private static final long serialVersionUID = 1L;
44 private final static Logger logger = Logger.getLogger(DomainArtifactsTabPanel.class.getName());
45 private final ArtifactsListPanel listPanel;
46 private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
47 private AbstractArtifactDetailsPanel rightPanel =
null;
48 private int dividerLocation = 300;
49 private final PropertyChangeListener dividerListener;
52 private final ListSelectionListener listener =
new ListSelectionListener() {
54 public void valueChanged(ListSelectionEvent event) {
55 if (!event.getValueIsAdjusting()) {
56 mainSplitPane.removePropertyChangeListener(dividerListener);
57 rightPanel.setArtifact(listPanel.getSelectedArtifact());
58 mainSplitPane.setDividerLocation(dividerLocation);
59 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
69 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
70 DomainArtifactsTabPanel(BlackboardArtifact.ARTIFACT_TYPE type) {
72 dividerListener =
new PropertyChangeListener() {
74 public void propertyChange(PropertyChangeEvent evt) {
75 if (evt.getPropertyName().equalsIgnoreCase(JSplitPane.DIVIDER_LOCATION_PROPERTY)
76 && evt.getNewValue() instanceof Integer
77 && evt.getOldValue() instanceof Integer
78 && (JSplitPane.UNDEFINED_CONDITION != (
int) evt.getNewValue())) {
79 dividerLocation = (int) evt.getNewValue();
83 this.artifactType = type;
84 listPanel =
new ArtifactsListPanel(artifactType);
85 listPanel.setPreferredSize(
new Dimension(100, 20));
86 listPanel.addMouseListener(
new ArtifactMenuMouseAdapter(listPanel));
88 mainSplitPane.setLeftComponent(listPanel);
91 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
92 dividerLocation = mainSplitPane.getDividerLocation();
93 listPanel.addSelectionListener(listener);
100 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
101 private
void setRightComponent() {
102 switch (artifactType) {
103 case TSK_WEB_HISTORY:
105 case TSK_WEB_SEARCH_QUERY:
106 case TSK_WEB_BOOKMARK:
107 rightPanel =
new GeneralPurposeArtifactViewer();
109 case TSK_WEB_DOWNLOAD:
111 rightPanel =
new ContentViewerDetailsPanel();
114 rightPanel =
new DefaultTableArtifactContentViewer();
117 if (rightPanel !=
null) {
118 mainSplitPane.setRightComponent(rightPanel.getComponent());
125 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
127 listPanel.focusList();
135 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
145 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
147 this.status = status;
148 mainSplitPane.removePropertyChangeListener(dividerListener);
150 listPanel.clearList();
153 if (rightPanel != null) {
154 rightPanel.setArtifact(null);
158 add(new LoadingPanel(artifactType.getDisplayName()));
160 mainSplitPane.setDividerLocation(dividerLocation);
161 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
172 if (artifactType == artifactresultEvent.getArtifactType() && status == ArtifactRetrievalStatus.POPULATING) {
173 SwingUtilities.invokeLater(() -> {
174 mainSplitPane.removePropertyChangeListener(dividerListener);
175 listPanel.removeSelectionListener(listener);
176 listPanel.addArtifacts(artifactresultEvent.getListOfArtifacts());
177 status = ArtifactRetrievalStatus.POPULATED;
178 setEnabled(!listPanel.isEmpty());
179 listPanel.addSelectionListener(listener);
180 listPanel.selectFirst();
183 mainSplitPane.setDividerLocation(dividerLocation);
184 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
185 if (artifactresultEvent.shouldGrabFocus()) {
192 }
catch (IllegalArgumentException notRegistered) {
193 logger.log(Level.INFO,
"Attempting to unregister tab which was not registered");
206 BlackboardArtifact.ARTIFACT_TYPE getArtifactType() {
215 @SuppressWarnings(
"unchecked")
217 private
void initComponents() {
219 mainSplitPane =
new javax.swing.JSplitPane();
221 mainSplitPane.setDividerLocation(dividerLocation);
222 mainSplitPane.setResizeWeight(0.2);
223 mainSplitPane.setLastDividerLocation(250);
225 setCursor(
new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
226 setMinimumSize(
new java.awt.Dimension(0, 0));
227 setLayout(
new java.awt.BorderLayout());
232 private javax.swing.JSplitPane mainSplitPane;
static EventBus getDiscoveryEventBus()