public class FileAssociationManager {
+ private static final String FILE_INDICATOR = "<FILE>";
+
+ private static final String[] TEXT_EDITOR_PATTERN = new String[] { "emc", FILE_INDICATOR };
+
+ private static final String DOCUMENT_EDITOR = "lowriter";
+
+ private static final String SPREADSHEET_EDITOR = "localc";
+
+ private static final String MUSIC_PLAYER = "clementine";
+
+ public static HashMap<String, String[]> extensionToApplication = new HashMap<String, String[]>();
+
private static boolean isLogFile(final String fileName) {
if (fileName.endsWith(".out"))
return true;
public static boolean openFile(final File file) {
if (isLogFile(file.getName())) {
- runOpeningApplication(file,
- new String[] { "glogg", FILE_INDICATOR });
+ runOpeningApplication(file, new String[] { "glogg", FILE_INDICATOR });
return true;
}
}
- private static void runOpeningApplication(final File file,
- final String[] commands) {
+ private static void runOpeningApplication(final File file, final String[] commands) {
for (int i = 0; i < commands.length; i++)
if (commands[i].equals(FILE_INDICATOR))
commands[i] = file.getAbsolutePath();
}
}
- private static final String FILE_INDICATOR = "<FILE>";
-
- private static final String[] TEXT_EDITOR_PATTERN = new String[] {
- "emacsclient", "-a", "\"\"", "-c", FILE_INDICATOR };
-
- private static final String DOCUMENT_EDITOR = "lowriter";
-
- private static final String SPREADSHEET_EDITOR = "localc";
-
- private static final String MUSIC_PLAYER = "clementine";
-
- public static HashMap<String, String[]> extensionToApplication = new HashMap<String, String[]>();
-
public FileAssociationManager() {
extensionToApplication.put("txt", TEXT_EDITOR_PATTERN);
extensionToApplication.put("ini", TEXT_EDITOR_PATTERN);
extensionToApplication.put("", TEXT_EDITOR_PATTERN);
- 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("flac", new String[] { MUSIC_PLAYER,
- FILE_INDICATOR });
- extensionToApplication.put("mp3", new String[] { MUSIC_PLAYER,
- FILE_INDICATOR });
- extensionToApplication.put("ogg", new String[] { MUSIC_PLAYER,
- FILE_INDICATOR });
- extensionToApplication.put("wav", new String[] { MUSIC_PLAYER,
- FILE_INDICATOR });
-
- extensionToApplication.put("ods", new String[] { SPREADSHEET_EDITOR,
- FILE_INDICATOR });
- extensionToApplication.put("xls", new String[] { SPREADSHEET_EDITOR,
- FILE_INDICATOR });
- extensionToApplication.put("xlsx", new String[] { SPREADSHEET_EDITOR,
- FILE_INDICATOR });
-
- extensionToApplication.put("docx", new String[] { DOCUMENT_EDITOR,
- FILE_INDICATOR });
- extensionToApplication.put("doc", new String[] { DOCUMENT_EDITOR,
- FILE_INDICATOR });
-
- extensionToApplication.put("desktop", new String[] { "run-desktop",
- FILE_INDICATOR });
-
- extensionToApplication.put("log", new String[] { "glogg",
- FILE_INDICATOR });
- extensionToApplication.put("out", new String[] { "glogg",
- FILE_INDICATOR });
-
- extensionToApplication.put("html", new String[] { "firefox",
- FILE_INDICATOR });
-
- extensionToApplication.put("htm", new String[] { "firefox",
- 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("flac", new String[] { MUSIC_PLAYER, FILE_INDICATOR });
+ extensionToApplication.put("mp3", new String[] { MUSIC_PLAYER, FILE_INDICATOR });
+ extensionToApplication.put("ogg", new String[] { MUSIC_PLAYER, FILE_INDICATOR });
+ extensionToApplication.put("wav", new String[] { MUSIC_PLAYER, FILE_INDICATOR });
+
+ extensionToApplication.put("ods", new String[] { SPREADSHEET_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("xls", new String[] { SPREADSHEET_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("xlsx", new String[] { SPREADSHEET_EDITOR, FILE_INDICATOR });
+
+ extensionToApplication.put("docx", new String[] { DOCUMENT_EDITOR, FILE_INDICATOR });
+ extensionToApplication.put("doc", new String[] { DOCUMENT_EDITOR, FILE_INDICATOR });
+
+ extensionToApplication.put("desktop", new String[] { "run-desktop", FILE_INDICATOR });
+
+ extensionToApplication.put("log", new String[] { "glogg", FILE_INDICATOR });
+ extensionToApplication.put("out", new String[] { "glogg", FILE_INDICATOR });
+
+ extensionToApplication.put("html", new String[] { "firefox", FILE_INDICATOR });
+
+ extensionToApplication.put("htm", new String[] { "firefox", FILE_INDICATOR });
}