X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FUtils.java;h=506feaa2139caa2da933ef6e5085bd03299e6e72;hb=617c93e31fc6f020323b503fe0028a8e10c746b6;hp=f382e7c6ed9f61fcdaf552ca9740b259c5eaccc1;hpb=8e31839bb326186944811ac3e54a3037ffa75106;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java index f382e7c..506feaa 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java @@ -1,33 +1,42 @@ 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 { - public static String getFileExtension(File file) { - // extract file name without file name extension - String fullFileName = file.getName(); - - int dot = fullFileName.lastIndexOf('.'); - String fileExtension; - if (dot == -1) { - fileExtension = ""; - } else { - fileExtension = fullFileName.substring(dot + 1); - fileExtension = fileExtension.toLowerCase(); - } - - return fileExtension; - } + 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); + } + } + + }