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;
30 final class DocumentPreviewViewer
extends javax.swing.JPanel {
32 private static final long serialVersionUID = 1L;
33 private final DefaultListModel<DocumentWrapper> documentListModel =
new DefaultListModel<>();
38 DocumentPreviewViewer() {
47 @SuppressWarnings(
"unchecked")
49 private
void initComponents() {
51 documentScrollPane =
new javax.swing.JScrollPane();
52 documentList =
new javax.swing.JList<>();
54 documentList.setModel(documentListModel);
55 documentList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
56 documentList.setCellRenderer(
new DocumentPanel());
57 documentScrollPane.setViewportView(documentList);
59 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
60 this.setLayout(layout);
61 layout.setHorizontalGroup(
62 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
63 .addGap(0, 400, Short.MAX_VALUE)
64 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
65 .addComponent(documentScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))
67 layout.setVerticalGroup(
68 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
69 .addGap(0, 300, Short.MAX_VALUE)
70 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
71 .addComponent(documentScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE))
80 documentListModel.removeAllElements();
81 documentScrollPane.getVerticalScrollBar().setValue(0);
91 void addListSelectionListener(ListSelectionListener listener) {
92 documentList.getSelectionModel().addListSelectionListener(listener);
102 List<AbstractFile> getInstancesForSelected() {
103 synchronized (
this) {
104 if (documentList.getSelectedIndex() == -1) {
105 return new ArrayList<>();
107 return documentListModel.getElementAt(documentList.getSelectedIndex()).getResultFile().getAllInstances();
113 private javax.swing.JList<DocumentWrapper> documentList;
114 private javax.swing.JScrollPane documentScrollPane;
123 void addDocument(DocumentWrapper documentWrapper) {
124 synchronized (
this) {
125 documentListModel.addElement(documentWrapper);