Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ResultsPanel.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.Component;
23 import java.awt.Image;
24 import java.awt.event.ItemEvent;
25 import java.awt.event.MouseAdapter;
26 import java.awt.event.MouseEvent;
27 import java.util.ArrayList;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Set;
31 import java.util.logging.Level;
32 import javax.swing.DefaultComboBoxModel;
33 import javax.swing.DefaultListCellRenderer;
34 import javax.swing.DefaultListModel;
35 import javax.swing.JList;
36 import javax.swing.JOptionPane;
37 import javax.swing.JPopupMenu;
38 import javax.swing.SwingUtilities;
39 import javax.swing.SwingWorker;
40 import javax.swing.event.ListSelectionListener;
41 import org.openide.util.NbBundle.Messages;
54 import org.sleuthkit.datamodel.AbstractFile;
55 import org.sleuthkit.datamodel.TskCoreException;
56 
61 public class ResultsPanel extends javax.swing.JPanel {
62 
63  private static final long serialVersionUID = 1L;
64  private final static Logger logger = Logger.getLogger(ResultsPanel.class.getName());
67  private List<FileSearchFiltering.FileFilter> searchFilters;
68  private FileSearch.AttributeType groupingAttribute;
69  private FileGroup.GroupSortingAlgorithm groupSort;
70  private FileSorter.SortingMethod fileSortMethod;
71  private GroupKey selectedGroupKey;
72  private int currentPage = 0;
73  private int previousPageSize = 10;
74  private FileSearchData.FileType resultType;
75  private int groupSize = 0;
76  private PageWorker pageWorker;
77  private final List<SwingWorker<Void, Void>> thumbnailWorkers = new ArrayList<>();
78  private final DefaultListModel<AbstractFile> instancesListModel = new DefaultListModel<>();
79  private ListSelectionListener listener = null;
80 
84  @Messages({"ResultsPanel.viewFileInDir.name=View File in Directory",
85  "ResultsPanel.openInExternalViewer.name=Open in External Viewer"})
86  public ResultsPanel() {
88  imageThumbnailViewer = new ImageThumbnailViewer();
89  videoThumbnailViewer = new VideoThumbnailViewer();
90  videoThumbnailViewer.addListSelectionListener((e) -> {
91  if (resultType == FileSearchData.FileType.VIDEO) {
92  if (!e.getValueIsAdjusting()) {
93  populateInstancesList();
94  } else {
95  instancesList.clearSelection();
96  }
97  }
98  });
99  imageThumbnailViewer.addListSelectionListener((e) -> {
100  if (resultType == FileSearchData.FileType.IMAGE) {
101  if (!e.getValueIsAdjusting()) {
102  populateInstancesList();
103  } else {
104  instancesList.clearSelection();
105  }
106  }
107  });
108  //Add the context menu when right clicking
109  instancesList.addMouseListener(new MouseAdapter() {
110  @Override
111  public void mousePressed(MouseEvent e) {
112  if (SwingUtilities.isRightMouseButton(e)) {
113  SwingUtilities.invokeLater(() -> {
114  instancesList.setSelectedIndex(instancesList.locationToIndex(e.getPoint()));
115  Set<AbstractFile> files = new HashSet<>();
116  files.add(instancesList.getSelectedValue());
117  JPopupMenu menu = new JPopupMenu();
118  menu.add(new ViewContextAction(Bundle.ResultsPanel_viewFileInDir_name(), instancesList.getSelectedValue()));
119  menu.add(new ExternalViewerAction(Bundle.ResultsPanel_openInExternalViewer_name(), new FileNode(instancesList.getSelectedValue())));
120  menu.add(ViewFileInTimelineAction.createViewFileAction(instancesList.getSelectedValue()));
121  menu.add(new DiscoveryExtractAction(files));
122  menu.add(AddContentTagAction.getInstance().getMenuForContent(files));
123  menu.add(DeleteFileContentTagAction.getInstance().getMenuForFiles(files));
124  menu.add(AddContentToHashDbAction.getInstance().getMenuForFiles(files));
125  menu.show(instancesList, e.getPoint().x, e.getPoint().y);
126  });
127  }
128  }
129  });
130 
131  }
132 
138  void addListSelectionListener(ListSelectionListener newListener) {
139  instancesList.removeListSelectionListener(listener);
140  listener = newListener;
141  instancesList.addListSelectionListener(listener);
142  }
143 
147  synchronized void populateInstancesList() {
148  SwingUtilities.invokeLater(() -> {
149  List<AbstractFile> files = getInstancesForSelected();
150  if (files.isEmpty()) {
151  //if there are no files currently remove the current items without removing listener to cause content viewer to reset
152  instancesListModel.removeAllElements();
153  } else {
154  //remove listener so content viewer node is not set multiple times
155  instancesList.removeListSelectionListener(listener);
156  instancesListModel.removeAllElements();
157  for (AbstractFile file : files) {
158  instancesListModel.addElement(file);
159  }
160  //add listener back to allow selection of first index to cause content viewer node to be set
161  instancesList.addListSelectionListener(listener);
162  if (!instancesListModel.isEmpty()) {
163  instancesList.setSelectedIndex(0);
164  }
165  }
166  });
167  }
168 
175  synchronized AbstractFile getSelectedFile() {
176  if (instancesList.getSelectedIndex() == -1) {
177  return null;
178  } else {
179  return instancesListModel.getElementAt(instancesList.getSelectedIndex());
180  }
181  }
182 
190  private List<AbstractFile> getInstancesForSelected() {
191  if (resultType == FileSearchData.FileType.VIDEO) {
192  return videoThumbnailViewer.getInstancesForSelected();
193  } else if (resultType == FileSearchData.FileType.IMAGE) {
194  return imageThumbnailViewer.getInstancesForSelected();
195  }
196  return new ArrayList<>();
197  }
198 
204  @Subscribe
205  void handlePageRetrievedEvent(DiscoveryEventUtils.PageRetrievedEvent pageRetrievedEvent) {
206  SwingUtilities.invokeLater(() -> {
207  populateInstancesList();
208  currentPage = pageRetrievedEvent.getPageNumber();
209  updateControls();
210  resetResultViewer();
211  if (pageRetrievedEvent.getType() == FileSearchData.FileType.IMAGE) {
212  populateImageViewer(pageRetrievedEvent.getSearchResults());
213  resultsViewerPanel.add(imageThumbnailViewer);
214  } else if (pageRetrievedEvent.getType() == FileSearchData.FileType.VIDEO) {
215  populateVideoViewer(pageRetrievedEvent.getSearchResults());
216  resultsViewerPanel.add(videoThumbnailViewer);
217  }
218  resultsViewerPanel.revalidate();
219  resultsViewerPanel.repaint();
220  }
221  );
222  }
223 
228  synchronized void resetResultViewer() {
229  resultsViewerPanel.remove(imageThumbnailViewer);
230  resultsViewerPanel.remove(videoThumbnailViewer);
231  //cancel any unfished thumb workers
232  for (SwingWorker<Void, Void> thumbWorker : thumbnailWorkers) {
233  if (!thumbWorker.isDone()) {
234  thumbWorker.cancel(true);
235  }
236  }
237  //clear old thumbnails
238  thumbnailWorkers.clear();
239  videoThumbnailViewer.clearViewer();
240  imageThumbnailViewer.clearViewer();
241  }
242 
249  synchronized void populateVideoViewer(List<ResultFile> files) {
250  for (ResultFile file : files) {
251  VideoThumbnailWorker thumbWorker = new VideoThumbnailWorker(file);
252  thumbWorker.execute();
253  //keep track of thumb worker for possible cancelation
254  thumbnailWorkers.add(thumbWorker);
255  }
256  }
257 
264  synchronized void populateImageViewer(List<ResultFile> files) {
265  for (ResultFile file : files) {
266  ImageThumbnailWorker thumbWorker = new ImageThumbnailWorker(file);
267  thumbWorker.execute();
268  //keep track of thumb worker for possible cancelation
269  thumbnailWorkers.add(thumbWorker);
270  }
271  }
272 
278  @Subscribe
279  void handleGroupSelectedEvent(DiscoveryEventUtils.GroupSelectedEvent groupSelectedEvent) {
280  SwingUtilities.invokeLater(() -> {
281  searchFilters = groupSelectedEvent.getFilters();
282  groupingAttribute = groupSelectedEvent.getGroupingAttr();
283  groupSort = groupSelectedEvent.getGroupSort();
284  fileSortMethod = groupSelectedEvent.getFileSort();
285  selectedGroupKey = groupSelectedEvent.getGroupKey();
286  resultType = groupSelectedEvent.getResultType();
287  groupSize = groupSelectedEvent.getGroupSize();
288  setPage(0);
289  });
290  }
291 
298  @Subscribe
299  void handleNoResultsEvent(DiscoveryEventUtils.NoResultsEvent noResultsEvent) {
300  SwingUtilities.invokeLater(() -> {
301  groupSize = 0;
302  currentPage = 0;
303  updateControls();
304  videoThumbnailViewer.clearViewer();
305  imageThumbnailViewer.clearViewer();
306  resultsViewerPanel.revalidate();
307  resultsViewerPanel.repaint();
308  });
309  }
310 
317  private synchronized void setPage(int startingEntry) {
318  int pageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
319  synchronized (this) {
320  if (pageWorker != null && !pageWorker.isDone()) {
321  pageWorker.cancel(true);
322  }
323  EamDb centralRepo = null;
324  if (EamDb.isEnabled()) {
325  try {
326  centralRepo = EamDb.getInstance();
327  } catch (EamDbException ex) {
328  centralRepo = null;
329  logger.log(Level.SEVERE, "Error loading central repository database, no central repository options will be available for File Discovery", ex);
330  }
331  }
332  pageWorker = new PageWorker(searchFilters, groupingAttribute, groupSort, fileSortMethod, selectedGroupKey, startingEntry, pageSize, resultType, centralRepo);
333  pageWorker.execute();
334  }
335  }
336 
340  @Messages({"# {0} - currentPage",
341  "# {1} - totalPages",
342  "ResultsPanel.currentPage.displayValue=Page: {0} of {1}"})
343  private void updateControls() {
344  previousPageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
345  int pageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
346  //handle edge case where group size is 0 and we want the empty results to be labeled paged 1 of 1 not page 1 of 0
347  double maxPageDouble = groupSize == 0 ? 1 : Math.ceil((double) groupSize / pageSize);
348  currentPageLabel.setText(Bundle.ResultsPanel_currentPage_displayValue(currentPage + 1, maxPageDouble));
349  previousPageButton.setEnabled(currentPage != 0);
350  nextPageButton.setEnabled(groupSize > ((currentPage + 1) * pageSize));
351  gotoPageField.setEnabled(groupSize > pageSize);
352  pageSizeComboBox.setEnabled(true);
353  }
354 
360  @SuppressWarnings("unchecked")
361  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
362  private void initComponents() {
363 
364  javax.swing.JPanel pagingPanel = new javax.swing.JPanel();
365  previousPageButton = new javax.swing.JButton();
366  currentPageLabel = new javax.swing.JLabel();
367  nextPageButton = new javax.swing.JButton();
368  javax.swing.JLabel pageControlsLabel = new javax.swing.JLabel();
369  javax.swing.JLabel gotoPageLabel = new javax.swing.JLabel();
370  gotoPageField = new javax.swing.JTextField();
371  javax.swing.JLabel pageSizeLabel = new javax.swing.JLabel();
372  pageSizeComboBox = new javax.swing.JComboBox<>();
373  javax.swing.JSplitPane resultsSplitPane = new javax.swing.JSplitPane();
374  javax.swing.JPanel instancesPanel = new javax.swing.JPanel();
375  javax.swing.JScrollPane instancesScrollPane = new javax.swing.JScrollPane();
376  instancesList = new javax.swing.JList<>();
377  resultsViewerPanel = new javax.swing.JPanel();
378 
379  setPreferredSize(new java.awt.Dimension(777, 475));
380 
381  pagingPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
382 
383  previousPageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_back.png"))); // NOI18N
384  previousPageButton.setBorder(null);
385  previousPageButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_back_disabled.png"))); // NOI18N
386  previousPageButton.setEnabled(false);
387  previousPageButton.setFocusable(false);
388  previousPageButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_back_hover.png"))); // NOI18N
389  previousPageButton.addActionListener(new java.awt.event.ActionListener() {
390  public void actionPerformed(java.awt.event.ActionEvent evt) {
391  previousPageButtonActionPerformed(evt);
392  }
393  });
394 
395  org.openide.awt.Mnemonics.setLocalizedText(currentPageLabel, org.openide.util.NbBundle.getMessage(ResultsPanel.class, "ResultsPanel.currentPageLabel.text")); // NOI18N
396  currentPageLabel.setMaximumSize(new java.awt.Dimension(90, 23));
397  currentPageLabel.setMinimumSize(new java.awt.Dimension(90, 23));
398  currentPageLabel.setPreferredSize(new java.awt.Dimension(90, 23));
399 
400  nextPageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_forward.png"))); // NOI18N
401  nextPageButton.setBorder(null);
402  nextPageButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_forward_disabled.png"))); // NOI18N
403  nextPageButton.setEnabled(false);
404  nextPageButton.setFocusable(false);
405  nextPageButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_forward_hover.png"))); // NOI18N
406  nextPageButton.addActionListener(new java.awt.event.ActionListener() {
407  public void actionPerformed(java.awt.event.ActionEvent evt) {
408  nextPageButtonActionPerformed(evt);
409  }
410  });
411 
412  org.openide.awt.Mnemonics.setLocalizedText(pageControlsLabel, org.openide.util.NbBundle.getMessage(ResultsPanel.class, "ResultsPanel.pageControlsLabel.text")); // NOI18N
413  pageControlsLabel.setMaximumSize(new java.awt.Dimension(33, 23));
414  pageControlsLabel.setMinimumSize(new java.awt.Dimension(33, 23));
415  pageControlsLabel.setPreferredSize(new java.awt.Dimension(33, 23));
416 
417  org.openide.awt.Mnemonics.setLocalizedText(gotoPageLabel, org.openide.util.NbBundle.getMessage(ResultsPanel.class, "ResultsPanel.gotoPageLabel.text")); // NOI18N
418  gotoPageLabel.setMaximumSize(new java.awt.Dimension(70, 23));
419  gotoPageLabel.setMinimumSize(new java.awt.Dimension(70, 23));
420  gotoPageLabel.setPreferredSize(new java.awt.Dimension(70, 23));
421 
422  gotoPageField.setEnabled(false);
423  gotoPageField.addActionListener(new java.awt.event.ActionListener() {
424  public void actionPerformed(java.awt.event.ActionEvent evt) {
425  gotoPageFieldActionPerformed(evt);
426  }
427  });
428 
429  org.openide.awt.Mnemonics.setLocalizedText(pageSizeLabel, org.openide.util.NbBundle.getMessage(ResultsPanel.class, "ResultsPanel.pageSizeLabel.text")); // NOI18N
430  pageSizeLabel.setMaximumSize(new java.awt.Dimension(60, 23));
431  pageSizeLabel.setMinimumSize(new java.awt.Dimension(60, 23));
432  pageSizeLabel.setPreferredSize(new java.awt.Dimension(60, 23));
433 
434  pageSizeComboBox.setModel(new DefaultComboBoxModel<Integer>(new Integer[] {25,50,75,100,125,150,175,200}));
435  pageSizeComboBox.setSelectedIndex(3);
436  pageSizeComboBox.addItemListener(new java.awt.event.ItemListener() {
437  public void itemStateChanged(java.awt.event.ItemEvent evt) {
438  pageSizeChanged(evt);
439  }
440  });
441 
442  javax.swing.GroupLayout pagingPanelLayout = new javax.swing.GroupLayout(pagingPanel);
443  pagingPanel.setLayout(pagingPanelLayout);
444  pagingPanelLayout.setHorizontalGroup(
445  pagingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
446  .addGroup(pagingPanelLayout.createSequentialGroup()
447  .addContainerGap()
448  .addComponent(currentPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
449  .addGap(18, 18, 18)
450  .addComponent(pageControlsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
451  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
452  .addComponent(previousPageButton)
453  .addGap(0, 0, 0)
454  .addComponent(nextPageButton)
455  .addGap(18, 18, 18)
456  .addComponent(gotoPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
457  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
458  .addComponent(gotoPageField, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
459  .addGap(18, 18, 18)
460  .addComponent(pageSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
461  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
462  .addComponent(pageSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
463  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
464  );
465  pagingPanelLayout.setVerticalGroup(
466  pagingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
467  .addGroup(pagingPanelLayout.createSequentialGroup()
468  .addGap(4, 4, 4)
469  .addGroup(pagingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
470  .addComponent(nextPageButton, javax.swing.GroupLayout.Alignment.TRAILING)
471  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pagingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
472  .addComponent(previousPageButton, javax.swing.GroupLayout.Alignment.TRAILING)
473  .addComponent(currentPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
474  .addComponent(pageControlsLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
475  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pagingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
476  .addComponent(gotoPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
477  .addComponent(gotoPageField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
478  .addComponent(pageSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
479  .addComponent(pageSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
480  .addGap(4, 4, 4))
481  );
482 
483  resultsSplitPane.setDividerLocation(380);
484  resultsSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
485  resultsSplitPane.setResizeWeight(1.0);
486  resultsSplitPane.setToolTipText(org.openide.util.NbBundle.getMessage(ResultsPanel.class, "ResultsPanel.resultsSplitPane.toolTipText")); // NOI18N
487  resultsSplitPane.setLastDividerLocation(180);
488  resultsSplitPane.setOpaque(false);
489  resultsSplitPane.setPreferredSize(new java.awt.Dimension(777, 440));
490 
491  instancesPanel.setPreferredSize(new java.awt.Dimension(775, 68));
492 
493  instancesScrollPane.setPreferredSize(new java.awt.Dimension(775, 60));
494 
495  instancesList.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(ResultsPanel.class, "ResultsPanel.instancesList.border.title"))); // NOI18N
496  instancesList.setModel(instancesListModel);
497  instancesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
498  instancesList.setCellRenderer(new InstancesCellRenderer());
499  instancesList.setPreferredSize(new java.awt.Dimension(0, 50));
500  instancesList.setVisibleRowCount(2);
501  instancesScrollPane.setViewportView(instancesList);
502 
503  javax.swing.GroupLayout instancesPanelLayout = new javax.swing.GroupLayout(instancesPanel);
504  instancesPanel.setLayout(instancesPanelLayout);
505  instancesPanelLayout.setHorizontalGroup(
506  instancesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
507  .addGap(0, 775, Short.MAX_VALUE)
508  .addGroup(instancesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
509  .addComponent(instancesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
510  );
511  instancesPanelLayout.setVerticalGroup(
512  instancesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
513  .addGap(0, 221, Short.MAX_VALUE)
514  .addGroup(instancesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
515  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, instancesPanelLayout.createSequentialGroup()
516  .addGap(0, 0, 0)
517  .addComponent(instancesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE)))
518  );
519 
520  resultsSplitPane.setRightComponent(instancesPanel);
521 
522  resultsViewerPanel.setPreferredSize(new java.awt.Dimension(0, 380));
523  resultsViewerPanel.setLayout(new java.awt.BorderLayout());
524  resultsSplitPane.setLeftComponent(resultsViewerPanel);
525 
526  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
527  this.setLayout(layout);
528  layout.setHorizontalGroup(
529  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
530  .addComponent(pagingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
531  .addComponent(resultsSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
532  );
533  layout.setVerticalGroup(
534  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
535  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
536  .addComponent(pagingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
537  .addGap(0, 0, 0)
538  .addComponent(resultsSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
539  .addGap(0, 0, 0))
540  );
541  }// </editor-fold>//GEN-END:initComponents
542 
548  private void previousPageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previousPageButtonActionPerformed
549  if (currentPage > 0) {
550  disablePagingControls();
551  int previousPage = currentPage - 1;
552  int pageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
553  setPage(previousPage * pageSize);
554  }
555  }//GEN-LAST:event_previousPageButtonActionPerformed
556 
562  private void nextPageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextPageButtonActionPerformed
563  disablePagingControls();
564  int nextPage = currentPage + 1;
565  int pageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
566  setPage(nextPage * pageSize);
567  }//GEN-LAST:event_nextPageButtonActionPerformed
568 
574  @Messages({"# {0} - selectedPage",
575  "# {1} - maxPage",
576  "ResultsPanel.invalidPageNumber.message=The selected page number {0} does not exist. Please select a value from 1 to {1}.",
577  "ResultsPanel.invalidPageNumber.title=Invalid Page Number"})
578  private void gotoPageFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gotoPageFieldActionPerformed
579  int newPage;
580  try {
581  newPage = Integer.parseInt(gotoPageField.getText());
582  } catch (NumberFormatException e) {
583  //ignore input
584  return;
585  }
586  int pageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
587  if ((newPage - 1) < 0 || groupSize <= ((newPage - 1) * pageSize)) {
588  JOptionPane.showMessageDialog(this,
589  Bundle.ResultsPanel_invalidPageNumber_message(newPage, Math.ceil((double) groupSize / pageSize)),
590  Bundle.ResultsPanel_invalidPageNumber_title(),
591  JOptionPane.WARNING_MESSAGE);
592  return;
593  }
594  disablePagingControls();
595  setPage((newPage - 1) * pageSize);
596  }//GEN-LAST:event_gotoPageFieldActionPerformed
597 
598  private void pageSizeChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_pageSizeChanged
599  if (evt.getStateChange() == ItemEvent.SELECTED) {
600  disablePagingControls();
601  int previousPage = currentPage - 1;
602  int pageSize = pageSizeComboBox.getItemAt(pageSizeComboBox.getSelectedIndex());
603  if (previousPageSize != pageSize) {
604  previousPage = 0;
605  }
606  setPage(previousPage * pageSize);
607  }
608  }//GEN-LAST:event_pageSizeChanged
609 
613  private void disablePagingControls() {
614  nextPageButton.setEnabled(false);
615  previousPageButton.setEnabled(false);
616  gotoPageField.setEnabled(false);
617  pageSizeComboBox.setEnabled(false);
618  }
619 
620  // Variables declaration - do not modify//GEN-BEGIN:variables
621  private javax.swing.JLabel currentPageLabel;
622  private javax.swing.JTextField gotoPageField;
623  private javax.swing.JList<AbstractFile> instancesList;
624  private javax.swing.JButton nextPageButton;
625  private javax.swing.JComboBox<Integer> pageSizeComboBox;
626  private javax.swing.JButton previousPageButton;
627  private javax.swing.JPanel resultsViewerPanel;
628  // End of variables declaration//GEN-END:variables
629 
634  private class VideoThumbnailWorker extends SwingWorker<Void, Void> {
635 
636  private final VideoThumbnailsWrapper thumbnailWrapper;
637 
644  VideoThumbnailWorker(ResultFile file) {
645  thumbnailWrapper = new VideoThumbnailsWrapper(file);
646  videoThumbnailViewer.addVideo(thumbnailWrapper);
647  }
648 
649  @Override
650  protected Void doInBackground() throws Exception {
651  FileSearch.getVideoThumbnails(thumbnailWrapper);
652  return null;
653  }
654 
655  @Override
656  protected void done() {
657  videoThumbnailViewer.repaint();
658  }
659  }
660 
665  private class ImageThumbnailWorker extends SwingWorker<Void, Void> {
666 
668 
675  ImageThumbnailWorker(ResultFile file) {
676  thumbnailWrapper = new ImageThumbnailWrapper(file);
677  imageThumbnailViewer.addImage(thumbnailWrapper);
678  }
679 
680  @Override
681  protected Void doInBackground() throws Exception {
682  Image thumbnail = ImageUtils.getThumbnail(thumbnailWrapper.getResultFile().getFirstInstance(), ImageUtils.ICON_SIZE_LARGE);
683  if (thumbnail != null) {
684  thumbnailWrapper.setImageThumbnail(thumbnail);
685  }
686  return null;
687  }
688 
689  @Override
690  protected void done() {
691  imageThumbnailViewer.repaint();
692  }
693 
694  }
695 
699  private class InstancesCellRenderer extends DefaultListCellRenderer {
700 
701  private static final long serialVersionUID = 1L;
702 
703  @Override
704  public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
705  super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
706  String name = "";
707  if (value instanceof AbstractFile) {
708  AbstractFile file = (AbstractFile) value;
709  try {
710  name = file.getUniquePath();
711  } catch (TskCoreException ingored) {
712  name = file.getParentPath() + "/" + file.getName();
713  }
714 
715  }
716  setText(name);
717  return this;
718  }
719 
720  }
721 }
List< FileSearchFiltering.FileFilter > searchFilters
void gotoPageFieldActionPerformed(java.awt.event.ActionEvent evt)
final VideoThumbnailViewer videoThumbnailViewer
javax.swing.JComboBox< Integer > pageSizeComboBox
Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)
final DefaultListModel< AbstractFile > instancesListModel
javax.swing.JList< AbstractFile > instancesList
final List< SwingWorker< Void, Void > > thumbnailWorkers
void nextPageButtonActionPerformed(java.awt.event.ActionEvent evt)
void previousPageButtonActionPerformed(java.awt.event.ActionEvent evt)
void pageSizeChanged(java.awt.event.ItemEvent evt)
FileGroup.GroupSortingAlgorithm groupSort
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
final ImageThumbnailViewer imageThumbnailViewer
static BufferedImage getThumbnail(Content content, int iconSize)
synchronized void setPage(int startingEntry)

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.