Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
NewRuleSetPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 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.logicalimager.configuration;
20 
21 import java.awt.BorderLayout;
22 import java.io.IOException;
23 import javax.swing.JButton;
24 import javax.swing.JPanel;
25 import org.apache.commons.lang3.tuple.ImmutablePair;
26 
30 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
31 class NewRuleSetPanel extends javax.swing.JPanel {
32 
33  private final JPanel nonFullPathsJPanel;
34  private final EditNonFullPathsRulePanel editNonFullPathsRulePanel;
35  private final JPanel fullPathsPanel;
36  private final EditFullPathsRulePanel editFullPathsRulePanel;
37 
41  NewRuleSetPanel(JButton okButton, JButton cancelButton) {
42  initComponents();
43 
44  nonFullPathsJPanel = createPanel();
45  editNonFullPathsRulePanel = new EditNonFullPathsRulePanel(okButton, cancelButton, "", new LogicalImagerRule(), false);
46  nonFullPathsJPanel.add(editNonFullPathsRulePanel, BorderLayout.NORTH);
47 
48  fullPathsPanel = createPanel();
49  editFullPathsRulePanel = new EditFullPathsRulePanel(okButton, cancelButton, "", new LogicalImagerRule(), false);
50  fullPathsPanel.add(editFullPathsRulePanel, BorderLayout.NORTH);
51 
52  sharedLayeredPane.add(nonFullPathsJPanel, Integer.valueOf(0));
53  sharedLayeredPane.add(fullPathsPanel, Integer.valueOf(1));
54  nonFullPathsJPanel.setVisible(true);
55  fullPathsPanel.setVisible(false);
56  }
57 
58  private JPanel createPanel() {
59  JPanel panel = new JPanel(new BorderLayout());
60  panel.setSize(800, 640);
61  return panel;
62  }
63 
69  @SuppressWarnings("unchecked")
70  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
71  private void initComponents() {
72 
73  chooseLabel = new javax.swing.JLabel();
74  chooseComboBox = new javax.swing.JComboBox<>();
75  sharedLayeredPane = new javax.swing.JLayeredPane();
76 
77  org.openide.awt.Mnemonics.setLocalizedText(chooseLabel, org.openide.util.NbBundle.getMessage(NewRuleSetPanel.class, "NewRuleSetPanel.chooseLabel.text")); // NOI18N
78 
79  chooseComboBox.setMaximumRowCount(2);
80  chooseComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "By Attribute", "By Full Path" }));
81  chooseComboBox.addActionListener(new java.awt.event.ActionListener() {
82  public void actionPerformed(java.awt.event.ActionEvent evt) {
83  chooseComboBoxActionPerformed(evt);
84  }
85  });
86 
87  javax.swing.GroupLayout sharedLayeredPaneLayout = new javax.swing.GroupLayout(sharedLayeredPane);
88  sharedLayeredPane.setLayout(sharedLayeredPaneLayout);
89  sharedLayeredPaneLayout.setHorizontalGroup(
90  sharedLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
91  .addGap(0, 0, Short.MAX_VALUE)
92  );
93  sharedLayeredPaneLayout.setVerticalGroup(
94  sharedLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95  .addGap(0, 373, Short.MAX_VALUE)
96  );
97 
98  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
99  this.setLayout(layout);
100  layout.setHorizontalGroup(
101  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
102  .addGroup(layout.createSequentialGroup()
103  .addGap(10, 10, 10)
104  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
105  .addComponent(chooseLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
106  .addComponent(chooseComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
107  .addContainerGap(716, Short.MAX_VALUE))
108  .addGroup(layout.createSequentialGroup()
109  .addContainerGap()
110  .addComponent(sharedLayeredPane)
111  .addContainerGap())
112  );
113  layout.setVerticalGroup(
114  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
115  .addGroup(layout.createSequentialGroup()
116  .addContainerGap()
117  .addComponent(chooseLabel)
118  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
119  .addComponent(chooseComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
120  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
121  .addComponent(sharedLayeredPane)
122  .addContainerGap())
123  );
124  }// </editor-fold>//GEN-END:initComponents
125 
126  private void chooseComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseComboBoxActionPerformed
127  int index = chooseComboBox.getSelectedIndex();
128  if (index == 0) {
129  nonFullPathsJPanel.setVisible(true);
130  fullPathsPanel.setVisible(false);
131  } else {
132  nonFullPathsJPanel.setVisible(false);
133  fullPathsPanel.setVisible(true);
134  }
135  }//GEN-LAST:event_chooseComboBoxActionPerformed
136 
137  // Variables declaration - do not modify//GEN-BEGIN:variables
138  private javax.swing.JComboBox<String> chooseComboBox;
139  private javax.swing.JLabel chooseLabel;
140  private javax.swing.JLayeredPane sharedLayeredPane;
141  // End of variables declaration//GEN-END:variables
142 
143  ImmutablePair<String, LogicalImagerRule> toRule() throws IOException, NumberFormatException {
144  ImmutablePair<String, LogicalImagerRule> ruleMap;
145  if (chooseComboBox.getSelectedIndex() == 0) {
146  ruleMap = editNonFullPathsRulePanel.toRule();
147  } else {
148  ruleMap = editFullPathsRulePanel.toRule();
149  }
150  return ruleMap;
151  }
152 
153 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.