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.SortedSet;
28 import java.util.logging.Level;
29 import java.util.regex.Pattern;
30 import java.util.regex.PatternSyntaxException;
31 import javax.swing.JButton;
32 import javax.swing.JComponent;
33 import javax.swing.JOptionPane;
34 import org.apache.tika.mime.MediaType;
35 import org.apache.tika.mime.MimeTypes;
36 import org.openide.DialogDisplayer;
37 import org.openide.NotifyDescriptor;
38 import org.openide.util.NbBundle;
39 import org.openide.util.NbBundle.Messages;
47 final class FilesSetRulePanel
extends javax.swing.JPanel {
50 "FilesSetRulePanel.bytes=Bytes",
51 "FilesSetRulePanel.kiloBytes=Kilobytes",
52 "FilesSetRulePanel.megaBytes=Megabytes",
53 "FilesSetRulePanel.gigaBytes=Gigabytes",
54 "FilesSetRulePanel.NoConditionError=Must have at least one condition to make a rule.",
55 "FilesSetRulePanel.NoMimeTypeError=Please select a valid MIME type.",
56 "FilesSetRulePanel.NoNameError=Name cannot be empty",
57 "FilesSetRulePanel.NoPathError=Path cannot be empty",
58 "FilesSetRulePanel.ZeroFileSizeError=File size condition value must not be 0 (Unless = is selected)."
61 private static final SortedSet<MediaType> mediaTypes = MimeTypes.getDefaultMimeTypes().getMediaTypeRegistry().getTypes();
62 private static final Logger logger = Logger.getLogger(FilesSetRulePanel.class.getName());
63 private static final String SLEUTHKIT_PATH_SEPARATOR =
"/";
64 private static final List<String> ILLEGAL_FILE_NAME_CHARS = InterestingItemDefsManager.getIllegalFileNameChars();
65 private static final List<String> ILLEGAL_FILE_PATH_CHARS = InterestingItemDefsManager.getIllegalFilePathChars();
66 private JButton okButton;
67 private JButton cancelButton;
72 FilesSetRulePanel(JButton okButton, JButton cancelButton) {
74 populateMimeTypesComboBox();
75 populateComponentsWithDefaultValues();
76 this.setButtons(okButton, cancelButton);
84 FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton) {
86 populateMimeTypesComboBox();
87 populateRuleNameComponent(rule);
88 populateTypeConditionComponents(rule);
89 populateNameConditionComponents(rule);
90 populatePathConditionComponents(rule);
91 populateMimeConditionComponents(rule);
92 populateSizeConditionComponents(rule);
93 this.setButtons(okButton, cancelButton);
99 private void populateComponentsWithDefaultValues() {
100 this.filesRadioButton.setSelected(
true);
101 this.fullNameRadioButton.setSelected(
true);
102 this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
103 this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
104 this.mimeTypeComboBox.setSelectedIndex(0);
107 private void populateMimeTypesComboBox() {
108 Set<String> fileTypesCollated =
new HashSet<>();
109 for (MediaType mediaType : mediaTypes) {
110 fileTypesCollated.add(mediaType.toString());
113 FileTypeDetector fileTypeDetector;
115 fileTypeDetector =
new FileTypeDetector();
116 List<String> userDefinedFileTypes = fileTypeDetector.getUserDefinedTypes();
117 fileTypesCollated.addAll(userDefinedFileTypes);
119 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
120 logger.log(Level.SEVERE,
"Unable to get user defined file types", ex);
123 List<String> toSort =
new ArrayList<>(fileTypesCollated);
124 toSort.sort((String string1, String string2) -> {
125 int result = String.CASE_INSENSITIVE_ORDER.compare(string1, string2);
127 result = string1.compareTo(string2);
132 for (String file : toSort) {
133 mimeTypeComboBox.addItem(file);
143 private void populateRuleNameComponent(FilesSet.Rule rule) {
144 this.ruleNameTextField.setText(rule.getName());
147 private void populateMimeConditionComponents(FilesSet.Rule rule) {
148 FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
149 if (mimeTypeCondition != null) {
150 this.mimeCheck.setSelected(
true);
151 this.mimeCheckActionPerformed(null);
152 this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
155 private void populateSizeConditionComponents(FilesSet.Rule rule) {
156 FilesSet.Rule.FileSizeCondition fileSizeCondition = rule.getFileSizeCondition();
157 if (fileSizeCondition != null) {
158 this.fileSizeCheck.setSelected(
true);
159 this.fileSizeCheckActionPerformed(null);
160 this.fileSizeSpinner.setValue(fileSizeCondition.getSizeValue());
161 this.fileSizeComboBox.setSelectedItem(fileSizeCondition.getUnit().getName());
162 this.equalitySymbolComboBox.setSelectedItem(fileSizeCondition.getComparator().getSymbol());
170 private void setOkButton() {
171 if (this.okButton != null) {
172 this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
173 || this.nameCheck.isSelected() || this.pathCheck.isSelected());
184 private JOptionPane getOptionPane(JComponent parent) {
185 JOptionPane pane = null;
186 if (!(parent instanceof JOptionPane)) {
187 pane = getOptionPane((JComponent) parent.getParent());
189 pane = (JOptionPane) parent;
200 private void setButtons(JButton ok, JButton cancel) {
202 this.cancelButton = cancel;
203 okButton.addActionListener(
new ActionListener() {
205 public void actionPerformed(ActionEvent e) {
206 JOptionPane pane = getOptionPane(okButton);
207 pane.setValue(okButton);
210 cancelButton.addActionListener(
new ActionListener() {
212 public void actionPerformed(ActionEvent e) {
213 JOptionPane pane = getOptionPane(cancelButton);
214 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);
235 case FILES_AND_DIRECTORIES:
236 this.filesAndDirsRadioButton.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);
315 if (this.nameTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
316 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
317 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInName"),
318 NotifyDescriptor.WARNING_MESSAGE);
319 DialogDisplayer.getDefault().notify(notifyDesc);
327 if (this.pathCheck.isSelected()) {
328 if (this.pathTextField.getText().isEmpty()) {
329 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
330 Bundle.FilesSetRulePanel_NoPathError(),
331 NotifyDescriptor.WARNING_MESSAGE);
332 DialogDisplayer.getDefault().notify(notifyDesc);
335 if (this.pathRegexCheckBox.isSelected()) {
337 Pattern.compile(this.pathTextField.getText());
338 }
catch (PatternSyntaxException ex) {
339 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
340 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidPathRegex", ex.getLocalizedMessage()),
341 NotifyDescriptor.WARNING_MESSAGE);
342 DialogDisplayer.getDefault().notify(notifyDesc);
346 if (this.pathTextField.getText().isEmpty() || !FilesSetRulePanel.containsOnlyLegalChars(this.pathTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
347 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
348 NbBundle.getMessage(FilesSetPanel.class,
"FilesSetRulePanel.messages.invalidCharInPath"),
349 NotifyDescriptor.WARNING_MESSAGE);
350 DialogDisplayer.getDefault().notify(notifyDesc);
355 if (this.mimeCheck.isSelected()) {
356 if (this.mimeTypeComboBox.getSelectedIndex() == 0) {
357 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
358 Bundle.FilesSetRulePanel_NoMimeTypeError(),
359 NotifyDescriptor.WARNING_MESSAGE);
360 DialogDisplayer.getDefault().notify(notifyDesc);
364 if (this.fileSizeCheck.isSelected()) {
365 if ((Integer) this.fileSizeSpinner.getValue() == 0 && !((String)this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
366 NotifyDescriptor notifyDesc =
new NotifyDescriptor.Message(
367 Bundle.FilesSetRulePanel_ZeroFileSizeError(),
368 NotifyDescriptor.WARNING_MESSAGE);
369 DialogDisplayer.getDefault().notify(notifyDesc);
382 String getRuleName() {
383 return this.ruleNameTextField.getText();
395 FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
396 FilesSet.Rule.FileNameCondition condition = null;
397 if (!this.nameTextField.getText().isEmpty()) {
398 if (this.nameRegexCheckbox.isSelected()) {
400 Pattern pattern = Pattern.compile(this.nameTextField.getText());
401 if (this.fullNameRadioButton.isSelected()) {
402 condition =
new FilesSet.Rule.FullNameCondition(pattern);
404 condition =
new FilesSet.Rule.ExtensionCondition(pattern);
406 }
catch (PatternSyntaxException ex) {
407 logger.log(Level.SEVERE,
"Attempt to get regex name condition that does not compile", ex);
408 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
411 if (FilesSetRulePanel.containsOnlyLegalChars(
this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
412 if (this.fullNameRadioButton.isSelected()) {
413 condition =
new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
415 condition =
new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
418 logger.log(Level.SEVERE,
"Attempt to get name condition with illegal chars");
419 throw new IllegalStateException(
"The files set rule panel name condition is not in a valid state");
431 FilesSet.Rule.MimeTypeCondition getMimeTypeCondition() {
432 FilesSet.Rule.MimeTypeCondition condition = null;
433 if (!this.mimeTypeComboBox.getSelectedItem().equals(
"")) {
434 condition =
new FilesSet.Rule.MimeTypeCondition((String) this.mimeTypeComboBox.getSelectedItem());
444 FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
445 FilesSet.Rule.FileSizeCondition condition = null;
446 if ((Integer) this.fileSizeSpinner.getValue() != 0 || ((String)this.equalitySymbolComboBox.getSelectedItem()).equals(
"=")) {
447 FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
448 FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
449 int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
450 condition =
new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
461 FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
462 if (this.filesRadioButton.isSelected()) {
463 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
464 }
else if (this.dirsRadioButton.isSelected()) {
465 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
467 return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
480 FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
481 FilesSet.Rule.ParentPathCondition condition = null;
482 if (!this.pathTextField.getText().isEmpty()) {
483 if (this.pathRegexCheckBox.isSelected()) {
485 condition =
new FilesSet.Rule.ParentPathCondition(Pattern.compile(
this.pathTextField.getText()));
486 }
catch (PatternSyntaxException ex) {
487 logger.log(Level.SEVERE,
"Attempt to get malformed path condition", ex);
488 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
491 String path = this.pathTextField.getText();
492 if (FilesSetRulePanel.containsOnlyLegalChars(path, FilesSetRulePanel.ILLEGAL_FILE_PATH_CHARS)) {
494 if (!path.startsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
495 path = FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR + path;
498 if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
499 path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
501 condition =
new FilesSet.Rule.ParentPathCondition(path);
503 logger.log(Level.SEVERE,
"Attempt to get path condition with illegal chars");
504 throw new IllegalStateException(
"The files set rule panel path condition is not in a valid state");
520 private static boolean containsOnlyLegalChars(String toBeChecked, List<String> illegalChars) {
521 for (String illegalChar : illegalChars) {
522 if (toBeChecked.contains(illegalChar)) {
533 private void setComponentsForSearchType() {
534 if (!this.filesRadioButton.isSelected()) {
535 this.fullNameRadioButton.setSelected(
true);
536 this.extensionRadioButton.setEnabled(
false);
537 this.mimeTypeComboBox.setEnabled(
false);
538 this.mimeTypeComboBox.setSelectedIndex(0);
539 this.equalitySymbolComboBox.setEnabled(
false);
540 this.fileSizeComboBox.setEnabled(
false);
541 this.fileSizeSpinner.setEnabled(
false);
542 this.fileSizeSpinner.setValue(0);
543 this.fileSizeCheck.setEnabled(
false);
544 this.fileSizeCheck.setSelected(
false);
545 this.mimeCheck.setEnabled(
false);
546 this.mimeCheck.setSelected(
false);
549 this.extensionRadioButton.setEnabled(
true);
550 this.fileSizeCheck.setEnabled(
true);
551 this.mimeCheck.setEnabled(
true);
560 @SuppressWarnings(
"unchecked")
562 private
void initComponents() {
564 nameButtonGroup =
new javax.swing.ButtonGroup();
565 typeButtonGroup =
new javax.swing.ButtonGroup();
566 ruleNameLabel =
new javax.swing.JLabel();
567 ruleNameTextField =
new javax.swing.JTextField();
568 jLabel1 =
new javax.swing.JLabel();
569 nameTextField =
new javax.swing.JTextField();
570 fullNameRadioButton =
new javax.swing.JRadioButton();
571 extensionRadioButton =
new javax.swing.JRadioButton();
572 nameRegexCheckbox =
new javax.swing.JCheckBox();
573 pathTextField =
new javax.swing.JTextField();
574 pathRegexCheckBox =
new javax.swing.JCheckBox();
575 pathSeparatorInfoLabel =
new javax.swing.JLabel();
576 jLabel5 =
new javax.swing.JLabel();
577 mimeTypeComboBox =
new javax.swing.JComboBox<String>();
578 equalitySymbolComboBox =
new javax.swing.JComboBox<String>();
579 fileSizeComboBox =
new javax.swing.JComboBox<String>();
580 fileSizeSpinner =
new javax.swing.JSpinner();
581 nameCheck =
new javax.swing.JCheckBox();
582 pathCheck =
new javax.swing.JCheckBox();
583 mimeCheck =
new javax.swing.JCheckBox();
584 fileSizeCheck =
new javax.swing.JCheckBox();
585 filesRadioButton =
new javax.swing.JRadioButton();
586 dirsRadioButton =
new javax.swing.JRadioButton();
587 filesAndDirsRadioButton =
new javax.swing.JRadioButton();
589 org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameLabel.text"));
591 ruleNameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.ruleNameTextField.text"));
592 ruleNameTextField.addActionListener(
new java.awt.event.ActionListener() {
593 public void actionPerformed(java.awt.event.ActionEvent evt) {
594 ruleNameTextFieldActionPerformed(evt);
598 org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel1.text"));
600 nameTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameTextField.text"));
601 nameTextField.setEnabled(
false);
603 nameButtonGroup.add(fullNameRadioButton);
604 org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fullNameRadioButton.text"));
605 fullNameRadioButton.setEnabled(
false);
606 fullNameRadioButton.addActionListener(
new java.awt.event.ActionListener() {
607 public void actionPerformed(java.awt.event.ActionEvent evt) {
608 fullNameRadioButtonActionPerformed(evt);
612 nameButtonGroup.add(extensionRadioButton);
613 org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.extensionRadioButton.text"));
614 extensionRadioButton.setEnabled(
false);
616 org.openide.awt.Mnemonics.setLocalizedText(nameRegexCheckbox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameRegexCheckbox.text"));
617 nameRegexCheckbox.setEnabled(
false);
619 pathTextField.setText(
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathTextField.text"));
620 pathTextField.setEnabled(
false);
622 org.openide.awt.Mnemonics.setLocalizedText(pathRegexCheckBox,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathRegexCheckBox.text"));
623 pathRegexCheckBox.setEnabled(
false);
625 pathSeparatorInfoLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/info-icon-16.png")));
626 org.openide.awt.Mnemonics.setLocalizedText(pathSeparatorInfoLabel,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathSeparatorInfoLabel.text"));
627 pathSeparatorInfoLabel.setEnabled(
false);
629 org.openide.awt.Mnemonics.setLocalizedText(jLabel5,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.jLabel5.text"));
631 mimeTypeComboBox.setEditable(
true);
632 mimeTypeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
""}));
633 mimeTypeComboBox.setEnabled(
false);
635 equalitySymbolComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] {
"=",
">",
"≥",
"<",
"≤" }));
636 equalitySymbolComboBox.setEnabled(
false);
638 fileSizeComboBox.setModel(
new javax.swing.DefaultComboBoxModel<String>(
new String[] { Bundle.FilesSetRulePanel_bytes(), Bundle.FilesSetRulePanel_kiloBytes(), Bundle.FilesSetRulePanel_megaBytes(), Bundle.FilesSetRulePanel_gigaBytes() }));
639 fileSizeComboBox.setEnabled(
false);
641 fileSizeSpinner.setModel(
new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
642 fileSizeSpinner.setEnabled(
false);
644 org.openide.awt.Mnemonics.setLocalizedText(nameCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.nameCheck.text"));
645 nameCheck.addActionListener(
new java.awt.event.ActionListener() {
646 public void actionPerformed(java.awt.event.ActionEvent evt) {
647 nameCheckActionPerformed(evt);
651 org.openide.awt.Mnemonics.setLocalizedText(pathCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.pathCheck.text"));
652 pathCheck.addActionListener(
new java.awt.event.ActionListener() {
653 public void actionPerformed(java.awt.event.ActionEvent evt) {
654 pathCheckActionPerformed(evt);
658 org.openide.awt.Mnemonics.setLocalizedText(mimeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.mimeCheck.text"));
659 mimeCheck.addActionListener(
new java.awt.event.ActionListener() {
660 public void actionPerformed(java.awt.event.ActionEvent evt) {
661 mimeCheckActionPerformed(evt);
665 org.openide.awt.Mnemonics.setLocalizedText(fileSizeCheck,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.fileSizeCheck.text"));
666 fileSizeCheck.addActionListener(
new java.awt.event.ActionListener() {
667 public void actionPerformed(java.awt.event.ActionEvent evt) {
668 fileSizeCheckActionPerformed(evt);
672 typeButtonGroup.add(filesRadioButton);
673 org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesRadioButton.text"));
674 filesRadioButton.addActionListener(
new java.awt.event.ActionListener() {
675 public void actionPerformed(java.awt.event.ActionEvent evt) {
676 filesRadioButtonActionPerformed(evt);
680 typeButtonGroup.add(dirsRadioButton);
681 org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.dirsRadioButton.text"));
682 dirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
683 public void actionPerformed(java.awt.event.ActionEvent evt) {
684 dirsRadioButtonActionPerformed(evt);
688 typeButtonGroup.add(filesAndDirsRadioButton);
689 org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadioButton,
org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class,
"FilesSetRulePanel.filesAndDirsRadioButton.text"));
690 filesAndDirsRadioButton.addActionListener(
new java.awt.event.ActionListener() {
691 public void actionPerformed(java.awt.event.ActionEvent evt) {
692 filesAndDirsRadioButtonActionPerformed(evt);
696 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
697 this.setLayout(layout);
698 layout.setHorizontalGroup(
699 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
700 .addGroup(layout.createSequentialGroup()
701 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
702 .addGroup(layout.createSequentialGroup()
704 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
705 .addGroup(layout.createSequentialGroup()
706 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
707 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
708 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))
709 .addGroup(layout.createSequentialGroup()
710 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
711 .addComponent(jLabel5)
712 .addGroup(layout.createSequentialGroup()
713 .addComponent(jLabel1)
715 .addComponent(filesRadioButton)
716 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
717 .addComponent(dirsRadioButton)
718 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
719 .addComponent(filesAndDirsRadioButton)))
720 .addGap(0, 0, Short.MAX_VALUE))))
721 .addGroup(layout.createSequentialGroup()
723 .addComponent(nameCheck)
724 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
725 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
726 .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
728 .addComponent(pathCheck)
730 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
731 .addGroup(layout.createSequentialGroup()
732 .addComponent(pathRegexCheckBox)
733 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
734 .addComponent(pathSeparatorInfoLabel))
735 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
736 .addGap(0, 0, Short.MAX_VALUE)
737 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
738 .addGroup(layout.createSequentialGroup()
739 .addComponent(fullNameRadioButton)
740 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
741 .addComponent(extensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
742 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
743 .addComponent(nameRegexCheckbox)
744 .addGap(0, 0, Short.MAX_VALUE))))
745 .addGroup(layout.createSequentialGroup()
747 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
748 .addComponent(mimeCheck)
749 .addComponent(fileSizeCheck))
750 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
751 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
752 .addGroup(layout.createSequentialGroup()
753 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
755 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
757 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
758 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))
761 layout.setVerticalGroup(
762 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
763 .addGroup(layout.createSequentialGroup()
764 .addComponent(jLabel5)
765 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
766 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
767 .addComponent(jLabel1)
768 .addComponent(filesRadioButton)
769 .addComponent(dirsRadioButton)
770 .addComponent(filesAndDirsRadioButton))
772 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
773 .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
774 .addComponent(nameCheck))
775 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
776 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
777 .addComponent(fullNameRadioButton)
778 .addComponent(extensionRadioButton)
779 .addComponent(nameRegexCheckbox))
780 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
781 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
782 .addComponent(pathTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
783 .addComponent(pathCheck))
784 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
785 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
786 .addComponent(pathRegexCheckBox)
787 .addComponent(pathSeparatorInfoLabel))
788 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
789 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
790 .addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
791 .addComponent(mimeCheck))
793 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
794 .addComponent(equalitySymbolComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
795 .addComponent(fileSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
796 .addComponent(fileSizeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
797 .addComponent(fileSizeCheck))
799 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
800 .addComponent(ruleNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
801 .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
806 private void ruleNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {
810 private void nameCheckActionPerformed(java.awt.event.ActionEvent evt) {
811 if (!this.nameCheck.isSelected()) {
812 this.nameTextField.setEnabled(
false);
813 this.nameTextField.setText(
"");
814 this.fullNameRadioButton.setEnabled(
false);
815 this.extensionRadioButton.setEnabled(
false);
816 this.nameRegexCheckbox.setEnabled(
false);
818 this.nameTextField.setEnabled(
true);
819 this.fullNameRadioButton.setEnabled(
true);
820 this.extensionRadioButton.setEnabled(
true);
821 this.nameRegexCheckbox.setEnabled(
true);
826 private void pathCheckActionPerformed(java.awt.event.ActionEvent evt) {
827 if (!this.pathCheck.isSelected()) {
828 this.pathTextField.setEnabled(
false);
829 this.pathTextField.setText(
"");
830 this.pathRegexCheckBox.setEnabled(
false);
831 this.pathSeparatorInfoLabel.setEnabled(
false);
833 this.pathTextField.setEnabled(
true);
834 this.pathRegexCheckBox.setEnabled(
true);
835 this.pathSeparatorInfoLabel.setEnabled(
true);
840 private void mimeCheckActionPerformed(java.awt.event.ActionEvent evt) {
841 if (!this.mimeCheck.isSelected()) {
842 this.mimeTypeComboBox.setEnabled(
false);
843 this.mimeTypeComboBox.setSelectedIndex(0);
845 this.mimeTypeComboBox.setEnabled(
true);
850 private void fileSizeCheckActionPerformed(java.awt.event.ActionEvent evt) {
851 if (!this.fileSizeCheck.isSelected()) {
852 this.fileSizeComboBox.setEnabled(
false);
853 this.fileSizeSpinner.setEnabled(
false);
854 this.fileSizeSpinner.setValue(0);
855 this.equalitySymbolComboBox.setEnabled(
false);
857 this.fileSizeComboBox.setEnabled(
true);
858 this.fileSizeSpinner.setEnabled(
true);
859 this.equalitySymbolComboBox.setEnabled(
true);
864 private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
866 this.setComponentsForSearchType();
869 private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
870 this.setComponentsForSearchType();
873 private void filesAndDirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
874 this.setComponentsForSearchType();
877 private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {
882 private javax.swing.JRadioButton dirsRadioButton;
883 private javax.swing.JComboBox<String> equalitySymbolComboBox;
884 private javax.swing.JRadioButton extensionRadioButton;
885 private javax.swing.JCheckBox fileSizeCheck;
886 private javax.swing.JComboBox<String> fileSizeComboBox;
887 private javax.swing.JSpinner fileSizeSpinner;
888 private javax.swing.JRadioButton filesAndDirsRadioButton;
889 private javax.swing.JRadioButton filesRadioButton;
890 private javax.swing.JRadioButton fullNameRadioButton;
891 private javax.swing.JLabel jLabel1;
892 private javax.swing.JLabel jLabel5;
893 private javax.swing.JCheckBox mimeCheck;
894 private javax.swing.JComboBox<String> mimeTypeComboBox;
895 private javax.swing.ButtonGroup nameButtonGroup;
896 private javax.swing.JCheckBox nameCheck;
897 private javax.swing.JCheckBox nameRegexCheckbox;
898 private javax.swing.JTextField nameTextField;
899 private javax.swing.JCheckBox pathCheck;
900 private javax.swing.JCheckBox pathRegexCheckBox;
901 private javax.swing.JLabel pathSeparatorInfoLabel;
902 private javax.swing.JTextField pathTextField;
903 private javax.swing.JLabel ruleNameLabel;
904 private javax.swing.JTextField ruleNameTextField;
905 private javax.swing.ButtonGroup typeButtonGroup;