19 package org.sleuthkit.autopsy.modules.photoreccarver;
21 import java.awt.Color;
22 import java.awt.Cursor;
23 import java.awt.Desktop;
24 import java.awt.event.MouseAdapter;
25 import java.awt.event.MouseEvent;
26 import java.io.IOException;
28 import java.net.URISyntaxException;
29 import java.util.Collections;
30 import java.util.List;
31 import java.util.logging.Level;
32 import java.util.stream.Collectors;
33 import java.util.stream.Stream;
34 import org.apache.commons.lang.StringUtils;
42 @SuppressWarnings(
"PMD.SingularField")
43 final class PhotoRecCarverIngestJobSettingsPanel extends IngestModuleIngestJobSettingsPanel {
45 private static final Logger logger = Logger.
getLogger(PhotoRecCarverIngestJobSettingsPanel.class.getName());
46 private static final String EXTENSION_LIST_SEPARATOR =
",";
47 private static final String PHOTOREC_TYPES_URL =
"http://sleuthkit.org/autopsy/docs/user-docs/latest/photorec_carver_page.html";
54 public PhotoRecCarverIngestJobSettingsPanel(PhotoRecCarverIngestJobSettings settings) {
56 customizeComponents(settings);
64 private void customizeComponents(PhotoRecCarverIngestJobSettings settings) {
65 includeExcludeCheckbox.setSelected(settings.getExtensionFilterOption() != PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER);
66 extensionListTextfield.setText(String.join(EXTENSION_LIST_SEPARATOR, settings.getExtensions()));
67 includeRadioButton.setSelected(settings.getExtensionFilterOption() == PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE);
68 excludeRadioButton.setSelected(settings.getExtensionFilterOption() == PhotoRecCarverIngestJobSettings.ExtensionFilterOption.EXCLUDE);
69 keepCorruptedFilesCheckbox.setSelected(settings.isKeepCorruptedFiles());
70 setupTypesHyperlink();
71 setIncludePanelEnabled();
78 private void setupTypesHyperlink() {
80 this.fullListOfTypesHyperlink.setForeground(Color.BLUE.darker());
81 this.fullListOfTypesHyperlink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
82 this.fullListOfTypesHyperlink.addMouseListener(
new MouseAdapter() {
84 public void mouseClicked(MouseEvent e) {
86 Desktop.getDesktop().browse(
new URI(PHOTOREC_TYPES_URL));
87 }
catch (IOException | URISyntaxException ex) {
88 logger.log(Level.WARNING,
"There was an error going to types hyperlink: " + PHOTOREC_TYPES_URL, ex);
99 private void setIncludePanelEnabled() {
100 setIncludePanelEnabled(includeExcludeCheckbox.isSelected());
109 private void setIncludePanelEnabled(
boolean enabled) {
110 includeRadioButton.setEnabled(enabled);
111 excludeRadioButton.setEnabled(enabled);
112 extensionListLabel.setEnabled(enabled);
113 extensionListTextfield.setEnabled(enabled);
114 exampleLabel.setEnabled(enabled);
115 fullListOfTypesLabel.setEnabled(enabled);
119 public IngestModuleIngestJobSettings getSettings() {
120 PhotoRecCarverIngestJobSettings.ExtensionFilterOption filterOption =
121 PhotoRecCarverIngestJobSettings.ExtensionFilterOption.NO_FILTER;
123 if (includeExcludeCheckbox.isSelected()) {
124 if (includeRadioButton.isSelected()) {
125 filterOption = PhotoRecCarverIngestJobSettings.ExtensionFilterOption.INCLUDE;
127 filterOption = PhotoRecCarverIngestJobSettings.ExtensionFilterOption.EXCLUDE;
132 return new PhotoRecCarverIngestJobSettings(
133 keepCorruptedFilesCheckbox.isSelected(),
135 getExtensions(extensionListTextfield.getText())
149 private List<String> getExtensions(String combinedList) {
150 if (StringUtils.isBlank(combinedList)) {
151 return Collections.emptyList();
154 return Stream.of(combinedList.split(EXTENSION_LIST_SEPARATOR))
155 .map(ext -> ext.trim())
156 .filter(ext -> StringUtils.isNotBlank(ext))
157 .sorted((a, b) -> a.toLowerCase().compareTo(b.toLowerCase()))
158 .collect(Collectors.toList());
166 @SuppressWarnings(
"unchecked")
168 private
void initComponents() {
170 includeExcludeButtonGroup =
new javax.swing.ButtonGroup();
171 keepCorruptedFilesCheckbox =
new javax.swing.JCheckBox();
172 javax.swing.JLabel detectionSettingsLabel =
new javax.swing.JLabel();
173 includeExcludeCheckbox =
new javax.swing.JCheckBox();
174 excludeRadioButton =
new javax.swing.JRadioButton();
175 exampleLabel =
new javax.swing.JLabel();
176 fullListOfTypesLabel =
new javax.swing.JLabel();
177 extensionListLabel =
new javax.swing.JLabel();
178 extensionListTextfield =
new javax.swing.JTextField();
179 includeRadioButton =
new javax.swing.JRadioButton();
180 fullListOfTypesHyperlink =
new javax.swing.JTextArea();
182 setPreferredSize(null);
184 org.openide.awt.Mnemonics.setLocalizedText(keepCorruptedFilesCheckbox,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.keepCorruptedFilesCheckbox.text"));
186 detectionSettingsLabel.setFont(detectionSettingsLabel.getFont().deriveFont(detectionSettingsLabel.getFont().getStyle() | java.awt.Font.BOLD));
187 org.openide.awt.Mnemonics.setLocalizedText(detectionSettingsLabel,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.detectionSettingsLabel.text"));
189 org.openide.awt.Mnemonics.setLocalizedText(includeExcludeCheckbox,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.includeExcludeCheckbox.text"));
190 includeExcludeCheckbox.addActionListener(
new java.awt.event.ActionListener() {
191 public void actionPerformed(java.awt.event.ActionEvent evt) {
192 includeExcludeCheckboxActionPerformed(evt);
196 includeExcludeButtonGroup.add(excludeRadioButton);
197 org.openide.awt.Mnemonics.setLocalizedText(excludeRadioButton,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.excludeRadioButton.text"));
199 org.openide.awt.Mnemonics.setLocalizedText(exampleLabel,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.exampleLabel.text"));
201 org.openide.awt.Mnemonics.setLocalizedText(fullListOfTypesLabel,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.fullListOfTypesLabel.text"));
203 org.openide.awt.Mnemonics.setLocalizedText(extensionListLabel,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.extensionListLabel.text"));
205 extensionListTextfield.setText(
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.extensionListTextfield.text"));
207 includeExcludeButtonGroup.add(includeRadioButton);
208 includeRadioButton.setSelected(
true);
209 org.openide.awt.Mnemonics.setLocalizedText(includeRadioButton,
org.openide.util.NbBundle.getMessage(PhotoRecCarverIngestJobSettingsPanel.class,
"PhotoRecCarverIngestJobSettingsPanel.includeRadioButton.text"));
211 fullListOfTypesHyperlink.setEditable(
false);
212 fullListOfTypesHyperlink.setColumns(20);
213 fullListOfTypesHyperlink.setLineWrap(
true);
214 fullListOfTypesHyperlink.setRows(5);
215 fullListOfTypesHyperlink.setText(PHOTOREC_TYPES_URL);
216 fullListOfTypesHyperlink.setFocusable(
false);
217 fullListOfTypesHyperlink.setOpaque(
false);
219 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
220 this.setLayout(layout);
221 layout.setHorizontalGroup(
222 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
223 .addGroup(layout.createSequentialGroup()
224 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
225 .addGroup(layout.createSequentialGroup()
227 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228 .addComponent(detectionSettingsLabel)
229 .addComponent(keepCorruptedFilesCheckbox)
230 .addComponent(includeExcludeCheckbox)))
231 .addGroup(layout.createSequentialGroup()
233 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
234 .addComponent(includeRadioButton)
235 .addComponent(excludeRadioButton)
236 .addComponent(exampleLabel)
237 .addComponent(extensionListTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
238 .addComponent(fullListOfTypesLabel)
239 .addComponent(extensionListLabel)
240 .addComponent(fullListOfTypesHyperlink, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE))))
241 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
243 layout.setVerticalGroup(
244 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
245 .addGroup(layout.createSequentialGroup()
247 .addComponent(detectionSettingsLabel)
249 .addComponent(keepCorruptedFilesCheckbox)
250 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251 .addComponent(includeExcludeCheckbox)
252 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
253 .addComponent(includeRadioButton)
254 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255 .addComponent(excludeRadioButton)
257 .addComponent(extensionListLabel)
258 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
259 .addComponent(extensionListTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
260 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
261 .addComponent(exampleLabel)
262 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
263 .addComponent(fullListOfTypesLabel)
264 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
265 .addComponent(fullListOfTypesHyperlink, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
270 private void includeExcludeCheckboxActionPerformed(java.awt.event.ActionEvent evt) {
271 setIncludePanelEnabled();
275 private javax.swing.JLabel exampleLabel;
276 private javax.swing.JRadioButton excludeRadioButton;
277 private javax.swing.JLabel extensionListLabel;
278 private javax.swing.JTextField extensionListTextfield;
279 private javax.swing.JTextArea fullListOfTypesHyperlink;
280 private javax.swing.JLabel fullListOfTypesLabel;
281 private javax.swing.ButtonGroup includeExcludeButtonGroup;
282 private javax.swing.JCheckBox includeExcludeCheckbox;
283 private javax.swing.JRadioButton includeRadioButton;
284 private javax.swing.JCheckBox keepCorruptedFilesCheckbox;
synchronized static Logger getLogger(String name)