switched to HTTPS protocol for custom maven repository
[instantlauncher.git] / src / main / java / eu / svjatoslav / instantlauncher / Utils.java
1 /*
2  * Instantlauncher. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5 package eu.svjatoslav.instantlauncher;
6
7 import eu.svjatoslav.commons.gui.dialog.ExceptionDialog;
8
9 import javax.swing.*;
10 import java.awt.*;
11 import java.io.File;
12 import java.io.IOException;
13
14 public class Utils {
15
16     private static final String FILE_INDICATOR = "{file}";
17
18     public static void setComponentSize(JComponent component, Dimension size) {
19         component.setMinimumSize(size);
20         component.setMaximumSize(size);
21         component.setSize(size);
22         component.setPreferredSize(size);
23     }
24
25     public static void runOpeningApplication(String commands, final File file) {
26         try {
27             String[] commandsArray = commands.split("\\s+");
28             for (int i=0; i< commandsArray.length; i++)
29                 commandsArray[i] = commandsArray[i].replaceAll("\\{file\\}", file.getAbsolutePath());
30
31             Runtime.getRuntime().exec(commandsArray);
32         } catch (final IOException e) {
33             new ExceptionDialog(e);
34         }
35     }
36
37     public static void executeCommand(String... c) {
38         try {
39             Runtime.getRuntime().exec(c);
40         } catch (final IOException e) {
41             new ExceptionDialog(e);
42         }
43     }
44
45
46 }