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;
31 final class DocumentPreviewViewer
extends javax.swing.JPanel {
33 private static final long serialVersionUID = 1L;
34 private final DefaultListModel<DocumentWrapper> documentListModel =
new DefaultListModel<>();
39 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
40 DocumentPreviewViewer() {
49 @SuppressWarnings(
"unchecked")
51 private
void initComponents() {
53 documentScrollPane =
new javax.swing.JScrollPane();
54 documentList =
new javax.swing.JList<>();
56 documentList.setModel(documentListModel);
57 documentList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
58 documentList.setCellRenderer(
new DocumentPanel());
59 documentScrollPane.setViewportView(documentList);
61 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
62 this.setLayout(layout);
63 layout.setHorizontalGroup(
64 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
65 .addGap(0, 400, Short.MAX_VALUE)
66 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
67 .addComponent(documentScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))
69 layout.setVerticalGroup(
70 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
71 .addGap(0, 300, Short.MAX_VALUE)
72 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
73 .addComponent(documentScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE))
80 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
82 documentListModel.removeAllElements();
83 documentScrollPane.getVerticalScrollBar().setValue(0);
92 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
93 void addListSelectionListener(ListSelectionListener listener) {
94 documentList.getSelectionModel().addListSelectionListener(listener);
104 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
105 List<AbstractFile> getInstancesForSelected() {
106 if (documentList.getSelectedIndex() == -1) {
107 return new ArrayList<>();
109 return documentListModel.getElementAt(documentList.getSelectedIndex()).getResultFile().getAllInstances();
114 private javax.swing.JList<DocumentWrapper> documentList;
115 private javax.swing.JScrollPane documentScrollPane;
124 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
125 void addDocument(DocumentWrapper documentWrapper) {
126 documentListModel.addElement(documentWrapper);