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.addActionListener(
new java.awt.event.ActionListener() {
219 public void actionPerformed(java.awt.event.ActionEvent evt) {
220 finalizeImageWriterActionPerformed(evt);
224 rulesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
225 rulesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
226 rulesTable.setShowHorizontalLines(
false);
227 rulesTable.setShowVerticalLines(
false);
228 rulesTable.getTableHeader().setReorderingAllowed(
false);
229 rulesTable.addMouseListener(
new java.awt.event.MouseAdapter() {
230 public void mouseReleased(java.awt.event.MouseEvent evt) {
231 rulesTableMouseReleased(evt);
234 rulesTable.addKeyListener(
new java.awt.event.KeyAdapter() {
235 public void keyReleased(java.awt.event.KeyEvent evt) {
236 rulesTableKeyReleased(evt);
239 rulesScrollPane.setViewportView(rulesTable);
240 if (rulesTable.getColumnModel().getColumnCount() > 0) {
241 rulesTable.getColumnModel().getColumn(0).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.rulesTable.columnModel.title0"));
242 rulesTable.getColumnModel().getColumn(1).setHeaderValue(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.rulesTable.columnModel.title1"));
245 org.openide.awt.Mnemonics.setLocalizedText(folderNamesLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.folderNamesLabel.text"));
247 org.openide.awt.Mnemonics.setLocalizedText(fileSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.fileSizeLabel.text"));
249 org.openide.awt.Mnemonics.setLocalizedText(minSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.minSizeLabel.text"));
251 minSizeTextField.setFormatterFactory(
new javax.swing.text.DefaultFormatterFactory(
new javax.swing.text.NumberFormatter(
new java.text.DecimalFormat(
"#,###; "))));
252 minSizeTextField.setEnabled(
false);
254 org.openide.awt.Mnemonics.setLocalizedText(maxSizeLabel,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.maxSizeLabel.text"));
256 maxSizeTextField.setFormatterFactory(
new javax.swing.text.DefaultFormatterFactory(
new javax.swing.text.NumberFormatter(
new java.text.DecimalFormat(
"#,###; "))));
257 maxSizeTextField.setEnabled(
false);
259 promptBeforeExit.setSelected(
true);
260 org.openide.awt.Mnemonics.setLocalizedText(promptBeforeExit,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.promptBeforeExit.text"));
261 promptBeforeExit.setActionCommand(
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.promptBeforeExit.actionCommand"));
262 promptBeforeExit.addActionListener(
new java.awt.event.ActionListener() {
263 public void actionPerformed(java.awt.event.ActionEvent evt) {
264 promptBeforeExitActionPerformed(evt);
268 org.openide.awt.Mnemonics.setLocalizedText(createVHDCheckBox,
org.openide.util.NbBundle.getMessage(ConfigVisualPanel2.class,
"ConfigVisualPanel2.createVHDCheckBox.text"));
269 createVHDCheckBox.addActionListener(
new java.awt.event.ActionListener() {
270 public void actionPerformed(java.awt.event.ActionEvent evt) {
271 createVHDCheckBoxActionPerformed(evt);
275 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
276 this.setLayout(layout);
277 layout.setHorizontalGroup(
278 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
279 .addGroup(layout.createSequentialGroup()
281 .addComponent(ruleSetFileLabel)
283 .addComponent(configFileTextField)
285 .addGroup(layout.createSequentialGroup()
287 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
288 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
289 .addComponent(newRuleButton)
290 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
291 .addComponent(editRuleButton)
292 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
293 .addComponent(deleteRuleButton))
294 .addComponent(rulesScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 341, javax.swing.GroupLayout.PREFERRED_SIZE))
295 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
296 .addGroup(layout.createSequentialGroup()
298 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
299 .addGroup(layout.createSequentialGroup()
300 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
301 .addComponent(extensionsLabel)
302 .addComponent(filenamesLabel)
303 .addComponent(descriptionLabel)
304 .addComponent(ruleNameLabel)
305 .addComponent(fullPathsLabel)
306 .addComponent(folderNamesLabel))
307 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
308 .addGroup(layout.createSequentialGroup()
309 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
310 .addGroup(layout.createSequentialGroup()
311 .addGap(129, 129, 129)
312 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
313 .addComponent(ruleNameEditTextField, javax.swing.GroupLayout.Alignment.LEADING)
314 .addComponent(descriptionEditTextField, javax.swing.GroupLayout.Alignment.LEADING)
315 .addComponent(extensionsTextField, javax.swing.GroupLayout.Alignment.LEADING)
316 .addComponent(fullPathsScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
317 .addComponent(filenamesScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
318 .addComponent(folderNamesScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
319 .addGroup(layout.createSequentialGroup()
320 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
321 .addComponent(shouldSaveCheckBox)
322 .addComponent(shouldAlertCheckBox)
323 .addGroup(layout.createSequentialGroup()
324 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 .addComponent(modifiedDateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
326 .addComponent(fileSizeLabel))
328 .addComponent(minSizeLabel)
329 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
330 .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
332 .addComponent(maxSizeLabel)
333 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
334 .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
335 .addGroup(layout.createSequentialGroup()
336 .addGap(129, 129, 129)
337 .addComponent(modifiedWithinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
338 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
339 .addComponent(daysIncludedLabel)))
340 .addGap(0, 0, Short.MAX_VALUE)))
341 .addContainerGap())))
342 .addGroup(layout.createSequentialGroup()
343 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
344 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
345 .addGroup(layout.createSequentialGroup()
346 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
347 .addComponent(flagEncryptionProgramsCheckBox)
348 .addComponent(finalizeImageWriter)
349 .addComponent(promptBeforeExit)
350 .addComponent(createVHDCheckBox))
351 .addGap(0, 0, Short.MAX_VALUE))
352 .addComponent(jSeparator1)))))
355 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {deleteRuleButton, editRuleButton, newRuleButton});
357 layout.setVerticalGroup(
358 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
359 .addGroup(layout.createSequentialGroup()
361 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
362 .addComponent(configFileTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
363 .addComponent(ruleSetFileLabel))
364 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
365 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
366 .addGroup(layout.createSequentialGroup()
367 .addComponent(rulesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
368 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
369 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
370 .addComponent(newRuleButton)
371 .addComponent(editRuleButton)
372 .addComponent(deleteRuleButton))
374 .addGroup(layout.createSequentialGroup()
375 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
376 .addGroup(layout.createSequentialGroup()
378 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
379 .addComponent(descriptionEditTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
380 .addComponent(descriptionLabel))
382 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
383 .addComponent(extensionsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
384 .addComponent(extensionsLabel)))
385 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
386 .addComponent(ruleNameEditTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
387 .addComponent(ruleNameLabel)))
388 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
389 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
390 .addComponent(filenamesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
391 .addComponent(filenamesLabel))
393 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
394 .addComponent(folderNamesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
395 .addComponent(folderNamesLabel))
397 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
398 .addComponent(fullPathsLabel)
399 .addComponent(fullPathsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
400 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
401 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
402 .addComponent(minSizeLabel)
403 .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
404 .addComponent(maxSizeLabel)
405 .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
406 .addComponent(fileSizeLabel))
407 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
408 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
409 .addComponent(modifiedDateLabel)
410 .addComponent(modifiedWithinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
411 .addComponent(daysIncludedLabel))
412 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
413 .addComponent(shouldSaveCheckBox)
414 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
415 .addComponent(shouldAlertCheckBox)
417 .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
418 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
419 .addComponent(flagEncryptionProgramsCheckBox)
420 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
421 .addComponent(finalizeImageWriter)
422 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
423 .addComponent(promptBeforeExit)
424 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
425 .addComponent(createVHDCheckBox))))
429 private void rulesTableKeyReleased(java.awt.event.KeyEvent evt) {
430 updateForSelectedRule();
434 "ConfigVisualPanel2.editRuleSet=Edit Rule",
435 "ConfigVisualPanel2.editRuleError=Edit rule error"
437 private void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
438 int row = rulesTable.getSelectedRow();
440 String ruleName = (String) rulesTable.getModel().getValueAt(row, 0);
441 LogicalImagerRule rule = getRuleSetFromCurrentConfig().getRules().get(row);
442 EditRulePanel editPanel =
new EditRulePanel(okButton, cancelButton, ruleName, rule);
443 editPanel.setEnabled(
true);
444 editPanel.setVisible(
true);
447 int option = JOptionPane.showOptionDialog(
this, editPanel.getPanel(), Bundle.ConfigVisualPanel2_editRuleSet(),
448 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
449 null,
new Object[]{okButton, cancelButton}, okButton);
450 if (option == JOptionPane.OK_OPTION) {
452 ImmutablePair<String, LogicalImagerRule> ruleMap = editPanel.toRule();
453 if (!ruleName.equals(ruleMap.getKey()) && ruleExists(ruleMap)) {
454 JOptionPane.showMessageDialog(
this,
455 Bundle.ConfigVisualPanel2_newRuleError_duplicateName(ruleMap.getKey()),
456 Bundle.ConfigVisualPanel2_editRuleError(),
457 JOptionPane.ERROR_MESSAGE);
460 updateRow(row, ruleMap);
462 }
catch (IOException | NumberFormatException ex) {
463 JOptionPane.showMessageDialog(
this,
465 Bundle.ConfigVisualPanel2_editRuleError(),
466 JOptionPane.ERROR_MESSAGE);
476 @Messages({
"ConfigVisualPanel2.newRule.name=New Rule",
477 "ConfigVisualPanel2.newRuleError.title=New rule error",
479 "ConfigVisualPanel2.newRuleError.duplicateName=A rule with name \"{0}\" already exists. Please enter a different rule name"})
480 private void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
482 panel =
new NewRulePanel(okButton, cancelButton);
483 panel.setEnabled(
true);
484 panel.setVisible(
true);
487 int option = JOptionPane.showOptionDialog(
this, panel, Bundle.ConfigVisualPanel2_newRule_name(),
488 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
489 null,
new Object[]{okButton, cancelButton}, okButton);
490 if (option == JOptionPane.OK_OPTION) {
493 ImmutablePair<String, LogicalImagerRule> ruleMap = panel.toRule();
494 if (ruleExists(ruleMap)) {
495 JOptionPane.showMessageDialog(
this,
496 Bundle.ConfigVisualPanel2_newRuleError_duplicateName(ruleMap.getKey()),
497 Bundle.ConfigVisualPanel2_newRuleError_title(),
498 JOptionPane.ERROR_MESSAGE);
504 }
catch (IOException | NumberFormatException ex) {
505 JOptionPane.showMessageDialog(
this,
507 Bundle.ConfigVisualPanel2_newRuleError_title(),
508 JOptionPane.ERROR_MESSAGE);
518 "ConfigVisualPanel2.deleteRuleSet=Delete rule ",
519 "ConfigVisualPanel2.deleteRuleSetConfirmation=Delete rule confirmation",})
520 private void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {
521 int index = rulesTable.getSelectedRow();
523 String ruleName = (String) rulesTable.getModel().getValueAt(index, 0);
525 int option = JOptionPane.showOptionDialog(
this,
526 Bundle.ConfigVisualPanel2_deleteRuleSet() + ruleName,
527 Bundle.ConfigVisualPanel2_deleteRuleSetConfirmation(),
528 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
529 if (option == JOptionPane.NO_OPTION) {
533 getRuleSetFromCurrentConfig().getRules().remove(index);
534 updatePanel(configFilename, config);
535 if (rulesTable.getRowCount() > 0) {
536 rulesTable.setRowSelectionInterval(0, 0);
537 updateForSelectedRule();
542 private void rulesTableMouseReleased(java.awt.event.MouseEvent evt) {
543 updateForSelectedRule();
546 private void flagEncryptionProgramsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
547 flagEncryptionPrograms = flagEncryptionProgramsCheckBox.isSelected();
548 setEnabledEncryptionProgramsRule(flagEncryptionPrograms);
551 private void finalizeImageWriterActionPerformed(java.awt.event.ActionEvent evt) {
552 config.setFinalizeImageWriter(finalizeImageWriter.isSelected());
555 private void promptBeforeExitActionPerformed(java.awt.event.ActionEvent evt) {
556 config.setPromptBeforeExit(promptBeforeExit.isSelected());
559 private void createVHDCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
560 config.setCreateVHD(createVHDCheckBox.isSelected());
570 private void setEnabledEncryptionProgramsRule(
boolean flagEncryptionPrograms) {
571 if (flagEncryptionPrograms) {
573 ImmutablePair<String, LogicalImagerRule> ruleMap = createEncryptionProgramsRule();
577 int index = ((RulesTableModel) rulesTable.getModel()).findRow(EncryptionProgramsRule.getName());
579 getRuleSetFromCurrentConfig().getRules().remove(index);
580 updatePanel(configFilename, config);
581 if (rulesTable.getRowCount() > 0) {
582 rulesTable.setRowSelectionInterval(0, 0);
583 updateForSelectedRule();
592 private ImmutablePair<String, LogicalImagerRule> createEncryptionProgramsRule() {
593 LogicalImagerRule.Builder builder =
new LogicalImagerRule.Builder();
594 builder.getName(EncryptionProgramsRule.getName())
595 .getDescription(EncryptionProgramsRule.getDescription())
596 .getShouldAlert(
true)
598 .getFilenames(EncryptionProgramsRule.getFilenames());
599 LogicalImagerRule rule = builder.build();
600 return new ImmutablePair<>(EncryptionProgramsRule.getName(), rule);
604 private javax.swing.JTextField configFileTextField;
605 private javax.swing.JCheckBox createVHDCheckBox;
606 private javax.swing.JLabel daysIncludedLabel;
607 private javax.swing.JButton deleteRuleButton;
608 private javax.swing.JTextField descriptionEditTextField;
609 private javax.swing.JLabel descriptionLabel;
610 private javax.swing.JButton editRuleButton;
611 private javax.swing.JLabel extensionsLabel;
612 private javax.swing.JTextField extensionsTextField;
613 private javax.swing.JLabel fileSizeLabel;
614 private javax.swing.JLabel filenamesLabel;
615 private javax.swing.JScrollPane filenamesScrollPane;
616 private javax.swing.JTable filenamesTable;
617 private javax.swing.JCheckBox finalizeImageWriter;
618 private javax.swing.JCheckBox flagEncryptionProgramsCheckBox;
619 private javax.swing.JLabel folderNamesLabel;
620 private javax.swing.JScrollPane folderNamesScrollPane;
621 private javax.swing.JTable folderNamesTable;
622 private javax.swing.JLabel fullPathsLabel;
623 private javax.swing.JScrollPane fullPathsScrollPane;
624 private javax.swing.JTable fullPathsTable;
625 private javax.swing.JSeparator jSeparator1;
626 private javax.swing.JLabel maxSizeLabel;
627 private javax.swing.JFormattedTextField maxSizeTextField;
628 private javax.swing.JLabel minSizeLabel;
629 private javax.swing.JFormattedTextField minSizeTextField;
630 private javax.swing.JLabel modifiedDateLabel;
631 private javax.swing.JTextField modifiedWithinTextField;
632 private javax.swing.JButton newRuleButton;
633 private javax.swing.JCheckBox promptBeforeExit;
634 private javax.swing.JTextField ruleNameEditTextField;
635 private javax.swing.JLabel ruleNameLabel;
636 private javax.swing.JLabel ruleSetFileLabel;
637 private javax.swing.JScrollPane rulesScrollPane;
638 private javax.swing.JTable rulesTable;
639 private javax.swing.JCheckBox shouldAlertCheckBox;
640 private javax.swing.JCheckBox shouldSaveCheckBox;
643 private LogicalImagerRuleSet getRuleSetFromCurrentConfig() {
644 if (config.getRuleSets().isEmpty()) {
645 List<LogicalImagerRuleSet> ruleSets =
new ArrayList<>();
646 ruleSets.add(
new LogicalImagerRuleSet(
"no-set-name",
new ArrayList<>()));
647 config.setRuleSet(ruleSets);
649 return config.getRuleSets().get(0);
659 private void updatePanel(String configFilePath, LogicalImagerConfig config, String rowSelectionkey) {
660 configFileTextField.setText(configFilePath);
661 finalizeImageWriter.setSelected(config.isFinalizeImageWriter());
662 promptBeforeExit.setSelected(config.isPromptBeforeExit());
663 createVHDCheckBox.setSelected(config.isCreateVHD());
664 LogicalImagerRuleSet ruleSet = getRuleSetFromCurrentConfig();
665 flagEncryptionProgramsCheckBox.setSelected(ruleSet.find(EncryptionProgramsRule.getName()) != null);
666 RulesTableModel rulesTableModel =
new RulesTableModel();
668 int selectThisRow = 0;
670 Collections.sort(ruleSet.getRules(),
new SortRuleByName());
672 for (LogicalImagerRule rule : ruleSet.getRules()) {
673 rulesTableModel.setValueAt(rule.getName(), row, 0);
674 if (rowSelectionkey != null && rowSelectionkey.equals(rule.getName())) {
677 rulesTableModel.setValueAt(rule.getDescription(), row, 1);
678 rulesTableModel.setValueAt(rule, row, 2);
681 rulesTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
682 rulesTable.setModel(rulesTableModel);
684 if (rulesTableModel.getRowCount() > 0) {
685 rulesTable.setRowSelectionInterval(selectThisRow, selectThisRow);
686 updateForSelectedRule();
689 updateRuleButtons(
false);
699 private void updatePanel(String configFilePath, LogicalImagerConfig config) {
700 updatePanel(configFilePath, config, null);
706 private void updateForSelectedRule() {
707 int index = rulesTable.getSelectedRow();
709 String ruleName = (String) rulesTable.getModel().getValueAt(index, 0);
710 String description = (String) rulesTable.getModel().getValueAt(index, 1);
711 updateRuleDetails(ruleName, description);
712 updateRuleButtons(!ruleName.equals(EncryptionProgramsRule.getName()));
715 updateRuleButtons(
false);
725 private void updateRuleDetails(String ruleName, String description) {
727 LogicalImagerRule rule = getRuleSetFromCurrentConfig().find(ruleName);
728 shouldAlertCheckBox.setSelected(rule.isShouldAlert());
729 shouldSaveCheckBox.setSelected(rule.isShouldSave());
730 ruleNameEditTextField.setText(ruleName);
731 descriptionEditTextField.setText(description);
732 updateExtensions(rule.getExtensions());
733 updateList(filenamesTable, rule.getFilenames());
734 updateList(folderNamesTable, rule.getPaths());
735 updateList(fullPathsTable, rule.getFullPaths());
736 if (rule.getMinFileSize() == null) {
737 minSizeTextField.setText(
"");
739 minSizeTextField.setText(rule.getMinFileSize().toString());
741 if (rule.getMaxFileSize() == null) {
742 maxSizeTextField.setText(
"");
744 maxSizeTextField.setText(rule.getMaxFileSize().toString());
746 if (rule.getMinDays() == null) {
747 modifiedWithinTextField.setText(
"");
749 modifiedWithinTextField.setText(Integer.toString(rule.getMinDays()));
756 private void clearRuleDetails() {
757 ruleNameEditTextField.setText(
"");
758 descriptionEditTextField.setText(
"");
759 extensionsTextField.setText(
"");
760 updateExtensions(null);
761 updateList(filenamesTable, null);
762 updateList(folderNamesTable, null);
763 updateList(fullPathsTable, null);
764 minSizeTextField.setText(
"");
765 maxSizeTextField.setText(
"");
766 modifiedWithinTextField.setText(
"");
767 shouldSaveCheckBox.setSelected(
true);
768 shouldAlertCheckBox.setSelected(
false);
777 private void updateExtensions(List<String> extensions) {
778 extensionsTextField.setText(
"");
779 if (extensions == null) {
783 boolean first =
true;
784 for (String ext : extensions) {
785 content += (first ?
"" :
",") + ext;
788 extensionsTextField.setText(content);
797 private void updateList(javax.swing.JTable jTable, List<String> list) {
798 SingleColumnTableModel tableModel =
new SingleColumnTableModel();
799 jTable.setTableHeader(null);
801 jTable.setModel(tableModel);
805 for (String s : list) {
806 tableModel.setValueAt(s, row, 0);
809 jTable.setModel(tableModel);
812 void setConfiguration(String configFilename, LogicalImagerConfig config) {
813 this.configFilename = configFilename;
814 this.config = config;
815 updatePanel(configFilename, config);
818 private void updateRow(
int index, ImmutablePair<String, LogicalImagerRule> ruleMap) {
819 getRuleSetFromCurrentConfig().getRules().remove(index);
820 getRuleSetFromCurrentConfig().getRules().add(ruleMap.getValue());
821 updatePanel(configFilename, config, ruleMap.getKey());
831 private boolean ruleExists(ImmutablePair<String, LogicalImagerRule> ruleMap) {
832 for (LogicalImagerRule rule : getRuleSetFromCurrentConfig().getRules()) {
833 if (rule.getName().equals(ruleMap.getKey())) {
840 private void appendRow(ImmutablePair<String, LogicalImagerRule> ruleMap) {
841 getRuleSetFromCurrentConfig().getRules().add(ruleMap.getValue());
842 updatePanel(configFilename, config, ruleMap.getKey());
851 private void updateRuleButtons(
boolean isRowSelected) {
852 newRuleButton.setEnabled(
true);
853 editRuleButton.setEnabled(isRowSelected);
854 deleteRuleButton.setEnabled(isRowSelected);
863 public int compare(LogicalImagerRule a, LogicalImagerRule b) {
864 return a.getName().compareToIgnoreCase(b.getName());
873 private static final long serialVersionUID = 1L;
874 private final List<String> ruleName =
new ArrayList<>();
876 private final List<LogicalImagerRule> rule =
new ArrayList<>();
878 int findRow(String name) {
879 return ruleName.indexOf(name);
884 return ruleName.size();
893 "ConfigVisualPanel2.rulesTable.columnModel.title0=Rule Name",
894 "ConfigVisualPanel2.rulesTable.columnModel.title1=Description"
898 String colName = null;
901 colName = Bundle.ConfigVisualPanel2_rulesTable_columnModel_title0();
904 colName = Bundle.ConfigVisualPanel2_rulesTable_columnModel_title1();
915 switch (columnIndex) {
917 ret = ruleName.get(rowIndex);
920 ret = ruleDescription.get(rowIndex);
923 ret = rule.get(rowIndex);
926 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
937 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
938 switch (columnIndex) {
940 ruleName.add((String) aValue);
943 ruleDescription.add((String) aValue);
946 rule.add((LogicalImagerRule) aValue);
949 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
952 if (columnIndex < 2) {
953 super.setValueAt(aValue, rowIndex, columnIndex);
963 private static final long serialVersionUID = 1L;
965 private final List<String> list =
new ArrayList<>();
985 if (columnIndex == 0) {
986 ret = list.get(rowIndex);
988 throw new UnsupportedOperationException(
"Invalid table column index: " + columnIndex);
999 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
1000 if (columnIndex == 0) {
1001 list.add((String) aValue);
1003 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)
Object getValueAt(int rowIndex, int columnIndex)