Autopsy  4.13.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;
38 import org.sleuthkit.datamodel.AbstractFile;
39 
43 @TopComponent.Description(preferredID = "DiscoveryTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER)
44 @TopComponent.Registration(mode = "discovery", openAtStartup = false)
45 @RetainLocation("discovery")
46 @NbBundle.Messages("DiscoveryTopComponent.name= File Discovery")
47 public final class DiscoveryTopComponent extends TopComponent {
48 
49  private static final long serialVersionUID = 1L;
50  private static final String PREFERRED_ID = "DiscoveryTopComponent"; // NON-NLS
51  private static final Color SELECTED_COLOR = new Color(216, 230, 242);
52  private static final Color UNSELECTED_COLOR = new Color(240, 240, 240);
53  private final FileSearchPanel fileSearchPanel;
54  private final GroupListPanel groupListPanel;
56  private final ResultsPanel resultsPanel;
57 
64  setName(Bundle.DiscoveryTopComponent_name());
65  fileSearchPanel = new FileSearchPanel();
66  dataContentPanel = DataContentPanel.createInstance();
67  resultsPanel = new ResultsPanel();
68  groupListPanel = new GroupListPanel();
69  leftSplitPane.setLeftComponent(fileSearchPanel);
70  leftSplitPane.setRightComponent(groupListPanel);
71  rightSplitPane.setTopComponent(resultsPanel);
72  rightSplitPane.setBottomComponent(dataContentPanel);
73  //add list selection listener so the content viewer will be updated with the selected file
74  //when a file is selected in the results panel
75  resultsPanel.addListSelectionListener(new ListSelectionListener() {
76  @Override
77  public void valueChanged(ListSelectionEvent e) {
78  if (!e.getValueIsAdjusting()) {
79  SwingUtilities.invokeLater(() -> {
80  AbstractFile file = resultsPanel.getSelectedFile();
81  if (file != null) {
82  dataContentPanel.setNode(new TableFilterNode(new FileNode(file), false));
83  } else {
84  dataContentPanel.setNode(null);
85  }
86  });
87  }
88  }
89  });
90 
91  }
92 
99  return (DiscoveryTopComponent) WindowManager.getDefault().findTopComponent(PREFERRED_ID);
100  }
101 
105  public void resetTopComponent() {
106  resultsPanel.resetResultViewer();
107  groupListPanel.resetGroupList();
108  }
109 
113  void updateSearchSettings() {
115  fileSearchPanel.resetPanel();
116  imagesButton.setSelected(true);
117  imagesButton.setEnabled(false);
118  imagesButton.setBackground(SELECTED_COLOR);
119  imagesButton.setForeground(Color.BLACK);
120  videosButton.setSelected(false);
121  videosButton.setEnabled(true);
122  videosButton.setBackground(UNSELECTED_COLOR);
123  fileSearchPanel.setSelectedType(FileSearchData.FileType.IMAGE);
124  }
125 
126  @Override
127  public void componentOpened() {
128  super.componentOpened();
129  WindowManager.getDefault().setTopComponentFloating(this, true);
130  DiscoveryEventUtils.getDiscoveryEventBus().register(this);
131  DiscoveryEventUtils.getDiscoveryEventBus().register(resultsPanel);
132  DiscoveryEventUtils.getDiscoveryEventBus().register(groupListPanel);
133  DiscoveryEventUtils.getDiscoveryEventBus().register(fileSearchPanel);
134  }
135 
136  @Override
137  protected void componentClosed() {
138  fileSearchPanel.cancelSearch();
139  DiscoveryEventUtils.getDiscoveryEventBus().unregister(this);
140  DiscoveryEventUtils.getDiscoveryEventBus().unregister(fileSearchPanel);
141  DiscoveryEventUtils.getDiscoveryEventBus().unregister(groupListPanel);
142  DiscoveryEventUtils.getDiscoveryEventBus().unregister(resultsPanel);
143  super.componentClosed();
144  }
145 
151  @SuppressWarnings("unchecked")
152  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
153  private void initComponents() {
154 
155  javax.swing.JSplitPane mainSplitPane = new javax.swing.JSplitPane();
156  leftSplitPane = new javax.swing.JSplitPane();
157  rightSplitPane = new javax.swing.JSplitPane();
158  javax.swing.JPanel toolBarPanel = new javax.swing.JPanel();
159  javax.swing.JToolBar toolBar = new javax.swing.JToolBar();
160  imagesButton = new javax.swing.JButton();
161  javax.swing.JLabel stepOneLabel = new javax.swing.JLabel();
162  videosButton = new javax.swing.JButton();
163  javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(62, 0), new java.awt.Dimension(62, 0), new java.awt.Dimension(62, 32767));
164 
165  setPreferredSize(new java.awt.Dimension(1400, 900));
166  setLayout(new java.awt.BorderLayout());
167 
168  mainSplitPane.setDividerLocation(450);
169  mainSplitPane.setPreferredSize(new java.awt.Dimension(1400, 828));
170 
171  leftSplitPane.setDividerLocation(325);
172  leftSplitPane.setToolTipText("");
173  leftSplitPane.setPreferredSize(new java.awt.Dimension(400, 828));
174  mainSplitPane.setLeftComponent(leftSplitPane);
175 
176  rightSplitPane.setDividerLocation(475);
177  rightSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
178  rightSplitPane.setResizeWeight(0.5);
179  rightSplitPane.setPreferredSize(new java.awt.Dimension(1000, 828));
180  mainSplitPane.setRightComponent(rightSplitPane);
181 
182  add(mainSplitPane, java.awt.BorderLayout.CENTER);
183 
184  toolBar.setFloatable(false);
185  toolBar.setRollover(true);
186 
187  imagesButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/pictures-icon.png"))); // NOI18N
188  org.openide.awt.Mnemonics.setLocalizedText(imagesButton, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.imagesButton.text")); // NOI18N
189  imagesButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/pictures-icon.png"))); // NOI18N
190  imagesButton.setFocusable(false);
191  imagesButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
192  imagesButton.setMaximumSize(new java.awt.Dimension(90, 43));
193  imagesButton.setMinimumSize(new java.awt.Dimension(90, 43));
194  imagesButton.setPreferredSize(new java.awt.Dimension(90, 43));
195  imagesButton.addActionListener(new java.awt.event.ActionListener() {
196  public void actionPerformed(java.awt.event.ActionEvent evt) {
198  }
199  });
200 
201  org.openide.awt.Mnemonics.setLocalizedText(stepOneLabel, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.stepOneLabel.text")); // NOI18N
202 
203  videosButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
204  org.openide.awt.Mnemonics.setLocalizedText(videosButton, org.openide.util.NbBundle.getMessage(DiscoveryTopComponent.class, "DiscoveryTopComponent.videosButton.text")); // NOI18N
205  videosButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
206  videosButton.setDisabledSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/video-icon.png"))); // NOI18N
207  videosButton.setFocusable(false);
208  videosButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
209  videosButton.setMaximumSize(new java.awt.Dimension(90, 43));
210  videosButton.setMinimumSize(new java.awt.Dimension(90, 43));
211  videosButton.setPreferredSize(new java.awt.Dimension(90, 43));
212  videosButton.addActionListener(new java.awt.event.ActionListener() {
213  public void actionPerformed(java.awt.event.ActionEvent evt) {
215  }
216  });
217 
218  javax.swing.GroupLayout toolBarPanelLayout = new javax.swing.GroupLayout(toolBarPanel);
219  toolBarPanel.setLayout(toolBarPanelLayout);
220  toolBarPanelLayout.setHorizontalGroup(
221  toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
222  .addGroup(toolBarPanelLayout.createSequentialGroup()
223  .addContainerGap(486, Short.MAX_VALUE)
224  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
225  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, toolBarPanelLayout.createSequentialGroup()
226  .addComponent(imagesButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
227  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228  .addComponent(videosButton, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
229  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, toolBarPanelLayout.createSequentialGroup()
230  .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
231  .addGap(0, 0, 0)
232  .addComponent(stepOneLabel)
233  .addGap(62, 62, 62)))
234  .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
235  .addContainerGap(486, Short.MAX_VALUE))
236  );
237  toolBarPanelLayout.setVerticalGroup(
238  toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
239  .addComponent(toolBar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
240  .addGroup(toolBarPanelLayout.createSequentialGroup()
241  .addGap(4, 4, 4)
242  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
243  .addComponent(stepOneLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
244  .addComponent(filler1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
245  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
246  .addGroup(toolBarPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
247  .addComponent(videosButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
248  .addComponent(imagesButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
249  .addGap(5, 5, 5))
250  );
251 
252  add(toolBarPanel, java.awt.BorderLayout.PAGE_START);
253  }// </editor-fold>//GEN-END:initComponents
254 
255  private void imagesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imagesButtonActionPerformed
257  imagesButton.setSelected(true);
258  imagesButton.setEnabled(false);
259  imagesButton.setBackground(SELECTED_COLOR);
260  imagesButton.setForeground(Color.BLACK);
261  videosButton.setSelected(false);
262  videosButton.setEnabled(true);
263  videosButton.setBackground(UNSELECTED_COLOR);
264  fileSearchPanel.setSelectedType(FileSearchData.FileType.IMAGE);
265  }//GEN-LAST:event_imagesButtonActionPerformed
266 
267  private void videosButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videosButtonActionPerformed
269  imagesButton.setSelected(false);
270  imagesButton.setEnabled(true);
271  imagesButton.setBackground(UNSELECTED_COLOR);
272  videosButton.setSelected(true);
273  videosButton.setEnabled(false);
274  videosButton.setBackground(SELECTED_COLOR);
275  videosButton.setForeground(Color.BLACK);
276  fileSearchPanel.setSelectedType(FileSearchData.FileType.VIDEO);
277  }//GEN-LAST:event_videosButtonActionPerformed
278 
284  @Subscribe
285  void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
286  SwingUtilities.invokeLater(() -> {
287  if (fileSearchPanel.getSelectedType() == FileType.VIDEO) {
288  imagesButton.setEnabled(true);
289  } else if (fileSearchPanel.getSelectedType() == FileType.IMAGE) {
290  videosButton.setEnabled(true);
291  }
292  });
293  }
294 
300  @Subscribe
301  void handleSearchCompletedEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompletedEvent) {
302  SwingUtilities.invokeLater(() -> {
303  if (fileSearchPanel.getSelectedType() == FileType.VIDEO) {
304  imagesButton.setEnabled(true);
305  } else if (fileSearchPanel.getSelectedType() == FileType.IMAGE) {
306  videosButton.setEnabled(true);
307  }
308  });
309  }
310 
311  @Override
312  public List<Mode> availableModes(List<Mode> modes) {
313  /*
314  * This looks like the right thing to do, but online discussions seems
315  * to indicate this method is effectively deprecated. A break point
316  * placed here was never hit.
317  */
318  return modes.stream().filter(mode -> mode.getName().equals("discovery"))
319  .collect(Collectors.toList());
320  }
321 
327  @Subscribe
328  void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
329  SwingUtilities.invokeLater(() -> {
330  imagesButton.setEnabled(false);
331  videosButton.setEnabled(false);
332  });
333  }
334 
335  // Variables declaration - do not modify//GEN-BEGIN:variables
336  private javax.swing.JButton imagesButton;
337  private javax.swing.JSplitPane leftSplitPane;
338  private javax.swing.JSplitPane rightSplitPane;
339  private javax.swing.JButton videosButton;
340  // End of variables declaration//GEN-END:variables
341 
342 }
void videosButtonActionPerformed(java.awt.event.ActionEvent evt)
void imagesButtonActionPerformed(java.awt.event.ActionEvent evt)

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