19 package org.sleuthkit.autopsy.casemodule;
 
   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;
 
   35     "LogicalFilesDspPanel.subTypeComboBox.localFilesOption.text=Local files and folders",
 
   36     "LogicalFilesDspPanel.subTypeComboBox.l01FileOption.text=Logical evidence file (L01)" 
   38 @SuppressWarnings(
"PMD.SingularField") 
 
   39 final class LogicalFilesDspPanel extends JPanel {
 
   41     private static final long serialVersionUID = 1L;
 
   43     private final LocalFilesPanel localFilesPanel = 
new LocalFilesPanel();
 
   44     private final LogicalEvidenceFilePanel l01panel = LogicalEvidenceFilePanel.createInstance();
 
   45     private static LogicalFilesDspPanel instance;
 
   50     private LogicalFilesDspPanel() {
 
   52         dspSubtypePanel.setLayout(
new BoxLayout(dspSubtypePanel, BoxLayout.Y_AXIS));
 
   53         dspSubtypePanel.add(l01panel);
 
   54         dspSubtypePanel.add(localFilesPanel);
 
   55         l01panel.setVisible(
false);
 
   59     public void addPropertyChangeListener(
final PropertyChangeListener listener) {
 
   60         super.addPropertyChangeListener(listener);
 
   61         localFilesPanel.addPropertyChangeListener(listener);
 
   62         l01panel.addPropertyChangeListener(listener);
 
   66     public void removePropertyChangeListener(
final PropertyChangeListener listener) {
 
   67         super.removePropertyChangeListener(listener);
 
   68         localFilesPanel.removePropertyChangeListener(listener);
 
   69         l01panel.removePropertyChangeListener(listener);
 
   72     static LogicalFilesDspPanel getDefault() {
 
   73         synchronized (LogicalFilesDspPanel.class) {
 
   74             if (instance == null) {
 
   75                 instance = 
new LogicalFilesDspPanel();
 
   81     String getContentType() {
 
   82         return NbBundle.getMessage(this.getClass(), 
"LocalFilesPanel.contentType.text");
 
   86         dspSubtypeComboBox.setSelectedIndex(0);
 
   87         localFilesPanel.setVisible(
true);
 
   88         l01panel.setVisible(
false);
 
   89         localFilesPanel.reset();
 
   91         dspSubtypePanel.repaint();
 
   95     public String toString() {
 
   96         return NbBundle.getMessage(this.getClass(), 
"LocalFilesDSProcessor.toString.text");
 
  104     @SuppressWarnings(
"unchecked")
 
  106     private 
void initComponents() {
 
  108         dspSubtypePanel = 
new javax.swing.JPanel();
 
  109         dspSubtypeComboBox = 
new javax.swing.JComboBox<>();
 
  111         dspSubtypePanel.setPreferredSize(
new java.awt.Dimension(467, 160));
 
  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)
 
  119         dspSubtypePanelLayout.setVerticalGroup(
 
  120             dspSubtypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 
  121             .addGap(0, 160, Short.MAX_VALUE)
 
  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);
 
  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()
 
  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))
 
  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)
 
  155     private void dspSubtypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {
 
  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);
 
  165             firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), 
false, 
true);
 
  174     boolean validatePanel() {
 
  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();
 
  187     private javax.swing.JComboBox<String> dspSubtypeComboBox;
 
  188     private javax.swing.JPanel dspSubtypePanel;
 
  196     boolean subTypeIsLogicalEvidencePanel() {
 
  197         final String selectedSubType = dspSubtypeComboBox.getSelectedItem().toString();
 
  198         return selectedSubType.equals(Bundle.LogicalFilesDspPanel_subTypeComboBox_l01FileOption_text());
 
  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();
 
  214             return new ArrayList<>();
 
  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();