5187 enforce checkboxes

This commit is contained in:
William Schaefer 2019-06-20 13:37:16 -04:00
parent b391a0641d
commit 173bb3820b
7 changed files with 148 additions and 119 deletions

View File

@ -94,12 +94,9 @@ EditFullPathsRulePanel.shouldSaveCheckBox.text=Extract file if it matches a path
EditFullPathsRulePanel.ruleNameTextField.text= EditFullPathsRulePanel.ruleNameTextField.text=
EditFullPathsRulePanel.fullPathsLabel.text=Full paths: EditFullPathsRulePanel.fullPathsLabel.text=Full paths:
EditFullPathsRulePanel.fullPathsLabel.toolTipText= EditFullPathsRulePanel.fullPathsLabel.toolTipText=
EditNonFullPathsRulePanel.ruleNameTextField.text=
EditNonFullPathsRulePanel.ruleNameLabel.text=Name: EditNonFullPathsRulePanel.ruleNameLabel.text=Name:
EditNonFullPathsRulePanel.descriptionTextField.text=
EditNonFullPathsRulePanel.shouldSaveCheckBox.text=Extract file if it matches a condition EditNonFullPathsRulePanel.shouldSaveCheckBox.text=Extract file if it matches a condition
EditNonFullPathsRulePanel.daysIncludedLabel.text=day(s) EditNonFullPathsRulePanel.daysIncludedLabel.text=day(s)
EditNonFullPathsRulePanel.extensionsTextField.text=
EditNonFullPathsRulePanel.shouldAlertCheckBox.actionCommand= EditNonFullPathsRulePanel.shouldAlertCheckBox.actionCommand=
EditNonFullPathsRulePanel.shouldAlertCheckBox.text=Alert in imager console if a condition matches EditNonFullPathsRulePanel.shouldAlertCheckBox.text=Alert in imager console if a condition matches
ConfigVisualPanel1.browseButton.text=Browse ConfigVisualPanel1.browseButton.text=Browse
@ -107,8 +104,6 @@ ConfigVisualPanel2.fullPathsTable.columnModel.title0=
ConfigVisualPanel2.folderNamesTable.columnModel.title0= ConfigVisualPanel2.folderNamesTable.columnModel.title0=
ConfigVisualPanel2.shouldSaveCheckBox.toolTipText= ConfigVisualPanel2.shouldSaveCheckBox.toolTipText=
NewRuleSetPanel.chooseLabel.text=Choose the type of rule NewRuleSetPanel.chooseLabel.text=Choose the type of rule
EditNonFullPathsRulePanel.minSizeTextField.text=
EditNonFullPathsRulePanel.maxSizeTextField.text=
ConfigVisualPanel2.maxSizeTextField.text= ConfigVisualPanel2.maxSizeTextField.text=
ConfigVisualPanel2.maxSizeLabel.text=Maximum: ConfigVisualPanel2.maxSizeLabel.text=Maximum:
ConfigVisualPanel2.minSizeTextField.text= ConfigVisualPanel2.minSizeTextField.text=
@ -116,10 +111,11 @@ ConfigVisualPanel2.minSizeLabel.text=Minimum:
EditNonFullPathsRulePanel.minDaysTextField.text=jFormattedTextField1 EditNonFullPathsRulePanel.minDaysTextField.text=jFormattedTextField1
ConfigVisualPanel1.browseButton.toolTipText= ConfigVisualPanel1.browseButton.toolTipText=
EditNonFullPathsRulePanel.userFolderNote.text=Starting a folder name with the token [USER_FOLDER] will allow matches of all user folders in the file system. EditNonFullPathsRulePanel.userFolderNote.text=Starting a folder name with the token [USER_FOLDER] will allow matches of all user folders in the file system.
EditNonFullPathsRulePanel.minSizeCheckBox.text=Minimum size:
EditNonFullPathsRulePanel.maxSizeCheckBox.text=Maximum size:
EditNonFullPathsRulePanel.modifiedWithinCheckbox.text=Modified within: EditNonFullPathsRulePanel.modifiedWithinCheckbox.text=Modified within:
EditNonFullPathsRulePanel.folderNamesCheckbox.text=Folder names: EditNonFullPathsRulePanel.folderNamesCheckbox.text=Folder names:
EditNonFullPathsRulePanel.fileNamesCheckbox.text=File names: EditNonFullPathsRulePanel.fileNamesCheckbox.text=File names:
EditNonFullPathsRulePanel.extensionsCheckbox.text=Extensions: EditNonFullPathsRulePanel.extensionsCheckbox.text=Extensions:
EditNonFullPathsRulePanel.descriptionCheckbox.text=Description: EditNonFullPathsRulePanel.descriptionCheckbox.text=Description:
EditNonFullPathsRulePanel.filenamesScrollPane.toolTipText=
EditNonFullPathsRulePanel.maxSizeCheckbox.text=Maximum size:
EditNonFullPathsRulePanel.minSizeCheckbox.text=Minimum size:

View File

