Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LogicalFilesDspPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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.casemodule;
20 
21 import java.beans.PropertyChangeListener;
22 import java.util.ArrayList;
23 import java.util.List;
24 import javax.swing.BoxLayout;
25 import javax.swing.JComboBox;
26 import javax.swing.JPanel;
27 import org.openide.util.NbBundle;
28 import org.openide.util.NbBundle.Messages;
30 
34 @Messages({
35  "LogicalFilesDspPanel.subTypeComboBox.localFilesOption.text=Local files and folders",
36  "LogicalFilesDspPanel.subTypeComboBox.l01FileOption.text=Logical evidence file (L01)"
37 })
38 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
39 final class LogicalFilesDspPanel extends JPanel {
40 
41  private static final long serialVersionUID = 1L;
42 
43  private final LocalFilesPanel localFilesPanel = new LocalFilesPanel();
44  private final LogicalEvidenceFilePanel l01panel = LogicalEvidenceFilePanel.createInstance();
45  private static LogicalFilesDspPanel instance;
46 
50  private LogicalFilesDspPanel() {
51  initComponents();
52  dspSubtypePanel.setLayout(new BoxLayout(dspSubtypePanel, BoxLayout.Y_AXIS));
53  dspSubtypePanel.add(l01panel);
54  dspSubtypePanel.add(localFilesPanel);
55  l01panel.setVisible(false);
56  }
57 
58  @Override
59  public void addPropertyChangeListener(final PropertyChangeListener listener) {
60  super.addPropertyChangeListener(listener);
61  localFilesPanel.addPropertyChangeListener(listener);
62  l01panel.addPropertyChangeListener(listener);
63  }
64 
65  @Override
66  public void removePropertyChangeListener(final PropertyChangeListener listener) {
67  super.removePropertyChangeListener(listener);
68  localFilesPanel.removePropertyChangeListener(listener);
69  l01panel.removePropertyChangeListener(listener);
70  }
71 
72  static LogicalFilesDspPanel getDefault() {
73  synchronized (LogicalFilesDspPanel.class) {
74  if (instance == null) {
75  instance = new LogicalFilesDspPanel();
76  }
77  return instance;
78  }
79  }
80 
81  String getContentType() {
82  return NbBundle.getMessage(this.getClass(), "LocalFilesPanel.contentType.text");
83  }
84 
85  void select() {
86  dspSubtypeComboBox.setSelectedIndex(0);
87  localFilesPanel.setVisible(true);
88  l01panel.setVisible(false);
89  localFilesPanel.reset();
90  l01panel.reset();
91  dspSubtypePanel.repaint();
92  }
93 
94  @Override
95  public String toString() {
96  return NbBundle.getMessage(this.getClass(), "LocalFilesDSProcessor.toString.text");
97  }
98 
104  @SuppressWarnings("unchecked")
105  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
106  private void initComponents() {
107 
108  dspSubtypePanel = new javax.swing.JPanel();
109  dspSubtypeComboBox = new javax.swing.JComboBox<>();
110 
111  dspSubtypePanel.setPreferredSize(new java.awt.Dimension(467, 160));
112 
113  javax.swing.GroupLayout dspSubtypePanelLayout = new javax.swing.GroupLayout(dspSubtypePanel);
114  dspSubtypePanel.setLayout(dspSubtypePanelLayout);
115  dspSubtypePanelLayout.setHorizontalGroup(
116  dspSubtypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
117  .addGap(0, 466, Short.MAX_VALUE)
118  );
119  dspSubtypePanelLayout.setVerticalGroup(
120  dspSubtypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121  .addGap(0, 160, Short.MAX_VALUE)
122  );
123 
124  dspSubtypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] {Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text(), Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text()}));
125  dspSubtypeComboBox.setMinimumSize(new java.awt.Dimension(379, 20));
126  dspSubtypeComboBox.setPreferredSize(new java.awt.Dimension(379, 20));
127  dspSubtypeComboBox.addActionListener(new java.awt.event.ActionListener() {
128  public void actionPerformed(java.awt.event.ActionEvent evt) {
129  dspSubtypeComboBoxActionPerformed(evt);
130  }
131  });
132 
133  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
134  this.setLayout(layout);
135  layout.setHorizontalGroup(
136  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
137  .addGroup(layout.createSequentialGroup()
138  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
139  .addGroup(layout.createSequentialGroup()
140  .addContainerGap()
141  .addComponent(dspSubtypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
142  .addComponent(dspSubtypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE))
143  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
144  );
145  layout.setVerticalGroup(
146  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147  .addGroup(layout.createSequentialGroup()
148  .addComponent(dspSubtypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
149  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
150  .addComponent(dspSubtypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
151  .addGap(0, 0, 0))
152  );
153  }// </editor-fold>//GEN-END:initComponents
154 
155  private void dspSubtypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dspSubtypeComboBoxActionPerformed
156  if (evt.getSource() instanceof JComboBox<?>) {
157  final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
158  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
159  localFilesPanel.setVisible(true);
160  l01panel.setVisible(false);
161  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
162  localFilesPanel.setVisible(false);
163  l01panel.setVisible(true);
164  }
165  firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true);
166  }
167  }//GEN-LAST:event_dspSubtypeComboBoxActionPerformed
168 
174  boolean validatePanel() {
175  // display warning if there is one (but don't disable "next" button)
176 
177  final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
178  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
179  return localFilesPanel.validatePanel();
180  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
181  return l01panel.validatePanel();
182  } else {
183  return false;
184  }
185  }
186  // Variables declaration - do not modify//GEN-BEGIN:variables
187  private javax.swing.JComboBox<String> dspSubtypeComboBox;
188  private javax.swing.JPanel dspSubtypePanel;
189  // End of variables declaration//GEN-END:variables
190 
196  boolean subTypeIsLogicalEvidencePanel() {
197  final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
198  return selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text());
199  }
200 
207  List<String> getContentPaths() {
208  String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
209  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
210  return localFilesPanel.getContentPaths();
211  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
212  return l01panel.getContentPaths();
213  } else {
214  return new ArrayList<>();
215  }
216 
217  }
218 
224  String getFileSetName() {
225  String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
226  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
227  return localFilesPanel.getFileSetName();
228  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
229  return l01panel.getFileSetName();
230  } else {
231  return "";
232  }
233  }
234 }

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