Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DomainArtifactsTabPanel.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 
22 import com.google.common.eventbus.Subscribe;
23 import java.util.logging.Level;
24 import javax.swing.JPanel;
25 import javax.swing.SwingUtilities;
26 import javax.swing.event.ListSelectionEvent;
27 import javax.swing.event.ListSelectionListener;
32 import org.sleuthkit.datamodel.BlackboardArtifact;
33 
37 final class DomainArtifactsTabPanel extends JPanel {
38 
39  private static final long serialVersionUID = 1L;
40  private final static Logger logger = Logger.getLogger(DomainArtifactsTabPanel.class.getName());
41  private final ArtifactsListPanel listPanel;
42  private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
43  private AbstractArtifactDetailsPanel rightPanel = null;
44 
45  private ArtifactRetrievalStatus status = ArtifactRetrievalStatus.UNPOPULATED;
46  private final ListSelectionListener listener = new ListSelectionListener() {
47  @Override
48  public void valueChanged(ListSelectionEvent event) {
49  if (!event.getValueIsAdjusting()) {
50  rightPanel.setArtifact(listPanel.getSelectedArtifact());
51  }
52  }
53  };
54 
60  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
61  DomainArtifactsTabPanel(BlackboardArtifact.ARTIFACT_TYPE type) {
62  initComponents();
63  this.artifactType = type;
64  listPanel = new ArtifactsListPanel(artifactType);
65  listPanel.addMouseListener(new ArtifactMenuMouseAdapter(listPanel));
66  mainSplitPane.setLeftComponent(listPanel);
67  add(mainSplitPane);
68  setRightComponent();
69  listPanel.addSelectionListener(listener);
70  }
71 
76  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
77  private void setRightComponent() {
78  switch (artifactType) {
79  case TSK_WEB_HISTORY:
80  case TSK_WEB_COOKIE:
81  case TSK_WEB_SEARCH_QUERY:
82  case TSK_WEB_BOOKMARK:
83  rightPanel = new GeneralPurposeArtifactViewer();
84  break;
85  case TSK_WEB_DOWNLOAD:
86  case TSK_WEB_CACHE:
87  rightPanel = new ContentViewerDetailsPanel();
88  break;
89  default:
90  rightPanel = new DefaultTableArtifactContentViewer();
91  break;
92  }
93  if (rightPanel != null) {
94  mainSplitPane.setRightComponent(rightPanel.getComponent());
95  }
96  }
97 
103  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
104  ArtifactRetrievalStatus getStatus() {
105  return status;
106  }
107 
113  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
114  void setStatus(ArtifactRetrievalStatus status) {
115  this.status = status;
116  if (status == ArtifactRetrievalStatus.UNPOPULATED) {
117  listPanel.clearList();
118  removeAll();
119  add(mainSplitPane);
120  if (rightPanel != null) {
121  rightPanel.setArtifact(null);
122  }
123  } else if (status == ArtifactRetrievalStatus.POPULATING) {
124  removeAll();
125  add(new LoadingPanel(artifactType.getDisplayName()));
126  }
127  }
128 
135  @Subscribe
136  void handleArtifactSearchResultEvent(DiscoveryEventUtils.ArtifactSearchResultEvent artifactresultEvent) {
137  if (artifactType == artifactresultEvent.getArtifactType() && status == ArtifactRetrievalStatus.POPULATING) {
138  SwingUtilities.invokeLater(() -> {
139  listPanel.removeSelectionListener(listener);
140  listPanel.addArtifacts(artifactresultEvent.getListOfArtifacts());
141  status = ArtifactRetrievalStatus.POPULATED;
142  setEnabled(!listPanel.isEmpty());
143  listPanel.addSelectionListener(listener);
144  listPanel.selectFirst();
145  removeAll();
146  add(mainSplitPane);
147  revalidate();
148  repaint();
149  try {
150  DiscoveryEventUtils.getDiscoveryEventBus().unregister(this);
151  } catch (IllegalArgumentException notRegistered) {
152  logger.log(Level.INFO, "Attempting to unregister tab which was not registered");
153  // attempting to remove a tab that was never registered
154  }
155  });
156  }
157  }
158 
164  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
165  BlackboardArtifact.ARTIFACT_TYPE getArtifactType() {
166  return artifactType;
167  }
168 
174  @SuppressWarnings("unchecked")
175  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
176  private void initComponents() {
177 
178  mainSplitPane = new javax.swing.JSplitPane();
179 
180  mainSplitPane.setDividerLocation(350);
181  mainSplitPane.setResizeWeight(0.1);
182 
183  setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
184  setMinimumSize(new java.awt.Dimension(0, 0));
185  setLayout(new java.awt.BorderLayout());
186  }// </editor-fold>//GEN-END:initComponents
187 
188 
189  // Variables declaration - do not modify//GEN-BEGIN:variables
190  private javax.swing.JSplitPane mainSplitPane;
191  // End of variables declaration//GEN-END:variables
192 
196  enum ArtifactRetrievalStatus {
197  UNPOPULATED(),
198  POPULATING(),
199  POPULATED();
200  }
201 
202 }

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.