19 package org.sleuthkit.autopsy.logicalimager.configuration;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.List;
26 import javax.swing.JButton;
27 import javax.swing.JOptionPane;
28 import javax.swing.JPanel;
29 import javax.swing.JTable;
30 import javax.swing.table.AbstractTableModel;
31 import org.apache.commons.lang3.tuple.ImmutablePair;
32 import org.openide.util.NbBundle;
38 "ConfigVisualPanel2.ok=OK",
39 "ConfigVisualPanel2.cancel=Cancel"
41 @SuppressWarnings(
"PMD.SingularField")
42 final class ConfigVisualPanel2
extends JPanel {
44 private static final List<String> EMPTY_LIST =
new ArrayList<>();
45 private String configFilename;
46 private LogicalImagerConfig config = null;
47 private final JButton okButton =
new JButton(Bundle.ConfigVisualPanel2_ok());
48 private final JButton cancelButton =
new JButton(Bundle.ConfigVisualPanel2_cancel());
49 private boolean flagEncryptionPrograms =
false;
54 ConfigVisualPanel2() {
57 updatePanel(configFilename, config);
62 "ConfigVisualPanel2.editConfiguration=Edit configuration"
65 public String getName() {
66 return Bundle.ConfigVisualPanel2_editConfiguration();
75 private void initComponents() {
77 modifiedDateLabel =
new javax.swing.JLabel();
78 daysIncludedTextField =
new javax.swing.JTextField();
79 daysIncludedLabel =
new javax.swing.JLabel();
80 fullPathsLabel =
new javax.swing.JLabel();
81 flagEncryptionProgramsCheckBox =
new javax.swing.JCheckBox();
82 ruleNameLabel =
new javax.swing.JLabel();
83 ruleNameEditTextField =
new javax.swing.JTextField();
84 newRuleButton =
new javax.swing.JButton();
85 descriptionLabel =
new javax.swing.JLabel();
86 editRuleButton =
new javax.swing.JButton();
87 descriptionEditTextField =
new javax.swing.JTextField();
88 deleteRuleButton =
new javax.swing.JButton();
89 jScrollPane5 =
new javax.swing.JScrollPane();
90 fullPathsTable =
new javax.swing.JTable();
91 jScrollPane6 =
new javax.swing.JScrollPane();
92 filenamesTable =
new javax.swing.JTable();
93 shouldSaveCheckBox =
new javax.swing.JCheckBox();
94 shouldAlertCheckBox =
new javax.swing.JCheckBox();
95 jScrollPane7 =
new javax.swing.JScrollPane();
96 folderNamesTable =
new javax.swing.JTable();
97 extensionsLabel =
new javax.swing.JLabel();
98 extensionsTextField =
new javax.swing.JTextField();
99 filenamesLabel =
new javax.swing.JLabel();
100 configFileTextField =
new javax.swing.JTextField();
101 ruleSetFileLabel =
new javax.swing.JLabel();
102 finalizeImageWriter =
new javax.swing.JCheckBox();
103 jScrollPane1 =
new javax.swing.JScrollPane();
104 rulesTable =
new javax.swing.JTable();
105 folderNamesLabel =
new javax.swing.JLabel();
106 fileSizeLabel =
new javax.swing.JLabel();
107 jSeparator1 =
new javax.swing.JSeparator();
108 minSizeLabel =
new javax.swing.JLabel();
109 minSizeTextField =
new javax.swing.JFormattedTextField();
110 maxSizeLabel =
new javax.swing.JLabel();
111 maxSizeTextField =
new javax.swing.JFormattedTextField();
113 org.openide.awt.Mnemonics.setLocalizedText(modifiedDateLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.modifiedDateLabel.text"));
115 daysIncludedTextField.setEditable(
false);
116 daysIncludedTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
117 daysIncludedTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.daysIncludedTextField.text"));
118 daysIncludedTextField.setEnabled(
false);
119 daysIncludedTextField.setMinimumSize(
new java.awt.Dimension(60, 20));
120 daysIncludedTextField.setPreferredSize(
new java.awt.Dimension(60, 20));
122 org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.daysIncludedLabel.text"));
123 daysIncludedLabel.setEnabled(
false);
125 org.openide.awt.Mnemonics.setLocalizedText(fullPathsLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fullPathsLabel.text"));
127 org.openide.awt.Mnemonics.setLocalizedText(flagEncryptionProgramsCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.flagEncryptionProgramsCheckBox.text"));
128 flagEncryptionProgramsCheckBox.addActionListener(
new java.awt.event.ActionListener() {
129 public void actionPerformed(java.awt.event.ActionEvent evt) {
130 flagEncryptionProgramsCheckBoxActionPerformed(evt);
134 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.ruleNameLabel.text"));
136 ruleNameEditTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.ruleNameEditTextField.text"));
137 ruleNameEditTextField.setEnabled(
false);
139 newRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/add16.png")));
140 org.openide.awt.Mnemonics.setLocalizedText(newRuleButton,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.newRuleButton.text"));
141 newRuleButton.addActionListener(
new java.awt.event.ActionListener() {
142 public void actionPerformed(java.awt.event.ActionEvent evt) {
143 newRuleButtonActionPerformed(evt);
147 org.openide.awt.Mnemonics.setLocalizedText(descriptionLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.descriptionLabel.text"));
149 editRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/edit16.png")));
150 org.openide.awt.Mnemonics.setLocalizedText(editRuleButton,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.editRuleButton.text"));
151 editRuleButton.addActionListener(
new java.awt.event.ActionListener() {
152 public void actionPerformed(java.awt.event.ActionEvent evt) {
153 editRuleButtonActionPerformed(evt);
157 descriptionEditTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.descriptionEditTextField.text"));
158 descriptionEditTextField.setEnabled(
false);
160 deleteRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/delete16.png")));
161 org.openide.awt.Mnemonics.setLocalizedText(deleteRuleButton,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.deleteRuleButton.text"));
162 deleteRuleButton.addActionListener(
new java.awt.event.ActionListener() {
163 public void actionPerformed(java.awt.event.ActionEvent evt) {
164 deleteRuleButtonActionPerformed(evt);
168 fullPathsTable.setColumnSelectionAllowed(
true);
169 fullPathsTable.setEnabled(
false);
170 fullPathsTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
171 fullPathsTable.setShowHorizontalLines(
false);
172 fullPathsTable.setShowVerticalLines(
false);
173 fullPathsTable.getTableHeader().setReorderingAllowed(
false);
174 jScrollPane5.setViewportView(fullPathsTable);
175 fullPathsTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
176 if (fullPathsTable.getColumnModel().getColumnCount() > 0) {
177 fullPathsTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fullPathsTable.columnModel.title0"));
180 filenamesTable.setEnabled(
false);
181 filenamesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
182 filenamesTable.setShowHorizontalLines(
false);
183 filenamesTable.setShowVerticalLines(
false);
184 filenamesTable.getTableHeader().setReorderingAllowed(
false);
185 jScrollPane6.setViewportView(filenamesTable);
186 if (filenamesTable.getColumnModel().getColumnCount() > 0) {
187 filenamesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.filenamesTable.columnModel.title0"));
190 shouldSaveCheckBox.setSelected(
true);
191 org.openide.awt.Mnemonics.setLocalizedText(shouldSaveCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.shouldSaveCheckBox.text"));
192 shouldSaveCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.shouldSaveCheckBox.toolTipText"));
193 shouldSaveCheckBox.setEnabled(
false);
195 shouldAlertCheckBox.setSelected(
true);
196 org.openide.awt.Mnemonics.setLocalizedText(shouldAlertCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.shouldAlertCheckBox.text"));
197 shouldAlertCheckBox.setEnabled(
false);
199 folderNamesTable.setEnabled(
false);
200 folderNamesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
201 folderNamesTable.setShowHorizontalLines(
false);
202 folderNamesTable.setShowVerticalLines(
false);
203 folderNamesTable.getTableHeader().setReorderingAllowed(
false);
204 jScrollPane7.setViewportView(folderNamesTable);
205 if (folderNamesTable.getColumnModel().getColumnCount() > 0) {
206 folderNamesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.folderNamesTable.columnModel.title0"));
209 org.openide.awt.Mnemonics.setLocalizedText(extensionsLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.extensionsLabel.text"));
211 extensionsTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.extensionsTextField.text"));
212 extensionsTextField.setEnabled(
false);
214 org.openide.awt.Mnemonics.setLocalizedText(filenamesLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.filenamesLabel.text"));
216 configFileTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.configFileTextField.text"));
217 configFileTextField.setToolTipText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.configFileTextField.toolTipText"));
218 configFileTextField.setEnabled(
false);
220 org.openide.awt.Mnemonics.setLocalizedText(ruleSetFileLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.ruleSetFileLabel.text"));
222 org.openide.awt.Mnemonics.setLocalizedText(finalizeImageWriter,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.finalizeImageWriter.text"));
223 finalizeImageWriter.addActionListener(
new java.awt.event.ActionListener() {
224 public void actionPerformed(java.awt.event.ActionEvent evt) {
225 finalizeImageWriterActionPerformed(evt);
229 rulesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
230 rulesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
231 rulesTable.setShowHorizontalLines(
false);
232 rulesTable.setShowVerticalLines(
false);
233 rulesTable.getTableHeader().setReorderingAllowed(
false);
234 rulesTable.addMouseListener(
new java.awt.event.MouseAdapter() {
235 public void mouseReleased(java.awt.event.MouseEvent evt) {
236 rulesTableMouseReleased(evt);
239 rulesTable.addKeyListener(
new java.awt.event.KeyAdapter() {
240 public void keyReleased(java.awt.event.KeyEvent evt) {
241 rulesTableKeyReleased(evt);
244 jScrollPane1.setViewportView(rulesTable);
245 if (rulesTable.getColumnModel().getColumnCount() > 0) {
246 rulesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.rulesTable.columnModel.title0"));
247 rulesTable.getColumnModel().getColumn(1).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.rulesTable.columnModel.title1"));
250 org.openide.awt.Mnemonics.setLocalizedText(folderNamesLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.folderNamesLabel.text"));
252 org.openide.awt.Mnemonics.setLocalizedText(fileSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fileSizeLabel.text"));
254 org.openide.awt.Mnemonics.setLocalizedText(minSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.minSizeLabel.text"));
256 minSizeTextField.setFormatterFactory(
new javax.swing.text.DefaultFormatterFactory(
new javax.swing.text.NumberFormatter(
new java.text.DecimalFormat(
"#,###; "))));
257 minSizeTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.minSizeTextField.text"));
258 minSizeTextField.setEnabled(
false);
260 org.openide.awt.Mnemonics.setLocalizedText(maxSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.maxSizeLabel.text"));
262 maxSizeTextField.setFormatterFactory(
new javax.swing.text.DefaultFormatterFactory(
new javax.swing.text.NumberFormatter(
new java.text.DecimalFormat(
"#,###; "))));
263 maxSizeTextField.setText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.maxSizeTextField.text"));
264 maxSizeTextField.setEnabled(
false);
266 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
267 this.setLayout(layout);
268 layout.setHorizontalGroup(
269 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
270 .addGroup(layout.createSequentialGroup()
271 .addGap(480, 480, 480)
272 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
273 .addGroup(layout.createSequentialGroup()
274 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
275 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
276 .addComponent(daysIncludedLabel))
277 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
278 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
279 .addComponent(ruleNameEditTextField, javax.swing.GroupLayout.Alignment.LEADING)
280 .addComponent(descriptionEditTextField, javax.swing.GroupLayout.Alignment.LEADING)
281 .addComponent(extensionsTextField, javax.swing.GroupLayout.Alignment.LEADING)
282 .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING)
283 .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING)
284 .addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.LEADING))
285 .addContainerGap())))
286 .addGroup(layout.createSequentialGroup()
287 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
288 .addGroup(layout.createSequentialGroup()
290 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
291 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 377, javax.swing.GroupLayout.PREFERRED_SIZE)
292 .addGroup(layout.createSequentialGroup()
293 .addComponent(newRuleButton)
294 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
295 .addComponent(editRuleButton)
297 .addComponent(deleteRuleButton)))
298 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
299 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
300 .addComponent(flagEncryptionProgramsCheckBox)
301 .addComponent(finalizeImageWriter)))
302 .addGroup(layout.createSequentialGroup()
303 .addGap(393, 393, 393)
304 .addComponent(shouldSaveCheckBox))
305 .addGroup(layout.createSequentialGroup()
306 .addGap(397, 397, 397)
307 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addComponent(extensionsLabel)
309 .addComponent(filenamesLabel)
310 .addComponent(descriptionLabel)
311 .addComponent(ruleNameLabel)))
312 .addGroup(layout.createSequentialGroup()
313 .addGap(397, 397, 397)
314 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
315 .addComponent(modifiedDateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
316 .addComponent(fileSizeLabel)
317 .addComponent(fullPathsLabel)
318 .addComponent(folderNamesLabel))
320 .addComponent(minSizeLabel)
321 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
322 .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
324 .addComponent(maxSizeLabel)
325 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
326 .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
327 .addGroup(layout.createSequentialGroup()
328 .addGap(393, 393, 393)
329 .addComponent(shouldAlertCheckBox)))
331 .addGroup(layout.createSequentialGroup()
332 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
333 .addGroup(layout.createSequentialGroup()
335 .addComponent(ruleSetFileLabel)
337 .addComponent(configFileTextField))
338 .addGroup(layout.createSequentialGroup()
339 .addGap(397, 397, 397)
340 .addComponent(jSeparator1)))
343 layout.setVerticalGroup(
344 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
345 .addGroup(layout.createSequentialGroup()
347 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
348 .addComponent(configFileTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
349 .addComponent(ruleSetFileLabel))
350 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
351 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
352 .addGroup(layout.createSequentialGroup()
353 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
354 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
355 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
356 .addComponent(newRuleButton)
357 .addComponent(editRuleButton)
358 .addComponent(deleteRuleButton)))
359 .addGroup(layout.createSequentialGroup()
360 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
361 .addGroup(layout.createSequentialGroup()
363 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
364 .addComponent(descriptionEditTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
365 .addComponent(descriptionLabel))
367 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
368 .addComponent(extensionsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
369 .addComponent(extensionsLabel)))
370 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
371 .addComponent(ruleNameEditTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
372 .addComponent(ruleNameLabel)))
373 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
374 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
375 .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
376 .addGroup(layout.createSequentialGroup()
377 .addComponent(filenamesLabel)
378 .addGap(0, 0, Short.MAX_VALUE)))
379 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
380 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
381 .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
382 .addGroup(layout.createSequentialGroup()
383 .addComponent(folderNamesLabel)
384 .addGap(0, 0, Short.MAX_VALUE)))
385 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
386 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
387 .addGroup(layout.createSequentialGroup()
388 .addComponent(fullPathsLabel)
389 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
390 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
391 .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
392 .addGap(11, 11, 11)))
393 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
394 .addComponent(minSizeLabel)
395 .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
396 .addComponent(maxSizeLabel)
397 .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
398 .addComponent(fileSizeLabel))
399 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
400 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
401 .addComponent(modifiedDateLabel)
402 .addComponent(daysIncludedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
403 .addComponent(daysIncludedLabel))
405 .addComponent(shouldAlertCheckBox)
406 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
407 .addComponent(shouldSaveCheckBox)
409 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
410 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
411 .addComponent(flagEncryptionProgramsCheckBox)
412 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
413 .addComponent(finalizeImageWriter)))
418 private void finalizeImageWriterActionPerformed(java.awt.event.ActionEvent evt) {
419 config.setFinalizeImageWriter(finalizeImageWriter.isSelected());
422 private void rulesTableKeyReleased(java.awt.event.KeyEvent evt) {
427 "ConfigVisualPanel2.editRuleSet=Edit rule",
428 "ConfigVisualPanel2.editRuleError=Edit rule error"
430 private void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
431 int row = rulesTable.getSelectedRow();
433 String ruleName = (String) rulesTable.getModel().getValueAt(row, 0);
434 LogicalImagerRule rule = getFirstRuleSet().getRules().get(row);
435 EditRulePanel editPanel =
new EditRulePanel(okButton, cancelButton, ruleName, rule);
436 editPanel.setEnabled(
true);
437 editPanel.setVisible(
true);
440 int option = JOptionPane.showOptionDialog(
this, editPanel.getPanel(), Bundle.ConfigVisualPanel2_editRuleSet(),
441 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
442 null,
new Object[]{okButton, cancelButton}, okButton);
443 if (option == JOptionPane.OK_OPTION) {
445 ImmutablePair<String, LogicalImagerRule> ruleMap = editPanel.toRule();
446 updateRow(row, ruleMap);
448 }
catch (IOException | NumberFormatException ex) {
449 JOptionPane.showMessageDialog(
this,
451 Bundle.ConfigVisualPanel2_editRuleError(),
452 JOptionPane.ERROR_MESSAGE);
462 private void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
463 NewRuleSetPanel panel;
464 panel =
new NewRuleSetPanel(okButton, cancelButton);
465 panel.setEnabled(
true);
466 panel.setVisible(
true);
469 int option = JOptionPane.showOptionDialog(
this, panel,
"New rule",
470 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
471 null,
new Object[]{okButton, cancelButton}, okButton);
472 if (option == JOptionPane.OK_OPTION) {
475 ImmutablePair<String, LogicalImagerRule> ruleMap = panel.toRule();
478 }
catch (IOException | NumberFormatException ex) {
479 JOptionPane.showMessageDialog(
this,
482 JOptionPane.ERROR_MESSAGE);
492 "ConfigVisualPanel2.deleteRuleSet=Delete rule ",
493 "ConfigVisualPanel2.deleteRuleSetConfirmation=Delete rule confirmation",
495 private void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
496 int index = rulesTable.getSelectedRow();
498 String ruleName = (String) rulesTable.getModel().getValueAt(index, 0);
500 int option = JOptionPane.showOptionDialog(
this,
501 Bundle.ConfigVisualPanel2_deleteRuleSet() + ruleName,
502 Bundle.ConfigVisualPanel2_deleteRuleSetConfirmation(),
503 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
504 if (option == JOptionPane.NO_OPTION) {
508 getFirstRuleSet().getRules().remove(index);
509 updatePanel(configFilename, config);
510 if (rulesTable.getRowCount() > 0) {
511 rulesTable.setRowSelectionInterval(0, 0);
517 private void flagEncryptionProgramsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
518 flagEncryptionPrograms = flagEncryptionProgramsCheckBox.isSelected();
519 toggleEncryptionProgramsRule(flagEncryptionPrograms);
522 private void rulesTableMouseReleased(java.awt.event.MouseEvent evt) {
526 private void toggleEncryptionProgramsRule(
boolean flagEncryptionPrograms) {
527 if (flagEncryptionPrograms) {
529 ImmutablePair<String, LogicalImagerRule> ruleMap = createEncryptionProgramsRule();
533 int index = ((RulesTableModel) rulesTable.getModel()).findRow(EncryptionProgramsRule.getName());
535 getFirstRuleSet().getRules().remove(index);
536 updatePanel(configFilename, config);
537 if (rulesTable.getRowCount() > 0) {
538 rulesTable.setRowSelectionInterval(0, 0);
548 private ImmutablePair<String, LogicalImagerRule> createEncryptionProgramsRule() {
549 LogicalImagerRule.Builder builder =
new LogicalImagerRule.Builder();
550 builder.getName(EncryptionProgramsRule.getName())
551 .getDescription(EncryptionProgramsRule.getDescription())
552 .getShouldAlert(
true)
554 .getFilenames(EncryptionProgramsRule.getFilenames());
555 LogicalImagerRule rule = builder.build();
556 return new ImmutablePair<>(EncryptionProgramsRule.getName(), rule);
560 private javax.swing.JTextField configFileTextField;
561 private javax.swing.JLabel daysIncludedLabel;
562 private javax.swing.JTextField daysIncludedTextField;
563 private javax.swing.JButton deleteRuleButton;
564 private javax.swing.JTextField descriptionEditTextField;
565 private javax.swing.JLabel descriptionLabel;
566 private javax.swing.JButton editRuleButton;
567 private javax.swing.JLabel extensionsLabel;
568 private javax.swing.JTextField extensionsTextField;
569 private javax.swing.JLabel fileSizeLabel;
570 private javax.swing.JLabel filenamesLabel;
571 private javax.swing.JTable filenamesTable;
572 private javax.swing.JCheckBox finalizeImageWriter;
573 private javax.swing.JCheckBox flagEncryptionProgramsCheckBox;
574 private javax.swing.JLabel folderNamesLabel;
575 private javax.swing.JTable folderNamesTable;
576 private javax.swing.JLabel fullPathsLabel;
577 private javax.swing.JTable fullPathsTable;
578 private javax.swing.JScrollPane jScrollPane1;
579 private javax.swing.JScrollPane jScrollPane5;
580 private javax.swing.JScrollPane jScrollPane6;
581 private javax.swing.JScrollPane jScrollPane7;
582 private javax.swing.JSeparator jSeparator1;
583 private javax.swing.JLabel maxSizeLabel;
584 private javax.swing.JFormattedTextField maxSizeTextField;
585 private javax.swing.JLabel minSizeLabel;
586 private javax.swing.JFormattedTextField minSizeTextField;
587 private javax.swing.JLabel modifiedDateLabel;
588 private javax.swing.JButton newRuleButton;
589 private javax.swing.JTextField ruleNameEditTextField;
590 private javax.swing.JLabel ruleNameLabel;
591 private javax.swing.JLabel ruleSetFileLabel;
592 private javax.swing.JTable rulesTable;
593 private javax.swing.JCheckBox shouldAlertCheckBox;
594 private javax.swing.JCheckBox shouldSaveCheckBox;
597 private LogicalImagerRuleSet getFirstRuleSet() {
598 if (config.getRuleSets().isEmpty()) {
599 List<LogicalImagerRuleSet> ruleSets =
new ArrayList<>();
600 ruleSets.add(
new LogicalImagerRuleSet(
"no-set-name",
new ArrayList<>()));
601 config.setRuleSet(ruleSets);
603 return config.getRuleSets().get(0);
606 private void updatePanel(String configFilePath, LogicalImagerConfig config, String rowSelectionkey) {
607 configFileTextField.setText(configFilePath);
608 finalizeImageWriter.setSelected(config.isFinalizeImageWriter());
609 LogicalImagerRuleSet ruleSet = getFirstRuleSet();
610 flagEncryptionProgramsCheckBox.setSelected(ruleSet.find(EncryptionProgramsRule.getName()) != null);
611 RulesTableModel rulesTableModel =
new RulesTableModel();
613 int selectThisRow = 0;
615 Collections.sort(ruleSet.getRules(),
new SortRuleByName());
617 for (LogicalImagerRule rule : ruleSet.getRules()) {
618 rulesTableModel.setValueAt(rule.getName(), row, 0);
619 if (rowSelectionkey != null && rowSelectionkey.equals(rule.getName())) {
622 rulesTableModel.setValueAt(rule.getDescription(), row, 1);
623 rulesTableModel.setValueAt(rule, row, 2);
626 rulesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
627 rulesTable.setModel(rulesTableModel);
629 if (rulesTableModel.getRowCount() > 0) {
630 rulesTable.setRowSelectionInterval(selectThisRow, selectThisRow);
633 updateRuleSetButtons(
false);
637 private void updatePanel(String configFilePath, LogicalImagerConfig config) {
638 updatePanel(configFilePath, config, null);
641 private void rulesTableSelect() {
642 int index = rulesTable.getSelectedRow();
644 String ruleName = (String) rulesTable.getModel().getValueAt(index, 0);
645 String description = (String) rulesTable.getModel().getValueAt(index, 1);
646 updateRuleDetails(ruleName, description, config);
647 updateRuleSetButtons(ruleName.equals(EncryptionProgramsRule.getName()) ?
false :
true);
649 updateRuleSetButtons(
false);
653 private void updateRuleDetails(String ruleName, String description, LogicalImagerConfig config) {
655 LogicalImagerRule rule = getFirstRuleSet().find(ruleName);
656 shouldAlertCheckBox.setSelected(rule.isShouldAlert());
657 shouldSaveCheckBox.setSelected(rule.isShouldSave());
658 ruleNameEditTextField.setText(ruleName);
659 descriptionEditTextField.setText(description);
660 updateExtensions(rule.getExtensions());
661 updateList(filenamesTable, rule.getFilenames());
662 updateList(folderNamesTable, rule.getPaths());
663 updateList(fullPathsTable, rule.getFullPaths());
664 if (rule.getMinFileSize() == null) {
665 minSizeTextField.setText(
"");
667 minSizeTextField.setText(rule.getMinFileSize().toString());
669 if (rule.getMaxFileSize() == null) {
670 maxSizeTextField.setText(
"");
672 maxSizeTextField.setText(rule.getMaxFileSize().toString());
674 if (rule.getMinDays() == null) {
675 daysIncludedTextField.setText(
"");
677 daysIncludedTextField.setText(Integer.toString(rule.getMinDays()));
681 private void clearRuleDetails() {
682 extensionsTextField.setText(
"");
683 shouldAlertCheckBox.setSelected(
false);
684 shouldSaveCheckBox.setSelected(
true);
687 private void updateExtensions(List<String> extensions) {
688 extensionsTextField.setText(
"");
689 if (extensions == null) {
693 boolean first =
true;
694 for (String ext : extensions) {
695 content += (first ?
"" :
",") + ext;
698 extensionsTextField.setText(content);
701 private void updateList(javax.swing.JTable jTable, List<String> set) {
702 SingleColumnTableModel tableModel =
new SingleColumnTableModel();
703 jTable.setTableHeader(null);
705 jTable.setModel(tableModel);
709 for (String s : set) {
710 tableModel.setValueAt(s, row, 0);
713 jTable.setModel(tableModel);
716 void setConfiguration(String configFilename, LogicalImagerConfig config,
boolean newFile) {
717 this.configFilename = configFilename;
718 this.config = config;
722 updatePanel(configFilename, config);
725 private void initPanel() {
726 configFileTextField.setText(
"");
727 rulesTable.setModel(
new RulesTableModel());
728 shouldAlertCheckBox.setSelected(
false);
729 shouldSaveCheckBox.setSelected(
true);
730 ruleNameEditTextField.setText(
"");
731 descriptionEditTextField.setText(
"");
732 extensionsTextField.setText(
"");
733 updateList(filenamesTable, EMPTY_LIST);
734 updateList(folderNamesTable, EMPTY_LIST);
737 private void updateRow(
int index, ImmutablePair<String, LogicalImagerRule> ruleMap) {
738 getFirstRuleSet().getRules().remove(index);
739 getFirstRuleSet().getRules().add(ruleMap.getValue());
740 updatePanel(configFilename, config, ruleMap.getKey());
743 private void appendRow(ImmutablePair<String, LogicalImagerRule> ruleMap) {
744 getFirstRuleSet().getRules().add(ruleMap.getValue());
745 updatePanel(configFilename, config, ruleMap.getKey());
748 private void updateRuleSetButtons(
boolean isRowSelected) {
749 newRuleButton.setEnabled(
true);
750 editRuleButton.setEnabled(isRowSelected);
751 deleteRuleButton.setEnabled(isRowSelected);
759 public int compare(LogicalImagerRule a, LogicalImagerRule b) {
760 return a.getName().compareToIgnoreCase(b.getName());
769 private final List<String> ruleName =
new ArrayList<>();
771 private final List<LogicalImagerRule> rule =
new ArrayList<>();
773 int findRow(String name) {
774 return ruleName.indexOf(name);
779 return ruleName.size();
788 "ConfigVisualPanel2.rulesTable.columnModel.title0=Rule Name",
789 "ConfigVisualPanel2.rulesTable.columnModel.title1=Description"
793 String colName = null;
796 colName = Bundle.ConfigVisualPanel2_rulesTable_columnModel_title0();
799 colName = Bundle.ConfigVisualPanel2_rulesTable_columnModel_title1();
810 switch (columnIndex) {
812 ret = ruleName.get(rowIndex);
815 ret = ruleDescription.get(rowIndex);
818 ret = rule.get(rowIndex);
821 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
832 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
833 switch (columnIndex) {
835 ruleName.add((String) aValue);
838 ruleDescription.add((String) aValue);
841 rule.add((LogicalImagerRule) aValue);
844 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
847 if (columnIndex < 2) {
848 super.setValueAt(aValue, rowIndex, columnIndex);
858 private final List<String>
list =
new ArrayList<>();
878 if (columnIndex == 0) {
879 ret = list.get(rowIndex);
881 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
892 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
893 if (columnIndex == 0) {
894 list.add((String) aValue);
896 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
void setValueAt(Object aValue, int rowIndex, int columnIndex)
String getColumnName(int column)
boolean isCellEditable(int rowIndex, int columnIndex)
String getColumnName(int column)
int compare(LogicalImagerRule a, LogicalImagerRule b)
final List< String > ruleDescription
Object getValueAt(int rowIndex, int columnIndex)
void setValueAt(Object aValue, int rowIndex, int columnIndex)
boolean isCellEditable(int rowIndex, int columnIndex)
final List< String > list
Object getValueAt(int rowIndex, int columnIndex)