X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FUtils.java;h=6f821a4fe851133c510eb697204b09a3f3d8f946;hb=155895d0ed0f436753bf862287341830653a9c9f;hp=1884fec50eb06f0a3cd6579c133c6f9ec7d7382d;hpb=ea9f229a2b0d0be0e765bdd508948b28cd2d490e;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java index 1884fec..6f821a4 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java @@ -1,3 +1,11 @@ +/* + * 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 eu.svjatoslav.commons.gui.dialog.ExceptionDialog; @@ -7,10 +15,10 @@ import java.awt.*; import java.io.File; import java.io.IOException; -import static eu.svjatoslav.commons.file.FilePathParser.getFileExtension; - public class Utils { + private static final String FILE_INDICATOR = "{file}"; + public static void setComponentSize(JComponent component, Dimension size) { component.setMinimumSize(size); component.setMaximumSize(size); @@ -18,20 +26,25 @@ public class Utils { component.setPreferredSize(size); } - private static final String FILE_INDICATOR = "{file}"; + public static void runOpeningApplication(String commands, final File file) { + try { + String[] commandsArray = commands.split("\\s+"); + for (int i=0; i< commandsArray.length; i++) + commandsArray[i] = commandsArray[i].replaceAll("\\{file\\}", file.getAbsolutePath()); - public static void runOpeningApplication(final File file, final String[] commands) { - for (int i = 0; i < commands.length; i++) - if (commands[i].equals(FILE_INDICATOR)) - commands[i] = file.getAbsolutePath(); + Runtime.getRuntime().exec(commandsArray); + } catch (final IOException e) { + new ExceptionDialog(e); + } + } + public static void executeCommand(String... c) { try { - Runtime.getRuntime().exec(commands); - InstantLauncher.exitProgram(); - + Runtime.getRuntime().exec(c); } catch (final IOException e) { new ExceptionDialog(e); } } + }