resolve symlinks before opening file
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 30 Jan 2015 08:32:16 +0000 (10:32 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Fri, 30 Jan 2015 08:32:16 +0000 (10:32 +0200)
src/main/java/eu/svjatoslav/instantlauncher/menu/MultiLevelMenu.java

index f66f952..017872f 100755 (executable)
@@ -117,15 +117,24 @@ public class MultiLevelMenu implements MenuListener {
                        if (chosenFile.canExecute()) {
                                executeCommand(chosenFile.getAbsolutePath());
                        } else {
-                               final boolean fileOpened = FileAssociationManager.openFile(chosenFile);
-                               if (fileOpened) {
-                                       InstantLauncher.exitProgram();
+                               boolean fileOpened;
+                               try {
+                                       fileOpened = FileAssociationManager.openFile(chosenFile.getCanonicalFile());
+                                       if (fileOpened) {
+                                               InstantLauncher.exitProgram();
+                                       }
+                               } catch (IOException e) {
+                                       e.printStackTrace();
                                }
                        }
                }
 
                if (chosenFile.isDirectory()) {
-                       executeCommand("nautilus", "-w", chosenFile.getAbsolutePath());
+                       try {
+                               executeCommand("nautilus", "-w", chosenFile.getCanonicalFile().getAbsolutePath());
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
                }
        }
 
@@ -144,7 +153,12 @@ public class MultiLevelMenu implements MenuListener {
                if (chosenFile.isFile()) {
                        chosenFile.setExecutable(!chosenFile.canExecute());
                } else {
-                       executeCommand("gnome-terminal", "--working-directory=" + chosenFile.getAbsolutePath());
+                       try {
+                               executeCommand("gnome-terminal", "--working-directory="
+                                               + chosenFile.getCanonicalFile().getAbsolutePath());
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
                }
        }
 
@@ -163,7 +177,11 @@ public class MultiLevelMenu implements MenuListener {
        @Override
        public void menuItemSelectedAlternative2(Menu menu, File chosenFile) {
                if (chosenFile.isFile()) {
-                       executeCommand("emacs", chosenFile.getAbsolutePath());
+                       try {
+                               executeCommand("emacs", chosenFile.getCanonicalFile().getAbsolutePath());
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
                }
        }