X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FInstantLauncher.java;h=02fc7a42c9dace5be8bc16d849407ce7df2af5df;hb=d84757dc1d3555a22d9411970a6fa7efccf2619e;hp=b13b58537832e3403e8478db62ce69fe7ed5f904;hpb=b72db77c2582c6eb3042dc2df08b995ef38a6a45;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java index b13b585..02fc7a4 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java @@ -1,28 +1,53 @@ +/* + * Instantlauncher. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * This project is released under Creative Commons Zero (CC0) license. + */ package eu.svjatoslav.instantlauncher; -import java.io.FileNotFoundException; +import eu.svjatoslav.instantlauncher.configuration.ConfigurationManager; +import eu.svjatoslav.instantlauncher.configuration.FileAssociation; + +import java.io.File; import java.io.IOException; -import org.apache.log4j.Logger; +import static eu.svjatoslav.instantlauncher.Utils.runOpeningApplication; public class InstantLauncher { - public Configuration configuration; + private final MainFrame mainFrame; + public ConfigurationManager configurationManager; - FileAssociationManager associationManager = new FileAssociationManager(); + public InstantLauncher() throws IOException { + configurationManager = new ConfigurationManager(); + mainFrame = new MainFrame(this); + } - public static final Logger LOGGER = Logger.getLogger(InstantLauncher.class); + public static void exitProgram() { + System.exit(0); + } - public void run() throws FileNotFoundException, IOException { - configuration = new Configuration(); + /** + * @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; - final MainFrame mainFrame = new MainFrame(this); + runOpeningApplication(fileAssociation.command, file); + return true; + } + + public void run() { mainFrame.show(); } - public static void exitProgram() { - LOGGER.info("Closing InstantLauncher"); - System.exit(0); + public void openDirectory(File chosenFile) { + runOpeningApplication(configurationManager.getConfiguration().directoryOpenCommand, chosenFile); + } + + public void openDirectoryInTerminal(File chosenFile) { + runOpeningApplication(configurationManager.getConfiguration().directoryTerminalOpenCommand, chosenFile); } }