19 package org.sleuthkit.autopsy.modules.interestingitems;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.List;
24 import java.util.SortedSet;
25 import java.util.logging.Level;
26 import java.util.regex.Pattern;
27 import java.util.regex.PatternSyntaxException;
28 import javax.swing.JButton;
29 import javax.swing.JComponent;
30 import javax.swing.JOptionPane;
31 import org.openide.DialogDisplayer;
32 import org.openide.NotifyDescriptor;
33 import org.openide.util.NbBundle;
34 import org.openide.util.NbBundle.Messages;
42 final class FilesSetRulePanel
extends javax.swing.JPanel {
45 "FilesSetRulePanel.bytes=Bytes",
46 "FilesSetRulePanel.kiloBytes=Kilobytes",
47 "FilesSetRulePanel.megaBytes=Megabytes",
48 "FilesSetRulePanel.gigaBytes=Gigabytes",
49 "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
50 "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
51 "FilesSetRulePanel.NoNameError=Name cannot be empty",
52 "FilesSetRulePanel.NoPathError=Path cannot be empty",
53 "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
56 private static final long serialVersionUID = 1L;
57 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
58 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
59 private static final List<String> ILLEGAL_FILE_NAME_CHARS = FilesSetsManager.getIllegalFileNameChars();
60 private static final List<String> ILLEGAL_FILE_PATH_CHARS = FilesSetsManager.getIllegalFilePathChars();
61 private JButton okButton;
62 private JButton cancelButton;
67 FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
69 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
70 mimeTypeComboBox.setVisible(
false);
71 mimeCheck.setVisible(
false);
72 fileSizeComboBox.setVisible(
false);
73 fileSizeCheck.setVisible(
false);
74 equalitySymbolComboBox.setVisible(
false);
75 fileSizeSpinner.setVisible(
false);
76 jLabel1.setVisible(
false);
77 filesRadioButton.setVisible(
false);
78 dirsRadioButton.setVisible(
false);
79 allRadioButton.setVisible(
false);
80 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ingest.jLabel5.text"));
83 populateMimeTypesComboBox();
85 populateComponentsWithDefaultValues();
86 this.setButtons(okButton, cancelButton);
94 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
96 if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) {
97 mimeTypeComboBox.setVisible(
false);
98 mimeCheck.setVisible(
false);
99 fileSizeComboBox.setVisible(
false);
100 fileSizeCheck.setVisible(
false);
101 equalitySymbolComboBox.setVisible(
false);
102 fileSizeSpinner.setVisible(
false);
103 jLabel1.setVisible(
false);
104 filesRadioButton.setVisible(
false);
105 dirsRadioButton.setVisible(
false);
106 allRadioButton.setVisible(
false);
108 populateMimeTypesComboBox();
109 populateMimeConditionComponents(rule);
110 populateSizeConditionComponents(rule);
112 populateMimeTypesComboBox();
113 populateRuleNameComponent(rule);
114 populateTypeConditionComponents(rule);
115 populateNameConditionComponents(rule);
116 populatePathConditionComponents(rule);
117 this.setButtons(okButton, cancelButton);
123 private void populateComponentsWithDefaultValues() {
124 this.filesRadioButton.setSelected(
true);
125 this.fullNameRadioButton.setSelected(
true);
126 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
127 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
128 this.mimeTypeComboBox.setSelectedIndex(0);
131 private void populateMimeTypesComboBox() {
133 SortedSet<String> detectableMimeTypes = FileTypeDetector.getDetectedTypes();
134 detectableMimeTypes.forEach((type) -> {
135 mimeTypeComboBox.addItem(type);
137 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
138 logger.log(Level.SEVERE,
"Unable to get detectable file types", ex);
148 private void populateRuleNameComponent(FilesSet.Rule rule) {
149 this.ruleNameTextField.setText(rule.getName());
152 private void populateMimeConditionComponents(FilesSet.Rule rule) {
153 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
154 if (mimeTypeCondition != null) {
155 this.mimeCheck.setSelected(
true);
156 this.mimeCheckActionPerformed(null);
157 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
161 private void populateSizeConditionComponents(FilesSet.Rule rule) {
162 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
163 if (fileSizeCondition != null) {
164 this.fileSizeCheck.setSelected(
true);
165 this.fileSizeCheckActionPerformed(null);
166 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
167 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
168 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
176 private void setOkButton() {
177 if (this.okButton != null) {
178 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
179 || this.nameCheck.isSelected() || this.pathCheck.isSelected());
190 private JOptionPane getOptionPane(JComponent parent) {
192 if (!(parent instanceof JOptionPane)) {
193 pane = getOptionPane((JComponent) parent.getParent());
195 pane = (JOptionPane) parent;
206 private void setButtons(JButton ok, JButton cancel) {
208 this.cancelButton = cancel;
209 okButton.addActionListener((ActionEvent e) -> {
210 JOptionPane pane = getOptionPane(okButton);
211 pane.setValue(okButton);
213 cancelButton.addActionListener((ActionEvent e) -> {
214 JOptionPane pane = getOptionPane(cancelButton);
215 pane.setValue(cancelButton);
226 private void populateTypeConditionComponents(FilesSet.Rule rule) {
227 FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
228 switch (typeCondition.getMetaType()) {
230 this.filesRadioButton.setSelected(
true);
233 this.dirsRadioButton.setSelected(
true);
236 this.allRadioButton.setSelected(
true);
246 private void populateNameConditionComponents(FilesSet.Rule rule) {
247 FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
248 if (nameCondition != null) {
249 this.nameCheck.setSelected(
true);
250 this.nameCheckActionPerformed(null);
251 this.nameTextField.setText(nameCondition.getTextToMatch());
252 this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
253 if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
254 this.fullNameRadioButton.setSelected(
true);
256 this.extensionRadioButton.setSelected(
true);
267 private void populatePathConditionComponents(FilesSet.Rule rule) {
268 FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
269 if (pathCondition != null) {
270 this.pathCheck.setSelected(
true);
271 this.pathCheckActionPerformed(null);
272 this.pathTextField.setText(pathCondition.getTextToMatch());
273 this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
284 boolean isValidRuleDefinition() {
286 if (!(this.mimeCheck.isSelected() || this.fileSizeCheck.isSelected() || this.pathCheck.isSelected() || this.nameCheck.isSelected())) {
287 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
288 Bundle.FilesSetRulePanel_NoConditionError(),
289 NotifyDescriptor.WARNING_MESSAGE);
290 DialogDisplayer.getDefault().notify(notifyDesc);
294 if (this.nameCheck.isSelected()) {
297 if (this.nameTextField.getText().isEmpty()) {
298 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
299 Bundle.FilesSetRulePanel_NoNameError(),
300 NotifyDescriptor.WARNING_MESSAGE);
301 DialogDisplayer.getDefault().notify(notifyDesc);
304 if (this.nameRegexCheckbox.isSelected()) {
306 Pattern.compile(this.nameTextField.getText());
307 }
catch (PatternSyntaxException ex) {
308 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
309 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidNameRegex", ex.getLocalizedMessage()),
310 NotifyDescriptor.WARNING_MESSAGE);
311 DialogDisplayer.getDefault().notify(notifyDesc);
314 }
else if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
315 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
316 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
317 NotifyDescriptor.WARNING_MESSAGE);
318 DialogDisplayer.getDefault().notify(notifyDesc);
325 if (this.pathCheck.isSelected()) {
326 if (this.pathTextField.getText().isEmpty()) {
327 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
328 Bundle.FilesSetRulePanel_NoPathError(),
329 NotifyDescriptor.WARNING_MESSAGE);
330 DialogDisplayer.getDefault().notify(notifyDesc);
333 if (this.pathRegexCheckBox.isSelected()) {
335 Pattern.compile(this.pathTextField.getText());
336 }
catch (PatternSyntaxException ex) {
337 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
338 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
339 NotifyDescriptor.WARNING_MESSAGE);
340 DialogDisplayer.getDefault().notify(notifyDesc);
343 }
else if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
344 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
345 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
346 NotifyDescriptor.WARNING_MESSAGE);
347 DialogDisplayer.getDefault().notify(notifyDesc);
351 if (this.mimeCheck.isSelected()) {
352 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
353 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
354 Bundle.FilesSetRulePanel_NoMimeTypeError(),
355 NotifyDescriptor.WARNING_MESSAGE);
356 DialogDisplayer.getDefault().notify(notifyDesc);
360 if (this.fileSizeCheck.isSelected()) {
361 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
362 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
363 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
364 NotifyDescriptor.WARNING_MESSAGE);
365 DialogDisplayer.getDefault().notify(notifyDesc);
378 String getRuleName() {
379 return this.ruleNameTextField.getText();
391 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
392 FilesSet.Rule.FileNameCondition condition = null;
393 if (!this.nameTextField.getText().isEmpty()) {
394 if (this.nameRegexCheckbox.isSelected()) {
396 Pattern pattern = Pattern.compile(this.nameTextField.getText());
397 if (this.fullNameRadioButton.isSelected()) {
398 condition =
new FilesSet.Rule.FullNameCondition(pattern);
400 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
402 }
catch (PatternSyntaxException ex) {
403 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
404 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
406 }
else if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
407 if (this.fullNameRadioButton.isSelected()) {
408 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
410 condition =
new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
413 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
414 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
425 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
426 FilesSet.Rule.MimeTypeCondition condition = null;
427 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
428 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
438 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
439 FilesSet.Rule.FileSizeCondition condition = null;
440 if (this.fileSizeCheck.isSelected()) {
441 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String) this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
442 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
443 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
444 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
445 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
457 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
458 if (this.filesRadioButton.isSelected()) {
459 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
460 }
else if (this.dirsRadioButton.isSelected()) {
461 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
463 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.ALL);
476 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
477 FilesSet.Rule.ParentPathCondition condition = null;
478 if (!this.pathTextField.getText().isEmpty()) {
479 if (this.pathRegexCheckBox.isSelected()) {
481 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText()));
482 }
catch (PatternSyntaxException ex) {
483 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
484 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
487 String path = this.pathTextField.getText();
488 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
490 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
491 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
494 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
495 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
497 condition =
new FilesSet.Rule.ParentPathCondition(path);
499 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
500 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
516 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
517 for (String illegalChar : illegalChars) {
518 if (toBeChecked.contains(illegalChar)) {
529 private void setComponentsForSearchType() {
530 if (!this.filesRadioButton.isSelected()) {
531 this.fullNameRadioButton.setSelected(
true);
532 this.extensionRadioButton.setEnabled(
false);
533 this.mimeTypeComboBox.setEnabled(
false);
534 this.mimeTypeComboBox.setSelectedIndex(0);
535 this.equalitySymbolComboBox.setEnabled(
false);
536 this.fileSizeComboBox.setEnabled(
false);
537 this.fileSizeSpinner.setEnabled(
false);
538 this.fileSizeSpinner.setValue(0);
539 this.fileSizeCheck.setEnabled(
false);
540 this.fileSizeCheck.setSelected(
false);
541 this.mimeCheck.setEnabled(
false);
542 this.mimeCheck.setSelected(
false);
544 if (this.nameCheck.isSelected()) {
545 this.extensionRadioButton.setEnabled(
true);
547 this.fileSizeCheck.setEnabled(
true);
548 this.mimeCheck.setEnabled(
true);
557 @SuppressWarnings(
"unchecked")
559 private
void initComponents() {
561 nameButtonGroup =
new javax.swing.ButtonGroup();
562 typeButtonGroup =
new javax.swing.ButtonGroup();
563 ruleNameLabel =
new javax.swing.JLabel();
564 ruleNameTextField =
new javax.swing.JTextField();
565 jLabel1 =
new javax.swing.JLabel();
566 nameTextField =
new javax.swing.JTextField();
567 fullNameRadioButton =
new javax.swing.JRadioButton();
568 extensionRadioButton =
new javax.swing.JRadioButton();
569 nameRegexCheckbox =
new javax.swing.JCheckBox();
570 pathTextField =
new javax.swing.JTextField();
571 pathRegexCheckBox =
new javax.swing.JCheckBox();
572 pathSeparatorInfoLabel =
new javax.swing.JLabel();
573 jLabel5 =
new javax.swing.JLabel();
574 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
575 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
576 fileSizeComboBox =
new javax.swing.JComboBox<String>();
577 fileSizeSpinner =
new javax.swing.JSpinner();
578 nameCheck =
new javax.swing.JCheckBox();
579 pathCheck =
new javax.swing.JCheckBox();
580 mimeCheck =
new javax.swing.JCheckBox();
581 fileSizeCheck =
new javax.swing.JCheckBox();
582 filesRadioButton =
new javax.swing.JRadioButton();
583 dirsRadioButton =
new javax.swing.JRadioButton();
584 allRadioButton =
new javax.swing.JRadioButton();
586 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
588 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
589 ruleNameTextField.addActionListener(
new java.awt.event.ActionListener() {
590 public void actionPerformed(java.awt.event.ActionEvent evt) {
591 ruleNameTextFieldActionPerformed(evt);
595 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
597 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
598 nameTextField.setEnabled(
false);
600 nameButtonGroup.add(fullNameRadioButton);
601 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
602 fullNameRadioButton.setEnabled(
false);
604 nameButtonGroup.add(extensionRadioButton);
605 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
606 extensionRadioButton.setEnabled(
false);
608 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
609 nameRegexCheckbox.setEnabled(
false);
611 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
612 pathTextField.setEnabled(
false);
614 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
615 pathRegexCheckBox.setEnabled(
false);
617 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
618 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
619 pathSeparatorInfoLabel.setEnabled(
false);
621 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.interesting.jLabel5.text"));
623 mimeTypeComboBox.setEditable(
true);
624 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
625 mimeTypeComboBox.setEnabled(
false);
627 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
628 equalitySymbolComboBox.setEnabled(
false);
630 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
631 fileSizeComboBox.setEnabled(
false);
633 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(0, 0, null, 1));
634 fileSizeSpinner.setEnabled(
false);
636 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
637 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
638 public void actionPerformed(java.awt.event.ActionEvent evt) {
639 nameCheckActionPerformed(evt);
643 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
644 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
645 public void actionPerformed(java.awt.event.ActionEvent evt) {
646 pathCheckActionPerformed(evt);
650 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
651 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
652 public void actionPerformed(java.awt.event.ActionEvent evt) {
653 mimeCheckActionPerformed(evt);
657 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
658 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
659 public void actionPerformed(java.awt.event.ActionEvent evt) {
660 fileSizeCheckActionPerformed(evt);
664 typeButtonGroup.add(filesRadioButton);
665 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
666 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
667 public void actionPerformed(java.awt.event.ActionEvent evt) {
668 filesRadioButtonActionPerformed(evt);
672 typeButtonGroup.add(dirsRadioButton);
673 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
674 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
675 public void actionPerformed(java.awt.event.ActionEvent evt) {
676 dirsRadioButtonActionPerformed(evt);
680 typeButtonGroup.add(allRadioButton);
681 org.openide.awt.Mnemonics.setLocalizedText(allRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.allRadioButton.text"));
682 allRadioButton.addActionListener(
new java.awt.event.ActionListener() {
683 public void actionPerformed(java.awt.event.ActionEvent evt) {
684 allRadioButtonActionPerformed(evt);
688 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
689 this.setLayout(layout);
690 layout.setHorizontalGroup(
691 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
692 .addGroup(layout.createSequentialGroup()
693 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
694 .addGroup(layout.createSequentialGroup()
696 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
697 .addGroup(layout.createSequentialGroup()
698 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
699 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
700 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
701 .addGroup(layout.createSequentialGroup()
702 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
703 .addComponent(jLabel5)
704 .addGroup(layout.createSequentialGroup()
705 .addComponent(jLabel1)
707 .addComponent(filesRadioButton)
708 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
709 .addComponent(dirsRadioButton)
710 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
711 .addComponent(allRadioButton)))
712 .addGap(0, 0, Short.MAX_VALUE))))
713 .addGroup(layout.createSequentialGroup()
715 .addComponent(nameCheck)
716 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
717 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
718 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
720 .addComponent(pathCheck)
722 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
723 .addGroup(layout.createSequentialGroup()
724 .addComponent(pathRegexCheckBox)
725 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
726 .addComponent(pathSeparatorInfoLabel))
727 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
728 .addGap(0, 0, Short.MAX_VALUE)
729 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
730 .addGroup(layout.createSequentialGroup()
731 .addComponent(fullNameRadioButton)
732 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
733 .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
734 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
735 .addComponent(nameRegexCheckbox)
736 .addGap(0, 0, Short.MAX_VALUE))))
737 .addGroup(layout.createSequentialGroup()
739 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
740 .addComponent(mimeCheck)
741 .addComponent(fileSizeCheck))
742 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
743 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
744 .addGroup(layout.createSequentialGroup()
745 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
747 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
749 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
750 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
753 layout.setVerticalGroup(
754 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
755 .addGroup(layout.createSequentialGroup()
756 .addComponent(jLabel5)
757 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
758 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
759 .addComponent(jLabel1)
760 .addComponent(filesRadioButton)
761 .addComponent(dirsRadioButton)
762 .addComponent(allRadioButton))
764 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
765 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
766 .addComponent(nameCheck))
767 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
768 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
769 .addComponent(fullNameRadioButton)
770 .addComponent(extensionRadioButton)
771 .addComponent(nameRegexCheckbox))
772 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
773 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
774 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
775 .addComponent(pathCheck))
776 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
777 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
778 .addComponent(pathRegexCheckBox)
779 .addComponent(pathSeparatorInfoLabel))
780 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
781 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
782 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
783 .addComponent(mimeCheck))
785 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
786 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
787 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
788 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
789 .addComponent(fileSizeCheck))
791 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
792 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
793 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
798 private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
802 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
803 if (!this.nameCheck.isSelected()) {
804 this.nameTextField.setEnabled(
false);
805 this.nameTextField.setText(
"");
806 this.fullNameRadioButton.setEnabled(
false);
807 this.extensionRadioButton.setEnabled(
false);
808 this.nameRegexCheckbox.setEnabled(
false);
810 this.nameTextField.setEnabled(
true);
811 this.fullNameRadioButton.setEnabled(
true);
812 if (this.filesRadioButton.isSelected()) {
813 this.extensionRadioButton.setEnabled(
true);
815 this.nameRegexCheckbox.setEnabled(
true);
820 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
821 if (!this.pathCheck.isSelected()) {
822 this.pathTextField.setEnabled(
false);
823 this.pathTextField.setText(
"");
824 this.pathRegexCheckBox.setEnabled(
false);
825 this.pathSeparatorInfoLabel.setEnabled(
false);
827 this.pathTextField.setEnabled(
true);
828 this.pathRegexCheckBox.setEnabled(
true);
829 this.pathSeparatorInfoLabel.setEnabled(
true);
834 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
835 if (!this.mimeCheck.isSelected()) {
836 this.mimeTypeComboBox.setEnabled(
false);
837 this.mimeTypeComboBox.setSelectedIndex(0);
839 this.mimeTypeComboBox.setEnabled(
true);
844 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
845 if (!this.fileSizeCheck.isSelected()) {
846 this.fileSizeComboBox.setEnabled(
false);
847 this.fileSizeSpinner.setEnabled(
false);
848 this.fileSizeSpinner.setValue(0);
849 this.equalitySymbolComboBox.setEnabled(
false);
851 this.fileSizeComboBox.setEnabled(
true);
852 this.fileSizeSpinner.setEnabled(
true);
853 this.equalitySymbolComboBox.setEnabled(
true);
858 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
860 this.setComponentsForSearchType();
863 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
864 this.setComponentsForSearchType();
867 private void allRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
868 this.setComponentsForSearchType();
872 private javax.swing.JRadioButton allRadioButton;
873 private javax.swing.JRadioButton dirsRadioButton;
874 private javax.swing.JComboBox<String> equalitySymbolComboBox;
875 private javax.swing.JRadioButton extensionRadioButton;
876 private javax.swing.JCheckBox fileSizeCheck;
877 private javax.swing.JComboBox<String> fileSizeComboBox;
878 private javax.swing.JSpinner fileSizeSpinner;
879 private javax.swing.JRadioButton filesRadioButton;
880 private javax.swing.JRadioButton fullNameRadioButton;
881 private javax.swing.JLabel jLabel1;
882 private javax.swing.JLabel jLabel5;
883 private javax.swing.JCheckBox mimeCheck;
884 private javax.swing.JComboBox<String> mimeTypeComboBox;
885 private javax.swing.ButtonGroup nameButtonGroup;
886 private javax.swing.JCheckBox nameCheck;
887 private javax.swing.JCheckBox nameRegexCheckbox;
888 private javax.swing.JTextField nameTextField;
889 private javax.swing.JCheckBox pathCheck;
890 private javax.swing.JCheckBox pathRegexCheckBox;
891 private javax.swing.JLabel pathSeparatorInfoLabel;
892 private javax.swing.JTextField pathTextField;
893 private javax.swing.JLabel ruleNameLabel;
894 private javax.swing.JTextField ruleNameTextField;
895 private javax.swing.ButtonGroup typeButtonGroup;