Possibility to configure terminal emulator.
[instantlauncher.git] / src / main / java / eu / svjatoslav / instantlauncher / Utils.java
1 package eu.svjatoslav.instantlauncher;
2
3 import eu.svjatoslav.commons.gui.dialog.ExceptionDialog;
4
5 import javax.swing.*;
6 import java.awt.*;
7 import java.io.File;
8 import java.io.IOException;
9
10 public class Utils {
11
12     private static final String FILE_INDICATOR = "{file}";
13
14     public static void setComponentSize(JComponent component, Dimension size) {
15         component.setMinimumSize(size);
16         component.setMaximumSize(size);
17         component.setSize(size);
18         component.setPreferredSize(size);
19     }
20
21     public static void runOpeningApplication(String commands, final File file) {
22         try {
23             String[] commandsArray = commands.split("\\s+");
24             for (int i=0; i< commandsArray.length; i++)
25                 commandsArray[i] = commandsArray[i].replaceAll("\\{file\\}", file.getAbsolutePath());
26
27             Runtime.getRuntime().exec(commandsArray);
28         } catch (final IOException e) {
29             new ExceptionDialog(e);
30         }
31     }
32
33     public static void executeCommand(String... c) {
34         try {
35             Runtime.getRuntime().exec(c);
36         } catch (final IOException e) {
37             new ExceptionDialog(e);
38         }
39     }
40
41
42 }