19 package org.sleuthkit.autopsy.discovery.ui;
22 import com.google.common.eventbus.Subscribe;
23 import java.awt.Dimension;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
26 import java.util.logging.Level;
27 import javax.swing.JPanel;
28 import javax.swing.JSplitPane;
29 import javax.swing.SwingUtilities;
30 import javax.swing.event.ListSelectionEvent;
31 import javax.swing.event.ListSelectionListener;
41 final 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;
51 private ArtifactRetrievalStatus status = ArtifactRetrievalStatus.UNPOPULATED;
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)
136 ArtifactRetrievalStatus getStatus() {
145 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
146 void setStatus(ArtifactRetrievalStatus status) {
147 this.status = status;
148 mainSplitPane.removePropertyChangeListener(dividerListener);
149 if (status == ArtifactRetrievalStatus.UNPOPULATED) {
150 listPanel.clearList();
153 if (rightPanel != null) {
154 rightPanel.setArtifact(null);
156 }
else if (status == ArtifactRetrievalStatus.POPULATING) {
158 add(
new LoadingPanel(artifactType.getDisplayName()));
160 mainSplitPane.setDividerLocation(dividerLocation);
161 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
171 void handleArtifactSearchResultEvent(DiscoveryEventUtils.ArtifactSearchResultEvent artifactresultEvent) {
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()) {
191 DiscoveryEventUtils.getDiscoveryEventBus().unregister(
this);
192 }
catch (IllegalArgumentException notRegistered) {
193 logger.log(Level.INFO,
"Attempting to unregister tab which was not registered");
205 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
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;
238 enum ArtifactRetrievalStatus {