Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
InterestingItemDefsPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.interestingitems;
20 
21 import java.awt.EventQueue;
22 import java.awt.Font;
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.TreeMap;
26 import javax.swing.DefaultListModel;
27 import javax.swing.JOptionPane;
28 import javax.swing.event.ListSelectionEvent;
29 import javax.swing.event.ListSelectionListener;
30 import org.openide.util.NbBundle;
34 
38 final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
39 
40  private final DefaultListModel<FilesSet> setsListModel = new DefaultListModel<>();
41  private final DefaultListModel<FilesSet.Rule> rulesListModel = new DefaultListModel<>();
42 
43  // The following is a map of interesting files set names to interesting
44  // files set definitions. It is a snapshot of the files set definitions
45  // obtained from the interesting item definitions manager at the time the
46  // the panel is loaded. When the panel saves or stores its settings, these
47  // definitions, possibly changed, are submitted back to the interesting item
48  // definitions manager. Note that it is a tree map to aid in displaying
49  // files sets in sorted order by name.
50  private TreeMap<String, FilesSet> filesSets;
51 
55  InterestingItemDefsPanel() {
56  this.initComponents();
57  this.setsList.setModel(setsListModel);
58  this.setsList.addListSelectionListener(new InterestingItemDefsPanel.SetsListSelectionListener());
59  this.rulesList.setModel(rulesListModel);
60  this.rulesList.addListSelectionListener(new InterestingItemDefsPanel.RulesListSelectionListener());
61  }
62 
66  @Override
67  public void saveSettings() {
68  InterestingItemDefsManager.getInstance().setInterestingFilesSets(this.filesSets);
69  }
70 
74  @Override
75  public void store() {
76  this.saveSettings();
77  }
78 
82  @Override
83  public void load() {
84  this.resetComponents();
85 
86  // Get a working copy of the interesting files set definitions and sort
87  // by set name.
88  this.filesSets = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
89 
90  // Populate the list model for the interesting files sets list
91  // component.
92  for (FilesSet set : this.filesSets.values()) {
93  this.setsListModel.addElement(set);
94  }
95 
96  if (!this.filesSets.isEmpty()) {
97  // Select the first files set by default. The list selections
98  // listeners will then populate the other components.
99  EventQueue.invokeLater(() -> {
100  InterestingItemDefsPanel.this.setsList.setSelectedIndex(0);
101  });
102  }
103  }
104 
108  private void resetComponents() {
109  this.resetRuleComponents();
110  this.setsListModel.clear();
111  this.setDescriptionTextArea.setText("");
112  this.ignoreKnownFilesCheckbox.setSelected(true);
113  this.newSetButton.setEnabled(true);
114  this.editSetButton.setEnabled(false);
115  this.deleteSetButton.setEnabled(false);
116  }
117 
122  private void resetRuleComponents() {
123  this.fileNameTextField.setText("");
124  this.fileNameRadioButton.setSelected(true);
125  this.fileNameRegexCheckbox.setSelected(false);
126  this.filesRadioButton.setSelected(true);
127  this.rulePathFilterTextField.setText("");
128  this.rulePathFilterRegexCheckBox.setSelected(false);
129  this.newRuleButton.setEnabled(!this.setsListModel.isEmpty());
130  this.editRuleButton.setEnabled(false);
131  this.deleteRuleButton.setEnabled(false);
132  }
133 
137  private final class SetsListSelectionListener implements ListSelectionListener {
138 
139  @Override
140  public void valueChanged(ListSelectionEvent e) {
141  if (e.getValueIsAdjusting()) {
142  return;
143  }
144 
145  InterestingItemDefsPanel.this.rulesListModel.clear();
146  InterestingItemDefsPanel.this.resetRuleComponents();
147 
148  // Get the selected interesting files set and populate the set
149  // components.
150  FilesSet selectedSet = InterestingItemDefsPanel.this.setsList.getSelectedValue();
151  if (selectedSet != null) {
152  // Populate the components that display the properties of the
153  // selected files set.
154  InterestingItemDefsPanel.this.setDescriptionTextArea.setText(selectedSet.getDescription());
155  InterestingItemDefsPanel.this.ignoreKnownFilesCheckbox.setSelected(selectedSet.ignoresKnownFiles());
156 
157  // Enable the new, edit and delete set buttons.
158  InterestingItemDefsPanel.this.newSetButton.setEnabled(true);
159  InterestingItemDefsPanel.this.editSetButton.setEnabled(true);
160  InterestingItemDefsPanel.this.deleteSetButton.setEnabled(true);
161 
162  // Populate the rule definitions list, sorted by name.
163  TreeMap<String, FilesSet.Rule> rules = new TreeMap<>(selectedSet.getRules());
164  for (FilesSet.Rule rule : rules.values()) {
165  InterestingItemDefsPanel.this.rulesListModel.addElement(rule);
166  }
167 
168  // Select the first rule by default.
169  if (!InterestingItemDefsPanel.this.rulesListModel.isEmpty()) {
170  InterestingItemDefsPanel.this.rulesList.setSelectedIndex(0);
171  }
172  }
173  }
174 
175  }
176 
181  private final class RulesListSelectionListener implements ListSelectionListener {
182 
183  @Override
184  public void valueChanged(ListSelectionEvent e) {
185  if (e.getValueIsAdjusting()) {
186  return;
187  }
188 
189  // Get the selected rule and populate the rule components.
190  FilesSet.Rule rule = InterestingItemDefsPanel.this.rulesList.getSelectedValue();
191  if (rule != null) {
192  // Get the filters that make up the rule.
193  FilesSet.Rule.FileNameFilter nameFilter = rule.getFileNameFilter();
194  FilesSet.Rule.MetaTypeFilter typeFilter = rule.getMetaTypeFilter();
195  FilesSet.Rule.ParentPathFilter pathFilter = rule.getPathFilter();
196 
197  // Populate the components that display the properties of the
198  // selected rule.
199  InterestingItemDefsPanel.this.fileNameTextField.setText(nameFilter.getTextToMatch());
200  InterestingItemDefsPanel.this.fileNameRadioButton.setSelected(nameFilter instanceof FilesSet.Rule.FullNameFilter);
201  InterestingItemDefsPanel.this.fileNameExtensionRadioButton.setSelected(nameFilter instanceof FilesSet.Rule.ExtensionFilter);
202  InterestingItemDefsPanel.this.fileNameRegexCheckbox.setSelected(nameFilter.isRegex());
203  switch (typeFilter.getMetaType()) {
204  case FILES:
205  InterestingItemDefsPanel.this.filesRadioButton.setSelected(true);
206  break;
207  case DIRECTORIES:
208  InterestingItemDefsPanel.this.dirsRadioButton.setSelected(true);
209  break;
210  case FILES_AND_DIRECTORIES:
211  InterestingItemDefsPanel.this.bothRadioButton.setSelected(true);
212  break;
213  }
214  if (pathFilter != null) {
215  InterestingItemDefsPanel.this.rulePathFilterTextField.setText(pathFilter.getTextToMatch());
216  InterestingItemDefsPanel.this.rulePathFilterRegexCheckBox.setSelected(pathFilter.isRegex());
217  } else {
218  InterestingItemDefsPanel.this.rulePathFilterTextField.setText("");
219  InterestingItemDefsPanel.this.rulePathFilterRegexCheckBox.setSelected(false);
220  }
221 
222  // Enable the new, edit and delete rule buttons.
223  InterestingItemDefsPanel.this.newRuleButton.setEnabled(true);
224  InterestingItemDefsPanel.this.editRuleButton.setEnabled(true);
225  InterestingItemDefsPanel.this.deleteRuleButton.setEnabled(true);
226  } else {
227  InterestingItemDefsPanel.this.resetRuleComponents();
228  }
229  }
230 
231  }
232 
240  private void doFileSetsDialog(FilesSet selectedSet) {
241  // Create a files set defintion panle.
242  FilesSetPanel panel;
243  if (selectedSet != null) {
244  // Editing an existing set definition.
245  panel = new FilesSetPanel(selectedSet);
246  } else {
247  // Creating a new set definition.
248  panel = new FilesSetPanel();
249  }
250 
251  // Do a dialog box with the files set panel until the user either enters
252  // a valid definition or cancels. Note that the panel gives the user
253  // feedback when isValidDefinition() is called.
254  int option = JOptionPane.OK_OPTION;
255  do {
256  option = JOptionPane.showConfirmDialog(null, panel, NbBundle.getMessage(FilesSetPanel.class, "FilesSetPanel.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
257  } while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
258 
259  // While adding new ruleset(selectedSet == null), if rule set with same name already exists, do not add to the filesSets hashMap.
260  // In case of editing an existing ruleset(selectedSet != null), following check is not performed.
261  if(this.filesSets.containsKey(panel.getFilesSetName()) && selectedSet == null) {
262  MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
263  "InterestingItemDefsPanel.doFileSetsDialog.duplicateRuleSet.text",
264  panel.getFilesSetName()));
265  return;
266  }
267 
268  if (option == JOptionPane.OK_OPTION) {
269  Map<String, FilesSet.Rule> rules = new HashMap<>();
270  if (selectedSet != null) {
271  // Interesting file sets are immutable for thread safety,
272  // so editing a files set definition is a replacement operation.
273  // Preserve the existing rules from the set being edited.
274  rules.putAll(selectedSet.getRules());
275  }
276  this.replaceFilesSet(selectedSet, panel.getFilesSetName(), panel.getFilesSetDescription(), panel.getFileSetIgnoresKnownFiles(), rules);
277  }
278  }
279 
287  private void doFilesSetRuleDialog(FilesSet.Rule selectedRule) {
288  // Create a files set rule panel.
289  FilesSetRulePanel panel;
290  if (selectedRule != null) {
291  // Editing an existing rule definition.
292  panel = new FilesSetRulePanel(selectedRule);
293  } else {
294  // Creating a new rule definition.
295  panel = new FilesSetRulePanel();
296  }
297 
298  // Do a dialog box with the files set panel until the user either enters
299  // a valid definition or cancels. Note that the panel gives the user
300  // feedback when isValidDefinition() is called.
301  int option = JOptionPane.OK_OPTION;
302  do {
303  option = JOptionPane.showConfirmDialog(null, panel, NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
304  } while (option == JOptionPane.OK_OPTION && !panel.isValidRuleDefinition());
305 
306  if (option == JOptionPane.OK_OPTION) {
307  // Interesting file sets are immutable for thread safety,
308  // so editing a files set rule definition is a replacement
309  // operation. Preserve the existing rules from the set being edited.
310  FilesSet selectedSet = this.setsList.getSelectedValue();
311  Map<String, FilesSet.Rule> rules = new HashMap<>(selectedSet.getRules());
312 
313  // Remove the "old" rule definition and add the new/edited
314  // definition.
315  if (selectedRule != null) {
316  rules.remove(selectedRule.getUuid());
317  }
318  FilesSet.Rule newRule = new FilesSet.Rule(panel.getRuleName(), panel.getFileNameFilter(), panel.getMetaTypeFilter(), panel.getPathFilter());
319  rules.put(newRule.getUuid(), newRule);
320 
321  // Add the new/edited files set definition, replacing any previous
322  // definition with the same name and refreshing the display.
323  this.replaceFilesSet(selectedSet, selectedSet.getName(), selectedSet.getDescription(), selectedSet.ignoresKnownFiles(), rules);
324 
325  // Select the new/edited rule. Queue it up so it happens after the
326  // selection listeners react to the selection of the "new" files
327  // set.
328  EventQueue.invokeLater(() -> {
329  this.rulesList.setSelectedValue(newRule, true);
330  });
331  }
332  }
333 
346  void replaceFilesSet(FilesSet oldSet, String name, String description, boolean ignoresKnownFiles, Map<String, FilesSet.Rule> rules) {
347  if (oldSet != null) {
348  // Remove the set to be replaced from the working copy if the files
349  // set definitions.
350  this.filesSets.remove(oldSet.getName());
351  }
352 
353  // Make the new/edited set definition and add it to the working copy of
354  // the files set definitions.
355  FilesSet newSet = new FilesSet(name, description, ignoresKnownFiles, rules);
356  this.filesSets.put(newSet.getName(), newSet);
357 
358  // Redo the list model for the files set list component, which will make
359  // everything stays sorted as in the working copy tree set.
360  InterestingItemDefsPanel.this.setsListModel.clear();
361  for (FilesSet set : this.filesSets.values()) {
362  this.setsListModel.addElement(set);
363  }
364 
365  // Select the new/edited files set definition in the set definitions
366  // list. This will cause the selection listeners to repopulate the
367  // subordinate components.
368  this.setsList.setSelectedValue(newSet, true);
369  }
370 
376  @SuppressWarnings("unchecked")
377  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
378  private void initComponents() {
379 
380  fileNameButtonGroup = new javax.swing.ButtonGroup();
381  jScrollPane1 = new javax.swing.JScrollPane();
382  jPanel1 = new javax.swing.JPanel();
383  jLabel6 = new javax.swing.JLabel();
384  newRuleButton = new javax.swing.JButton();
385  filesRadioButton = new javax.swing.JRadioButton();
386  editRuleButton = new javax.swing.JButton();
387  rulesListLabel = new javax.swing.JLabel();
388  rulesListScrollPane = new javax.swing.JScrollPane();
389  rulesList = new javax.swing.JList<FilesSet.Rule>();
390  setDescScrollPanel = new javax.swing.JScrollPane();
391  setDescriptionTextArea = new javax.swing.JTextArea();
392  editSetButton = new javax.swing.JButton();
393  setsListScrollPane = new javax.swing.JScrollPane();
394  setsList = new javax.swing.JList<FilesSet>();
395  fileNameExtensionRadioButton = new javax.swing.JRadioButton();
396  jLabel3 = new javax.swing.JLabel();
397  fileNameTextField = new javax.swing.JTextField();
398  jLabel5 = new javax.swing.JLabel();
399  fileNameRadioButton = new javax.swing.JRadioButton();
400  rulePathFilterTextField = new javax.swing.JTextField();
401  ignoreKnownFilesCheckbox = new javax.swing.JCheckBox();
402  fileNameRegexCheckbox = new javax.swing.JCheckBox();
403  separator = new javax.swing.JSeparator();
404  setsListLabel = new javax.swing.JLabel();
405  bothRadioButton = new javax.swing.JRadioButton();
406  deleteSetButton = new javax.swing.JButton();
407  deleteRuleButton = new javax.swing.JButton();
408  newSetButton = new javax.swing.JButton();
409  jLabel2 = new javax.swing.JLabel();
410  dirsRadioButton = new javax.swing.JRadioButton();
411  jLabel1 = new javax.swing.JLabel();
412  jLabel4 = new javax.swing.JLabel();
413  rulePathFilterRegexCheckBox = new javax.swing.JCheckBox();
414  jScrollPane2 = new javax.swing.JScrollPane();
415  jTextArea1 = new javax.swing.JTextArea();
416 
417  org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel6.text")); // NOI18N
418 
419  newRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
420  org.openide.awt.Mnemonics.setLocalizedText(newRuleButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.newRuleButton.text")); // NOI18N
421  newRuleButton.setEnabled(false);
422  newRuleButton.addActionListener(new java.awt.event.ActionListener() {
423  public void actionPerformed(java.awt.event.ActionEvent evt) {
424  newRuleButtonActionPerformed(evt);
425  }
426  });
427 
428  filesRadioButton.setSelected(true);
429  org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.filesRadioButton.text")); // NOI18N
430  filesRadioButton.setEnabled(false);
431 
432  editRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
433  org.openide.awt.Mnemonics.setLocalizedText(editRuleButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.editRuleButton.text")); // NOI18N
434  editRuleButton.setEnabled(false);
435  editRuleButton.addActionListener(new java.awt.event.ActionListener() {
436  public void actionPerformed(java.awt.event.ActionEvent evt) {
437  editRuleButtonActionPerformed(evt);
438  }
439  });
440 
441  org.openide.awt.Mnemonics.setLocalizedText(rulesListLabel, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulesListLabel.text")); // NOI18N
442 
443  rulesList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
444  rulesListScrollPane.setViewportView(rulesList);
445 
446  setDescriptionTextArea.setEditable(false);
447  setDescriptionTextArea.setBackground(new java.awt.Color(240, 240, 240));
448  setDescriptionTextArea.setColumns(20);
449  setDescriptionTextArea.setLineWrap(true);
450  setDescriptionTextArea.setRows(2);
451  setDescScrollPanel.setViewportView(setDescriptionTextArea);
452 
453  editSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/edit16.png"))); // NOI18N
454  org.openide.awt.Mnemonics.setLocalizedText(editSetButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.editSetButton.text")); // NOI18N
455  editSetButton.setEnabled(false);
456  editSetButton.addActionListener(new java.awt.event.ActionListener() {
457  public void actionPerformed(java.awt.event.ActionEvent evt) {
458  editSetButtonActionPerformed(evt);
459  }
460  });
461 
462  setsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
463  setsListScrollPane.setViewportView(setsList);
464 
465  fileNameButtonGroup.add(fileNameExtensionRadioButton);
466  org.openide.awt.Mnemonics.setLocalizedText(fileNameExtensionRadioButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.fileNameExtensionRadioButton.text")); // NOI18N
467  fileNameExtensionRadioButton.setEnabled(false);
468 
469  org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel3.text")); // NOI18N
470 
471  fileNameTextField.setEditable(false);
472  fileNameTextField.setText(org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.fileNameTextField.text")); // NOI18N
473 
474  org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel5.text")); // NOI18N
475 
476  fileNameButtonGroup.add(fileNameRadioButton);
477  org.openide.awt.Mnemonics.setLocalizedText(fileNameRadioButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.fileNameRadioButton.text")); // NOI18N
478  fileNameRadioButton.setEnabled(false);
479 
480  rulePathFilterTextField.setEditable(false);
481  rulePathFilterTextField.setText(org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulePathFilterTextField.text")); // NOI18N
482 
483  org.openide.awt.Mnemonics.setLocalizedText(ignoreKnownFilesCheckbox, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.ignoreKnownFilesCheckbox.text")); // NOI18N
484  ignoreKnownFilesCheckbox.setEnabled(false);
485  ignoreKnownFilesCheckbox.addActionListener(new java.awt.event.ActionListener() {
486  public void actionPerformed(java.awt.event.ActionEvent evt) {
487  ignoreKnownFilesCheckboxActionPerformed(evt);
488  }
489  });
490 
491  org.openide.awt.Mnemonics.setLocalizedText(fileNameRegexCheckbox, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.fileNameRegexCheckbox.text")); // NOI18N
492  fileNameRegexCheckbox.setEnabled(false);
493 
494  separator.setOrientation(javax.swing.SwingConstants.VERTICAL);
495 
496  org.openide.awt.Mnemonics.setLocalizedText(setsListLabel, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.setsListLabel.text")); // NOI18N
497 
498  org.openide.awt.Mnemonics.setLocalizedText(bothRadioButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.bothRadioButton.text")); // NOI18N
499  bothRadioButton.setEnabled(false);
500 
501  deleteSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
502  org.openide.awt.Mnemonics.setLocalizedText(deleteSetButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.deleteSetButton.text")); // NOI18N
503  deleteSetButton.setEnabled(false);
504  deleteSetButton.addActionListener(new java.awt.event.ActionListener() {
505  public void actionPerformed(java.awt.event.ActionEvent evt) {
506  deleteSetButtonActionPerformed(evt);
507  }
508  });
509 
510  deleteRuleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/delete16.png"))); // NOI18N
511  org.openide.awt.Mnemonics.setLocalizedText(deleteRuleButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.deleteRuleButton.text")); // NOI18N
512  deleteRuleButton.setEnabled(false);
513  deleteRuleButton.addActionListener(new java.awt.event.ActionListener() {
514  public void actionPerformed(java.awt.event.ActionEvent evt) {
515  deleteRuleButtonActionPerformed(evt);
516  }
517  });
518 
519  newSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/add16.png"))); // NOI18N
520  org.openide.awt.Mnemonics.setLocalizedText(newSetButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.newSetButton.text")); // NOI18N
521  newSetButton.addActionListener(new java.awt.event.ActionListener() {
522  public void actionPerformed(java.awt.event.ActionEvent evt) {
523  newSetButtonActionPerformed(evt);
524  }
525  });
526 
527  org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel2.text")); // NOI18N
528 
529  org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.dirsRadioButton.text")); // NOI18N
530  dirsRadioButton.setEnabled(false);
531  dirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
532  public void actionPerformed(java.awt.event.ActionEvent evt) {
533  dirsRadioButtonActionPerformed(evt);
534  }
535  });
536 
537  org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel1.text")); // NOI18N
538 
539  org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel4.text")); // NOI18N
540 
541  org.openide.awt.Mnemonics.setLocalizedText(rulePathFilterRegexCheckBox, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulePathFilterRegexCheckBox.text")); // NOI18N
542  rulePathFilterRegexCheckBox.setEnabled(false);
543 
544  jTextArea1.setBackground(new java.awt.Color(240, 240, 240));
545  jTextArea1.setColumns(20);
546  jTextArea1.setFont(jTextArea1.getFont().deriveFont(Font.PLAIN, 11)); // NON-NLS
547  jTextArea1.setLineWrap(true);
548  jTextArea1.setRows(3);
549  jTextArea1.setText(org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jTextArea1.text")); // NOI18N
550  jTextArea1.setWrapStyleWord(true);
551  jScrollPane2.setViewportView(jTextArea1);
552 
553  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
554  jPanel1.setLayout(jPanel1Layout);
555  jPanel1Layout.setHorizontalGroup(
556  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
557  .addGroup(jPanel1Layout.createSequentialGroup()
558  .addContainerGap()
559  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
560  .addComponent(setsListLabel)
561  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
562  .addComponent(setsListScrollPane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
563  .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING))
564  .addGroup(jPanel1Layout.createSequentialGroup()
565  .addComponent(newSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
566  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
567  .addComponent(editSetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
568  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
569  .addComponent(deleteSetButton)))
570  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
571  .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
572  .addGap(10, 10, 10)
573  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
574  .addComponent(rulesListLabel)
575  .addComponent(jLabel5)
576  .addComponent(ignoreKnownFilesCheckbox)
577  .addGroup(jPanel1Layout.createSequentialGroup()
578  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
579  .addComponent(jLabel2)
580  .addComponent(jLabel1))
581  .addGap(18, 18, 18)
582  .addComponent(filesRadioButton)
583  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
584  .addComponent(dirsRadioButton)
585  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
586  .addComponent(bothRadioButton))
587  .addGroup(jPanel1Layout.createSequentialGroup()
588  .addGap(9, 9, 9)
589  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
590  .addGroup(jPanel1Layout.createSequentialGroup()
591  .addGap(2, 2, 2)
592  .addComponent(jLabel3)
593  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
594  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
595  .addGroup(jPanel1Layout.createSequentialGroup()
596  .addComponent(fileNameRadioButton)
597  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
598  .addComponent(fileNameExtensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
599  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
600  .addComponent(fileNameRegexCheckbox))
601  .addComponent(fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)))
602  .addGroup(jPanel1Layout.createSequentialGroup()
603  .addComponent(jLabel4)
604  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
605  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
606  .addComponent(rulePathFilterRegexCheckBox)
607  .addComponent(rulePathFilterTextField)))))
608  .addGroup(jPanel1Layout.createSequentialGroup()
609  .addComponent(newRuleButton)
610  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
611  .addComponent(editRuleButton)
612  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
613  .addComponent(deleteRuleButton))
614  .addComponent(setDescScrollPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE)
615  .addComponent(jLabel6)
616  .addComponent(rulesListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE))
617  .addContainerGap())
618  );
619  jPanel1Layout.setVerticalGroup(
620  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
621  .addGroup(jPanel1Layout.createSequentialGroup()
622  .addContainerGap()
623  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
624  .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, 444, javax.swing.GroupLayout.PREFERRED_SIZE)
625  .addGroup(jPanel1Layout.createSequentialGroup()
626  .addComponent(jLabel6)
627  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
628  .addComponent(jLabel5)
629  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
630  .addComponent(setDescScrollPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
631  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
632  .addComponent(ignoreKnownFilesCheckbox)
633  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
634  .addComponent(rulesListLabel)
635  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
636  .addComponent(rulesListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
637  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
638  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
639  .addComponent(newRuleButton)
640  .addComponent(editRuleButton)
641  .addComponent(deleteRuleButton))
642  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
643  .addComponent(jLabel1)
644  .addGap(2, 2, 2)
645  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
646  .addComponent(jLabel2)
647  .addComponent(filesRadioButton)
648  .addComponent(dirsRadioButton)
649  .addComponent(bothRadioButton))
650  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
651  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
652  .addComponent(jLabel3)
653  .addComponent(fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
654  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
655  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
656  .addComponent(fileNameRadioButton)
657  .addComponent(fileNameExtensionRadioButton)
658  .addComponent(fileNameRegexCheckbox))
659  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
660  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
661  .addComponent(jLabel4)
662  .addComponent(rulePathFilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
663  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
664  .addComponent(rulePathFilterRegexCheckBox))
665  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
666  .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
667  .addGap(18, 18, 18)
668  .addComponent(setsListLabel)
669  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
670  .addComponent(setsListScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
671  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
672  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
673  .addComponent(newSetButton)
674  .addComponent(editSetButton)
675  .addComponent(deleteSetButton))))
676  .addContainerGap())
677  );
678 
679  jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {deleteRuleButton, deleteSetButton, editRuleButton, editSetButton, newRuleButton, newSetButton});
680 
681  jScrollPane1.setViewportView(jPanel1);
682 
683  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
684  this.setLayout(layout);
685  layout.setHorizontalGroup(
686  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
687  .addGroup(layout.createSequentialGroup()
688  .addContainerGap()
689  .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 710, javax.swing.GroupLayout.PREFERRED_SIZE)
690  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
691  );
692  layout.setVerticalGroup(
693  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
694  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
695  .addGap(0, 11, Short.MAX_VALUE)
696  .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 468, javax.swing.GroupLayout.PREFERRED_SIZE))
697  );
698  }// </editor-fold>//GEN-END:initComponents
699 
700  private void newSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newSetButtonActionPerformed
701  this.doFileSetsDialog(null);
702  }//GEN-LAST:event_newSetButtonActionPerformed
703 
704  private void editSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editSetButtonActionPerformed
705  this.doFileSetsDialog(this.setsList.getSelectedValue());
706  }//GEN-LAST:event_editSetButtonActionPerformed
707 
708  private void newRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newRuleButtonActionPerformed
709  this.doFilesSetRuleDialog(null);
710  }//GEN-LAST:event_newRuleButtonActionPerformed
711 
712  private void editRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editRuleButtonActionPerformed
713  this.doFilesSetRuleDialog(this.rulesList.getSelectedValue());
714  }//GEN-LAST:event_editRuleButtonActionPerformed
715 
716  private void deleteSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSetButtonActionPerformed
717  FilesSet selectedSet = this.setsList.getSelectedValue();
718  this.filesSets.remove(selectedSet.getName());
719  this.setsListModel.removeElement(selectedSet);
720 
721  // Select the first of the remaining set definitions. This will cause
722  // the selection listeners to repopulate the subordinate components.
723  if (!this.filesSets.isEmpty()) {
724  this.setsList.setSelectedIndex(0);
725  } else {
726  this.resetComponents();
727  }
728  }//GEN-LAST:event_deleteSetButtonActionPerformed
729 
730  private void deleteRuleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteRuleButtonActionPerformed
731  // Interesting file sets are immutable for thread safety,
732  // so editing a files set rule definition is a replacement
733  // operation. Preserve the existing rules from the set being
734  // edited, except for the deleted rule.
735  FilesSet oldSet = this.setsList.getSelectedValue();
736  Map<String, FilesSet.Rule> rules = new HashMap<>(oldSet.getRules());
737  FilesSet.Rule selectedRule = this.rulesList.getSelectedValue();
738  rules.remove(selectedRule.getUuid());
739  this.replaceFilesSet(oldSet, oldSet.getName(), oldSet.getDescription(), oldSet.ignoresKnownFiles(), rules);
740  }//GEN-LAST:event_deleteRuleButtonActionPerformed
741 
742  private void ignoreKnownFilesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ignoreKnownFilesCheckboxActionPerformed
743  // TODO add your handling code here:
744  }//GEN-LAST:event_ignoreKnownFilesCheckboxActionPerformed
745 
746  private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed
747  // TODO add your handling code here:
748  }//GEN-LAST:event_dirsRadioButtonActionPerformed
749 
750  // Variables declaration - do not modify//GEN-BEGIN:variables
751  private javax.swing.JRadioButton bothRadioButton;
752  private javax.swing.JButton deleteRuleButton;
753  private javax.swing.JButton deleteSetButton;
754  private javax.swing.JRadioButton dirsRadioButton;
755  private javax.swing.JButton editRuleButton;
756  private javax.swing.JButton editSetButton;
757  private javax.swing.ButtonGroup fileNameButtonGroup;
758  private javax.swing.JRadioButton fileNameExtensionRadioButton;
759  private javax.swing.JRadioButton fileNameRadioButton;
760  private javax.swing.JCheckBox fileNameRegexCheckbox;
761  private javax.swing.JTextField fileNameTextField;
762  private javax.swing.JRadioButton filesRadioButton;
763  private javax.swing.JCheckBox ignoreKnownFilesCheckbox;
764  private javax.swing.JLabel jLabel1;
765  private javax.swing.JLabel jLabel2;
766  private javax.swing.JLabel jLabel3;
767  private javax.swing.JLabel jLabel4;
768  private javax.swing.JLabel jLabel5;
769  private javax.swing.JLabel jLabel6;
770  private javax.swing.JPanel jPanel1;
771  private javax.swing.JScrollPane jScrollPane1;
772  private javax.swing.JScrollPane jScrollPane2;
773  private javax.swing.JTextArea jTextArea1;
774  private javax.swing.JButton newRuleButton;
775  private javax.swing.JButton newSetButton;
776  private javax.swing.JCheckBox rulePathFilterRegexCheckBox;
777  private javax.swing.JTextField rulePathFilterTextField;
778  private javax.swing.JList<FilesSet.Rule> rulesList;
779  private javax.swing.JLabel rulesListLabel;
780  private javax.swing.JScrollPane rulesListScrollPane;
781  private javax.swing.JSeparator separator;
782  private javax.swing.JScrollPane setDescScrollPanel;
783  private javax.swing.JTextArea setDescriptionTextArea;
784  private javax.swing.JList<FilesSet> setsList;
785  private javax.swing.JLabel setsListLabel;
786  private javax.swing.JScrollPane setsListScrollPane;
787  // End of variables declaration//GEN-END:variables
788 
789 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.