Autopsy  4.21.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 
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, 524, Short.MAX_VALUE)
118  );
119  dspSubtypePanelLayout.setVerticalGroup(
120  dspSubtypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121  .addGap(0, 334, 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  .addContainerGap()
139  .addComponent(dspSubtypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
140  .addComponent(dspSubtypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 524, javax.swing.GroupLayout.PREFERRED_SIZE)
141  );
142  layout.setVerticalGroup(
143  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144  .addGroup(layout.createSequentialGroup()
145  .addComponent(dspSubtypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
146  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
147  .addComponent(dspSubtypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE)
148  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
149  );
150  }// </editor-fold>//GEN-END:initComponents
151 
152  private void dspSubtypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dspSubtypeComboBoxActionPerformed
153  if (evt.getSource() instanceof JComboBox<?>) {
154  final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
155  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
156  localFilesPanel.setVisible(true);
157  l01panel.setVisible(false);
158  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
159  localFilesPanel.setVisible(false);
160  l01panel.setVisible(true);
161  }
162  firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true);
163  }
164  }//GEN-LAST:event_dspSubtypeComboBoxActionPerformed
165 
171  boolean validatePanel() {
172  // display warning if there is one (but don't disable "next" button)
173 
174  final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
175  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
176  return localFilesPanel.validatePanel();
177  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
178  return l01panel.validatePanel();
179  } else {
180  return false;
181  }
182  }
183  // Variables declaration - do not modify//GEN-BEGIN:variables
184  private javax.swing.JComboBox<String> dspSubtypeComboBox;
185  private javax.swing.JPanel dspSubtypePanel;
186  // End of variables declaration//GEN-END:variables
187 
193  boolean subTypeIsLogicalEvidencePanel() {
194  final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
195  return selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text());
196  }
197 
204  List<String> getContentPaths() {
205  String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
206  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
207  return localFilesPanel.getContentPaths();
208  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
209  return l01panel.getContentPaths();
210  } else {
211  return new ArrayList<>();
212  }
213 
214  }
215 
221  String getFileSetName() {
222  String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
223  if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_localFilesOption_text())) {
224  return localFilesPanel.getFileSetName();
225  } else if (selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text())) {
226  return l01panel.getFileSetName();
227  } else {
228  return "";
229  }
230  }
231 
237  Boolean getCreateTimestamp() {
238  return localFilesPanel.getCreateTimestamps();
239  }
240 
246  Boolean getModifiedTimestamp() {
247  return localFilesPanel.getModifiedTimestamps();
248  }
249 
255  Boolean getAccessTimestamp() {
256  return localFilesPanel.getAccessTimestamps();
257  }
258 
259 }

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