Autopsy  4.14.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 final ReportWizardPortableCaseOptionsPanel wizPanel;
37  private PortableCaseReportModuleSettings settings = null;
38  private Map<String, ReportModuleConfig> moduleConfigs;
39  private final boolean useCaseSpecificData;
40 
44  ReportWizardPortableCaseOptionsVisualPanel(ReportWizardPortableCaseOptionsPanel wizPanel, Map<String, ReportModuleConfig> moduleConfigs, boolean useCaseSpecificData) {
45  this.wizPanel = wizPanel;
46  this.useCaseSpecificData = useCaseSpecificData;
47  this.moduleConfigs = moduleConfigs;
48  initComponents();
49  customizeComponents();
50  }
51 
52  private void customizeComponents() {
53 
54  if (!PlatformUtil.isWindowsOS()) {
55  errorLabel.setVisible(true);
56  compressCheckbox.setEnabled(false);
57  } else {
58  errorLabel.setVisible(false);
59  }
60 
61  for (ChunkSize chunkSize : ChunkSize.values()) {
62  chunkSizeComboBox.addItem(chunkSize);
63  }
64 
65  // initialize settings
66  if (moduleConfigs != null) {
67  // get configuration for this module
68  ReportModuleConfig config = moduleConfigs.get(PortableCaseReportModule.class.getCanonicalName());
69  if (config != null) {
70  // there is an existing configuration for this module
71  ReportModuleSettings reportSettings = config.getModuleSettings();
72  // check if the settings are for this module, it could be NoReportModuleSettings
73  if (reportSettings instanceof PortableCaseReportModuleSettings) {
74  settings = (PortableCaseReportModuleSettings) reportSettings;
75  }
76  }
77  }
78 
79  if (settings == null) {
80  // get default module configuration
81  settings = new PortableCaseReportModuleSettings();
82  }
83 
84  // update according to input configuration
85  compressCheckbox.setSelected(settings.shouldCompress());
86  chunkSizeComboBox.setEnabled(settings.shouldCompress());
87  chunkSizeComboBox.setSelectedItem(settings.getChunkSize());
88 
89  // initialize other panels and pass them the settings
90  listPanel.setLayout(new GridLayout(1,2));
91  listPanel.add(new PortableCaseTagsListPanel(wizPanel, settings, useCaseSpecificData));
92  listPanel.add(new PortableCaseInterestingItemsListPanel(wizPanel, settings, useCaseSpecificData));
93  }
94 
95  @NbBundle.Messages({
96  "ReportWizardPortableCaseOptionsVisualPanel.getName.title=Choose Portable Case settings",
97  })
98  @Override
99  public String getName() {
100  return Bundle.ReportWizardPortableCaseOptionsVisualPanel_getName_title();
101  }
102 
108  private ChunkSize getChunkSize() {
109  return (ChunkSize) chunkSizeComboBox.getSelectedItem();
110  }
111 
115  private void updateCompression() {
116  if (settings != null) {
117  settings.updateCompression(compressCheckbox.isSelected(), getChunkSize());
118  wizPanel.setFinish(settings.isValid());
119  }
120  }
121 
127  PortableCaseReportModuleSettings getPortableCaseReportSettings() {
128  return settings;
129  }
130 
136  @SuppressWarnings("unchecked")
137  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
138  private void initComponents() {
139 
140  jPanel1 = new javax.swing.JPanel();
141  chunkSizeComboBox = new javax.swing.JComboBox<>();
142  compressCheckbox = new javax.swing.JCheckBox();
143  errorLabel = new javax.swing.JLabel();
144  listPanel = new javax.swing.JPanel();
145 
146  chunkSizeComboBox.addActionListener(new java.awt.event.ActionListener() {
147  public void actionPerformed(java.awt.event.ActionEvent evt) {
148  chunkSizeComboBoxActionPerformed(evt);
149  }
150  });
151 
152  org.openide.awt.Mnemonics.setLocalizedText(compressCheckbox, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.text")); // NOI18N
153  compressCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.toolTipText")); // NOI18N
154  compressCheckbox.addActionListener(new java.awt.event.ActionListener() {
155  public void actionPerformed(java.awt.event.ActionEvent evt) {
156  compressCheckboxActionPerformed(evt);
157  }
158  });
159 
160  errorLabel.setForeground(new java.awt.Color(255, 0, 0));
161  org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(ReportWizardPortableCaseOptionsVisualPanel.class, "ReportWizardPortableCaseOptionsVisualPanel.errorLabel.text")); // NOI18N
162 
163  javax.swing.GroupLayout listPanelLayout = new javax.swing.GroupLayout(listPanel);
164  listPanel.setLayout(listPanelLayout);
165  listPanelLayout.setHorizontalGroup(
166  listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167  .addGap(0, 0, Short.MAX_VALUE)
168  );
169  listPanelLayout.setVerticalGroup(
170  listPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
171  .addGap(0, 217, Short.MAX_VALUE)
172  );
173 
174  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
175  jPanel1.setLayout(jPanel1Layout);
176  jPanel1Layout.setHorizontalGroup(
177  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
178  .addGroup(jPanel1Layout.createSequentialGroup()
179  .addContainerGap()
180  .addComponent(compressCheckbox)
181  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
182  .addComponent(chunkSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
183  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184  .addComponent(errorLabel)
185  .addContainerGap(41, Short.MAX_VALUE))
186  .addComponent(listPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
187  );
188  jPanel1Layout.setVerticalGroup(
189  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190  .addGroup(jPanel1Layout.createSequentialGroup()
191  .addComponent(listPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
192  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
193  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
194  .addComponent(compressCheckbox)
195  .addComponent(chunkSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
196  .addComponent(errorLabel))
197  .addContainerGap())
198  );
199 
200  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
201  this.setLayout(layout);
202  layout.setHorizontalGroup(
203  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
204  .addGap(0, 463, Short.MAX_VALUE)
205  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
207  );
208  layout.setVerticalGroup(
209  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
210  .addGap(0, 259, Short.MAX_VALUE)
211  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
212  .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
213  );
214  }// </editor-fold>//GEN-END:initComponents
215 
216  private void chunkSizeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chunkSizeComboBoxActionPerformed
217  updateCompression();
218  }//GEN-LAST:event_chunkSizeComboBoxActionPerformed
219 
220  private void compressCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_compressCheckboxActionPerformed
221  chunkSizeComboBox.setEnabled(compressCheckbox.isSelected());
222  updateCompression();
223  }//GEN-LAST:event_compressCheckboxActionPerformed
224 
225 
226  // Variables declaration - do not modify//GEN-BEGIN:variables
227  private javax.swing.JComboBox<ChunkSize> chunkSizeComboBox;
228  private javax.swing.JCheckBox compressCheckbox;
229  private javax.swing.JLabel errorLabel;
230  private javax.swing.JPanel jPanel1;
231  private javax.swing.JPanel listPanel;
232  // End of variables declaration//GEN-END:variables
233 }

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