X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FUtils.java;h=7410bab5d670e4f0d8b13d3e7fda750cb6e3dab3;hb=d84757dc1d3555a22d9411970a6fa7efccf2619e;hp=c5d76410c77b7a8f32666be0120072ca731d18fe;hpb=dcc5f6b34d80ffcebd604993305e9924bcdffbd3;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java index c5d7641..7410bab 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java @@ -1,17 +1,46 @@ +/* + * Instantlauncher. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * This project is released under Creative Commons Zero (CC0) license. + */ package eu.svjatoslav.instantlauncher; +import eu.svjatoslav.commons.gui.dialog.ExceptionDialog; + import javax.swing.*; import java.awt.*; import java.io.File; +import java.io.IOException; public class Utils { + private static final String FILE_INDICATOR = "{file}"; + public static void setComponentSize(JComponent component, Dimension size) { component.setMinimumSize(size); component.setMaximumSize(size); component.setSize(size); component.setPreferredSize(size); + } + + 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()); + Runtime.getRuntime().exec(commandsArray); + } catch (final IOException e) { + new ExceptionDialog(e); + } } + public static void executeCommand(String... c) { + try { + Runtime.getRuntime().exec(c); + } catch (final IOException e) { + new ExceptionDialog(e); + } + } + + }