1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.util.launcher;
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.net.URL;
25
26 /***
27 * Provides a default implementation for the {@link Launcher} interface.
28 */
29 public class DefaultLauncher implements Launcher {
30
31
32
33
34
35 private String command;
36 private String key;
37 private String name;
38
39
40
41 public DefaultLauncher(String key, String name, String command)
42 {
43 this.key = key;
44 this.name = name;
45 this.command = command;
46 }
47
48
49
50 /***
51 * Returns the command of the launcher.
52 */
53 public String getCommand()
54 {
55 return command;
56 }
57
58 /***
59 * Returns the key.
60 */
61 public String getKey()
62 {
63 return key;
64 }
65
66 /***
67 * Returns the name of the launcher.
68 */
69 public String getName()
70 {
71 return name;
72 }
73
74 /***
75 * Returns true.
76 */
77 public boolean isEditable()
78 {
79 return true;
80 }
81
82 /***
83 * Returns true.
84 */
85 public boolean isEnabled()
86 {
87 return true;
88 }
89
90 /***
91 * Launches <code>file</code>.
92 */
93 public void open(File file) throws IOException
94 {
95 LauncherManager.exec(getCommand(), new File[] { file });
96 }
97
98
99 /***
100 * Sets command to <code>command</code>.
101 */
102 public void setCommand(String command)
103 {
104 this.command = command;
105 }
106
107
108
109
110 public void open(URL url) throws IOException
111 {
112 LauncherManager.exec(new String[] { getCommand(), url.toExternalForm() });
113 }
114
115 }