Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
DiscoveryTopComponent.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2019 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.filequery;
20 
21 import com.google.common.eventbus.Subscribe;
22 import java.awt.Color;
23 import java.util.List;
24 import java.util.stream.Collectors;
25 import javax.swing.SwingUtilities;
26 import javax.swing.event.ListSelectionEvent;
27 import javax.swing.event.ListSelectionListener;
28 import org.openide.util.NbBundle;
29 import org.openide.windows.Mode;
30 import org.openide.windows.RetainLocation;
31 import org.openide.windows.TopComponent;
32 import org.openide.windows.WindowManager;
37 import org.sleuthkit.datamodel.AbstractFile;
38 
42 @TopComponent.Description(preferredID = "DiscoveryTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
43 @TopComponent.Registration(mode = "discovery", openAtStartup = false)
44 @RetainLocation("discovery")
45 @NbBundle.Messages("DiscoveryTopComponent.name= File Discovery")
46 public final class DiscoveryTopComponent extends TopComponent {
47 
48  private static final long serialVersionUID = 1L;
49  private static final String PREFERRED_ID = "DiscoveryTopComponent"; // NON-NLS
50  private static final Color SELECTED_COLOR = new Color(216, 230, 242);
51  private static final Color UNSELECTED_COLOR = new Color(240, 240, 240);
52  private final FileSearchPanel fileSearchPanel;
53  private final GroupListPanel groupListPanel;
55  private final ResultsPanel resultsPanel;
56 
63  setName(Bundle.DiscoveryTopComponent_name());
64  fileSearchPanel = new FileSearchPanel();
65  dataContentPanel = DataContentPanel.createInstance();
66  resultsPanel = new ResultsPanel();
67  groupListPanel = new GroupListPanel();
68  leftSplitPane.setLeftComponent(fileSearchPanel);
69  leftSplitPane.setRightComponent(groupListPanel);
70  rightSplitPane.setTopComponent(resultsPanel);
71  rightSplitPane.setBottomComponent(dataContentPanel);
72  //add list selection listener so the content viewer will be updated with the selected file
73  //when a file is selected in the results panel
74  resultsPanel.addListSelectionListener(new ListSelectionListener() {
75  @Override
76  public void valueChanged(ListSelectionEvent e) {
77  if (!e.getValueIsAdjusting()) {
78  SwingUtilities.invokeLater(() -> {
79  AbstractFile file = resultsPanel.getSelectedFile();
80  if (file != null) {
81  dataContentPanel.setNode(new TableFilterNode(new FileNode(file), false));
82  } else {
83  dataContentPanel.setNode(null);
84  }
85  });
86  }
87  }
88  });
89 
90  }
91 
98  return (DiscoveryTopComponent) WindowManager.getDefault().findTopComponent(PREFERRED_ID);
99  }
100 
104  public void resetTopComponent() {
105  resultsPanel.resetResultViewer();
106  groupListPanel.resetGroupList();
107  }
108 
112  void updateSearchSettings() {
114  fileSearchPanel.resetPanel();
115  imagesButton.setSelected(true);
116  imagesButton.setEnabled(false);
117  imagesButton.setBackground(SELECTED_COLOR);
118  imagesButton.setForeground(Color.BLACK);
119  videosButton.setSelected(false);
120  videosButton.setEnabled(true);
121  videosButton.setBackground(UNSELECTED_COLOR);
122  documentsButton.setSelected(false);
123  documentsButton.setEnabled(true);
124  documentsButton.setBackground(UNSELECTED_COLOR);
125  fileSearchPanel.setSelectedType(FileSearchData.FileType.IMAGE);
126  }
127 
128  @Override
129  public void componentOpened() {
130  super.componentOpened();
131  WindowManager.getDefault().setTopComponentFloating(this, true);
132  DiscoveryEventUtils.getDiscoveryEventBus().register(this);
133  DiscoveryEventUtils.getDiscoveryEventBus().register(resultsPanel);
134  DiscoveryEventUtils.getDiscoveryEventBus().register(groupListPanel);
135  DiscoveryEventUtils.getDiscoveryEventBus().register(fileSearchPanel);
136  }
137 
138  @Override
139  protected void componentClosed() {
140  fileSearchPanel.cancelSearch();
141  DiscoveryEventUtils.getDiscoveryEventBus().unregister(this);
142  DiscoveryEventUtils.getDiscoveryEventBus().unregister(fileSearchPanel);
143  DiscoveryEventUtils.getDiscoveryEventBus().unregister(groupListPanel);
144  DiscoveryEventUtils.getDiscoveryEventBus().unregister(resultsPanel);
145  super.componentClosed();
146  }
147 
153  @SuppressWarnings("unchecked")
154  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
155  private void initComponents() {
156 
157  javax.swing.JSplitPane mainSplitPane = new javax.swing.JSplitPane();
158  leftSplitPane = new javax.swing.JSplitPane();
159  rightSplitPane = new javax.swing.JSplitPane();
160  javax.swing.JPanel toolBarPanel = new javax.swing.JPanel();
161  imagesButton = new javax.swing.JButton();
162  javax.swing.JLabel stepOneLabel = new javax.swing.JLabel();
163  videosButton = new javax.swing.JButton();
164  javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(119, 0), new java.awt.Dimension(119, 0), new java.awt.Dimension(119, 32767));
165  documentsButton = new javax.swing.JButton();
166 
167  setPreferredSize(new java.awt.Dimension(1400, 900));
168  setLayout(new java.awt.BorderLayout());
169 
170  mainSplitPane.setDividerLocation(450);
171  mainSplitPane.setPreferredSize(new java.awt.Dimension(1400, 828));
172 
173  leftSplitPane.setDividerLocation(325);
174  leftSplitPane.setToolTipText("");
175  leftSplitPane.setPreferredSize(new java.awt.Dimension(400, 828));
176  mainSplitPane.setLeftComponent(leftSplitPane);
177 
178  rightSplitPane.setDividerLocation(475);
179  rightSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
180  rightSplitPane.setResizeWeight(0.5);
181  rightSplitPane.setPreferredSize(new java.awt.Dimension(1000, 828));
182  mainSplitPane.setRightComponent(rightSplitPane);
183 
184  add(mainSplitPane, java.awt.BorderLayout.CENTER);
185 
186  imagesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/pictures-icon.png"))); // NOI18N
187  org.openide.awt.Mnemonics.setLocalizedText(imagesButton, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.imagesButton.text")); // NOI18N
188  imagesButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/pictures-icon.png"))); // NOI18N
189  imagesButton.setFocusable(false);
190  imagesButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
191  imagesButton.setMaximumSize(new java.awt.Dimension(90, 43));
192  imagesButton.setMinimumSize(new java.awt.Dimension(90, 43));
193  imagesButton.setPreferredSize(new java.awt.Dimension(90, 43));
194  imagesButton.addActionListener(new java.awt.event.ActionListener() {
195  public void actionPerformed(java.awt.event.ActionEvent evt) {
197  }
198  });
199 
200  org.openide.awt.Mnemonics.setLocalizedText(stepOneLabel, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.stepOneLabel.text")); // NOI18N
201 
202  videosButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
203  org.openide.awt.Mnemonics.setLocalizedText(videosButton, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.videosButton.text")); // NOI18N
204  videosButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
205  videosButton.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
206  videosButton.setFocusable(false);
207  videosButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
208  videosButton.setMaximumSize(new java.awt.Dimension(90, 43));
209  videosButton.setMinimumSize(new java.awt.Dimension(90, 43));
210  videosButton.setPreferredSize(new java.awt.Dimension(90, 43));
211  videosButton.addActionListener(new java.awt.event.ActionListener() {
212  public void actionPerformed(java.awt.event.ActionEvent evt) {
214  }
215  });
216 
217  documentsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/documents-icon.png"))); // NOI18N
218  org.openide.awt.Mnemonics.setLocalizedText(documentsButton, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.documentsButton.text")); // NOI18N
219  documentsButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/documents-icon.png"))); // NOI18N
220  documentsButton.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/documents-icon.png"))); // NOI18N
221  documentsButton.setFocusable(false);
222  documentsButton.addActionListener(new java.awt.event.ActionListener() {
223  public void actionPerformed(java.awt.event.ActionEvent evt) {
225  }
226  });
227 
228  javax.swing.GroupLayout toolBarPanelLayout = new javax.swing.GroupLayout(toolBarPanel);
229  toolBarPanel.setLayout(toolBarPanelLayout);
230  toolBarPanelLayout.setHorizontalGroup(
231  toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232  .addGroup(toolBarPanelLayout.createSequentialGroup()
233  .addContainerGap(414, Short.MAX_VALUE)
234  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235  .addGroup(toolBarPanelLayout.createSequentialGroup()
236  .addComponent(imagesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
237  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238  .addComponent(videosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
239  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240  .addComponent(documentsButton))
241  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, toolBarPanelLayout.createSequentialGroup()
242  .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
243  .addGap(0, 0, 0)
244  .addComponent(stepOneLabel)
245  .addGap(119, 119, 119)))
246  .addContainerGap(413, Short.MAX_VALUE))
247  );
248 
249  toolBarPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {documentsButton, imagesButton, videosButton});
250 
251  toolBarPanelLayout.setVerticalGroup(
252  toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
253  .addGroup(toolBarPanelLayout.createSequentialGroup()
254  .addGap(4, 4, 4)
255  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
256  .addComponent(stepOneLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
257  .addComponent(filler1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
258  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
259  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
260  .addComponent(videosButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
261  .addComponent(imagesButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
262  .addComponent(documentsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
263  .addGap(5, 5, 5))
264  );
265 
266  toolBarPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {documentsButton, imagesButton, videosButton});
267 
268  add(toolBarPanel, java.awt.BorderLayout.PAGE_START);
269  }// </editor-fold>//GEN-END:initComponents
270 
271  private void imagesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imagesButtonActionPerformed
273  imagesButton.setSelected(true);
274  imagesButton.setEnabled(false);
275  imagesButton.setBackground(SELECTED_COLOR);
276  imagesButton.setForeground(Color.BLACK);
277  videosButton.setSelected(false);
278  videosButton.setEnabled(true);
279  videosButton.setBackground(UNSELECTED_COLOR);
280  documentsButton.setSelected(false);
281  documentsButton.setEnabled(true);
282  documentsButton.setBackground(UNSELECTED_COLOR);
283  fileSearchPanel.setSelectedType(FileSearchData.FileType.IMAGE);
284  }//GEN-LAST:event_imagesButtonActionPerformed
285 
286  private void videosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videosButtonActionPerformed
288  imagesButton.setSelected(false);
289  imagesButton.setEnabled(true);
290  imagesButton.setBackground(UNSELECTED_COLOR);
291  videosButton.setSelected(true);
292  videosButton.setEnabled(false);
293  videosButton.setBackground(SELECTED_COLOR);
294  videosButton.setForeground(Color.BLACK);
295  documentsButton.setSelected(false);
296  documentsButton.setEnabled(true);
297  documentsButton.setBackground(UNSELECTED_COLOR);
298  fileSearchPanel.setSelectedType(FileSearchData.FileType.VIDEO);
299  }//GEN-LAST:event_videosButtonActionPerformed
300 
301  private void documentsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_documentsButtonActionPerformed
303  documentsButton.setSelected(true);
304  documentsButton.setEnabled(false);
305  documentsButton.setBackground(SELECTED_COLOR);
306  documentsButton.setForeground(Color.BLACK);
307  videosButton.setSelected(false);
308  videosButton.setEnabled(true);
309  videosButton.setBackground(UNSELECTED_COLOR);
310  imagesButton.setSelected(false);
311  imagesButton.setEnabled(true);
312  imagesButton.setBackground(UNSELECTED_COLOR);
313  fileSearchPanel.setSelectedType(FileSearchData.FileType.DOCUMENTS);
314  }//GEN-LAST:event_documentsButtonActionPerformed
315 
321  @Subscribe
322  void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
323  SwingUtilities.invokeLater(() -> {
324  if (null != fileSearchPanel.getSelectedType()) {
325  switch (fileSearchPanel.getSelectedType()) {
326  case VIDEO:
327  imagesButton.setEnabled(true);
328  documentsButton.setEnabled(true);
329  break;
330  case IMAGE:
331  videosButton.setEnabled(true);
332  documentsButton.setEnabled(true);
333  break;
334  case DOCUMENTS:
335  videosButton.setEnabled(true);
336  imagesButton.setEnabled(true);
337  break;
338  default:
339  break;
340  }
341  }
342 
343  });
344  }
345 
351  @Subscribe
352  void handleSearchCompletedEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompletedEvent) {
353  SwingUtilities.invokeLater(() -> {
354  if (null != fileSearchPanel.getSelectedType()) {
355  switch (fileSearchPanel.getSelectedType()) {
356  case VIDEO:
357  imagesButton.setEnabled(true);
358  documentsButton.setEnabled(true);
359  break;
360  case IMAGE:
361  videosButton.setEnabled(true);
362  documentsButton.setEnabled(true);
363  break;
364  case DOCUMENTS:
365  videosButton.setEnabled(true);
366  imagesButton.setEnabled(true);
367  break;
368  default:
369  break;
370  }
371  }
372  });
373  }
374 
375  @Override
376  public List<Mode> availableModes(List<Mode> modes) {
377  /*
378  * This looks like the right thing to do, but online discussions seems
379  * to indicate this method is effectively deprecated. A break point
380  * placed here was never hit.
381  */
382  return modes.stream().filter(mode -> mode.getName().equals("discovery"))
383  .collect(Collectors.toList());
384  }
385 
391  @Subscribe
392  void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
393  SwingUtilities.invokeLater(() -> {
394  imagesButton.setEnabled(false);
395  videosButton.setEnabled(false);
396  documentsButton.setEnabled(false);
397  });
398  }
399 
400  // Variables declaration - do not modify//GEN-BEGIN:variables
401  private javax.swing.JButton documentsButton;
402  private javax.swing.JButton imagesButton;
403  private javax.swing.JSplitPane leftSplitPane;
404  private javax.swing.JSplitPane rightSplitPane;
405  private javax.swing.JButton videosButton;
406  // End of variables declaration//GEN-END:variables
407 
408 }
void videosButtonActionPerformed(java.awt.event.ActionEvent evt)
void documentsButtonActionPerformed(java.awt.event.ActionEvent evt)
void imagesButtonActionPerformed(java.awt.event.ActionEvent evt)

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.