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;
33 import org.openide.util.NbBundle.Messages;
39 "ConfigVisualPanel2.ok=OK",
40 "ConfigVisualPanel2.cancel=Cancel" 42 @SuppressWarnings(
"PMD.SingularField")
43 final class ConfigVisualPanel2
extends JPanel {
45 private static final long serialVersionUID = 1L;
46 private String configFilename;
47 private LogicalImagerConfig config = null;
48 private final JButton okButton =
new JButton(Bundle.ConfigVisualPanel2_ok());
49 private final JButton cancelButton =
new JButton(Bundle.ConfigVisualPanel2_cancel());
50 private boolean flagEncryptionPrograms =
false;
55 ConfigVisualPanel2() {
58 updatePanel(configFilename, config);
63 "ConfigVisualPanel2.editConfiguration=Configure imager" 66 public String getName() {
67 return Bundle.ConfigVisualPanel2_editConfiguration();
76 private void initComponents() {
78 modifiedDateLabel =
new javax.swing.JLabel();
79 modifiedWithinTextField =
new javax.swing.JTextField();
80 daysIncludedLabel =
new javax.swing.JLabel();
81 fullPathsLabel =
new javax.swing.JLabel();
82 flagEncryptionProgramsCheckBox =
new javax.swing.JCheckBox();
83 ruleNameLabel =
new javax.swing.JLabel();
84 ruleNameEditTextField =
new javax.swing.JTextField();
85 newRuleButton =
new javax.swing.JButton();
86 descriptionLabel =
new javax.swing.JLabel();
87 editRuleButton =
new javax.swing.JButton();
88 descriptionEditTextField =
new javax.swing.JTextField();
89 deleteRuleButton =
new javax.swing.JButton();
90 fullPathsScrollPane =
new javax.swing.JScrollPane();
91 fullPathsTable =
new javax.swing.JTable();
92 filenamesScrollPane =
new javax.swing.JScrollPane();
93 filenamesTable =
new javax.swing.JTable();
94 shouldSaveCheckBox =
new javax.swing.JCheckBox();
95 shouldAlertCheckBox =
new javax.swing.JCheckBox();
96 folderNamesScrollPane =
new javax.swing.JScrollPane();
97 folderNamesTable =
new javax.swing.JTable();
98 extensionsLabel =
new javax.swing.JLabel();
99 extensionsTextField =
new javax.swing.JTextField();
100 filenamesLabel =
new javax.swing.JLabel();
101 configFileTextField =
new javax.swing.JTextField();
102 ruleSetFileLabel =
new javax.swing.JLabel();
103 finalizeImageWriter =
new javax.swing.JCheckBox();
104 rulesScrollPane =
new javax.swing.JScrollPane();
105 rulesTable =
new javax.swing.JTable();
106 folderNamesLabel =
new javax.swing.JLabel();
107 fileSizeLabel =
new javax.swing.JLabel();
108 jSeparator1 =
new javax.swing.JSeparator();
109 minSizeLabel =
new javax.swing.JLabel();
110 minSizeTextField =
new javax.swing.JFormattedTextField();
111 maxSizeLabel =
new javax.swing.JLabel();
112 maxSizeTextField =
new javax.swing.JFormattedTextField();
113 promptBeforeExit =
new javax.swing.JCheckBox();
114 createVHDCheckBox =
new javax.swing.JCheckBox();
116 org.openide.awt.Mnemonics.setLocalizedText(modifiedDateLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.modifiedDateLabel.text"));
118 modifiedWithinTextField.setEditable(
false);
119 modifiedWithinTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
120 modifiedWithinTextField.setEnabled(
false);
121 modifiedWithinTextField.setMinimumSize(
new java.awt.Dimension(60, 20));
122 modifiedWithinTextField.setPreferredSize(
new java.awt.Dimension(60, 20));
124 org.openide.awt.Mnemonics.setLocalizedText(daysIncludedLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.daysIncludedLabel.text"));
126 org.openide.awt.Mnemonics.setLocalizedText(fullPathsLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fullPathsLabel.text"));
128 org.openide.awt.Mnemonics.setLocalizedText(flagEncryptionProgramsCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.flagEncryptionProgramsCheckBox.text"));
129 flagEncryptionProgramsCheckBox.addActionListener(
new java.awt.event.ActionListener() {
130 public void actionPerformed(java.awt.event.ActionEvent evt) {
131 flagEncryptionProgramsCheckBoxActionPerformed(evt);
135 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.ruleNameLabel.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.setEnabled(
false);
159 deleteRuleButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/delete16.png")));
160 org.openide.awt.Mnemonics.setLocalizedText(deleteRuleButton,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.deleteRuleButton.text"));
161 deleteRuleButton.addActionListener(
new java.awt.event.ActionListener() {
162 public void actionPerformed(java.awt.event.ActionEvent evt) {
163 deleteRuleButtonActionPerformed(evt);
167 fullPathsTable.setColumnSelectionAllowed(
true);
168 fullPathsTable.setEnabled(
false);
169 fullPathsTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
170 fullPathsTable.setShowHorizontalLines(
false);
171 fullPathsTable.setShowVerticalLines(
false);
172 fullPathsTable.getTableHeader().setReorderingAllowed(
false);
173 fullPathsScrollPane.setViewportView(fullPathsTable);
174 fullPathsTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
175 if (fullPathsTable.getColumnModel().getColumnCount() > 0) {
176 fullPathsTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fullPathsTable.columnModel.title0"));
179 filenamesTable.setEnabled(
false);
180 filenamesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
181 filenamesTable.setShowHorizontalLines(
false);
182 filenamesTable.setShowVerticalLines(
false);
183 filenamesTable.getTableHeader().setReorderingAllowed(
false);
184 filenamesScrollPane.setViewportView(filenamesTable);
185 if (filenamesTable.getColumnModel().getColumnCount() > 0) {
186 filenamesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.filenamesTable.columnModel.title0"));
189 org.openide.awt.Mnemonics.setLocalizedText(shouldSaveCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.shouldSaveCheckBox.text"));
190 shouldSaveCheckBox.setToolTipText(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.shouldSaveCheckBox.toolTipText"));
191 shouldSaveCheckBox.setEnabled(
false);
193 org.openide.awt.Mnemonics.setLocalizedText(shouldAlertCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.shouldAlertCheckBox.text"));
194 shouldAlertCheckBox.setEnabled(
false);
196 folderNamesTable.setEnabled(
false);
197 folderNamesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
198 folderNamesTable.setShowHorizontalLines(
false);
199 folderNamesTable.setShowVerticalLines(
false);
200 folderNamesTable.getTableHeader().setReorderingAllowed(
false);
201 folderNamesScrollPane.setViewportView(folderNamesTable);
202 if (folderNamesTable.getColumnModel().getColumnCount() > 0) {
203 folderNamesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.folderNamesTable.columnModel.title0"));
206 org.openide.awt.Mnemonics.setLocalizedText(extensionsLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.extensionsLabel.text"));
208 extensionsTextField.setEnabled(
false);
210 org.openide.awt.Mnemonics.setLocalizedText(filenamesLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.filenamesLabel.text"));
212 configFileTextField.setToolTipText(
"");
213 configFileTextField.setEnabled(
false);
215 org.openide.awt.Mnemonics.setLocalizedText(ruleSetFileLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.ruleSetFileLabel.text"));
217 org.openide.awt.Mnemonics.setLocalizedText(finalizeImageWriter,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.finalizeImageWriter.text"));
218 finalizeImageWriter.setEnabled(
false);
219 finalizeImageWriter.addActionListener(
new java.awt.event.ActionListener() {
220 public void actionPerformed(java.awt.event.ActionEvent evt) {
221 finalizeImageWriterActionPerformed(evt);
225 rulesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
226 rulesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
227 rulesTable.setShowHorizontalLines(
false);
228 rulesTable.setShowVerticalLines(
false);
229 rulesTable.getTableHeader().setReorderingAllowed(
false);
230 rulesTable.addMouseListener(
new java.awt.event.MouseAdapter() {
231 public void mouseReleased(java.awt.event.MouseEvent evt) {
232 rulesTableMouseReleased(evt);
235 rulesTable.addKeyListener(
new java.awt.event.KeyAdapter() {
236 public void keyReleased(java.awt.event.KeyEvent evt) {
237 rulesTableKeyReleased(evt);
240 rulesScrollPane.setViewportView(rulesTable);
241 if (rulesTable.getColumnModel().getColumnCount() > 0) {
242 rulesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.rulesTable.columnModel.title0"));
243 rulesTable.getColumnModel().getColumn(1).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.rulesTable.columnModel.title1"));
246 org.openide.awt.Mnemonics.setLocalizedText(folderNamesLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.folderNamesLabel.text"));
248 org.openide.awt.Mnemonics.setLocalizedText(fileSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fileSizeLabel.text"));
250 org.openide.awt.Mnemonics.setLocalizedText(minSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.minSizeLabel.text"));
252 minSizeTextField.setFormatterFactory(
new javax.swing.text.DefaultFormatterFactory(
new javax.swing.text.NumberFormatter(
new java.text.DecimalFormat(
"#,###; "))));
253 minSizeTextField.setEnabled(
false);
255 org.openide.awt.Mnemonics.setLocalizedText(maxSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.maxSizeLabel.text"));
257 maxSizeTextField.setFormatterFactory(
new javax.swing.text.DefaultFormatterFactory(
new javax.swing.text.NumberFormatter(
new java.text.DecimalFormat(
"#,###; "))));
258 maxSizeTextField.setEnabled(
false);
260 promptBeforeExit.setSelected(
true);
261 org.openide.awt.Mnemonics.setLocalizedText(promptBeforeExit,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.promptBeforeExit.text"));
262 promptBeforeExit.setActionCommand(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.promptBeforeExit.actionCommand"));
263 promptBeforeExit.addActionListener(
new java.awt.event.ActionListener() {
264 public void actionPerformed(java.awt.event.ActionEvent evt) {
265 promptBeforeExitActionPerformed(evt);
269 org.openide.awt.Mnemonics.setLocalizedText(createVHDCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.createVHDCheckBox.text"));
270 createVHDCheckBox.addActionListener(
new java.awt.event.ActionListener() {
271 public void actionPerformed(java.awt.event.ActionEvent evt) {
272 createVHDCheckBoxActionPerformed(evt);
276 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
277 this.setLayout(layout);
278 layout.setHorizontalGroup(
279 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
280 .addGroup(layout.createSequentialGroup()
282 .addComponent(ruleSetFileLabel)
284 .addComponent(configFileTextField)
286 .addGroup(layout.createSequentialGroup()
288 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
290 .addComponent(newRuleButton)
291 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
292 .addComponent(editRuleButton)
293 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
294 .addComponent(deleteRuleButton))
295 .addComponent(rulesScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 341, javax.swing.GroupLayout.PREFERRED_SIZE))
296 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
297 .addGroup(layout.createSequentialGroup()
299 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
300 .addGroup(layout.createSequentialGroup()
301 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
302 .addComponent(extensionsLabel)
303 .addComponent(filenamesLabel)
304 .addComponent(descriptionLabel)
305 .addComponent(ruleNameLabel)
306 .addComponent(fullPathsLabel)
307 .addComponent(folderNamesLabel))
308 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
309 .addGroup(layout.createSequentialGroup()
310 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
311 .addGroup(layout.createSequentialGroup()
312 .addGap(129, 129, 129)
313 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
314 .addComponent(ruleNameEditTextField, javax.swing.GroupLayout.Alignment.LEADING)
315 .addComponent(descriptionEditTextField, javax.swing.GroupLayout.Alignment.LEADING)
316 .addComponent(extensionsTextField, javax.swing.GroupLayout.Alignment.LEADING)
317 .addComponent(fullPathsScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
318 .addComponent(filenamesScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
319 .addComponent(folderNamesScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
320 .addGroup(layout.createSequentialGroup()
321 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322 .addComponent(shouldSaveCheckBox)
323 .addComponent(shouldAlertCheckBox)
324 .addGroup(layout.createSequentialGroup()
325 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
326 .addComponent(modifiedDateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
327 .addComponent(fileSizeLabel))
329 .addComponent(minSizeLabel)
330 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
331 .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
333 .addComponent(maxSizeLabel)
334 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
335 .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
336 .addGroup(layout.createSequentialGroup()
337 .addGap(129, 129, 129)
338 .addComponent(modifiedWithinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
339 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
340 .addComponent(daysIncludedLabel)))
341 .addGap(0, 0, Short.MAX_VALUE)))
342 .addContainerGap())))
343 .addGroup(layout.createSequentialGroup()
344 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
345 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
346 .addGroup(layout.createSequentialGroup()
347 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
348 .addComponent(flagEncryptionProgramsCheckBox)
349 .addComponent(createVHDCheckBox)
350 .addComponent(promptBeforeExit)
351 .addGroup(layout.createSequentialGroup()
353 .addComponent(finalizeImageWriter)))
354 .addGap(0, 0, Short.MAX_VALUE))
355 .addComponent(jSeparator1)))))
358 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {deleteRuleButton, editRuleButton, newRuleButton});
360 layout.setVerticalGroup(
361 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
362 .addGroup(layout.createSequentialGroup()
364 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
365 .addComponent(configFileTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
366 .addComponent(ruleSetFileLabel))
367 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
368 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
369 .addGroup(layout.createSequentialGroup()
370 .addComponent(rulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
371 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
372 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
373 .addComponent(newRuleButton)
374 .addComponent(editRuleButton)
375 .addComponent(deleteRuleButton))
377 .addGroup(layout.createSequentialGroup()
378 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
379 .addGroup(layout.createSequentialGroup()
381 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
382 .addComponent(descriptionEditTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
383 .addComponent(descriptionLabel))
385 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
386 .addComponent(extensionsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
387 .addComponent(extensionsLabel)))
388 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
389 .addComponent(ruleNameEditTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
390 .addComponent(ruleNameLabel)))
391 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
392 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
393 .addComponent(filenamesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
394 .addComponent(filenamesLabel))
396 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
397 .addComponent(folderNamesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
398 .addComponent(folderNamesLabel))
400 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
401 .addComponent(fullPathsLabel)
402 .addComponent(fullPathsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
403 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
404 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
405 .addComponent(minSizeLabel)
406 .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
407 .addComponent(maxSizeLabel)
408 .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
409 .addComponent(fileSizeLabel))
410 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
411 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
412 .addComponent(modifiedDateLabel)
413 .addComponent(modifiedWithinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
414 .addComponent(daysIncludedLabel))
415 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
416 .addComponent(shouldSaveCheckBox)
417 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
418 .addComponent(shouldAlertCheckBox)
420 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
421 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
422 .addComponent(flagEncryptionProgramsCheckBox)
423 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
424 .addComponent(createVHDCheckBox)
425 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
426 .addComponent(finalizeImageWriter)
427 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
428 .addComponent(promptBeforeExit)
429 .addGap(19, 19, 19))))
433 private void rulesTableKeyReleased(java.awt.event.KeyEvent evt) {
434 updateForSelectedRule();
438 "ConfigVisualPanel2.editRuleSet=Edit Rule",
439 "ConfigVisualPanel2.editRuleError=Edit rule error" 441 private void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
442 int row = rulesTable.getSelectedRow();
444 String ruleName = (String) rulesTable.getModel().getValueAt(row, 0);
445 LogicalImagerRule rule = getRuleSetFromCurrentConfig().getRules().get(row);
446 EditRulePanel editPanel =
new EditRulePanel(okButton, cancelButton, ruleName, rule);
447 editPanel.setEnabled(
true);
448 editPanel.setVisible(
true);
451 int option = JOptionPane.showOptionDialog(
this, editPanel.getPanel(), Bundle.ConfigVisualPanel2_editRuleSet(),
452 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
453 null,
new Object[]{okButton, cancelButton}, okButton);
454 if (option == JOptionPane.OK_OPTION) {
456 ImmutablePair<String, LogicalImagerRule> ruleMap = editPanel.toRule();
457 if (!ruleName.equals(ruleMap.getKey()) && ruleExists(ruleMap)) {
458 JOptionPane.showMessageDialog(
this,
459 Bundle.ConfigVisualPanel2_newRuleError_duplicateName(ruleMap.getKey()),
460 Bundle.ConfigVisualPanel2_editRuleError(),
461 JOptionPane.ERROR_MESSAGE);
464 updateRow(row, ruleMap);
466 }
catch (IOException | NumberFormatException ex) {
467 JOptionPane.showMessageDialog(
this,
469 Bundle.ConfigVisualPanel2_editRuleError(),
470 JOptionPane.ERROR_MESSAGE);
480 @Messages({
"ConfigVisualPanel2.newRule.name=New Rule",
481 "ConfigVisualPanel2.newRuleError.title=New rule error",
483 "ConfigVisualPanel2.newRuleError.duplicateName=A rule with name \"{0}\" already exists. Please enter a different rule name"})
484 private void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
486 panel =
new NewRulePanel(okButton, cancelButton);
487 panel.setEnabled(
true);
488 panel.setVisible(
true);
491 int option = JOptionPane.showOptionDialog(
this, panel, Bundle.ConfigVisualPanel2_newRule_name(),
492 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
493 null,
new Object[]{okButton, cancelButton}, okButton);
494 if (option == JOptionPane.OK_OPTION) {
497 ImmutablePair<String, LogicalImagerRule> ruleMap = panel.toRule();
498 if (ruleExists(ruleMap)) {
499 JOptionPane.showMessageDialog(
this,
500 Bundle.ConfigVisualPanel2_newRuleError_duplicateName(ruleMap.getKey()),
501 Bundle.ConfigVisualPanel2_newRuleError_title(),
502 JOptionPane.ERROR_MESSAGE);
508 }
catch (IOException | NumberFormatException ex) {
509 JOptionPane.showMessageDialog(
this,
511 Bundle.ConfigVisualPanel2_newRuleError_title(),
512 JOptionPane.ERROR_MESSAGE);
522 "ConfigVisualPanel2.deleteRuleSet=Delete rule ",
523 "ConfigVisualPanel2.deleteRuleSetConfirmation=Delete rule confirmation",})
524 private void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
525 int index = rulesTable.getSelectedRow();
527 String ruleName = (String) rulesTable.getModel().getValueAt(index, 0);
529 int option = JOptionPane.showOptionDialog(
this,
530 Bundle.ConfigVisualPanel2_deleteRuleSet() + ruleName,
531 Bundle.ConfigVisualPanel2_deleteRuleSetConfirmation(),
532 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
533 if (option == JOptionPane.NO_OPTION) {
537 getRuleSetFromCurrentConfig().getRules().remove(index);
538 updatePanel(configFilename, config);
539 if (rulesTable.getRowCount() > 0) {
540 rulesTable.setRowSelectionInterval(0, 0);
541 updateForSelectedRule();
546 private void rulesTableMouseReleased(java.awt.event.MouseEvent evt) {
547 updateForSelectedRule();
550 private void flagEncryptionProgramsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
551 flagEncryptionPrograms = flagEncryptionProgramsCheckBox.isSelected();
552 setEnabledEncryptionProgramsRule(flagEncryptionPrograms);
555 private void finalizeImageWriterActionPerformed(java.awt.event.ActionEvent evt) {
556 config.setFinalizeImageWriter(finalizeImageWriter.isSelected());
559 private void promptBeforeExitActionPerformed(java.awt.event.ActionEvent evt) {
560 config.setPromptBeforeExit(promptBeforeExit.isSelected());
563 private void createVHDCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
564 config.setCreateVHD(createVHDCheckBox.isSelected());
565 finalizeImageWriter.setEnabled(createVHDCheckBox.isSelected());
575 private void setEnabledEncryptionProgramsRule(
boolean flagEncryptionPrograms) {
576 if (flagEncryptionPrograms) {
578 ImmutablePair<String, LogicalImagerRule> ruleMap = createEncryptionProgramsRule();
582 int index = ((RulesTableModel) rulesTable.getModel()).findRow(EncryptionProgramsRule.getName());
584 getRuleSetFromCurrentConfig().getRules().remove(index);
585 updatePanel(configFilename, config);
586 if (rulesTable.getRowCount() > 0) {
587 rulesTable.setRowSelectionInterval(0, 0);
588 updateForSelectedRule();
597 private ImmutablePair<String, LogicalImagerRule> createEncryptionProgramsRule() {
598 LogicalImagerRule.Builder builder =
new LogicalImagerRule.Builder();
599 builder.getName(EncryptionProgramsRule.getName())
600 .getDescription(EncryptionProgramsRule.getDescription())
601 .getShouldAlert(
true)
603 .getFilenames(EncryptionProgramsRule.getFilenames());
604 LogicalImagerRule rule = builder.build();
605 return new ImmutablePair<>(EncryptionProgramsRule.getName(), rule);
609 private javax.swing.JTextField configFileTextField;
610 private javax.swing.JCheckBox createVHDCheckBox;
611 private javax.swing.JLabel daysIncludedLabel;
612 private javax.swing.JButton deleteRuleButton;
613 private javax.swing.JTextField descriptionEditTextField;
614 private javax.swing.JLabel descriptionLabel;
615 private javax.swing.JButton editRuleButton;
616 private javax.swing.JLabel extensionsLabel;
617 private javax.swing.JTextField extensionsTextField;
618 private javax.swing.JLabel fileSizeLabel;
619 private javax.swing.JLabel filenamesLabel;
620 private javax.swing.JScrollPane filenamesScrollPane;
621 private javax.swing.JTable filenamesTable;
622 private javax.swing.JCheckBox finalizeImageWriter;
623 private javax.swing.JCheckBox flagEncryptionProgramsCheckBox;
624 private javax.swing.JLabel folderNamesLabel;
625 private javax.swing.JScrollPane folderNamesScrollPane;
626 private javax.swing.JTable folderNamesTable;
627 private javax.swing.JLabel fullPathsLabel;
628 private javax.swing.JScrollPane fullPathsScrollPane;
629 private javax.swing.JTable fullPathsTable;
630 private javax.swing.JSeparator jSeparator1;
631 private javax.swing.JLabel maxSizeLabel;
632 private javax.swing.JFormattedTextField maxSizeTextField;
633 private javax.swing.JLabel minSizeLabel;
634 private javax.swing.JFormattedTextField minSizeTextField;
635 private javax.swing.JLabel modifiedDateLabel;
636 private javax.swing.JTextField modifiedWithinTextField;
637 private javax.swing.JButton newRuleButton;
638 private javax.swing.JCheckBox promptBeforeExit;
639 private javax.swing.JTextField ruleNameEditTextField;
640 private javax.swing.JLabel ruleNameLabel;
641 private javax.swing.JLabel ruleSetFileLabel;
642 private javax.swing.JScrollPane rulesScrollPane;
643 private javax.swing.JTable rulesTable;
644 private javax.swing.JCheckBox shouldAlertCheckBox;
645 private javax.swing.JCheckBox shouldSaveCheckBox;
648 private LogicalImagerRuleSet getRuleSetFromCurrentConfig() {
649 if (config.getRuleSets().isEmpty()) {
650 List<LogicalImagerRuleSet> ruleSets =
new ArrayList<>();
651 ruleSets.add(
new LogicalImagerRuleSet(
"no-set-name",
new ArrayList<>()));
652 config.setRuleSet(ruleSets);
654 return config.getRuleSets().get(0);
664 private void updatePanel(String configFilePath, LogicalImagerConfig config, String rowSelectionkey) {
665 configFileTextField.setText(configFilePath);
666 finalizeImageWriter.setSelected(config.isFinalizeImageWriter());
667 promptBeforeExit.setSelected(config.isPromptBeforeExit());
668 createVHDCheckBox.setSelected(config.isCreateVHD());
669 finalizeImageWriter.setEnabled(config.isCreateVHD());
670 LogicalImagerRuleSet ruleSet = getRuleSetFromCurrentConfig();
671 flagEncryptionProgramsCheckBox.setSelected(ruleSet.find(EncryptionProgramsRule.getName()) != null);
672 RulesTableModel rulesTableModel =
new RulesTableModel();
674 int selectThisRow = 0;
676 Collections.sort(ruleSet.getRules(),
new SortRuleByName());
678 for (LogicalImagerRule rule : ruleSet.getRules()) {
679 rulesTableModel.setValueAt(rule.getName(), row, 0);
680 if (rowSelectionkey != null && rowSelectionkey.equals(rule.getName())) {
683 rulesTableModel.setValueAt(rule.getDescription(), row, 1);
684 rulesTableModel.setValueAt(rule, row, 2);
687 rulesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
688 rulesTable.setModel(rulesTableModel);
690 if (rulesTableModel.getRowCount() > 0) {
691 rulesTable.setRowSelectionInterval(selectThisRow, selectThisRow);
692 updateForSelectedRule();
695 updateRuleButtons(
false);
705 private void updatePanel(String configFilePath, LogicalImagerConfig config) {
706 updatePanel(configFilePath, config, null);
712 private void updateForSelectedRule() {
713 int index = rulesTable.getSelectedRow();
715 String ruleName = (String) rulesTable.getModel().getValueAt(index, 0);
716 String description = (String) rulesTable.getModel().getValueAt(index, 1);
717 updateRuleDetails(ruleName, description);
718 updateRuleButtons(!ruleName.equals(EncryptionProgramsRule.getName()));
721 updateRuleButtons(
false);
731 private void updateRuleDetails(String ruleName, String description) {
733 LogicalImagerRule rule = getRuleSetFromCurrentConfig().find(ruleName);
734 shouldAlertCheckBox.setSelected(rule.isShouldAlert());
735 shouldSaveCheckBox.setSelected(rule.isShouldSave());
736 ruleNameEditTextField.setText(ruleName);
737 descriptionEditTextField.setText(description);
738 updateExtensions(rule.getExtensions());
739 updateList(filenamesTable, rule.getFilenames());
740 updateList(folderNamesTable, rule.getPaths());
741 updateList(fullPathsTable, rule.getFullPaths());
742 if (rule.getMinFileSize() == null) {
743 minSizeTextField.setText(
"");
745 minSizeTextField.setText(rule.getMinFileSize().toString());
747 if (rule.getMaxFileSize() == null) {
748 maxSizeTextField.setText(
"");
750 maxSizeTextField.setText(rule.getMaxFileSize().toString());
752 if (rule.getMinDays() == null) {
753 modifiedWithinTextField.setText(
"");
755 modifiedWithinTextField.setText(Integer.toString(rule.getMinDays()));
762 private void clearRuleDetails() {
763 ruleNameEditTextField.setText(
"");
764 descriptionEditTextField.setText(
"");
765 extensionsTextField.setText(
"");
766 updateExtensions(null);
767 updateList(filenamesTable, null);
768 updateList(folderNamesTable, null);
769 updateList(fullPathsTable, null);
770 minSizeTextField.setText(
"");
771 maxSizeTextField.setText(
"");
772 modifiedWithinTextField.setText(
"");
773 shouldSaveCheckBox.setSelected(
true);
774 shouldAlertCheckBox.setSelected(
false);
783 private void updateExtensions(List<String> extensions) {
784 extensionsTextField.setText(
"");
785 if (extensions == null) {
789 boolean first =
true;
790 for (String ext : extensions) {
791 content += (first ?
"" :
",") + ext;
794 extensionsTextField.setText(content);
803 private void updateList(javax.swing.JTable jTable, List<String> list) {
804 SingleColumnTableModel tableModel =
new SingleColumnTableModel();
805 jTable.setTableHeader(null);
807 jTable.setModel(tableModel);
811 for (String s : list) {
812 tableModel.setValueAt(s, row, 0);
815 jTable.setModel(tableModel);
818 void setConfiguration(String configFilename, LogicalImagerConfig config) {
819 this.configFilename = configFilename;
820 this.config = config;
821 updatePanel(configFilename, config);
824 private void updateRow(
int index, ImmutablePair<String, LogicalImagerRule> ruleMap) {
825 getRuleSetFromCurrentConfig().getRules().remove(index);
826 getRuleSetFromCurrentConfig().getRules().add(ruleMap.getValue());
827 updatePanel(configFilename, config, ruleMap.getKey());
837 private boolean ruleExists(ImmutablePair<String, LogicalImagerRule> ruleMap) {
838 for (LogicalImagerRule rule : getRuleSetFromCurrentConfig().getRules()) {
839 if (rule.getName().equals(ruleMap.getKey())) {
846 private void appendRow(ImmutablePair<String, LogicalImagerRule> ruleMap) {
847 getRuleSetFromCurrentConfig().getRules().add(ruleMap.getValue());
848 updatePanel(configFilename, config, ruleMap.getKey());
857 private void updateRuleButtons(
boolean isRowSelected) {
858 newRuleButton.setEnabled(
true);
859 editRuleButton.setEnabled(isRowSelected);
860 deleteRuleButton.setEnabled(isRowSelected);
869 public int compare(LogicalImagerRule a, LogicalImagerRule b) {
870 return a.getName().compareToIgnoreCase(b.getName());
879 private static final long serialVersionUID = 1L;
880 private final List<String> ruleName =
new ArrayList<>();
881 private final List<String> ruleDescription =
new ArrayList<>();
882 private final List<LogicalImagerRule> rule =
new ArrayList<>();
884 int findRow(String name) {
885 return ruleName.indexOf(name);
890 return ruleName.size();
899 "ConfigVisualPanel2.rulesTable.columnModel.title0=Rule Name",
900 "ConfigVisualPanel2.rulesTable.columnModel.title1=Description" 904 String colName = null;
907 colName = Bundle.ConfigVisualPanel2_rulesTable_columnModel_title0();
910 colName = Bundle.ConfigVisualPanel2_rulesTable_columnModel_title1();
921 switch (columnIndex) {
923 ret = ruleName.get(rowIndex);
926 ret = ruleDescription.get(rowIndex);
929 ret = rule.get(rowIndex);
932 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
943 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
944 switch (columnIndex) {
946 ruleName.add((String) aValue);
949 ruleDescription.add((String) aValue);
952 rule.add((LogicalImagerRule) aValue);
955 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
958 if (columnIndex < 2) {
959 super.setValueAt(aValue, rowIndex, columnIndex);
969 private static final long serialVersionUID = 1L;
971 private final List<String> list =
new ArrayList<>();
991 if (columnIndex == 0) {
992 ret = list.get(rowIndex);
994 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
1005 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
1006 if (columnIndex == 0) {
1007 list.add((String) aValue);
1009 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)
Object getValueAt(int rowIndex, int columnIndex)
void setValueAt(Object aValue, int rowIndex, int columnIndex)
boolean isCellEditable(int rowIndex, int columnIndex)
Object getValueAt(int rowIndex, int columnIndex)