|
23 | 23 | package processing.app.platform; |
24 | 24 |
|
25 | 25 | import java.io.File; |
| 26 | +import java.awt.Desktop; |
26 | 27 | import java.awt.Toolkit; |
27 | 28 |
|
28 | 29 | import processing.app.Base; |
@@ -97,26 +98,34 @@ static public String getHomeDir(String user) throws Exception { |
97 | 98 | } |
98 | 99 |
|
99 | 100 |
|
| 101 | + @Override |
100 | 102 | public File getSettingsFolder() throws Exception { |
101 | 103 | return new File(getHomeDir(), ".processing"); |
102 | 104 | } |
103 | 105 |
|
104 | 106 |
|
| 107 | + @Override |
105 | 108 | public File getDefaultSketchbookFolder() throws Exception { |
106 | 109 | return new File(getHomeDir(), "sketchbook"); |
107 | 110 | } |
108 | 111 |
|
109 | 112 |
|
| 113 | + @Override |
110 | 114 | public void openURL(String url) throws Exception { |
111 | | - if (openFolderAvailable()) { |
112 | | - String launcher = Preferences.get("launcher"); |
113 | | - if (launcher != null) { |
114 | | - Runtime.getRuntime().exec(new String[] { launcher, url }); |
115 | | - } |
| 115 | + if (Desktop.isDesktopSupported()) { |
| 116 | + super.openURL(url); |
| 117 | + |
| 118 | + } else if (openFolderAvailable()) { |
| 119 | + String launcher = Preferences.get("launcher"); // guaranteed non-null |
| 120 | + Runtime.getRuntime().exec(new String[] { launcher, url }); |
| 121 | + |
| 122 | + } else { |
| 123 | + System.err.println("No launcher set, cannot open " + url); |
116 | 124 | } |
117 | 125 | } |
118 | 126 |
|
119 | 127 |
|
| 128 | + @Override |
120 | 129 | public boolean openFolderAvailable() { |
121 | 130 | if (Preferences.get("launcher") != null) { |
122 | 131 | return true; |
@@ -151,19 +160,18 @@ public boolean openFolderAvailable() { |
151 | 160 | } |
152 | 161 |
|
153 | 162 |
|
| 163 | + @Override |
154 | 164 | public void openFolder(File file) throws Exception { |
155 | | - if (openFolderAvailable()) { |
156 | | - String lunch = Preferences.get("launcher"); |
157 | | - try { |
158 | | - String[] params = new String[] { lunch, file.getAbsolutePath() }; |
159 | | - //processing.core.PApplet.println(params); |
160 | | - /*Process p =*/ Runtime.getRuntime().exec(params); |
161 | | - /*int result =*/ //p.waitFor(); |
162 | | - } catch (Exception e) { |
163 | | - e.printStackTrace(); |
164 | | - } |
| 165 | + if (Desktop.isDesktopSupported()) { |
| 166 | + super.openFolder(file); |
| 167 | + |
| 168 | + } else if (openFolderAvailable()) { |
| 169 | + String launcher = Preferences.get("launcher"); |
| 170 | + String[] params = new String[] { launcher, file.getAbsolutePath() }; |
| 171 | + Runtime.getRuntime().exec(params); |
| 172 | + |
165 | 173 | } else { |
166 | | - System.out.println("No launcher set, cannot open " + |
| 174 | + System.err.println("No launcher set, cannot open " + |
167 | 175 | file.getAbsolutePath()); |
168 | 176 | } |
169 | 177 | } |
|
0 commit comments