19 package org.sleuthkit.autopsy.modules.fileextmismatch;
21 import java.awt.event.ActionEvent;
22 import java.util.HashMap;
24 import java.util.logging.Level;
25 import javax.swing.AbstractAction;
26 import javax.swing.JOptionPane;
27 import org.openide.util.NbBundle;
28 import org.openide.util.NbBundle.Messages;
35 class AddFileExtensionAction
extends AbstractAction {
37 private static final long serialVersionUID = 1L;
39 private final String extStr;
40 private final String mimeTypeStr;
41 private final FileExtMismatchSettings settings;
43 AddFileExtensionAction(String menuItemStr, String extStr, String mimeTypeStr, FileExtMismatchSettings settings) {
45 this.mimeTypeStr = mimeTypeStr;
47 this.settings = settings;
51 @Messages({
"AddFileExtensionAction.writeError.message=Could not write file extension settings."})
52 public void actionPerformed(ActionEvent event) {
53 HashMap<String, Set<String>> editableMap;
54 editableMap = settings.getMimeTypeToExtsMap();
55 Set<String> editedExtensions = editableMap.get(mimeTypeStr);
56 editedExtensions.add(extStr);
59 FileExtMismatchSettings.writeSettings(
new FileExtMismatchSettings(editableMap));
60 }
catch (FileExtMismatchSettings.FileExtMismatchSettingsException ex) {
62 JOptionPane.showMessageDialog(null,
63 Bundle.AddFileExtensionAction_writeError_message(),
64 NbBundle.getMessage(this.getClass(),
"AddFileExtensionAction.msgDlg.title"),
65 JOptionPane.ERROR_MESSAGE);
66 logger.log(Level.SEVERE,
"Could not write file extension settings.", ex);
synchronized static Logger getLogger(String name)