+/*
+ * Instantlauncher. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ */
+
package eu.svjatoslav.instantlauncher.menu;
import eu.svjatoslav.instantlauncher.InstantLauncher;
import java.io.IOException;
import java.util.ArrayList;
+import static eu.svjatoslav.instantlauncher.Utils.executeCommand;
+
public class MultiLevelMenu implements MenuListener {
private static final int VERTICAL_MENUS_COUNT = 7;
public void menuItemSelected(final File chosenFile) {
if (chosenFile.isFile()) {
if (chosenFile.canExecute()) {
- instantLauncher.executeCommand(chosenFile.getAbsolutePath());
+ executeCommand(chosenFile.getAbsolutePath());
+ InstantLauncher.exitProgram();
} else {
boolean fileOpened;
try {
if (chosenFile.isDirectory()) {
try {
instantLauncher.openDirectory(chosenFile.getCanonicalFile());
+ InstantLauncher.exitProgram();
} catch (IOException e) {
e.printStackTrace();
}
if (chosenFile.isFile())
chosenFile.setExecutable(!chosenFile.canExecute());
else {
- try {
- instantLauncher.executeCommand("gnome-terminal", "--working-directory="
- + chosenFile.getCanonicalFile().getAbsolutePath());
- } catch (IOException e) {
- e.printStackTrace();
- }
+ instantLauncher.openDirectoryInTerminal(chosenFile);
+ InstantLauncher.exitProgram();
}
}
@Override
public void menuItemSelectedAlternative2(File chosenFile) {
- if (chosenFile.isFile()) {
- try {
- instantLauncher.executeCommand("emacs", chosenFile.getCanonicalFile().getAbsolutePath());
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ // TODO: define some middle mouse click functions
}