Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DocumentPreviewViewer.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2020 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.discovery.ui;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.DefaultListModel;
24 import javax.swing.event.ListSelectionListener;
26 import org.sleuthkit.datamodel.AbstractFile;
27 
31 final class DocumentPreviewViewer extends javax.swing.JPanel {
32 
33  private static final long serialVersionUID = 1L;
34  private final DefaultListModel<DocumentWrapper> documentListModel = new DefaultListModel<>();
35 
39  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
40  DocumentPreviewViewer() {
41  initComponents();
42  }
43 
49  @SuppressWarnings("unchecked")
50  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
51  private void initComponents() {
52 
53  documentScrollPane = new javax.swing.JScrollPane();
54  documentList = new javax.swing.JList<>();
55 
56  documentList.setModel(documentListModel);
57  documentList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
58  documentList.setCellRenderer(new DocumentPanel());
59  documentScrollPane.setViewportView(documentList);
60 
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))
68  );
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))
74  );
75  }// </editor-fold>//GEN-END:initComponents
76 
80  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
81  void clearViewer() {
82  documentListModel.removeAllElements();
83  documentScrollPane.getVerticalScrollBar().setValue(0);
84  }
85 
92  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
93  void addListSelectionListener(ListSelectionListener listener) {
94  documentList.getSelectionModel().addListSelectionListener(listener);
95  }
96 
104  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
105  List<AbstractFile> getInstancesForSelected() {
106  if (documentList.getSelectedIndex() == -1) {
107  return new ArrayList<>();
108  } else {
109  return documentListModel.getElementAt(documentList.getSelectedIndex()).getResultFile().getAllInstances();
110  }
111  }
112 
113  // Variables declaration - do not modify//GEN-BEGIN:variables
114  private javax.swing.JList<DocumentWrapper> documentList;
115  private javax.swing.JScrollPane documentScrollPane;
116  // End of variables declaration//GEN-END:variables
117 
124  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
125  void addDocument(DocumentWrapper documentWrapper) {
126  documentListModel.addElement(documentWrapper);
127  }
128 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.