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=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..b21b2b3 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/InstantLauncher.java @@ -1,23 +1,37 @@ package eu.svjatoslav.instantlauncher; -import java.io.FileNotFoundException; +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 org.apache.log4j.Logger; +import static eu.svjatoslav.instantlauncher.Utils.runOpeningApplication; public class InstantLauncher { - public Configuration configuration; + private static final Logger LOGGER = Logger.getLogger(InstantLauncher.class); + public ConfigurationManager configurationManager; + final MainFrame mainFrame; - FileAssociationManager associationManager = new FileAssociationManager(); + public InstantLauncher() throws IOException { + configurationManager = new ConfigurationManager(); + mainFrame = new MainFrame(this); + } - public static final Logger LOGGER = Logger.getLogger(InstantLauncher.class); + /** + * @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; - public void run() throws FileNotFoundException, IOException { - configuration = new Configuration(); + final String[] commands = fileAssociation.getCommands(); + runOpeningApplication(file, commands); - final MainFrame mainFrame = new MainFrame(this); - mainFrame.show(); + return false; } public static void exitProgram() { @@ -25,4 +39,8 @@ public class InstantLauncher { System.exit(0); } + public void run() throws IOException { + mainFrame.show(); + } + }