Autopsy  4.16.0
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;
25 import org.sleuthkit.datamodel.AbstractFile;
26 
30 final class DocumentPreviewViewer extends javax.swing.JPanel {
31 
32  private static final long serialVersionUID = 1L;
33  private final DefaultListModel<DocumentWrapper> documentListModel = new DefaultListModel<>();
34 
38  DocumentPreviewViewer() {
39  initComponents();
40  }
41 
47  @SuppressWarnings("unchecked")
48  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
49  private void initComponents() {
50 
51  documentScrollPane = new javax.swing.JScrollPane();
52  documentList = new javax.swing.JList<>();
53 
54  documentList.setModel(documentListModel);
55  documentList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
56  documentList.setCellRenderer(new DocumentPanel());
57  documentScrollPane.setViewportView(documentList);
58 
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))
66  );
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))
72  );
73  }// </editor-fold>//GEN-END:initComponents
74 
78  void clearViewer() {
79  synchronized (this) {
80  documentListModel.removeAllElements();
81  documentScrollPane.getVerticalScrollBar().setValue(0);
82  }
83  }
84 
91  void addListSelectionListener(ListSelectionListener listener) {
92  documentList.getSelectionModel().addListSelectionListener(listener);
93  }
94 
102  List<AbstractFile> getInstancesForSelected() {
103  synchronized (this) {
104  if (documentList.getSelectedIndex() == -1) {
105  return new ArrayList<>();
106  } else {
107  return documentListModel.getElementAt(documentList.getSelectedIndex()).getResultFile().getAllInstances();
108  }
109  }
110  }
111 
112  // Variables declaration - do not modify//GEN-BEGIN:variables
113  private javax.swing.JList<DocumentWrapper> documentList;
114  private javax.swing.JScrollPane documentScrollPane;
115  // End of variables declaration//GEN-END:variables
116 
123  void addDocument(DocumentWrapper documentWrapper) {
124  synchronized (this) {
125  documentListModel.addElement(documentWrapper);
126  }
127  }
128 }

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.