Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ReportWizardPortableCaseOptionsVisualPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 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.report.infrastructure;
20 
24 import java.awt.GridLayout;
25 import java.util.Map;
26 import org.openide.util.NbBundle;
29 
33 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
34 class ReportWizardPortableCaseOptionsVisualPanel extends javax.swing.JPanel {
35 
36  private static final long serialVersionUID = 1L;
37 
38  private final ReportWizardPortableCaseOptionsPanel wizPanel;
39  private PortableCaseReportModuleSettings settings = null;
40  private final Map<String, ReportModuleConfig> moduleConfigs;
41  private final boolean useCaseSpecificData;
42 
46  ReportWizardPortableCaseOptionsVisualPanel(ReportWizardPortableCaseOptionsPanel wizPanel, Map<String, ReportModuleConfig> moduleConfigs, boolean useCaseSpecificData) {
47  this.wizPanel = wizPanel;
48  this.useCaseSpecificData = useCaseSpecificData;
49  this.moduleConfigs = moduleConfigs;
50  initComponents();
51  customizeComponents();
52  }
53 
54  private void customizeComponents() {
55 
56  if (!PlatformUtil.isWindowsOS()) {
57  errorLabel.setVisible(true);
58  compressCheckbox.setEnabled(false);
59  } else {
60  errorLabel.setVisible(false);
61  }
62 
63  for (ChunkSize chunkSize : ChunkSize.values()) {
64  chunkSizeComboBox.addItem(chunkSize);
65  }
66 
67  // initialize settings
68  if (moduleConfigs != null) {
69  // get configuration for this module
70  ReportModuleConfig config = moduleConfigs.get(PortableCaseReportModule.class.getCanonicalName());
71  if (config != null) {
72  // there is an existing configuration for this module
73  ReportModuleSettings reportSettings = config.getModuleSettings();
74  // check if the settings are for this module, it could be NoReportModuleSettings
75  if (reportSettings instanceof PortableCaseReportModuleSettings) {
76  settings = (PortableCaseReportModuleSettings) reportSettings;
77  }
78  }
79  }
80 
81  if (settings == null) {
82  // get default module configuration
83  settings = new PortableCaseReportModuleSettings();
84  }
85 
86  // update according to input configuration
87  compressCheckbox.setSelected(settings.shouldCompress());
88  chunkSizeComboBox.setEnabled(settings.shouldCompress());
89  chunkSizeComboBox.setSelectedItem(settings.getChunkSize());
90 
91  // initialize other panels and pass them the settings
92  listPanel.setLayout(new GridLayout(1, 2));
93  listPanel.add(new PortableCaseTagsListPanel(wizPanel, settings, useCaseSpecificData));
94  listPanel.add(new PortableCaseInterestingItemsListPanel(wizPanel, settings, useCaseSpecificData));
95  }
96 
97  @NbBundle.Messages({
98  "ReportWizardPortableCaseOptionsVisualPanel.getName.title=Choose Portable Case settings",})
99  @Override
100  public String getName() {
101  return Bundle.ReportWizardPortableCaseOptionsVisualPanel_getName_title();
102  }
103 
109  private ChunkSize getChunkSize() {
110  return (ChunkSize) chunkSizeComboBox.getSelectedItem();
111  }
112 
117  private void updateCompression() {
118  if (settings != null) {
119  settings.updateCompression(compressCheckbox.isSelected(), getChunkSize());
120  wizPanel.setFinish(settings.isValid());
121  }
122  }
123 
127  private void updateIncludeApplication() {
128  if (settings != null) {
129  settings.setIncludeApplication(includeAppCheckbox.isSelected());
130  }
131  }
132 
138  PortableCaseReportModuleSettings getPortableCaseReportSettings() {
139  return settings;
140  }
141 
147  @SuppressWarnings("unchecked")
148  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
149  private void initComponents() {
150 
151  mainPanel = new javax.swing.JPanel();
152  chunkSizeComboBox = new javax.swing.JComboBox<>();
153  compressCheckbox = new javax.swing.JCheckBox();
154  errorLabel = new javax.swing.JLabel();
155  listPanel = new javax.swing.JPanel();
156  includeAppCheckbox = new javax.swing.JCheckBox();
157 
158  setPreferredSize(new java.awt.Dimension(834, 374));
159 
160  chunkSizeComboBox.addActionListener(new java.awt.event.ActionListener() {
161  public void actionPerformed(java.awt.event.ActionEvent evt) {
162  chunkSizeComboBoxActionPerformed(evt);
163  }
164  });
165 
166  org.openide.awt.Mnemonics.setLocalizedText(compressCheckbox, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.text")); // NOI18N
167  compressCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.toolTipText")); // NOI18N
168  compressCheckbox.addActionListener(new java.awt.event.ActionListener() {
169  public void actionPerformed(java.awt.event.ActionEvent evt) {
170  compressCheckboxActionPerformed(evt);
171  }
172  });
173 
174  errorLabel.setForeground(new java.awt.Color(255, 0, 0));
175  org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.errorLabel.text")); // NOI18N
176 
177  javax.swing.GroupLayout listPanelLayout = new javax.swing.GroupLayout(listPanel);
178  listPanel.setLayout(listPanelLayout);
179  listPanelLayout.setHorizontalGroup(
180  listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
181  .addGap(0, 0, Short.MAX_VALUE)
182  );
183  listPanelLayout.setVerticalGroup(
184  listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
185  .addGap(0, 190, Short.MAX_VALUE)
186  );
187 
188  org.openide.awt.Mnemonics.setLocalizedText(includeAppCheckbox, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.includeAppCheckbox.text")); // NOI18N
189  includeAppCheckbox.addActionListener(new java.awt.event.ActionListener() {
190  public void actionPerformed(java.awt.event.ActionEvent evt) {
191  includeAppCheckboxActionPerformed(evt);
192  }
193  });
194 
195  javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
196  mainPanel.setLayout(mainPanelLayout);
197  mainPanelLayout.setHorizontalGroup(
198  mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199  .addComponent(listPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
200  .addGroup(mainPanelLayout.createSequentialGroup()
201  .addContainerGap()
202  .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
203  .addGroup(mainPanelLayout.createSequentialGroup()
204  .addComponent(compressCheckbox)
205  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
206  .addComponent(chunkSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
207  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208  .addComponent(errorLabel))
209  .addComponent(includeAppCheckbox))
210  .addContainerGap(41, Short.MAX_VALUE))
211  );
212  mainPanelLayout.setVerticalGroup(
213  mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
214  .addGroup(mainPanelLayout.createSequentialGroup()
215  .addComponent(listPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
216  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
217  .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
218  .addComponent(compressCheckbox)
219  .addComponent(chunkSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
220  .addComponent(errorLabel))
221  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
222  .addComponent(includeAppCheckbox)
223  .addContainerGap())
224  );
225 
226  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
227  this.setLayout(layout);
228  layout.setHorizontalGroup(
229  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
230  .addGap(0, 463, Short.MAX_VALUE)
231  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232  .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
233  );
234  layout.setVerticalGroup(
235  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236  .addGap(0, 259, Short.MAX_VALUE)
237  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
238  .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
239  );
240  }// </editor-fold>//GEN-END:initComponents
241 
242  private void chunkSizeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chunkSizeComboBoxActionPerformed
243  updateCompression();
244  }//GEN-LAST:event_chunkSizeComboBoxActionPerformed
245 
246  private void compressCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_compressCheckboxActionPerformed
247  chunkSizeComboBox.setEnabled(compressCheckbox.isSelected() && !includeAppCheckbox.isSelected());
248  updateCompression();
249  }//GEN-LAST:event_compressCheckboxActionPerformed
250 
251  private void includeAppCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_includeAppCheckboxActionPerformed
252  if (includeAppCheckbox.isSelected()) {
253  chunkSizeComboBox.setEnabled(false);
254  chunkSizeComboBox.setSelectedItem(ChunkSize.NONE);
255  } else {
256  chunkSizeComboBox.setEnabled(compressCheckbox.isSelected());
257  }
258  updateIncludeApplication();
259  }//GEN-LAST:event_includeAppCheckboxActionPerformed
260 
261 
262  // Variables declaration - do not modify//GEN-BEGIN:variables
263  private javax.swing.JComboBox<ChunkSize> chunkSizeComboBox;
264  private javax.swing.JCheckBox compressCheckbox;
265  private javax.swing.JLabel errorLabel;
266  private javax.swing.JCheckBox includeAppCheckbox;
267  private javax.swing.JPanel listPanel;
268  private javax.swing.JPanel mainPanel;
269  // End of variables declaration//GEN-END:variables
270 }

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.