X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FInstantLauncher.java;h=b21b2b3cb6616f64198641d8290a4ab6f566a4d4;hb=ea9f229a2b0d0be0e765bdd508948b28cd2d490e;hp=c68c70e2e8ee1cf1d778219201b914566aa5d53a;hpb=8e31839bb326186944811ac3e54a3037ffa75106;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java index c68c70e..b21b2b3 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java @@ -1,14 +1,38 @@ package eu.svjatoslav.instantlauncher; +import eu.svjatoslav.instantlauncher.configuration.ConfigurationManager; +import eu.svjatoslav.instantlauncher.configuration.FileAssociation; import org.apache.log4j.Logger; +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(); + public ConfigurationManager configurationManager; + final MainFrame mainFrame; + + public InstantLauncher() throws IOException { + configurationManager = new ConfigurationManager(); + mainFrame = new MainFrame(this); + } + + /** + * @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 String[] commands = fileAssociation.getCommands(); + runOpeningApplication(file, commands); + + return false; + } public static void exitProgram() { LOGGER.info("Closing InstantLauncher"); @@ -16,9 +40,6 @@ public class InstantLauncher { } public void run() throws IOException { - configuration = new Configuration(); - - final MainFrame mainFrame = new MainFrame(this); mainFrame.show(); }