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

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.