19 package org.sleuthkit.autopsy.discovery.ui;
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.Dimension;
23 import java.beans.PropertyChangeEvent;
24 import java.beans.PropertyChangeListener;
25 import javax.swing.JSplitPane;
26 import javax.swing.SwingUtilities;
27 import javax.swing.event.ListSelectionEvent;
28 import javax.swing.event.ListSelectionListener;
29 import org.openide.util.NbBundle;
38 final class MiniTimelinePanel
extends javax.swing.JPanel {
40 private static final long serialVersionUID = 1L;
42 private final MiniTimelineDateListPanel dateListPanel =
new MiniTimelineDateListPanel();
43 private final MiniTimelineArtifactListPanel artifactListPanel =
new MiniTimelineArtifactListPanel();
44 private DomainArtifactsTabPanel.ArtifactRetrievalStatus status = DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED;
45 private AbstractArtifactDetailsPanel rightPanel =
new GeneralPurposeArtifactViewer();
46 private String selectedDomain = null;
47 private final ListSelectionListener artifactListener;
48 private final ListSelectionListener dateListener;
49 private int leftSplitPaneDividerLocation = 125;
50 private int mainSplitPaneDividerLocation = 300;
51 private final PropertyChangeListener dividerListener;
53 @NbBundle.Messages({
"MiniTimelinePanel.loadingPanel.details=the Timeline view"})
57 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
60 artifactListPanel.addMouseListener(
new ArtifactMenuMouseAdapter(artifactListPanel));
61 artifactListener =
new ListSelectionListener() {
63 public void valueChanged(ListSelectionEvent event) {
64 if (!event.getValueIsAdjusting()) {
65 BlackboardArtifact artifact = artifactListPanel.getSelectedArtifact();
66 if (artifact != null && (artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_CACHE.getTypeID()
67 || artifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD.getTypeID())) {
68 rightPanel =
new ContentViewerDetailsPanel();
70 rightPanel =
new GeneralPurposeArtifactViewer();
72 leftSplitPane.removePropertyChangeListener(dividerListener);
73 mainSplitPane.removePropertyChangeListener(dividerListener);
74 mainSplitPane.setRightComponent(rightPanel.getComponent());
75 rightPanel.setArtifact(artifact);
76 mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
77 leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
78 mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
79 leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
80 leftSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
81 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
87 dividerListener =
new PropertyChangeListener() {
89 public void propertyChange(PropertyChangeEvent evt) {
90 if (evt.getPropertyName().equalsIgnoreCase(JSplitPane.DIVIDER_LOCATION_PROPERTY)
91 && evt.getNewValue() instanceof Integer
92 && evt.getOldValue() instanceof Integer
93 && (JSplitPane.UNDEFINED_CONDITION != (int) evt.getNewValue())) {
94 if (evt.getSource().equals(leftSplitPane)) {
95 leftSplitPaneDividerLocation = (int) evt.getNewValue();
96 }
else if (evt.getSource().equals(mainSplitPane)) {
97 mainSplitPaneDividerLocation = (int) evt.getNewValue();
102 dateListener =
new ListSelectionListener() {
104 public void valueChanged(ListSelectionEvent event) {
105 if (!event.getValueIsAdjusting()) {
106 artifactListPanel.removeSelectionListener(artifactListener);
107 leftSplitPane.removePropertyChangeListener(dividerListener);
108 mainSplitPane.removePropertyChangeListener(dividerListener);
109 artifactListPanel.clearList();
110 artifactListPanel.addArtifacts(dateListPanel.getArtifactsForSelectedDate());
111 artifactListPanel.addSelectionListener(artifactListener);
112 artifactListPanel.selectFirst();
113 mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
114 leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
115 leftSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
116 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
122 dateListPanel.addSelectionListener(dateListener);
123 artifactListPanel.addSelectionListener(artifactListener);
124 dateListPanel.setPreferredSize(
new Dimension(100, 20));
125 leftSplitPane.setLeftComponent(dateListPanel);
126 artifactListPanel.setPreferredSize(
new Dimension(100, 20));
127 leftSplitPane.setRightComponent(artifactListPanel);
128 mainSplitPane.setRightComponent(rightPanel.getComponent());
130 leftSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
131 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
132 leftSplitPaneDividerLocation = leftSplitPane.getDividerLocation();
133 mainSplitPaneDividerLocation = mainSplitPane.getDividerLocation();
141 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
142 DomainArtifactsTabPanel.ArtifactRetrievalStatus getStatus() {
149 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
151 dateListPanel.focusList();
160 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
161 void setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus status, String domain) {
162 this.status = status;
163 this.selectedDomain = domain;
164 if (status == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
165 artifactListPanel.clearList();
166 dateListPanel.clearList();
169 if (rightPanel != null) {
170 rightPanel.setArtifact(null);
172 }
else if (status == DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING) {
174 add(
new LoadingPanel(Bundle.MiniTimelinePanel_loadingPanel_details()));
185 void handleMiniTimelineResultEvent(DiscoveryEventUtils.MiniTimelineResultEvent miniTimelineResultEvent) {
186 SwingUtilities.invokeLater(() -> {
187 if (miniTimelineResultEvent.getDomain().equals(selectedDomain)) {
188 dateListPanel.removeListSelectionListener(dateListener);
189 artifactListPanel.removeSelectionListener(artifactListener);
190 leftSplitPane.removePropertyChangeListener(dividerListener);
191 mainSplitPane.removePropertyChangeListener(dividerListener);
192 dateListPanel.addArtifacts(miniTimelineResultEvent.getResultList());
193 status = DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATED;
194 setEnabled(!dateListPanel.isEmpty());
195 dateListPanel.addSelectionListener(dateListener);
196 artifactListPanel.addSelectionListener(artifactListener);
197 dateListPanel.selectFirst();
198 if (miniTimelineResultEvent.shouldGrabFocus()) {
203 mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
204 leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
205 leftSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
206 mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
218 @SuppressWarnings(
"unchecked")
220 private
void initComponents() {
222 mainSplitPane =
new javax.swing.JSplitPane();
223 leftSplitPane =
new javax.swing.JSplitPane();
225 mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
226 mainSplitPane.setResizeWeight(0.2);
227 mainSplitPane.setToolTipText(
"");
228 mainSplitPane.setMinimumSize(
new java.awt.Dimension(0, 0));
230 leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
231 leftSplitPane.setResizeWeight(0.5);
232 leftSplitPane.setMinimumSize(
new java.awt.Dimension(0, 0));
233 mainSplitPane.setLeftComponent(leftSplitPane);
235 setMinimumSize(
new java.awt.Dimension(0, 0));
236 setLayout(
new java.awt.BorderLayout());
241 private javax.swing.JSplitPane leftSplitPane;
242 private javax.swing.JSplitPane mainSplitPane;