19 package org.sleuthkit.autopsy.modules.fileextmismatch;
21 import org.openide.util.NbBundle;
22 import java.awt.event.ActionEvent;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.HashMap;
26 import javax.swing.AbstractAction;
27 import javax.swing.JOptionPane;
33 class AddFileExtensionAction
extends AbstractAction {
35 private String extStr;
36 private String mimeTypeStr;
38 public AddFileExtensionAction(String menuItemStr, String extStr, String mimeTypeStr) {
40 this.mimeTypeStr = mimeTypeStr;
45 public void actionPerformed(ActionEvent event) {
46 HashMap<String, String[]> editableMap = FileExtMismatchXML.getDefault().load();
47 ArrayList<String> editedExtensions =
new ArrayList<>(Arrays.asList(editableMap.get(mimeTypeStr)));
48 editedExtensions.add(extStr);
51 editableMap.put(mimeTypeStr, editedExtensions.toArray(
new String[0]));
53 if (!FileExtMismatchXML.getDefault().save(editableMap)) {
55 JOptionPane.showMessageDialog(null,
56 NbBundle.getMessage(
this.getClass(),
"AddFileExtensionAction.msgDlg.msg"),
57 NbBundle.getMessage(
this.getClass(),
"AddFileExtensionAction.msgDlg.title"),
58 JOptionPane.ERROR_MESSAGE);