Autopsy  4.16.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  chunkSizeComboBox.addActionListener(new java.awt.event.ActionListener() {
159  public void actionPerformed(java.awt.event.ActionEvent evt) {
160  chunkSizeComboBoxActionPerformed(evt);
161  }
162  });
163 
164  org.openide.awt.Mnemonics.setLocalizedText(compressCheckbox, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.text")); // NOI18N
165  compressCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.toolTipText")); // NOI18N
166  compressCheckbox.addActionListener(new java.awt.event.ActionListener() {
167  public void actionPerformed(java.awt.event.ActionEvent evt) {
168  compressCheckboxActionPerformed(evt);
169  }
170  });
171 
172  errorLabel.setForeground(new java.awt.Color(255, 0, 0));
173  org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.errorLabel.text")); // NOI18N
174 
175  javax.swing.GroupLayout listPanelLayout = new javax.swing.GroupLayout(listPanel);
176  listPanel.setLayout(listPanelLayout);
177  listPanelLayout.setHorizontalGroup(
178  listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
179  .addGap(0, 0, Short.MAX_VALUE)
180  );
181  listPanelLayout.setVerticalGroup(
182  listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
183  .addGap(0, 190, Short.MAX_VALUE)
184  );
185 
186  org.openide.awt.Mnemonics.setLocalizedText(includeAppCheckbox, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.includeAppCheckbox.text")); // NOI18N
187  includeAppCheckbox.addActionListener(new java.awt.event.ActionListener() {
188  public void actionPerformed(java.awt.event.ActionEvent evt) {
189  includeAppCheckboxActionPerformed(evt);
190  }
191  });
192 
193  javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
194  mainPanel.setLayout(mainPanelLayout);
195  mainPanelLayout.setHorizontalGroup(
196  mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
197  .addComponent(listPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
198  .addGroup(mainPanelLayout.createSequentialGroup()
199  .addContainerGap()
200  .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
201  .addGroup(mainPanelLayout.createSequentialGroup()
202  .addComponent(compressCheckbox)
203  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
204  .addComponent(chunkSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
205  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
206  .addComponent(errorLabel))
207  .addComponent(includeAppCheckbox))
208  .addContainerGap(41, Short.MAX_VALUE))
209  );
210  mainPanelLayout.setVerticalGroup(
211  mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
212  .addGroup(mainPanelLayout.createSequentialGroup()
213  .addComponent(listPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
214  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
215  .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
216  .addComponent(compressCheckbox)
217  .addComponent(chunkSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
218  .addComponent(errorLabel))
219  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
220  .addComponent(includeAppCheckbox)
221  .addContainerGap())
222  );
223 
224  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
225  this.setLayout(layout);
226  layout.setHorizontalGroup(
227  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228  .addGap(0, 463, Short.MAX_VALUE)
229  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
230  .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
231  );
232  layout.setVerticalGroup(
233  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
234  .addGap(0, 259, Short.MAX_VALUE)
235  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
236  .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
237  );
238  }// </editor-fold>//GEN-END:initComponents
239 
240  private void chunkSizeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chunkSizeComboBoxActionPerformed
241  updateCompression();
242  }//GEN-LAST:event_chunkSizeComboBoxActionPerformed
243 
244  private void compressCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_compressCheckboxActionPerformed
245  chunkSizeComboBox.setEnabled(compressCheckbox.isSelected() && !includeAppCheckbox.isSelected());
246  updateCompression();
247  }//GEN-LAST:event_compressCheckboxActionPerformed
248 
249  private void includeAppCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_includeAppCheckboxActionPerformed
250  if (includeAppCheckbox.isSelected()) {
251  chunkSizeComboBox.setEnabled(false);
252  chunkSizeComboBox.setSelectedItem(ChunkSize.NONE);
253  } else {
254  chunkSizeComboBox.setEnabled(compressCheckbox.isSelected());
255  }
256  updateIncludeApplication();
257  }//GEN-LAST:event_includeAppCheckboxActionPerformed
258 
259 
260  // Variables declaration - do not modify//GEN-BEGIN:variables
261  private javax.swing.JComboBox<ChunkSize> chunkSizeComboBox;
262  private javax.swing.JCheckBox compressCheckbox;
263  private javax.swing.JLabel errorLabel;
264  private javax.swing.JCheckBox includeAppCheckbox;
265  private javax.swing.JPanel listPanel;
266  private javax.swing.JPanel mainPanel;
267  // End of variables declaration//GEN-END:variables
268 }

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.