public class FileAssociationManager {
- private static final String TEXT_EDITOR = "scribes";
+ private static final String TEXT_EDITOR = "gd";
private static final String FILE_INDICATOR = "<FILE>";
public static HashMap<String, String[]> extensionToApplication = new HashMap<String, String[]>();
- public FileAssociationManager() {
-
- extensionToApplication.put("txt", new String[] { TEXT_EDITOR, FILE_INDICATOR });
- extensionToApplication.put("xml", new String[] { TEXT_EDITOR, FILE_INDICATOR });
- extensionToApplication.put("properties", new String[] { TEXT_EDITOR, FILE_INDICATOR });
- extensionToApplication.put("ini", new String[] { TEXT_EDITOR, FILE_INDICATOR });
- extensionToApplication.put("", new String[] { TEXT_EDITOR, FILE_INDICATOR });
-
- extensionToApplication.put("jpg", new String[] { "eog", FILE_INDICATOR });
- extensionToApplication.put("jpeg", new String[] { "eog", FILE_INDICATOR });
- extensionToApplication.put("png", new String[] { "eog", FILE_INDICATOR });
-
- extensionToApplication.put("pdf", new String[] { "evince", FILE_INDICATOR });
-
- extensionToApplication.put("mp3", new String[] { "banshee", FILE_INDICATOR });
- extensionToApplication.put("ogg", new String[] { "banshee", FILE_INDICATOR });
-
- extensionToApplication.put("avi", new String[] { "vlc", FILE_INDICATOR });
- extensionToApplication.put("mkv", new String[] { "vlc", FILE_INDICATOR });
- extensionToApplication.put("ogv", new String[] { "vlc", FILE_INDICATOR });
- extensionToApplication.put("mp4", new String[] { "vlc", FILE_INDICATOR });
- extensionToApplication.put("flv", new String[] { "vlc", FILE_INDICATOR });
- extensionToApplication.put("wmv", new String[] { "vlc", FILE_INDICATOR });
-
- extensionToApplication.put("ods", new String[] { "localc", FILE_INDICATOR });
- extensionToApplication.put("docx", new String[] { "lowriter", FILE_INDICATOR });
-
- }
-
public static boolean openFile(final File file) {
final String fileExtension = Utils.getFileExtension(file);
final String[] c = new String[commands.length];
- for (int i = 0; i < commands.length; i++) {
-
- if (commands[i].equals(FILE_INDICATOR)) {
+ for (int i = 0; i < commands.length; i++)
+ if (commands[i].equals(FILE_INDICATOR))
c[i] = file.getAbsolutePath();
- } else {
+ else
c[i] = commands[i];
- }
- }
try {
Runtime.getRuntime().exec(c);
}
return true;
- } else {
+ } else
return false;
- }
+
+ }
+
+ public FileAssociationManager() {
+
+ extensionToApplication.put("txt", new String[] { TEXT_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("xml", new String[] { TEXT_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("properties", new String[] { TEXT_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("ini", new String[] { TEXT_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("", new String[] { TEXT_EDITOR, FILE_INDICATOR });
+
+ extensionToApplication.put("jpg", new String[] { "eog", FILE_INDICATOR });
+ extensionToApplication.put("jpeg", new String[] { "eog", FILE_INDICATOR });
+ extensionToApplication.put("png", new String[] { "eog", FILE_INDICATOR });
+
+ extensionToApplication.put("pdf", new String[] { "evince", FILE_INDICATOR });
+
+ extensionToApplication.put("mp3", new String[] { "banshee", FILE_INDICATOR });
+ extensionToApplication.put("ogg", new String[] { "banshee", FILE_INDICATOR });
+
+ extensionToApplication.put("avi", new String[] { "vlc", FILE_INDICATOR });
+ extensionToApplication.put("mkv", new String[] { "vlc", FILE_INDICATOR });
+ extensionToApplication.put("ogv", new String[] { "vlc", FILE_INDICATOR });
+ extensionToApplication.put("mp4", new String[] { "vlc", FILE_INDICATOR });
+ extensionToApplication.put("flv", new String[] { "vlc", FILE_INDICATOR });
+ extensionToApplication.put("wmv", new String[] { "vlc", FILE_INDICATOR });
+
+ extensionToApplication.put("ods", new String[] { "localc", FILE_INDICATOR });
+ extensionToApplication.put("docx", new String[] { "lowriter", FILE_INDICATOR });
}