+/*
+ * 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;
-import org.apache.log4j.Logger;
+import eu.svjatoslav.instantlauncher.configuration.ConfigurationManager;
+import eu.svjatoslav.instantlauncher.configuration.FileAssociation;
+import java.io.File;
import java.io.IOException;
+import static eu.svjatoslav.instantlauncher.Utils.runOpeningApplication;
+
public class InstantLauncher {
- private static final Logger LOGGER = Logger.getLogger(InstantLauncher.class);
- public Configuration configuration;
- FileAssociationManager associationManager = new FileAssociationManager();
+ private final MainFrame mainFrame;
+ public ConfigurationManager configurationManager;
+
+ public InstantLauncher() throws IOException {
+ configurationManager = new ConfigurationManager();
+ mainFrame = new MainFrame(this);
+ }
public static void exitProgram() {
- LOGGER.info("Closing InstantLauncher");
System.exit(0);
}
- public void run() throws IOException {
- configuration = new Configuration();
+ /**
+ * @return <code>true</code> if file was opened. <code>false</code> if
+ * unknown file type.
+ */
+ public boolean openFile(final File file) {
+ FileAssociation fileAssociation = configurationManager.getConfiguration().findFileAssociation(file);
+ if (fileAssociation == null) return false;
+
+ runOpeningApplication(fileAssociation.command, file);
+ return true;
+ }
- final MainFrame mainFrame = new MainFrame(this);
+ public void run() {
mainFrame.show();
}
+ public void openDirectory(File chosenFile) {
+ runOpeningApplication(configurationManager.getConfiguration().directoryOpenCommand, chosenFile);
+ }
+
+ public void openDirectoryInTerminal(File chosenFile) {
+ runOpeningApplication(configurationManager.getConfiguration().directoryTerminalOpenCommand, chosenFile);
+ }
+
}