19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.DefaultListModel;
24 import javax.swing.event.ListSelectionListener;
32 final class ImageThumbnailViewer
extends javax.swing.JPanel {
34 private static final long serialVersionUID = 1L;
36 private final DefaultListModel<ImageThumbnailWrapper> thumbnailListModel =
new DefaultListModel<>();
41 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
42 ImageThumbnailViewer() {
52 @SuppressWarnings(
"unchecked")
54 private
void initComponents() {
56 thumbnailListScrollPane =
new javax.swing.JScrollPane();
57 thumbnailList =
new javax.swing.JList<>();
59 setLayout(
new java.awt.BorderLayout());
61 thumbnailList.setModel(thumbnailListModel);
62 thumbnailList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
63 thumbnailList.setCellRenderer(
new ImageThumbnailPanel());
64 thumbnailList.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP);
65 thumbnailList.setVisibleRowCount(0);
66 thumbnailListScrollPane.setViewportView(thumbnailList);
68 add(thumbnailListScrollPane, java.awt.BorderLayout.CENTER);
73 private javax.swing.JList<ImageThumbnailWrapper> thumbnailList;
74 private javax.swing.JScrollPane thumbnailListScrollPane;
82 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
83 void addListSelectionListener(ListSelectionListener listener) {
84 thumbnailList.getSelectionModel().addListSelectionListener(listener);
94 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
95 List<AbstractFile> getInstancesForSelected() {
96 if (thumbnailList.getSelectedIndex() == -1) {
97 return new ArrayList<>();
99 return thumbnailListModel.getElementAt(thumbnailList.getSelectedIndex()).getResultFile().getAllInstances();
106 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
108 thumbnailListModel.removeAllElements();
109 thumbnailListScrollPane.getVerticalScrollBar().setValue(0);
119 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
120 void addImage(ImageThumbnailWrapper thumbnailWrapper) {
121 thumbnailListModel.addElement(thumbnailWrapper);