Possibility to configure terminal emulator.
[instantlauncher.git] / src / main / java / eu / svjatoslav / instantlauncher / Utils.java
index c5d7641..506feaa 100755 (executable)
@@ -1,17 +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 {
 
+    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);
+        }
+    }
+
+
 }