updated text editor
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Tue, 5 Jan 2016 06:08:41 +0000 (08:08 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Tue, 5 Jan 2016 06:08:41 +0000 (08:08 +0200)
src/main/java/eu/svjatoslav/instantlauncher/FileAssociationManager.java

index 0d07648..51d900f 100755 (executable)
@@ -8,6 +8,18 @@ import eu.svjatoslav.commons.gui.dialog.ExceptionDialog;
 
 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;
@@ -26,8 +38,7 @@ public class FileAssociationManager {
        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;
                }
 
@@ -42,8 +53,7 @@ public class FileAssociationManager {
 
        }
 
-       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();
@@ -57,19 +67,6 @@ public class FileAssociationManager {
                }
        }
 
-       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);
@@ -79,68 +76,42 @@ public class FileAssociationManager {
                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 });
 
        }