From 4e722ce81a00a10ae1053a85f1ea9ac99cff307d Mon Sep 17 00:00:00 2001 From: Sophie Mori Date: Fri, 7 Oct 2016 17:23:59 -0400 Subject: [PATCH] Eliminated use of action command binding --- .../autopsy/directorytree/AddRulePanel.java | 59 +++++++++---------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/AddRulePanel.java b/Core/src/org/sleuthkit/autopsy/directorytree/AddRulePanel.java index 85d4572b94..7b20894c3d 100755 --- a/Core/src/org/sleuthkit/autopsy/directorytree/AddRulePanel.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/AddRulePanel.java @@ -142,39 +142,36 @@ class AddRulePanel extends javax.swing.JPanel { } String name = nameTextField.getText(); - String buttonActionCommand = buttonGroup.getSelection().getActionCommand(); - switch (buttonActionCommand) { - case "mime": //NON-NLS - FileTypeDetector detector; - try { - detector = new FileTypeDetector(); - } catch (FileTypeDetector.FileTypeDetectorInitException ex) { - logger.log(Level.WARNING, "Couldn't create file type detector for file ext mismatch settings.", ex); - return null; - } - if (name.isEmpty() || !detector.isDetectable(name)) { - JOptionPane.showMessageDialog(null, - NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidMime.message"), - NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidMime.title"), - JOptionPane.ERROR_MESSAGE); - return null; - } - return new ExternalViewerRule(name, exePath, ExternalViewerRule.RuleType.MIME); - case "ext": //NON-NLS - if (name.isEmpty() || !name.matches("^\\.?\\w+$")) { - JOptionPane.showMessageDialog(null, - NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidExt.message"), - NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidExt.title"), - JOptionPane.ERROR_MESSAGE); - return null; - } - if (name.charAt(0) != '.') { - name = "." + name; - } - return new ExternalViewerRule(name.toLowerCase(), exePath, ExternalViewerRule.RuleType.EXT); - default: + if (mimeRadioButton.isSelected()) { + FileTypeDetector detector; + try { + detector = new FileTypeDetector(); + } catch (FileTypeDetector.FileTypeDetectorInitException ex) { + logger.log(Level.WARNING, "Couldn't create file type detector for file ext mismatch settings.", ex); return null; + } + if (name.isEmpty() || !detector.isDetectable(name)) { + JOptionPane.showMessageDialog(null, + NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidMime.message"), + NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidMime.title"), + JOptionPane.ERROR_MESSAGE); + return null; + } + return new ExternalViewerRule(name, exePath, ExternalViewerRule.RuleType.MIME); + } else if (extRadioButton.isSelected()) { + if (name.isEmpty() || !name.matches("^\\.?\\w+$")) { + JOptionPane.showMessageDialog(null, + NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidExt.message"), + NbBundle.getMessage(ExternalViewerGlobalSettingsPanel.class, "ExternalViewerGlobalSettingsPanel.JOptionPane.invalidExt.title"), + JOptionPane.ERROR_MESSAGE); + return null; + } + if (name.charAt(0) != '.') { + name = "." + name; + } + return new ExternalViewerRule(name.toLowerCase(), exePath, ExternalViewerRule.RuleType.EXT); } + return null; } /**