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;
29 import org.openide.windows.WindowManager;
36 class AddFileExtensionAction
extends AbstractAction {
38 private static final long serialVersionUID = 1L;
40 private final String extStr;
41 private final String mimeTypeStr;
42 private final FileExtMismatchSettings settings;
44 AddFileExtensionAction(String menuItemStr, String extStr, String mimeTypeStr, FileExtMismatchSettings settings) {
46 this.mimeTypeStr = mimeTypeStr;
48 this.settings = settings;
52 @Messages({
"AddFileExtensionAction.writeError.message=Could not write file extension settings."})
53 public void actionPerformed(ActionEvent event) {
54 HashMap<String, Set<String>> editableMap;
55 editableMap = settings.getMimeTypeToExtsMap();
56 Set<String> editedExtensions = editableMap.get(mimeTypeStr);
57 editedExtensions.add(extStr);
60 FileExtMismatchSettings.writeSettings(
new FileExtMismatchSettings(editableMap));
61 }
catch (FileExtMismatchSettings.FileExtMismatchSettingsException ex) {
63 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
64 Bundle.AddFileExtensionAction_writeError_message(),
65 NbBundle.getMessage(this.getClass(),
"AddFileExtensionAction.msgDlg.title"),
66 JOptionPane.ERROR_MESSAGE);
67 logger.log(Level.SEVERE,
"Could not write file extension settings.", ex);
synchronized static Logger getLogger(String name)