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());
} 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
}