X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FInstantLauncher.java;h=02fc7a42c9dace5be8bc16d849407ce7df2af5df;hb=refs%2Fheads%2Fmaster;hp=a0ff09ec1946d0e39ded10463ef14759c270f541;hpb=dcc5f6b34d80ffcebd604993305e9924bcdffbd3;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java index a0ff09e..02fc7a4 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java @@ -1,26 +1,53 @@ +/* + * Instantlauncher. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * This project is released under Creative Commons Zero (CC0) license. + */ package eu.svjatoslav.instantlauncher; import eu.svjatoslav.instantlauncher.configuration.ConfigurationManager; -import org.apache.log4j.Logger; +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 ConfigurationManager 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 ConfigurationManager(); + /** + * @return true if file was opened. false 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); + } + }