Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MiniTimelinePanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2020 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.discovery.ui;
20 
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;
33 import org.sleuthkit.datamodel.BlackboardArtifact;
34 
38 final class MiniTimelinePanel extends javax.swing.JPanel {
39 
40  private static final long serialVersionUID = 1L;
41 
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;
52 
53  @NbBundle.Messages({"MiniTimelinePanel.loadingPanel.details=the Timeline view"})
57  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
58  MiniTimelinePanel() {
59  initComponents();
60  artifactListPanel.addMouseListener(new ArtifactMenuMouseAdapter(artifactListPanel));
61  artifactListener = new ListSelectionListener() {
62  @Override
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();
69  } else {
70  rightPanel = new GeneralPurposeArtifactViewer();
71  }
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);
82  validate();
83  repaint();
84  }
85  }
86  };
87  dividerListener = new PropertyChangeListener() {
88  @Override
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();
98  }
99  }
100  }
101  };
102  dateListener = new ListSelectionListener() {
103  @Override
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);
117  validate();
118  repaint();
119  }
120  }
121  };
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());
129  add(mainSplitPane);
130  leftSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
131  mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
132  leftSplitPaneDividerLocation = leftSplitPane.getDividerLocation();
133  mainSplitPaneDividerLocation = mainSplitPane.getDividerLocation();
134  }
135 
141  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
142  DomainArtifactsTabPanel.ArtifactRetrievalStatus getStatus() {
143  return status;
144  }
145 
149  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
150  void focusList() {
151  dateListPanel.focusList();
152  }
153 
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();
167  removeAll();
168  add(mainSplitPane);
169  if (rightPanel != null) {
170  rightPanel.setArtifact(null);
171  }
172  } else if (status == DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING) {
173  removeAll();
174  add(new LoadingPanel(Bundle.MiniTimelinePanel_loadingPanel_details()));
175  }
176  }
177 
184  @Subscribe
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()) {
199  focusList();
200  }
201  removeAll();
202  add(mainSplitPane);
203  mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
204  leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
205  leftSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
206  mainSplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, dividerListener);
207  revalidate();
208  repaint();
209  }
210  });
211  }
212 
218  @SuppressWarnings("unchecked")
219  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
220  private void initComponents() {
221 
222  mainSplitPane = new javax.swing.JSplitPane();
223  leftSplitPane = new javax.swing.JSplitPane();
224 
225  mainSplitPane.setDividerLocation(mainSplitPaneDividerLocation);
226  mainSplitPane.setResizeWeight(0.2);
227  mainSplitPane.setToolTipText("");
228  mainSplitPane.setMinimumSize(new java.awt.Dimension(0, 0));
229 
230  leftSplitPane.setDividerLocation(leftSplitPaneDividerLocation);
231  leftSplitPane.setResizeWeight(0.5);
232  leftSplitPane.setMinimumSize(new java.awt.Dimension(0, 0));
233  mainSplitPane.setLeftComponent(leftSplitPane);
234 
235  setMinimumSize(new java.awt.Dimension(0, 0));
236  setLayout(new java.awt.BorderLayout());
237  }// </editor-fold>//GEN-END:initComponents
238 
239 
240  // Variables declaration - do not modify//GEN-BEGIN:variables
241  private javax.swing.JSplitPane leftSplitPane;
242  private javax.swing.JSplitPane mainSplitPane;
243  // End of variables declaration//GEN-END:variables
244 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.