@ -65,6 +65,8 @@ EditNonFullPathsRulePanel.modifiedDaysMustBeNumberException=Modified days must b
EditNonFullPathsRulePanel.modifiedDaysNotPositiveException=Modified days must be a positive EditNonFullPathsRulePanel.modifiedDaysNotPositiveException=Modified days must be a positive
# {0} - fieldName # {0} - fieldName
EditRulePanel.blankLineException={0} cannot have a blank line EditRulePanel.blankLineException={0} cannot have a blank line
EditRulePanel.emptyRuleName.message=Rule name cannot be empty
EditRulePanel.reservedRuleName.message=Rule name cannot be {0} that name is reserved for an autogenerated rule
EditRulePanel.shouldAlertCheckBox.text=Alert in imager console if rule matches EditRulePanel.shouldAlertCheckBox.text=Alert in imager console if rule matches
EditRulePanel.shouldSaveCheckBox.text=Extract file if it matches a rule EditRulePanel.shouldSaveCheckBox.text=Extract file if it matches a rule
EditRulePanel.fullPathsLabel.text=Full paths: EditRulePanel.fullPathsLabel.text=Full paths:
@ -137,19 +139,15 @@ EditFullPathsRulePanel.shouldSaveCheckBox.text=Extract file if it matches a path
EditFullPathsRulePanel.ruleNameTextField.text= EditFullPathsRulePanel.ruleNameTextField.text=
EditFullPathsRulePanel.fullPathsLabel.text=Full paths: EditFullPathsRulePanel.fullPathsLabel.text=Full paths:
EditFullPathsRulePanel.fullPathsLabel.toolTipText= EditFullPathsRulePanel.fullPathsLabel.toolTipText=
EditNonFullPathsRulePanel.ruleNameTextField.text=
EditNonFullPathsRulePanel.ruleNameLabel.text=Name: EditNonFullPathsRulePanel.ruleNameLabel.text=Name:
EditNonFullPathsRulePanel.descriptionTextField.text=
EditNonFullPathsRulePanel.shouldSaveCheckBox.text=Extract file if it matches a condition EditNonFullPathsRulePanel.shouldSaveCheckBox.text=Extract file if it matches a condition
EditNonFullPathsRulePanel.daysIncludedLabel.text=day(s) EditNonFullPathsRulePanel.daysIncludedLabel.text=day(s)
EditNonFullPathsRulePanel.extensionsTextField.text=
EditNonFullPathsRulePanel.shouldAlertCheckBox.actionCommand= EditNonFullPathsRulePanel.shouldAlertCheckBox.actionCommand=
EditNonFullPathsRulePanel.shouldAlertCheckBox.text=Alert in imager console if a condition matches EditNonFullPathsRulePanel.shouldAlertCheckBox.text=Alert in imager console if a condition matches
ConfigVisualPanel1.browseButton.text=Browse ConfigVisualPanel1.browseButton.text=Browse
ConfigVisualPanel2.fullPathsTable.columnModel.title0= ConfigVisualPanel2.fullPathsTable.columnModel.title0=
ConfigVisualPanel2.folderNamesTable.columnModel.title0= ConfigVisualPanel2.folderNamesTable.columnModel.title0=
ConfigVisualPanel2.shouldSaveCheckBox.toolTipText= ConfigVisualPanel2.shouldSaveCheckBox.toolTipText=
EditRulePanel.validateRuleNameExceptionMsg=Rule name cannot be empty
EncryptionProgramsRule.encryptionProgramsRuleDescription=Find encryption programs EncryptionProgramsRule.encryptionProgramsRuleDescription=Find encryption programs
EncryptionProgramsRule.encryptionProgramsRuleName=Encryption Programs EncryptionProgramsRule.encryptionProgramsRuleName=Encryption Programs
LogicalImagerConfigDeserializer.fullPathsException=A rule with full-paths cannot have other rule definitions LogicalImagerConfigDeserializer.fullPathsException=A rule with full-paths cannot have other rule definitions
@ -159,8 +157,6 @@ LogicalImagerConfigDeserializer.unsupportedKeyException=Unsupported key: {0}
NewRuleSetPanel.attributeRule.description=Search for files based on one or more attributes or metadata fields. NewRuleSetPanel.attributeRule.description=Search for files based on one or more attributes or metadata fields.
NewRuleSetPanel.attributeRule.name=Attribute NewRuleSetPanel.attributeRule.name=Attribute
NewRuleSetPanel.chooseLabel.text=Choose the type of rule NewRuleSetPanel.chooseLabel.text=Choose the type of rule
EditNonFullPathsRulePanel.minSizeTextField.text=
EditNonFullPathsRulePanel.maxSizeTextField.text=
ConfigVisualPanel2.maxSizeTextField.text= ConfigVisualPanel2.maxSizeTextField.text=
ConfigVisualPanel2.maxSizeLabel.text=Maximum: ConfigVisualPanel2.maxSizeLabel.text=Maximum:
ConfigVisualPanel2.minSizeTextField.text= ConfigVisualPanel2.minSizeTextField.text=
@ -168,12 +164,13 @@ ConfigVisualPanel2.minSizeLabel.text=Minimum:
EditNonFullPathsRulePanel.minDaysTextField.text=jFormattedTextField1 EditNonFullPathsRulePanel.minDaysTextField.text=jFormattedTextField1
ConfigVisualPanel1.browseButton.toolTipText= ConfigVisualPanel1.browseButton.toolTipText=
EditNonFullPathsRulePanel.userFolderNote.text=Starting a folder name with the token [USER_FOLDER] will allow matches of all user folders in the file system. EditNonFullPathsRulePanel.userFolderNote.text=Starting a folder name with the token [USER_FOLDER] will allow matches of all user folders in the file system.
EditNonFullPathsRulePanel.minSizeCheckBox.text=Minimum size:
EditNonFullPathsRulePanel.maxSizeCheckBox.text=Maximum size:
EditNonFullPathsRulePanel.modifiedWithinCheckbox.text=Modified within: EditNonFullPathsRulePanel.modifiedWithinCheckbox.text=Modified within:
EditNonFullPathsRulePanel.folderNamesCheckbox.text=Folder names: EditNonFullPathsRulePanel.folderNamesCheckbox.text=Folder names:
EditNonFullPathsRulePanel.fileNamesCheckbox.text=File names: EditNonFullPathsRulePanel.fileNamesCheckbox.text=File names:
EditNonFullPathsRulePanel.extensionsCheckbox.text=Extensions: EditNonFullPathsRulePanel.extensionsCheckbox.text=Extensions:
EditNonFullPathsRulePanel.descriptionCheckbox.text=Description: EditNonFullPathsRulePanel.descriptionCheckbox.text=Description:
EditNonFullPathsRulePanel.filenamesScrollPane.toolTipText=
EditNonFullPathsRulePanel.maxSizeCheckbox.text=Maximum size:
EditNonFullPathsRulePanel.minSizeCheckbox.text=Minimum size:
NewRuleSetPanel.fullPathRule.description=Search for files based on full exact match path. NewRuleSetPanel.fullPathRule.description=Search for files based on full exact match path.
NewRuleSetPanel.fullPathRule.name=Full Path NewRuleSetPanel.fullPathRule.name=Full Path

