19 package org.sleuthkit.autopsy.modules.interestingitems;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.ArrayList;
24 import java.util.HashSet;
25 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.regex.Pattern;
29 import java.util.regex.PatternSyntaxException;
30 import javax.swing.JButton;
31 import javax.swing.JComponent;
32 import javax.swing.JOptionPane;
33 import org.openide.DialogDisplayer;
34 import org.openide.NotifyDescriptor;
35 import org.openide.util.NbBundle;
36 import org.openide.util.NbBundle.Messages;
44 final class FilesSetRulePanel
extends javax.swing.JPanel {
47 "FilesSetRulePanel.bytes=Bytes",
48 "FilesSetRulePanel.kiloBytes=Kilobytes",
49 "FilesSetRulePanel.megaBytes=Megabytes",
50 "FilesSetRulePanel.gigaBytes=Gigabytes",
51 "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
52 "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
53 "FilesSetRulePanel.NoNameError=Name cannot be empty",
54 "FilesSetRulePanel.NoPathError=Path cannot be empty",
55 "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
58 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
59 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
60 private static final List<String> ILLEGAL_FILE_NAME_CHARS = InterestingItemDefsManager.getIllegalFileNameChars();
61 private static final List<String> ILLEGAL_FILE_PATH_CHARS = InterestingItemDefsManager.getIllegalFilePathChars();
62 private JButton okButton;
63 private JButton cancelButton;
68 FilesSetRulePanel(JButton okButton, JButton cancelButton) {
70 populateMimeTypesComboBox();
71 populateComponentsWithDefaultValues();
72 this.setButtons(okButton, cancelButton);
80 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton) {
82 populateMimeTypesComboBox();
83 populateRuleNameComponent(rule);
84 populateTypeConditionComponents(rule);
85 populateNameConditionComponents(rule);
86 populatePathConditionComponents(rule);
87 populateMimeConditionComponents(rule);
88 populateSizeConditionComponents(rule);
89 this.setButtons(okButton, cancelButton);
95 private void populateComponentsWithDefaultValues() {
96 this.filesRadioButton.setSelected(
true);
97 this.fullNameRadioButton.setSelected(
true);
98 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
99 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
100 this.mimeTypeComboBox.setSelectedIndex(0);
103 private void populateMimeTypesComboBox() {
104 Set<String> fileTypesCollated =
new HashSet<>();
105 for (String mediaType : FileTypeDetector.getStandardDetectedTypes()) {
106 fileTypesCollated.add(mediaType);
109 FileTypeDetector fileTypeDetector;
111 fileTypeDetector =
new FileTypeDetector();
112 List<String> userDefinedFileTypes = fileTypeDetector.getUserDefinedTypes();
113 fileTypesCollated.addAll(userDefinedFileTypes);
115 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
116 logger.log(Level.SEVERE,
"Unable to get user defined file types", ex);
119 List<String> toSort =
new ArrayList<>(fileTypesCollated);
120 toSort.sort((String string1, String string2) -> {
121 int result = String.CASE_INSENSITIVE_ORDER.compare(string1, string2);
123 result = string1.compareTo(string2);
128 for (String file : toSort) {
129 mimeTypeComboBox.addItem(file);
139 private void populateRuleNameComponent(FilesSet.Rule rule) {
140 this.ruleNameTextField.setText(rule.getName());
143 private void populateMimeConditionComponents(FilesSet.Rule rule) {
144 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
145 if (mimeTypeCondition != null) {
146 this.mimeCheck.setSelected(
true);
147 this.mimeCheckActionPerformed(null);
148 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
152 private void populateSizeConditionComponents(FilesSet.Rule rule) {
153 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
154 if (fileSizeCondition != null) {
155 this.fileSizeCheck.setSelected(
true);
156 this.fileSizeCheckActionPerformed(null);
157 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
158 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
159 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
167 private void setOkButton() {
168 if (this.okButton != null) {
169 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
170 || this.nameCheck.isSelected() || this.pathCheck.isSelected());
181 private JOptionPane getOptionPane(JComponent parent) {
182 JOptionPane pane = null;
183 if (!(parent instanceof JOptionPane)) {
184 pane = getOptionPane((JComponent) parent.getParent());
186 pane = (JOptionPane) parent;
197 private void setButtons(JButton ok, JButton cancel) {
199 this.cancelButton = cancel;
200 okButton.addActionListener(
new ActionListener() {
202 public void actionPerformed(ActionEvent e) {
203 JOptionPane pane = getOptionPane(okButton);
204 pane.setValue(okButton);
207 cancelButton.addActionListener(
new ActionListener() {
209 public void actionPerformed(ActionEvent e) {
210 JOptionPane pane = getOptionPane(cancelButton);
211 pane.setValue(cancelButton);
223 private void populateTypeConditionComponents(FilesSet.Rule rule) {
224 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
225 switch (typeCondition.getMetaType()) {
227 this.filesRadioButton.setSelected(
true);
230 this.dirsRadioButton.setSelected(
true);
232 case FILES_AND_DIRECTORIES:
233 this.filesAndDirsRadioButton.setSelected(
true);
243 private void populateNameConditionComponents(FilesSet.Rule rule) {
244 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
245 if (nameCondition != null) {
246 this.nameCheck.setSelected(
true);
247 this.nameCheckActionPerformed(null);
248 this.nameTextField.setText(nameCondition.getTextToMatch());
249 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
250 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
251 this.fullNameRadioButton.setSelected(
true);
253 this.extensionRadioButton.setSelected(
true);
264 private void populatePathConditionComponents(FilesSet.Rule rule) {
265 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
266 if (pathCondition != null) {
267 this.pathCheck.setSelected(
true);
268 this.pathCheckActionPerformed(null);
269 this.pathTextField.setText(pathCondition.getTextToMatch());
270 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
281 boolean isValidRuleDefinition() {
283 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected())) {
284 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
285 Bundle.FilesSetRulePanel_NoConditionError(),
286 NotifyDescriptor.WARNING_MESSAGE);
287 DialogDisplayer.getDefault().notify(notifyDesc);
291 if (this.nameCheck.isSelected()) {
294 if (this.nameTextField.getText().isEmpty()) {
295 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
296 Bundle.FilesSetRulePanel_NoNameError(),
297 NotifyDescriptor.WARNING_MESSAGE);
298 DialogDisplayer.getDefault().notify(notifyDesc);
301 if (this.nameRegexCheckbox.isSelected()) {
303 Pattern.compile(this.nameTextField.getText());
304 }
catch (PatternSyntaxException ex) {
305 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
306 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
307 NotifyDescriptor.WARNING_MESSAGE);
308 DialogDisplayer.getDefault().notify(notifyDesc);
311 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
312 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
313 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
314 NotifyDescriptor.WARNING_MESSAGE);
315 DialogDisplayer.getDefault().notify(notifyDesc);
322 if (this.pathCheck.isSelected()) {
323 if (this.pathTextField.getText().isEmpty()) {
324 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
325 Bundle.FilesSetRulePanel_NoPathError(),
326 NotifyDescriptor.WARNING_MESSAGE);
327 DialogDisplayer.getDefault().notify(notifyDesc);
330 if (this.pathRegexCheckBox.isSelected()) {
332 Pattern.compile(this.pathTextField.getText());
333 }
catch (PatternSyntaxException ex) {
334 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
335 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
336 NotifyDescriptor.WARNING_MESSAGE);
337 DialogDisplayer.getDefault().notify(notifyDesc);
340 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
341 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
342 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
343 NotifyDescriptor.WARNING_MESSAGE);
344 DialogDisplayer.getDefault().notify(notifyDesc);
348 if (this.mimeCheck.isSelected()) {
349 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
350 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
351 Bundle.FilesSetRulePanel_NoMimeTypeError(),
352 NotifyDescriptor.WARNING_MESSAGE);
353 DialogDisplayer.getDefault().notify(notifyDesc);
357 if (this.fileSizeCheck.isSelected()) {
358 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
359 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
360 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
361 NotifyDescriptor.WARNING_MESSAGE);
362 DialogDisplayer.getDefault().notify(notifyDesc);
375 String getRuleName() {
376 return this.ruleNameTextField.getText();
388 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
389 FilesSet.Rule.FileNameCondition condition = null;
390 if (!this.nameTextField.getText().isEmpty()) {
391 if (this.nameRegexCheckbox.isSelected()) {
393 Pattern pattern = Pattern.compile(this.nameTextField.getText());
394 if (this.fullNameRadioButton.isSelected()) {
395 condition =
new FilesSet.Rule.FullNameCondition(pattern);
397 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
399 }
catch (PatternSyntaxException ex) {
400 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
401 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
403 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
404 if (this.fullNameRadioButton.isSelected()) {
405 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
407 condition =
new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
410 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
411 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
422 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
423 FilesSet.Rule.MimeTypeCondition condition = null;
424 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
425 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
435 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
436 FilesSet.Rule.FileSizeCondition condition = null;
437 if (this.fileSizeCheck.isSelected()) {
438 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
439 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
440 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
441 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
442 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
454 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
455 if (this.filesRadioButton.isSelected()) {
456 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
457 }
else if (this.dirsRadioButton.isSelected()) {
458 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
460 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
473 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
474 FilesSet.Rule.ParentPathCondition condition = null;
475 if (!this.pathTextField.getText().isEmpty()) {
476 if (this.pathRegexCheckBox.isSelected()) {
478 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText()));
479 }
catch (PatternSyntaxException ex) {
480 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
481 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
484 String path = this.pathTextField.getText();
485 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
487 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
488 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
491 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
492 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
494 condition =
new FilesSet.Rule.ParentPathCondition(path);
496 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
497 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
513 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
514 for (String illegalChar : illegalChars) {
515 if (toBeChecked.contains(illegalChar)) {
526 private void setComponentsForSearchType() {
527 if (!this.filesRadioButton.isSelected()) {
528 this.fullNameRadioButton.setSelected(
true);
529 this.extensionRadioButton.setEnabled(
false);
530 this.mimeTypeComboBox.setEnabled(
false);
531 this.mimeTypeComboBox.setSelectedIndex(0);
532 this.equalitySymbolComboBox.setEnabled(
false);
533 this.fileSizeComboBox.setEnabled(
false);
534 this.fileSizeSpinner.setEnabled(
false);
535 this.fileSizeSpinner.setValue(0);
536 this.fileSizeCheck.setEnabled(
false);
537 this.fileSizeCheck.setSelected(
false);
538 this.mimeCheck.setEnabled(
false);
539 this.mimeCheck.setSelected(
false);
542 if (this.nameCheck.isSelected()) {
543 this.extensionRadioButton.setEnabled(
true);
545 this.fileSizeCheck.setEnabled(
true);
546 this.mimeCheck.setEnabled(
true);
555 @SuppressWarnings(
"unchecked")
557 private
void initComponents() {
559 nameButtonGroup =
new javax.swing.ButtonGroup();
560 typeButtonGroup =
new javax.swing.ButtonGroup();
561 ruleNameLabel =
new javax.swing.JLabel();
562 ruleNameTextField =
new javax.swing.JTextField();
563 jLabel1 =
new javax.swing.JLabel();
564 nameTextField =
new javax.swing.JTextField();
565 fullNameRadioButton =
new javax.swing.JRadioButton();
566 extensionRadioButton =
new javax.swing.JRadioButton();
567 nameRegexCheckbox =
new javax.swing.JCheckBox();
568 pathTextField =
new javax.swing.JTextField();
569 pathRegexCheckBox =
new javax.swing.JCheckBox();
570 pathSeparatorInfoLabel =
new javax.swing.JLabel();
571 jLabel5 =
new javax.swing.JLabel();
572 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
573 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
574 fileSizeComboBox =
new javax.swing.JComboBox<String>();
575 fileSizeSpinner =
new javax.swing.JSpinner();
576 nameCheck =
new javax.swing.JCheckBox();
577 pathCheck =
new javax.swing.JCheckBox();
578 mimeCheck =
new javax.swing.JCheckBox();
579 fileSizeCheck =
new javax.swing.JCheckBox();
580 filesRadioButton =
new javax.swing.JRadioButton();
581 dirsRadioButton =
new javax.swing.JRadioButton();
582 filesAndDirsRadioButton =
new javax.swing.JRadioButton();
584 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
586 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
587 ruleNameTextField.addActionListener(
new java.awt.event.ActionListener() {
588 public void actionPerformed(java.awt.event.ActionEvent evt) {
589 ruleNameTextFieldActionPerformed(evt);
593 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
595 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
596 nameTextField.setEnabled(
false);
598 nameButtonGroup.add(fullNameRadioButton);
599 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
600 fullNameRadioButton.setEnabled(
false);
601 fullNameRadioButton.addActionListener(
new java.awt.event.ActionListener() {
602 public void actionPerformed(java.awt.event.ActionEvent evt) {
603 fullNameRadioButtonActionPerformed(evt);
607 nameButtonGroup.add(extensionRadioButton);
608 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
609 extensionRadioButton.setEnabled(
false);
611 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
612 nameRegexCheckbox.setEnabled(
false);
614 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
615 pathTextField.setEnabled(
false);
617 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
618 pathRegexCheckBox.setEnabled(
false);
620 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
621 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
622 pathSeparatorInfoLabel.setEnabled(
false);
624 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel5.text"));
626 mimeTypeComboBox.setEditable(
true);
627 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
628 mimeTypeComboBox.setEnabled(
false);
630 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
631 equalitySymbolComboBox.setEnabled(
false);
633 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
634 fileSizeComboBox.setEnabled(
false);
636 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
637 fileSizeSpinner.setEnabled(
false);
639 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
640 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
641 public void actionPerformed(java.awt.event.ActionEvent evt) {
642 nameCheckActionPerformed(evt);
646 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
647 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
648 public void actionPerformed(java.awt.event.ActionEvent evt) {
649 pathCheckActionPerformed(evt);
653 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
654 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
655 public void actionPerformed(java.awt.event.ActionEvent evt) {
656 mimeCheckActionPerformed(evt);
660 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
661 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
662 public void actionPerformed(java.awt.event.ActionEvent evt) {
663 fileSizeCheckActionPerformed(evt);
667 typeButtonGroup.add(filesRadioButton);
668 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
669 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
670 public void actionPerformed(java.awt.event.ActionEvent evt) {
671 filesRadioButtonActionPerformed(evt);
675 typeButtonGroup.add(dirsRadioButton);
676 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
677 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
678 public void actionPerformed(java.awt.event.ActionEvent evt) {
679 dirsRadioButtonActionPerformed(evt);
683 typeButtonGroup.add(filesAndDirsRadioButton);
684 org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesAndDirsRadioButton.text"));
685 filesAndDirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
686 public void actionPerformed(java.awt.event.ActionEvent evt) {
687 filesAndDirsRadioButtonActionPerformed(evt);
691 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
692 this.setLayout(layout);
693 layout.setHorizontalGroup(
694 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
695 .addGroup(layout.createSequentialGroup()
696 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
697 .addGroup(layout.createSequentialGroup()
699 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
700 .addGroup(layout.createSequentialGroup()
701 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
702 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
703 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
704 .addGroup(layout.createSequentialGroup()
705 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
706 .addComponent(jLabel5)
707 .addGroup(layout.createSequentialGroup()
708 .addComponent(jLabel1)
710 .addComponent(filesRadioButton)
711 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
712 .addComponent(dirsRadioButton)
713 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
714 .addComponent(filesAndDirsRadioButton)))
715 .addGap(0, 0, Short.MAX_VALUE))))
716 .addGroup(layout.createSequentialGroup()
718 .addComponent(nameCheck)
719 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
720 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
721 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
723 .addComponent(pathCheck)
725 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
726 .addGroup(layout.createSequentialGroup()
727 .addComponent(pathRegexCheckBox)
728 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
729 .addComponent(pathSeparatorInfoLabel))
730 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
731 .addGap(0, 0, Short.MAX_VALUE)
732 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
733 .addGroup(layout.createSequentialGroup()
734 .addComponent(fullNameRadioButton)
735 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
736 .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
737 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
738 .addComponent(nameRegexCheckbox)
739 .addGap(0, 0, Short.MAX_VALUE))))
740 .addGroup(layout.createSequentialGroup()
742 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
743 .addComponent(mimeCheck)
744 .addComponent(fileSizeCheck))
745 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
746 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
747 .addGroup(layout.createSequentialGroup()
748 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
750 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
752 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
753 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
756 layout.setVerticalGroup(
757 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
758 .addGroup(layout.createSequentialGroup()
759 .addComponent(jLabel5)
760 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
761 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
762 .addComponent(jLabel1)
763 .addComponent(filesRadioButton)
764 .addComponent(dirsRadioButton)
765 .addComponent(filesAndDirsRadioButton))
767 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
768 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
769 .addComponent(nameCheck))
770 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
771 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
772 .addComponent(fullNameRadioButton)
773 .addComponent(extensionRadioButton)
774 .addComponent(nameRegexCheckbox))
775 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
776 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
777 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
778 .addComponent(pathCheck))
779 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
780 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
781 .addComponent(pathRegexCheckBox)
782 .addComponent(pathSeparatorInfoLabel))
783 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
784 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
785 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
786 .addComponent(mimeCheck))
788 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
789 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
790 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
791 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
792 .addComponent(fileSizeCheck))
794 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
795 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
796 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
801 private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
805 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
806 if (!this.nameCheck.isSelected()) {
807 this.nameTextField.setEnabled(
false);
808 this.nameTextField.setText(
"");
809 this.fullNameRadioButton.setEnabled(
false);
810 this.extensionRadioButton.setEnabled(
false);
811 this.nameRegexCheckbox.setEnabled(
false);
813 this.nameTextField.setEnabled(
true);
814 this.fullNameRadioButton.setEnabled(
true);
815 if (this.filesRadioButton.isSelected()) {
816 this.extensionRadioButton.setEnabled(
true);
818 this.nameRegexCheckbox.setEnabled(
true);
823 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
824 if (!this.pathCheck.isSelected()) {
825 this.pathTextField.setEnabled(
false);
826 this.pathTextField.setText(
"");
827 this.pathRegexCheckBox.setEnabled(
false);
828 this.pathSeparatorInfoLabel.setEnabled(
false);
830 this.pathTextField.setEnabled(
true);
831 this.pathRegexCheckBox.setEnabled(
true);
832 this.pathSeparatorInfoLabel.setEnabled(
true);
837 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
838 if (!this.mimeCheck.isSelected()) {
839 this.mimeTypeComboBox.setEnabled(
false);
840 this.mimeTypeComboBox.setSelectedIndex(0);
842 this.mimeTypeComboBox.setEnabled(
true);
847 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
848 if (!this.fileSizeCheck.isSelected()) {
849 this.fileSizeComboBox.setEnabled(
false);
850 this.fileSizeSpinner.setEnabled(
false);
851 this.fileSizeSpinner.setValue(0);
852 this.equalitySymbolComboBox.setEnabled(
false);
854 this.fileSizeComboBox.setEnabled(
true);
855 this.fileSizeSpinner.setEnabled(
true);
856 this.equalitySymbolComboBox.setEnabled(
true);
861 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
863 this.setComponentsForSearchType();
866 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
867 this.setComponentsForSearchType();
870 private void filesAndDirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
871 this.setComponentsForSearchType();
874 private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
879 private javax.swing.JRadioButton dirsRadioButton;
880 private javax.swing.JComboBox<String> equalitySymbolComboBox;
881 private javax.swing.JRadioButton extensionRadioButton;
882 private javax.swing.JCheckBox fileSizeCheck;
883 private javax.swing.JComboBox<String> fileSizeComboBox;
884 private javax.swing.JSpinner fileSizeSpinner;
885 private javax.swing.JRadioButton filesAndDirsRadioButton;
886 private javax.swing.JRadioButton filesRadioButton;
887 private javax.swing.JRadioButton fullNameRadioButton;
888 private javax.swing.JLabel jLabel1;
889 private javax.swing.JLabel jLabel5;
890 private javax.swing.JCheckBox mimeCheck;
891 private javax.swing.JComboBox<String> mimeTypeComboBox;
892 private javax.swing.ButtonGroup nameButtonGroup;
893 private javax.swing.JCheckBox nameCheck;
894 private javax.swing.JCheckBox nameRegexCheckbox;
895 private javax.swing.JTextField nameTextField;
896 private javax.swing.JCheckBox pathCheck;
897 private javax.swing.JCheckBox pathRegexCheckBox;
898 private javax.swing.JLabel pathSeparatorInfoLabel;
899 private javax.swing.JTextField pathTextField;
900 private javax.swing.JLabel ruleNameLabel;
901 private javax.swing.JTextField ruleNameTextField;
902 private javax.swing.ButtonGroup typeButtonGroup;