View File

@ -425,7 +425,7 @@ final class ConfigVisualPanel2 extends JPanel {
int row = rulesTable.getSelectedRow(); int row = rulesTable.getSelectedRow();
if (row != -1) { if (row != -1) {
String ruleName = (String) rulesTable.getModel().getValueAt(row, 0); String ruleName = (String) rulesTable.getModel().getValueAt(row, 0);
LogicalImagerRule rule = getFirstRuleSet().getRules().get(row); LogicalImagerRule rule = getRuleSetFromCurrentConfig().getRules().get(row);
EditRulePanel editPanel = new EditRulePanel(okButton, cancelButton, ruleName, rule); EditRulePanel editPanel = new EditRulePanel(okButton, cancelButton, ruleName, rule);
editPanel.setEnabled(true); editPanel.setEnabled(true);
editPanel.setVisible(true); editPanel.setVisible(true);
@ -499,7 +499,7 @@ final class ConfigVisualPanel2 extends JPanel {
return; return;
} }
getFirstRuleSet().getRules().remove(index); getRuleSetFromCurrentConfig().getRules().remove(index);
updatePanel(configFilename, config); updatePanel(configFilename, config);
if (rulesTable.getRowCount() > 0) { if (rulesTable.getRowCount() > 0) {
rulesTable.setRowSelectionInterval(0, 0); rulesTable.setRowSelectionInterval(0, 0);
@ -526,7 +526,7 @@ final class ConfigVisualPanel2 extends JPanel {
// remove it // remove it
int index = ((RulesTableModel) rulesTable.getModel()).findRow(EncryptionProgramsRule.getName()); int index = ((RulesTableModel) rulesTable.getModel()).findRow(EncryptionProgramsRule.getName());
if (index != -1) { if (index != -1) {
getFirstRuleSet().getRules().remove(index); getRuleSetFromCurrentConfig().getRules().remove(index);
updatePanel(configFilename, config); updatePanel(configFilename, config);
if (rulesTable.getRowCount() > 0) { if (rulesTable.getRowCount() > 0) {
rulesTable.setRowSelectionInterval(0, 0); rulesTable.setRowSelectionInterval(0, 0);
@ -588,7 +588,7 @@ final class ConfigVisualPanel2 extends JPanel {
private javax.swing.JCheckBox shouldSaveCheckBox; private javax.swing.JCheckBox shouldSaveCheckBox;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private LogicalImagerRuleSet getFirstRuleSet() { private LogicalImagerRuleSet getRuleSetFromCurrentConfig() {
if (config.getRuleSets().isEmpty()) { if (config.getRuleSets().isEmpty()) {
List<LogicalImagerRuleSet> ruleSets = new ArrayList<>(); List<LogicalImagerRuleSet> ruleSets = new ArrayList<>();
ruleSets.add(new LogicalImagerRuleSet("no-set-name", new ArrayList<>())); // NON-NLS ruleSets.add(new LogicalImagerRuleSet("no-set-name", new ArrayList<>())); // NON-NLS
@ -600,7 +600,7 @@ final class ConfigVisualPanel2 extends JPanel {
private void updatePanel(String configFilePath, LogicalImagerConfig config, String rowSelectionkey) { private void updatePanel(String configFilePath, LogicalImagerConfig config, String rowSelectionkey) {
configFileTextField.setText(configFilePath); configFileTextField.setText(configFilePath);
finalizeImageWriter.setSelected(config.isFinalizeImageWriter()); finalizeImageWriter.setSelected(config.isFinalizeImageWriter());
LogicalImagerRuleSet ruleSet = getFirstRuleSet(); LogicalImagerRuleSet ruleSet = getRuleSetFromCurrentConfig();
flagEncryptionProgramsCheckBox.setSelected(ruleSet.find(EncryptionProgramsRule.getName()) != null); flagEncryptionProgramsCheckBox.setSelected(ruleSet.find(EncryptionProgramsRule.getName()) != null);
RulesTableModel rulesTableModel = new RulesTableModel(); RulesTableModel rulesTableModel = new RulesTableModel();
int row = 0; int row = 0;
@ -646,7 +646,7 @@ final class ConfigVisualPanel2 extends JPanel {
private void updateRuleDetails(String ruleName, String description, LogicalImagerConfig config) { private void updateRuleDetails(String ruleName, String description, LogicalImagerConfig config) {
clearRuleDetails(); clearRuleDetails();
LogicalImagerRule rule = getFirstRuleSet().find(ruleName); LogicalImagerRule rule = getRuleSetFromCurrentConfig().find(ruleName);
shouldAlertCheckBox.setSelected(rule.isShouldAlert()); shouldAlertCheckBox.setSelected(rule.isShouldAlert());
shouldSaveCheckBox.setSelected(rule.isShouldSave()); shouldSaveCheckBox.setSelected(rule.isShouldSave());
ruleNameEditTextField.setText(ruleName); ruleNameEditTextField.setText(ruleName);
@ -729,13 +729,13 @@ final class ConfigVisualPanel2 extends JPanel {
} }
private void updateRow(int index, ImmutablePair<String, LogicalImagerRule> ruleMap) { private void updateRow(int index, ImmutablePair<String, LogicalImagerRule> ruleMap) {
getFirstRuleSet().getRules().remove(index); getRuleSetFromCurrentConfig().getRules().remove(index);
getFirstRuleSet().getRules().add(ruleMap.getValue()); getRuleSetFromCurrentConfig().getRules().add(ruleMap.getValue());
updatePanel(configFilename, config, ruleMap.getKey()); updatePanel(configFilename, config, ruleMap.getKey());
} }
private void appendRow(ImmutablePair<String, LogicalImagerRule> ruleMap) { private void appendRow(ImmutablePair<String, LogicalImagerRule> ruleMap) {
getFirstRuleSet().getRules().add(ruleMap.getValue()); getRuleSetFromCurrentConfig().getRules().add(ruleMap.getValue());
updatePanel(configFilename, config, ruleMap.getKey()); updatePanel(configFilename, config, ruleMap.getKey());
} }

View File

@ -30,8 +30,8 @@
<Component id="ruleNameLabel" alignment="0" max="32767" attributes="0"/> <Component id="ruleNameLabel" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0"> <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="minSizeCheckBox" alignment="0" max="32767" attributes="0"/> <Component id="minSizeCheckbox" alignment="0" max="32767" attributes="0"/>
<Component id="maxSizeCheckBox" alignment="0" pref="101" max="32767" attributes="0"/> <Component id="maxSizeCheckbox" alignment="0" pref="101" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
@ -63,7 +63,7 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="modifiedWithinCheckbox" min="-2" max="-2" attributes="0"/> <Component id="modifiedWithinCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/> <EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Component id="modifiedWithTextField" min="-2" pref="63" max="-2" attributes="0"/> <Component id="modifiedWithinTextField" min="-2" pref="63" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="daysIncludedLabel" min="-2" max="-2" attributes="0"/> <Component id="daysIncludedLabel" min="-2" max="-2" attributes="0"/>
</Group> </Group>
@ -117,17 +117,17 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="minSizeTextField" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="minSizeTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="minSizeCheckBox" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="minSizeCheckbox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="maxSizeTextField" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="maxSizeTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="maxSizeCheckBox" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="maxSizeCheckbox" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0"> <Group type="103" groupAlignment="2" attributes="0">
<Component id="daysIncludedLabel" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="daysIncludedLabel" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="modifiedWithTextField" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="modifiedWithinTextField" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="modifiedWithinCheckbox" alignment="2" min="-2" max="-2" attributes="0"/> <Component id="modifiedWithinCheckbox" alignment="2" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -167,17 +167,11 @@
</Component> </Component>
<Component class="javax.swing.JTextField" name="extensionsTextField"> <Component class="javax.swing.JTextField" name="extensionsTextField">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.extensionsTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/> <Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="descriptionTextField"> <Component class="javax.swing.JTextField" name="descriptionTextField">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.descriptionTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/> <Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
</Component> </Component>
@ -189,14 +183,12 @@
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="ruleNameTextField"> <Component class="javax.swing.JTextField" name="ruleNameTextField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.ruleNameTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component> </Component>
<Container class="javax.swing.JScrollPane" name="filenamesScrollPane"> <Container class="javax.swing.JScrollPane" name="filenamesScrollPane">
<Properties> <Properties>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.filenamesScrollPane.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/> <Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
@ -214,9 +206,6 @@
<Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor"> <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor">
<Format format="#,###; " subtype="-1" type="0"/> <Format format="#,###; " subtype="-1" type="0"/>
</Property> </Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.minSizeTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/> <Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
</Component> </Component>
@ -225,13 +214,10 @@
<Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor"> <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor">
<Format format="#,###; " subtype="-1" type="0"/> <Format format="#,###; " subtype="-1" type="0"/>
</Property> </Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.maxSizeTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/> <Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JFormattedTextField" name="modifiedWithTextField"> <Component class="javax.swing.JFormattedTextField" name="modifiedWithinTextField">
<Properties> <Properties>
<Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor"> <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor">
<Format format="####; " subtype="-1" type="0"/> <Format format="####; " subtype="-1" type="0"/>
@ -249,24 +235,24 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="minSizeCheckBox"> <Component class="javax.swing.JCheckBox" name="minSizeCheckbox">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.minSizeCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.minSizeCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="minSizeCheckBoxActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="minSizeCheckboxActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="maxSizeCheckBox"> <Component class="javax.swing.JCheckBox" name="maxSizeCheckbox">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.maxSizeCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties" key="EditNonFullPathsRulePanel.maxSizeCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="maxSizeCheckBoxActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="maxSizeCheckboxActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="modifiedWithinCheckbox"> <Component class="javax.swing.JCheckBox" name="modifiedWithinCheckbox">

View File

@ -32,6 +32,10 @@ import javax.swing.JOptionPane;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.apache.commons.lang.StringUtils;
import static org.apache.commons.lang.StringUtils.isBlank; import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.strip; import static org.apache.commons.lang3.StringUtils.strip;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
@ -44,10 +48,10 @@ import org.openide.util.NbBundle;
final class EditNonFullPathsRulePanel extends javax.swing.JPanel { final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Color DISABLED_COLOR = new Color(240,240,240); private static final Color DISABLED_COLOR = new Color(240, 240, 240);
private JButton okButton; private JButton okButton;
private JButton cancelButton; private JButton cancelButton;
private final javax.swing.JTextArea filenamesTextArea; private final javax.swing.JTextArea fileNamesTextArea;
private final javax.swing.JTextArea folderNamesTextArea; private final javax.swing.JTextArea folderNamesTextArea;
/** /**
@ -68,11 +72,11 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
setExtensions(rule.getExtensions()); setExtensions(rule.getExtensions());
filenamesTextArea = new JTextArea(); fileNamesTextArea = new JTextArea();
initTextArea(filenamesScrollPane, filenamesTextArea); initTextArea(filenamesScrollPane, fileNamesTextArea);
setTextArea(filenamesTextArea, rule.getFilenames()); setTextArea(fileNamesTextArea, rule.getFilenames());
if (rule.getExtensions() != null) { if (rule.getExtensions() != null && !rule.getExtensions().isEmpty()) {
extensionsCheckbox.setSelected(true); extensionsCheckbox.setSelected(true);
} else if (rule.getFilenames() != null && !rule.getFilenames().isEmpty()) { } else if (rule.getFilenames() != null && !rule.getFilenames().isEmpty()) {
fileNamesCheckbox.setSelected(true); fileNamesCheckbox.setSelected(true);
@ -89,7 +93,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
ruleNameTextField.requestFocus(); ruleNameTextField.requestFocus();
EditRulePanel.setTextFieldPrompts(extensionsTextField, Bundle.EditNonFullPathsRulePanel_example() + "gif,jpg,png"); // NON-NLS EditRulePanel.setTextFieldPrompts(extensionsTextField, Bundle.EditNonFullPathsRulePanel_example() + "gif,jpg,png"); // NON-NLS
EditRulePanel.setTextFieldPrompts(filenamesTextArea, "<html>" EditRulePanel.setTextFieldPrompts(fileNamesTextArea, "<html>"
+ Bundle.EditNonFullPathsRulePanel_example() + Bundle.EditNonFullPathsRulePanel_example()
+ "<br>filename.txt<br>readme.txt</html>"); // NON-NLS + "<br>filename.txt<br>readme.txt</html>"); // NON-NLS
EditRulePanel.setTextFieldPrompts(folderNamesTextArea, "<html>" EditRulePanel.setTextFieldPrompts(folderNamesTextArea, "<html>"
@ -98,6 +102,40 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
+ "<br>/Program Files/Common Files</html>"); // NON-NLS + "<br>/Program Files/Common Files</html>"); // NON-NLS
validate(); validate();
repaint(); repaint();
addDocumentListeners();
}
/**
* Update the OK button when contents of a field change
*/
private void addDocumentListeners() {
SwingUtilities.invokeLater(() -> {
setOkButton(); //ensure initial state before listeners added is correct
});
DocumentListener docListener;
docListener = new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
setOkButton();
}
@Override
public void insertUpdate(DocumentEvent e) {
setOkButton();
}
@Override
public void removeUpdate(DocumentEvent e) {
setOkButton();
}
};
ruleNameTextField.getDocument().addDocumentListener(docListener);
extensionsTextField.getDocument().addDocumentListener(docListener);
fileNamesTextArea.getDocument().addDocumentListener(docListener);
folderNamesTextArea.getDocument().addDocumentListener(docListener);
minSizeTextField.getDocument().addDocumentListener(docListener);
maxSizeTextField.getDocument().addDocumentListener(docListener);
modifiedWithinTextField.getDocument().addDocumentListener(docListener);
} }
private void initTextArea(JScrollPane pane, JTextArea textArea) { private void initTextArea(JScrollPane pane, JTextArea textArea) {
@ -123,7 +161,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
} }
private void setMinDays(Integer minDays) { private void setMinDays(Integer minDays) {
modifiedWithTextField.setText(minDays == null ? "" : minDays.toString()); modifiedWithinTextField.setText(minDays == null ? "" : minDays.toString());
} }
private void setTextArea(JTextArea textArea, List<String> set) { private void setTextArea(JTextArea textArea, List<String> set) {
@ -167,10 +205,10 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
folderNamesScrollPane = new javax.swing.JScrollPane(); folderNamesScrollPane = new javax.swing.JScrollPane();
minSizeTextField = new javax.swing.JFormattedTextField(); minSizeTextField = new javax.swing.JFormattedTextField();
maxSizeTextField = new javax.swing.JFormattedTextField(); maxSizeTextField = new javax.swing.JFormattedTextField();
modifiedWithTextField = new javax.swing.JFormattedTextField(); modifiedWithinTextField = new javax.swing.JFormattedTextField();
userFolderNote = new javax.swing.JLabel(); userFolderNote = new javax.swing.JLabel();
minSizeCheckBox = new javax.swing.JCheckBox(); minSizeCheckbox = new javax.swing.JCheckBox();
maxSizeCheckBox = new javax.swing.JCheckBox(); maxSizeCheckbox = new javax.swing.JCheckBox();
modifiedWithinCheckbox = new javax.swing.JCheckBox(); modifiedWithinCheckbox = new javax.swing.JCheckBox();
folderNamesCheckbox = new javax.swing.JCheckBox(); folderNamesCheckbox = new javax.swing.JCheckBox();
fileNamesCheckbox = new javax.swing.JCheckBox(); fileNamesCheckbox = new javax.swing.JCheckBox();
@ -185,45 +223,40 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
org.openide.awt.Mnemonics.setLocalizedText(shouldAlertCheckBox, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.shouldAlertCheckBox.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(shouldAlertCheckBox, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.shouldAlertCheckBox.text")); // NOI18N
shouldAlertCheckBox.setActionCommand(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.shouldAlertCheckBox.actionCommand")); // NOI18N shouldAlertCheckBox.setActionCommand(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.shouldAlertCheckBox.actionCommand")); // NOI18N
extensionsTextField.setText(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.extensionsTextField.text")); // NOI18N
extensionsTextField.setEnabled(false); extensionsTextField.setEnabled(false);
descriptionTextField.setText(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.descriptionTextField.text")); // NOI18N
descriptionTextField.setEnabled(false); descriptionTextField.setEnabled(false);
org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.ruleNameLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.ruleNameLabel.text")); // NOI18N
ruleNameTextField.setText(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.ruleNameTextField.text")); // NOI18N filenamesScrollPane.setToolTipText(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.filenamesScrollPane.toolTipText")); // NOI18N
filenamesScrollPane.setEnabled(false); filenamesScrollPane.setEnabled(false);
folderNamesScrollPane.setEnabled(false); folderNamesScrollPane.setEnabled(false);
minSizeTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###; ")))); minSizeTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###; "))));
minSizeTextField.setText(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.minSizeTextField.text")); // NOI18N
minSizeTextField.setEnabled(false); minSizeTextField.setEnabled(false);
maxSizeTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###; ")))); maxSizeTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###; "))));
maxSizeTextField.setText(org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.maxSizeTextField.text")); // NOI18N
maxSizeTextField.setEnabled(false); maxSizeTextField.setEnabled(false);
modifiedWithTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####; ")))); modifiedWithinTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####; "))));
modifiedWithTextField.setEnabled(false); modifiedWithinTextField.setEnabled(false);
userFolderNote.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/info-icon-16.png"))); // NOI18N userFolderNote.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/info-icon-16.png"))); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(userFolderNote, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.userFolderNote.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(userFolderNote, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.userFolderNote.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(minSizeCheckBox, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.minSizeCheckBox.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(minSizeCheckbox, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.minSizeCheckbox.text")); // NOI18N
minSizeCheckBox.addActionListener(new java.awt.event.ActionListener() { minSizeCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
minSizeCheckBoxActionPerformed(evt); minSizeCheckboxActionPerformed(evt);
} }
}); });
org.openide.awt.Mnemonics.setLocalizedText(maxSizeCheckBox, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.maxSizeCheckBox.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(maxSizeCheckbox, org.openide.util.NbBundle.getMessage(EditNonFullPathsRulePanel.class, "EditNonFullPathsRulePanel.maxSizeCheckbox.text")); // NOI18N
maxSizeCheckBox.addActionListener(new java.awt.event.ActionListener() { maxSizeCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
maxSizeCheckBoxActionPerformed(evt); maxSizeCheckboxActionPerformed(evt);
} }
}); });
@ -279,8 +312,8 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
.addComponent(descriptionCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(descriptionCheckbox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(ruleNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(minSizeCheckBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(minSizeCheckbox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(maxSizeCheckBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))) .addComponent(maxSizeCheckbox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(ruleNameTextField, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(ruleNameTextField, javax.swing.GroupLayout.Alignment.TRAILING)
@ -303,7 +336,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(modifiedWithinCheckbox) .addComponent(modifiedWithinCheckbox)
.addGap(10, 10, 10) .addGap(10, 10, 10)
.addComponent(modifiedWithTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(modifiedWithinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(daysIncludedLabel)) .addComponent(daysIncludedLabel))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -343,15 +376,15 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(minSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(minSizeCheckBox)) .addComponent(minSizeCheckbox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(maxSizeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(maxSizeCheckBox)) .addComponent(maxSizeCheckbox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(daysIncludedLabel) .addComponent(daysIncludedLabel)
.addComponent(modifiedWithTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(modifiedWithinTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(modifiedWithinCheckbox)) .addComponent(modifiedWithinCheckbox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(shouldSaveCheckBox) .addComponent(shouldSaveCheckBox)
@ -366,6 +399,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
fileNamesCheckbox.setSelected(false); fileNamesCheckbox.setSelected(false);
} }
updateExclusiveConditions(); updateExclusiveConditions();
setOkButton();
}//GEN-LAST:event_extensionsCheckboxActionPerformed }//GEN-LAST:event_extensionsCheckboxActionPerformed
private void fileNamesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileNamesCheckboxActionPerformed private void fileNamesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileNamesCheckboxActionPerformed
@ -373,6 +407,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
extensionsCheckbox.setSelected(false); extensionsCheckbox.setSelected(false);
} }
updateExclusiveConditions(); updateExclusiveConditions();
setOkButton();
}//GEN-LAST:event_fileNamesCheckboxActionPerformed }//GEN-LAST:event_fileNamesCheckboxActionPerformed
private void descriptionCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descriptionCheckboxActionPerformed private void descriptionCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descriptionCheckboxActionPerformed
@ -384,23 +419,27 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
folderNamesTextArea.setEditable(folderNamesCheckbox.isSelected()); folderNamesTextArea.setEditable(folderNamesCheckbox.isSelected());
folderNamesTextArea.setEnabled(folderNamesCheckbox.isSelected()); folderNamesTextArea.setEnabled(folderNamesCheckbox.isSelected());
updateTextAreaBackgroundColor(folderNamesTextArea); updateTextAreaBackgroundColor(folderNamesTextArea);
setOkButton();
}//GEN-LAST:event_folderNamesCheckboxActionPerformed }//GEN-LAST:event_folderNamesCheckboxActionPerformed
private void minSizeCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minSizeCheckBoxActionPerformed private void minSizeCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minSizeCheckboxActionPerformed
minSizeTextField.setEnabled(minSizeCheckBox.isSelected()); minSizeTextField.setEnabled(minSizeCheckbox.isSelected());
}//GEN-LAST:event_minSizeCheckBoxActionPerformed setOkButton();
}//GEN-LAST:event_minSizeCheckboxActionPerformed
private void maxSizeCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxSizeCheckBoxActionPerformed private void maxSizeCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxSizeCheckboxActionPerformed
maxSizeTextField.setEnabled(maxSizeCheckBox.isSelected()); maxSizeTextField.setEnabled(maxSizeCheckbox.isSelected());
}//GEN-LAST:event_maxSizeCheckBoxActionPerformed setOkButton();
}//GEN-LAST:event_maxSizeCheckboxActionPerformed
private void modifiedWithinCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modifiedWithinCheckboxActionPerformed private void modifiedWithinCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modifiedWithinCheckboxActionPerformed
modifiedWithTextField.setEnabled(modifiedWithinCheckbox.isSelected()); modifiedWithinTextField.setEnabled(modifiedWithinCheckbox.isSelected());
setOkButton();
}//GEN-LAST:event_modifiedWithinCheckboxActionPerformed }//GEN-LAST:event_modifiedWithinCheckboxActionPerformed
private static void updateTextAreaBackgroundColor(JTextArea textArea){ private static void updateTextAreaBackgroundColor(JTextArea textArea) {
if (textArea.isEnabled()){ if (textArea.isEnabled()) {
textArea.setBackground(Color.WHITE); textArea.setBackground(Color.WHITE);
} else { } else {
textArea.setBackground(DISABLED_COLOR); textArea.setBackground(DISABLED_COLOR);
@ -410,9 +449,9 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
private void updateExclusiveConditions() { private void updateExclusiveConditions() {
extensionsTextField.setEnabled(extensionsCheckbox.isSelected()); extensionsTextField.setEnabled(extensionsCheckbox.isSelected());
filenamesScrollPane.setEnabled(fileNamesCheckbox.isSelected()); filenamesScrollPane.setEnabled(fileNamesCheckbox.isSelected());
filenamesTextArea.setEditable(fileNamesCheckbox.isSelected()); fileNamesTextArea.setEditable(fileNamesCheckbox.isSelected());
filenamesTextArea.setEnabled(fileNamesCheckbox.isSelected()); fileNamesTextArea.setEnabled(fileNamesCheckbox.isSelected());
updateTextAreaBackgroundColor(filenamesTextArea); updateTextAreaBackgroundColor(fileNamesTextArea);
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
@ -425,12 +464,12 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
private javax.swing.JScrollPane filenamesScrollPane; private javax.swing.JScrollPane filenamesScrollPane;
private javax.swing.JCheckBox folderNamesCheckbox; private javax.swing.JCheckBox folderNamesCheckbox;
private javax.swing.JScrollPane folderNamesScrollPane; private javax.swing.JScrollPane folderNamesScrollPane;
private javax.swing.JCheckBox maxSizeCheckBox; private javax.swing.JCheckBox maxSizeCheckbox;
private javax.swing.JFormattedTextField maxSizeTextField; private javax.swing.JFormattedTextField maxSizeTextField;
private javax.swing.JCheckBox minSizeCheckBox; private javax.swing.JCheckBox minSizeCheckbox;
private javax.swing.JFormattedTextField minSizeTextField; private javax.swing.JFormattedTextField minSizeTextField;
private javax.swing.JFormattedTextField modifiedWithTextField;
private javax.swing.JCheckBox modifiedWithinCheckbox; private javax.swing.JCheckBox modifiedWithinCheckbox;
private javax.swing.JFormattedTextField modifiedWithinTextField;
private javax.swing.JLabel ruleNameLabel; private javax.swing.JLabel ruleNameLabel;
private javax.swing.JTextField ruleNameTextField; private javax.swing.JTextField ruleNameTextField;
private javax.swing.JCheckBox shouldAlertCheckBox; private javax.swing.JCheckBox shouldAlertCheckBox;
@ -451,10 +490,20 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
*/ */
private void setOkButton() { private void setOkButton() {
if (this.okButton != null) { if (this.okButton != null) {
this.okButton.setEnabled(true); this.okButton.setEnabled(!StringUtils.isBlank(ruleNameTextField.getText()) && atLeastOneConditionSet());
} }
} }
private boolean atLeastOneConditionSet() {
return (extensionsCheckbox.isSelected() && !StringUtils.isBlank(extensionsTextField.getText()))
|| (fileNamesCheckbox.isSelected() && !StringUtils.isBlank(fileNamesTextArea.getText()))
|| (folderNamesCheckbox.isSelected() && !StringUtils.isBlank(folderNamesTextArea.getText()))
|| (minSizeCheckbox.isSelected() && !StringUtils.isBlank(minSizeTextField.getText()))
|| (maxSizeCheckbox.isSelected() && !StringUtils.isBlank(maxSizeTextField.getText()))
|| (modifiedWithinCheckbox.isSelected() && !StringUtils.isBlank(modifiedWithinTextField.getText()));
}
/** /**
* Gets the JOptionPane that is used to contain this panel if there is one * Gets the JOptionPane that is used to contain this panel if there is one
* *
@ -509,9 +558,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
"EditNonFullPathsRulePanel.folderNames=Folder names",}) "EditNonFullPathsRulePanel.folderNames=Folder names",})
ImmutablePair<String, LogicalImagerRule> toRule() throws IOException { ImmutablePair<String, LogicalImagerRule> toRule() throws IOException {
String ruleName = EditRulePanel.validRuleName(ruleNameTextField.getText()); String ruleName = EditRulePanel.validRuleName(ruleNameTextField.getText());
List<String> extensions = validateExtensions(extensionsTextField); List<String> folderNames = folderNamesCheckbox.isSelected() ? EditRulePanel.validateTextList(folderNamesTextArea, Bundle.EditNonFullPathsRulePanel_folderNames()) : null;
List<String> filenames = EditRulePanel.validateTextList(filenamesTextArea, Bundle.EditNonFullPathsRulePanel_fileNames());
List<String> folderNames = EditRulePanel.validateTextList(folderNamesTextArea, Bundle.EditNonFullPathsRulePanel_folderNames());
LogicalImagerRule.Builder builder = new LogicalImagerRule.Builder(); LogicalImagerRule.Builder builder = new LogicalImagerRule.Builder();
builder.getName(ruleName) builder.getName(ruleName)
@ -521,16 +568,16 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
.getPaths(folderNames); .getPaths(folderNames);
if (extensionsCheckbox.isSelected()) { if (extensionsCheckbox.isSelected()) {
builder.getExtensions(extensions); builder.getExtensions(validateExtensions(extensionsTextField));
} else if (fileNamesCheckbox.isSelected()) { } else if (fileNamesCheckbox.isSelected()) {
builder.getFilenames(filenames); builder.getFilenames( EditRulePanel.validateTextList(fileNamesTextArea, Bundle.EditNonFullPathsRulePanel_fileNames()));
} }
int minDays; int minDays;
if (!isBlank(modifiedWithTextField.getText())) { if (modifiedWithinCheckbox.isSelected() && !isBlank(modifiedWithinTextField.getText())) {
try { try {
modifiedWithTextField.commitEdit(); modifiedWithinTextField.commitEdit();
minDays = ((Number) modifiedWithTextField.getValue()).intValue(); minDays = ((Number) modifiedWithinTextField.getValue()).intValue();
if (minDays < 0) { if (minDays < 0) {
throw new IOException(Bundle.EditNonFullPathsRulePanel_modifiedDaysNotPositiveException()); throw new IOException(Bundle.EditNonFullPathsRulePanel_modifiedDaysNotPositiveException());
} }
@ -541,7 +588,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
} }
int minFileSize = 0; int minFileSize = 0;
if (!isBlank(minSizeTextField.getText())) { if (minSizeCheckbox.isSelected() && !isBlank(minSizeTextField.getText())) {
try { try {
minSizeTextField.commitEdit(); minSizeTextField.commitEdit();
minFileSize = ((Number) minSizeTextField.getValue()).intValue(); minFileSize = ((Number) minSizeTextField.getValue()).intValue();
@ -554,7 +601,7 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
} }
int maxFileSize = 0; int maxFileSize = 0;
if (!isBlank(maxSizeTextField.getText())) { if (maxSizeCheckbox.isSelected() && !isBlank(maxSizeTextField.getText())) {
try { try {
maxSizeTextField.commitEdit(); maxSizeTextField.commitEdit();
maxFileSize = ((Number) maxSizeTextField.getValue()).intValue(); maxFileSize = ((Number) maxSizeTextField.getValue()).intValue();
@ -569,10 +616,10 @@ final class EditNonFullPathsRulePanel extends javax.swing.JPanel {
if (maxFileSize != 0 && (maxFileSize < minFileSize)) { if (maxFileSize != 0 && (maxFileSize < minFileSize)) {
throw new IOException(Bundle.EditNonFullPathsRulePanel_maxFileSizeSmallerThanMinException(maxFileSize, minFileSize)); throw new IOException(Bundle.EditNonFullPathsRulePanel_maxFileSizeSmallerThanMinException(maxFileSize, minFileSize));
} }
if (minFileSize != 0) { if (minSizeCheckbox.isSelected() && minFileSize != 0) {
builder.getMinFileSize(minFileSize); builder.getMinFileSize(minFileSize);
} }
if (maxFileSize != 0) { if (maxSizeCheckbox.isSelected() && maxFileSize != 0) {
builder.getMaxFileSize(maxFileSize); builder.getMaxFileSize(maxFileSize);
} }

View File

@ -89,12 +89,16 @@ final class EditRulePanel extends JPanel {
} }
@NbBundle.Messages({ @NbBundle.Messages({
"EditRulePanel.validateRuleNameExceptionMsg=Rule name cannot be empty" "EditRulePanel.emptyRuleName.message=Rule name cannot be empty",
}) "EditRulePanel.reservedRuleName.message=Rule name cannot be {0} that name is reserved for an autogenerated rule" })
static String validRuleName(String name) throws IOException { static String validRuleName(String name) throws IOException {
if (name.isEmpty()) { if (name.isEmpty()) {
throw new IOException(Bundle.EditRulePanel_validateRuleNameExceptionMsg()); throw new IOException(Bundle.EditRulePanel_emptyRuleName_message());
} }
if (name.equals(EncryptionProgramsRule.getName())){
throw new IOException(Bundle.EditRulePanel_reservedRuleName_message(name));
}
//WJS-TODO check if rule name exists already
return name; return name;
} }

View File

@ -37,7 +37,6 @@ final class EncryptionProgramsRule {
private EncryptionProgramsRule() {} private EncryptionProgramsRule() {}
// TODO: Add more files here
static { static {
// Truecrypt // Truecrypt
FILENAMES.add("truecrypt.exe"); // NON-NLS FILENAMES.add("truecrypt.exe"); // NON-NLS