1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.bin; |
22 |
|
|
23 |
|
import java.io.BufferedReader; |
24 |
|
import java.io.File; |
25 |
|
import java.io.FileOutputStream; |
26 |
|
import java.io.IOException; |
27 |
|
import java.io.InputStreamReader; |
28 |
|
import java.io.OutputStreamWriter; |
29 |
|
import java.io.PrintWriter; |
30 |
|
import java.net.MalformedURLException; |
31 |
|
import java.net.URI; |
32 |
|
import java.net.URISyntaxException; |
33 |
|
import java.net.URL; |
34 |
|
import java.security.AllPermission; |
35 |
|
import java.security.CodeSource; |
36 |
|
import java.security.PermissionCollection; |
37 |
|
import java.security.Permissions; |
38 |
|
import java.security.Policy; |
39 |
|
import java.util.HashMap; |
40 |
|
import java.util.Map; |
41 |
|
import java.util.Vector; |
42 |
|
import java.util.logging.ConsoleHandler; |
43 |
|
import java.util.logging.Level; |
44 |
|
import java.util.logging.Logger; |
45 |
|
|
46 |
|
import javax.swing.UIManager; |
47 |
|
import javax.swing.UIManager.LookAndFeelInfo; |
48 |
|
|
49 |
|
import com.threerings.getdown.util.LaunchUtil; |
50 |
|
|
51 |
|
import groovy.lang.Binding; |
52 |
|
import groovy.util.GroovyScriptEngine; |
53 |
|
import jalview.ext.so.SequenceOntology; |
54 |
|
import jalview.gui.AlignFrame; |
55 |
|
import jalview.gui.Desktop; |
56 |
|
import jalview.gui.PromptUserConfig; |
57 |
|
import jalview.io.AppletFormatAdapter; |
58 |
|
import jalview.io.BioJsHTMLOutput; |
59 |
|
import jalview.io.DataSourceType; |
60 |
|
import jalview.io.FileFormat; |
61 |
|
import jalview.io.FileFormatException; |
62 |
|
import jalview.io.FileFormatI; |
63 |
|
import jalview.io.FileLoader; |
64 |
|
import jalview.io.HtmlSvgOutput; |
65 |
|
import jalview.io.IdentifyFile; |
66 |
|
import jalview.io.NewickFile; |
67 |
|
import jalview.io.gff.SequenceOntologyFactory; |
68 |
|
import jalview.schemes.ColourSchemeI; |
69 |
|
import jalview.schemes.ColourSchemeProperty; |
70 |
|
import jalview.util.MessageManager; |
71 |
|
import jalview.util.Platform; |
72 |
|
import jalview.ws.jws2.Jws2Discoverer; |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
@author |
87 |
|
@version |
88 |
|
|
|
|
| 49.3% |
Uncovered Elements: 307 (605) |
Complexity: 154 |
Complexity Density: 0.38 |
|
89 |
|
public class Jalview |
90 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
19 |
static... |
92 |
|
{ |
93 |
19 |
Platform.getURLCommandArguments(); |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
private static Jalview instance; |
99 |
|
|
100 |
|
private Desktop desktop; |
101 |
|
|
102 |
|
public static AlignFrame currentAlignFrame; |
103 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
104 |
19 |
static... |
105 |
|
{ |
106 |
19 |
if (!Platform.isJS()) |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
{ |
113 |
|
|
114 |
19 |
Policy.setPolicy(new Policy() |
115 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
116 |
0 |
@Override... |
117 |
|
public PermissionCollection getPermissions(CodeSource codesource) |
118 |
|
{ |
119 |
0 |
Permissions perms = new Permissions(); |
120 |
0 |
perms.add(new AllPermission()); |
121 |
0 |
return (perms); |
122 |
|
} |
123 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
124 |
0 |
@Override... |
125 |
|
public void refresh() |
126 |
|
{ |
127 |
|
} |
128 |
|
}); |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
@author |
136 |
|
|
137 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
138 |
|
class FeatureFetcher |
139 |
|
{ |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
private int queued = 0; |
146 |
|
|
147 |
|
private int running = 0; |
148 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
149 |
0 |
public FeatureFetcher()... |
150 |
|
{ |
151 |
|
|
152 |
|
} |
153 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
154 |
0 |
public void addFetcher(final AlignFrame af,... |
155 |
|
final Vector<String> dasSources) |
156 |
|
{ |
157 |
0 |
final long id = System.currentTimeMillis(); |
158 |
0 |
queued++; |
159 |
0 |
final FeatureFetcher us = this; |
160 |
0 |
new Thread(new Runnable() |
161 |
|
{ |
162 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
163 |
0 |
@Override... |
164 |
|
public void run() |
165 |
|
{ |
166 |
0 |
synchronized (us) |
167 |
|
{ |
168 |
0 |
queued--; |
169 |
0 |
running++; |
170 |
|
} |
171 |
|
|
172 |
0 |
af.setProgressBar(MessageManager |
173 |
|
.getString("status.das_features_being_retrived"), id); |
174 |
0 |
af.featureSettings_actionPerformed(null); |
175 |
0 |
af.setProgressBar(null, id); |
176 |
0 |
synchronized (us) |
177 |
|
{ |
178 |
0 |
running--; |
179 |
|
} |
180 |
|
} |
181 |
|
}).start(); |
182 |
|
} |
183 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
0 |
public synchronized boolean allFinished()... |
185 |
|
{ |
186 |
0 |
return queued == 0 && running == 0; |
187 |
|
} |
188 |
|
|
189 |
|
} |
190 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
0 |
public static Jalview getInstance()... |
192 |
|
{ |
193 |
0 |
return instance; |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
@param |
200 |
|
|
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
202 |
35 |
public static void main(String[] args)... |
203 |
|
{ |
204 |
|
|
205 |
35 |
instance = new Jalview(); |
206 |
35 |
instance.doMain(args); |
207 |
|
} |
208 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
209 |
0 |
private static void logClass(String name)... |
210 |
|
{ |
211 |
|
|
212 |
0 |
ConsoleHandler consoleHandler = new ConsoleHandler(); |
213 |
0 |
consoleHandler.setLevel(Level.ALL); |
214 |
0 |
Logger logger = Logger.getLogger(name); |
215 |
0 |
logger.setLevel(Level.ALL); |
216 |
0 |
logger.addHandler(consoleHandler); |
217 |
|
} |
218 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
219 |
0 |
@SuppressWarnings("unused")... |
220 |
|
private static void setLogging() |
221 |
|
{ |
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
{ |
228 |
0 |
System.out.println("not in js"); |
229 |
|
} |
230 |
|
|
231 |
|
|
232 |
0 |
if (!Platform.isJS()) |
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
{ |
239 |
0 |
Logger.getLogger("").setLevel(Level.ALL); |
240 |
0 |
logClass("java.awt.EventDispatchThread"); |
241 |
0 |
logClass("java.awt.EventQueue"); |
242 |
0 |
logClass("java.awt.Component"); |
243 |
0 |
logClass("java.awt.focus.Component"); |
244 |
0 |
logClass("java.awt.focus.DefaultKeyboardFocusManager"); |
245 |
|
} |
246 |
|
|
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
|
@param |
251 |
|
|
|
|
| 59.8% |
Uncovered Elements: 169 (420) |
Complexity: 97 |
Complexity Density: 0.34 |
|
252 |
35 |
void doMain(String[] args)... |
253 |
|
{ |
254 |
|
|
255 |
35 |
if (!Platform.isJS()) |
256 |
|
{ |
257 |
35 |
System.setSecurityManager(null); |
258 |
|
} |
259 |
|
|
260 |
35 |
System.out |
261 |
|
.println("Java version: " + System.getProperty("java.version")); |
262 |
35 |
System.out.println("Java Home: " + System.getProperty("java.home")); |
263 |
35 |
System.out.println(System.getProperty("os.arch") + " " |
264 |
|
+ System.getProperty("os.name") + " " |
265 |
|
+ System.getProperty("os.version")); |
266 |
35 |
String val = System.getProperty("sys.install4jVersion"); |
267 |
35 |
if (val != null) |
268 |
|
{ |
269 |
0 |
System.out.println("Install4j version: " + val); |
270 |
|
} |
271 |
35 |
val = System.getProperty("installer_template_version"); |
272 |
35 |
if (val != null) |
273 |
|
{ |
274 |
0 |
System.out.println("Install4j template version: " + val); |
275 |
|
} |
276 |
35 |
val = System.getProperty("launcher_version"); |
277 |
35 |
if (val != null) |
278 |
|
{ |
279 |
0 |
System.out.println("Launcher version: " + val); |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
35 |
Cache.loadBuildProperties(true); |
284 |
|
|
285 |
35 |
ArgsParser aparser = new ArgsParser(args); |
286 |
35 |
boolean headless = false; |
287 |
|
|
288 |
35 |
String usrPropsFile = aparser.getValue("props"); |
289 |
35 |
Cache.loadProperties(usrPropsFile); |
290 |
35 |
if (usrPropsFile != null) |
291 |
|
{ |
292 |
11 |
System.out.println( |
293 |
|
"CMD [-props " + usrPropsFile + "] executed successfully!"); |
294 |
|
} |
295 |
|
|
296 |
35 |
if (!Platform.isJS()) |
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
{ |
303 |
35 |
if (aparser.contains("help") || aparser.contains("h")) |
304 |
|
{ |
305 |
0 |
showUsage(); |
306 |
0 |
System.exit(0); |
307 |
|
} |
308 |
35 |
if (aparser.contains("nodisplay") || aparser.contains("nogui") |
309 |
|
|| aparser.contains("headless")) |
310 |
|
{ |
311 |
17 |
System.setProperty("java.awt.headless", "true"); |
312 |
17 |
headless = true; |
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
35 |
final String jabawsUrl = aparser.getValue("jabaws"); |
317 |
35 |
if (jabawsUrl != null) |
318 |
|
{ |
319 |
1 |
try |
320 |
|
{ |
321 |
1 |
Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl); |
322 |
1 |
System.out.println( |
323 |
|
"CMD [-jabaws " + jabawsUrl + "] executed successfully!"); |
324 |
|
} catch (MalformedURLException e) |
325 |
|
{ |
326 |
0 |
System.err.println( |
327 |
|
"Invalid jabaws parameter: " + jabawsUrl + " ignored"); |
328 |
|
} |
329 |
|
} |
330 |
|
|
331 |
|
} |
332 |
35 |
String defs = aparser.getValue("setprop"); |
333 |
35 |
while (defs != null) |
334 |
|
{ |
335 |
0 |
int p = defs.indexOf('='); |
336 |
0 |
if (p == -1) |
337 |
|
{ |
338 |
0 |
System.err.println("Ignoring invalid setprop argument : " + defs); |
339 |
|
} |
340 |
|
else |
341 |
|
{ |
342 |
0 |
System.out.println("Executing setprop argument: " + defs); |
343 |
0 |
if (Platform.isJS()) |
344 |
|
{ |
345 |
0 |
Cache.setProperty(defs.substring(0, p), defs.substring(p + 1)); |
346 |
|
} |
347 |
|
} |
348 |
0 |
defs = aparser.getValue("setprop"); |
349 |
|
} |
350 |
35 |
if (System.getProperty("java.awt.headless") != null |
351 |
|
&& System.getProperty("java.awt.headless").equals("true")) |
352 |
|
{ |
353 |
17 |
headless = true; |
354 |
|
} |
355 |
35 |
System.setProperty("http.agent", |
356 |
|
"Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown")); |
357 |
35 |
try |
358 |
|
{ |
359 |
35 |
Cache.initLogger(); |
360 |
|
} catch (NoClassDefFoundError error) |
361 |
|
{ |
362 |
0 |
error.printStackTrace(); |
363 |
0 |
System.out.println("\nEssential logging libraries not found." |
364 |
|
+ "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview"); |
365 |
0 |
System.exit(0); |
366 |
|
} |
367 |
|
|
368 |
35 |
desktop = null; |
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
35 |
String lafProp = System.getProperty("laf"); |
374 |
35 |
String lafSetting = Cache.getDefault("PREFERRED_LAF", null); |
375 |
35 |
String laf = "none"; |
376 |
35 |
if (lafProp != null) |
377 |
|
{ |
378 |
0 |
laf = lafProp; |
379 |
|
} |
380 |
35 |
else if (lafSetting != null) |
381 |
|
{ |
382 |
0 |
laf = lafSetting; |
383 |
|
} |
384 |
35 |
boolean lafSet = false; |
385 |
35 |
switch (laf) |
386 |
|
{ |
387 |
0 |
case "crossplatform": |
388 |
0 |
lafSet = setCrossPlatformLookAndFeel(); |
389 |
0 |
if (!lafSet) |
390 |
|
{ |
391 |
0 |
System.err.println("Could not set requested laf=" + laf); |
392 |
|
} |
393 |
0 |
break; |
394 |
0 |
case "system": |
395 |
0 |
lafSet = setSystemLookAndFeel(); |
396 |
0 |
if (!lafSet) |
397 |
|
{ |
398 |
0 |
System.err.println("Could not set requested laf=" + laf); |
399 |
|
} |
400 |
0 |
break; |
401 |
0 |
case "gtk": |
402 |
0 |
lafSet = setGtkLookAndFeel(); |
403 |
|
{ |
404 |
0 |
System.err.println("Could not set requested laf=" + laf); |
405 |
|
} |
406 |
0 |
break; |
407 |
0 |
case "metal": |
408 |
0 |
lafSet = setMetalLookAndFeel(); |
409 |
|
{ |
410 |
0 |
System.err.println("Could not set requested laf=" + laf); |
411 |
|
} |
412 |
0 |
break; |
413 |
0 |
case "nimbus": |
414 |
0 |
lafSet = setNimbusLookAndFeel(); |
415 |
|
{ |
416 |
0 |
System.err.println("Could not set requested laf=" + laf); |
417 |
|
} |
418 |
0 |
break; |
419 |
0 |
case "quaqua": |
420 |
0 |
lafSet = setQuaquaLookAndFeel(); |
421 |
|
{ |
422 |
0 |
System.err.println("Could not set requested laf=" + laf); |
423 |
|
} |
424 |
0 |
break; |
425 |
0 |
case "vaqua": |
426 |
0 |
lafSet = setVaquaLookAndFeel(); |
427 |
|
{ |
428 |
0 |
System.err.println("Could not set requested laf=" + laf); |
429 |
|
} |
430 |
0 |
break; |
431 |
0 |
case "mac": |
432 |
0 |
lafSet = setMacLookAndFeel(); |
433 |
0 |
if (!lafSet) |
434 |
|
{ |
435 |
0 |
System.err.println("Could not set requested laf=" + laf); |
436 |
|
} |
437 |
0 |
break; |
438 |
35 |
case "none": |
439 |
35 |
break; |
440 |
0 |
default: |
441 |
0 |
System.err.println("Requested laf=" + laf + " not implemented"); |
442 |
|
} |
443 |
35 |
if (!lafSet) |
444 |
|
{ |
445 |
35 |
setSystemLookAndFeel(); |
446 |
35 |
if (Platform.isLinux() && !Platform.isJS()) |
447 |
|
{ |
448 |
35 |
setMetalLookAndFeel(); |
449 |
|
} |
450 |
35 |
if (Platform.isAMacAndNotJS()) |
451 |
|
{ |
452 |
0 |
setMacLookAndFeel(); |
453 |
|
} |
454 |
|
} |
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
|
460 |
35 |
boolean soDefault = !Platform.isJS(); |
461 |
35 |
if (Cache.getDefault("USE_FULL_SO", soDefault)) |
462 |
|
{ |
463 |
35 |
SequenceOntologyFactory.setInstance(new SequenceOntology()); |
464 |
|
} |
465 |
|
|
466 |
35 |
if (!headless) |
467 |
|
{ |
468 |
18 |
desktop = new Desktop(); |
469 |
18 |
desktop.setInBatchMode(true); |
470 |
|
|
471 |
18 |
try |
472 |
|
{ |
473 |
18 |
JalviewTaskbar.setTaskbar(this); |
474 |
|
} catch (Throwable t) |
475 |
|
{ |
476 |
0 |
System.out.println("Error setting Taskbar: " + t.getMessage()); |
477 |
|
} |
478 |
|
|
479 |
18 |
desktop.setVisible(true); |
480 |
|
|
481 |
18 |
if (!Platform.isJS()) |
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
{ |
488 |
18 |
desktop.startServiceDiscovery(); |
489 |
18 |
if (!aparser.contains("nousagestats")) |
490 |
|
{ |
491 |
17 |
startUsageStats(desktop); |
492 |
|
} |
493 |
|
else |
494 |
|
{ |
495 |
1 |
System.err.println("CMD [-nousagestats] executed successfully!"); |
496 |
|
} |
497 |
|
|
498 |
18 |
if (!aparser.contains("noquestionnaire")) |
499 |
|
{ |
500 |
16 |
String url = aparser.getValue("questionnaire"); |
501 |
16 |
if (url != null) |
502 |
|
{ |
503 |
|
|
504 |
|
|
505 |
0 |
Cache.log.debug("Starting questionnaire url at " + url); |
506 |
0 |
desktop.checkForQuestionnaire(url); |
507 |
0 |
System.out.println("CMD questionnaire[-" + url |
508 |
|
+ "] executed successfully!"); |
509 |
|
} |
510 |
|
else |
511 |
|
{ |
512 |
16 |
if (Cache.getProperty("NOQUESTIONNAIRES") == null) |
513 |
|
{ |
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
0 |
String defurl = "http://www.jalview.org/cgi-bin/questionnaire.pl"; |
520 |
0 |
Cache.log.debug( |
521 |
|
"Starting questionnaire with default url: " + defurl); |
522 |
0 |
desktop.checkForQuestionnaire(defurl); |
523 |
|
} |
524 |
|
} |
525 |
|
} |
526 |
|
else |
527 |
|
{ |
528 |
2 |
System.err |
529 |
|
.println("CMD [-noquestionnaire] executed successfully!"); |
530 |
|
} |
531 |
|
|
532 |
18 |
if (!aparser.contains("nonews")) |
533 |
|
{ |
534 |
6 |
desktop.checkForNews(); |
535 |
|
} |
536 |
|
|
537 |
18 |
BioJsHTMLOutput.updateBioJS(); |
538 |
|
} |
539 |
|
} |
540 |
|
|
541 |
|
|
542 |
|
|
543 |
35 |
String appdirString = System.getProperty("getdownappdir"); |
544 |
35 |
if (appdirString != null && appdirString.length() > 0) |
545 |
|
{ |
546 |
0 |
final File appdir = new File(appdirString); |
547 |
0 |
new Thread() |
548 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
549 |
0 |
@Override... |
550 |
|
public void run() |
551 |
|
{ |
552 |
0 |
LaunchUtil.upgradeGetdown( |
553 |
|
new File(appdir, "getdown-launcher-old.jar"), |
554 |
|
new File(appdir, "getdown-launcher.jar"), |
555 |
|
new File(appdir, "getdown-launcher-new.jar")); |
556 |
|
} |
557 |
|
}.start(); |
558 |
|
} |
559 |
|
|
560 |
35 |
String file = null, data = null; |
561 |
35 |
FileFormatI format = null; |
562 |
35 |
DataSourceType protocol = null; |
563 |
35 |
FileLoader fileLoader = new FileLoader(!headless); |
564 |
|
|
565 |
35 |
String groovyscript = null; |
566 |
|
|
567 |
|
|
568 |
35 |
groovyscript = aparser.getValue("groovy", true); |
569 |
35 |
file = aparser.getValue("open", true); |
570 |
|
|
571 |
35 |
if (file == null && desktop == null) |
572 |
|
{ |
573 |
0 |
System.out.println("No files to open!"); |
574 |
0 |
System.exit(1); |
575 |
|
} |
576 |
35 |
long progress = -1; |
577 |
|
|
578 |
35 |
if (file != null) |
579 |
|
{ |
580 |
18 |
if (!headless) |
581 |
|
{ |
582 |
1 |
desktop.setProgressBar( |
583 |
|
MessageManager |
584 |
|
.getString("status.processing_commandline_args"), |
585 |
|
progress = System.currentTimeMillis()); |
586 |
|
} |
587 |
18 |
System.out.println("CMD [-open " + file + "] executed successfully!"); |
588 |
|
|
589 |
18 |
if (!Platform.isJS()) |
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
{ |
596 |
18 |
if (!file.startsWith("http://") && !file.startsWith("https://")) |
597 |
|
|
598 |
|
{ |
599 |
18 |
if (!(new File(file)).exists()) |
600 |
|
{ |
601 |
0 |
System.out.println("Can't find " + file); |
602 |
0 |
if (headless) |
603 |
|
{ |
604 |
0 |
System.exit(1); |
605 |
|
} |
606 |
|
} |
607 |
|
} |
608 |
|
} |
609 |
|
|
610 |
18 |
protocol = AppletFormatAdapter.checkProtocol(file); |
611 |
|
|
612 |
18 |
try |
613 |
|
{ |
614 |
18 |
format = new IdentifyFile().identify(file, protocol); |
615 |
|
} catch (FileFormatException e1) |
616 |
|
{ |
617 |
|
|
618 |
|
} |
619 |
|
|
620 |
18 |
AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol, |
621 |
|
format); |
622 |
18 |
if (af == null) |
623 |
|
{ |
624 |
1 |
System.out.println("error"); |
625 |
|
} |
626 |
|
else |
627 |
|
{ |
628 |
17 |
setCurrentAlignFrame(af); |
629 |
17 |
data = aparser.getValue("colour", true); |
630 |
17 |
if (data != null) |
631 |
|
{ |
632 |
1 |
data.replaceAll("%20", " "); |
633 |
|
|
634 |
1 |
ColourSchemeI cs = ColourSchemeProperty.getColourScheme( |
635 |
|
af.getViewport(), af.getViewport().getAlignment(), data); |
636 |
|
|
637 |
1 |
if (cs != null) |
638 |
|
{ |
639 |
1 |
System.out.println( |
640 |
|
"CMD [-color " + data + "] executed successfully!"); |
641 |
|
} |
642 |
1 |
af.changeColour(cs); |
643 |
|
} |
644 |
|
|
645 |
|
|
646 |
17 |
data = aparser.getValue("groups", true); |
647 |
17 |
if (data != null) |
648 |
|
{ |
649 |
0 |
af.parseFeaturesFile(data, |
650 |
|
AppletFormatAdapter.checkProtocol(data)); |
651 |
|
|
652 |
0 |
System.out.println( |
653 |
|
"CMD groups[-" + data + "] executed successfully!"); |
654 |
|
} |
655 |
17 |
data = aparser.getValue("features", true); |
656 |
17 |
if (data != null) |
657 |
|
{ |
658 |
1 |
af.parseFeaturesFile(data, |
659 |
|
AppletFormatAdapter.checkProtocol(data)); |
660 |
|
|
661 |
1 |
System.out.println( |
662 |
|
"CMD [-features " + data + "] executed successfully!"); |
663 |
|
} |
664 |
|
|
665 |
17 |
data = aparser.getValue("annotations", true); |
666 |
17 |
if (data != null) |
667 |
|
{ |
668 |
1 |
af.loadJalviewDataFile(data, null, null, null); |
669 |
|
|
670 |
1 |
System.out.println( |
671 |
|
"CMD [-annotations " + data + "] executed successfully!"); |
672 |
|
} |
673 |
|
|
674 |
17 |
if (aparser.contains("sortbytree")) |
675 |
|
{ |
676 |
1 |
af.getViewport().setSortByTree(true); |
677 |
1 |
if (af.getViewport().getSortByTree()) |
678 |
|
{ |
679 |
1 |
System.out.println("CMD [-sortbytree] executed successfully!"); |
680 |
|
} |
681 |
|
} |
682 |
17 |
if (aparser.contains("no-annotation")) |
683 |
|
{ |
684 |
0 |
af.getViewport().setShowAnnotation(false); |
685 |
0 |
if (!af.getViewport().isShowAnnotation()) |
686 |
|
{ |
687 |
0 |
System.out.println("CMD no-annotation executed successfully!"); |
688 |
|
} |
689 |
|
} |
690 |
17 |
if (aparser.contains("nosortbytree")) |
691 |
|
{ |
692 |
1 |
af.getViewport().setSortByTree(false); |
693 |
1 |
if (!af.getViewport().getSortByTree()) |
694 |
|
{ |
695 |
1 |
System.out |
696 |
|
.println("CMD [-nosortbytree] executed successfully!"); |
697 |
|
} |
698 |
|
} |
699 |
17 |
data = aparser.getValue("tree", true); |
700 |
17 |
if (data != null) |
701 |
|
{ |
702 |
1 |
try |
703 |
|
{ |
704 |
1 |
System.out.println( |
705 |
|
"CMD [-tree " + data + "] executed successfully!"); |
706 |
1 |
NewickFile nf = new NewickFile(data, |
707 |
|
AppletFormatAdapter.checkProtocol(data)); |
708 |
1 |
af.getViewport() |
709 |
|
.setCurrentTree(af.showNewickTree(nf, data).getTree()); |
710 |
|
} catch (IOException ex) |
711 |
|
{ |
712 |
0 |
System.err.println("Couldn't add tree " + data); |
713 |
0 |
ex.printStackTrace(System.err); |
714 |
|
} |
715 |
|
} |
716 |
|
|
717 |
|
|
718 |
|
|
719 |
17 |
if (groovyscript != null) |
720 |
|
{ |
721 |
|
|
722 |
|
|
723 |
0 |
System.out.println("Executing script " + groovyscript); |
724 |
0 |
executeGroovyScript(groovyscript, af); |
725 |
0 |
System.out.println("CMD groovy[" + groovyscript |
726 |
|
+ "] executed successfully!"); |
727 |
0 |
groovyscript = null; |
728 |
|
} |
729 |
17 |
String imageName = "unnamed.png"; |
730 |
33 |
while (aparser.getSize() > 1) |
731 |
|
{ |
732 |
16 |
String outputFormat = aparser.nextValue(); |
733 |
16 |
file = aparser.nextValue(); |
734 |
|
|
735 |
16 |
if (outputFormat.equalsIgnoreCase("png")) |
736 |
|
{ |
737 |
1 |
af.createPNG(new File(file)); |
738 |
1 |
imageName = (new File(file)).getName(); |
739 |
1 |
System.out.println("Creating PNG image: " + file); |
740 |
1 |
continue; |
741 |
|
} |
742 |
15 |
else if (outputFormat.equalsIgnoreCase("svg")) |
743 |
|
{ |
744 |
1 |
File imageFile = new File(file); |
745 |
1 |
imageName = imageFile.getName(); |
746 |
1 |
af.createSVG(imageFile); |
747 |
1 |
System.out.println("Creating SVG image: " + file); |
748 |
1 |
continue; |
749 |
|
} |
750 |
14 |
else if (outputFormat.equalsIgnoreCase("html")) |
751 |
|
{ |
752 |
1 |
File imageFile = new File(file); |
753 |
1 |
imageName = imageFile.getName(); |
754 |
1 |
HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel); |
755 |
1 |
htmlSVG.exportHTML(file); |
756 |
|
|
757 |
1 |
System.out.println("Creating HTML image: " + file); |
758 |
1 |
continue; |
759 |
|
} |
760 |
13 |
else if (outputFormat.equalsIgnoreCase("biojsmsa")) |
761 |
|
{ |
762 |
0 |
if (file == null) |
763 |
|
{ |
764 |
0 |
System.err.println("The output html file must not be null"); |
765 |
0 |
return; |
766 |
|
} |
767 |
0 |
try |
768 |
|
{ |
769 |
0 |
BioJsHTMLOutput.refreshVersionInfo( |
770 |
|
BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY); |
771 |
|
} catch (URISyntaxException e) |
772 |
|
{ |
773 |
0 |
e.printStackTrace(); |
774 |
|
} |
775 |
0 |
BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel); |
776 |
0 |
bjs.exportHTML(file); |
777 |
0 |
System.out |
778 |
|
.println("Creating BioJS MSA Viwer HTML file: " + file); |
779 |
0 |
continue; |
780 |
|
} |
781 |
13 |
else if (outputFormat.equalsIgnoreCase("imgMap")) |
782 |
|
{ |
783 |
0 |
af.createImageMap(new File(file), imageName); |
784 |
0 |
System.out.println("Creating image map: " + file); |
785 |
0 |
continue; |
786 |
|
} |
787 |
13 |
else if (outputFormat.equalsIgnoreCase("eps")) |
788 |
|
{ |
789 |
5 |
File outputFile = new File(file); |
790 |
5 |
System.out.println( |
791 |
|
"Creating EPS file: " + outputFile.getAbsolutePath()); |
792 |
5 |
af.createEPS(outputFile); |
793 |
5 |
continue; |
794 |
|
} |
795 |
|
|
796 |
8 |
af.saveAlignment(file, format); |
797 |
8 |
if (af.isSaveAlignmentSuccessful()) |
798 |
|
{ |
799 |
8 |
System.out.println("Written alignment in " + format |
800 |
|
+ " format to " + file); |
801 |
|
} |
802 |
|
else |
803 |
|
{ |
804 |
0 |
System.out.println("Error writing file " + file + " in " |
805 |
|
+ format + " format!!"); |
806 |
|
} |
807 |
|
|
808 |
|
} |
809 |
|
|
810 |
17 |
while (aparser.getSize() > 0) |
811 |
|
{ |
812 |
0 |
System.out.println("Unknown arg: " + aparser.nextValue()); |
813 |
|
} |
814 |
|
} |
815 |
|
} |
816 |
35 |
AlignFrame startUpAlframe = null; |
817 |
|
|
818 |
|
|
819 |
|
|
820 |
|
|
821 |
35 |
if (!Platform.isJS() && !headless && file == null |
822 |
|
&& Cache.getDefault("SHOW_STARTUP_FILE", true)) |
823 |
|
|
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
|
828 |
|
{ |
829 |
0 |
file = Cache.getDefault("STARTUP_FILE", |
830 |
|
Cache.getDefault("www.jalview.org", "http://www.jalview.org") |
831 |
|
+ "/examples/exampleFile_2_7.jar"); |
832 |
0 |
if (file.equals( |
833 |
|
"http://www.jalview.org/examples/exampleFile_2_3.jar")) |
834 |
|
{ |
835 |
|
|
836 |
0 |
file.replace("_2_3.jar", "_2_7.jar"); |
837 |
|
|
838 |
0 |
Cache.removeProperty("STARTUP_FILE"); |
839 |
|
} |
840 |
|
|
841 |
0 |
protocol = DataSourceType.FILE; |
842 |
|
|
843 |
0 |
if (file.indexOf("http:") > -1) |
844 |
|
{ |
845 |
0 |
protocol = DataSourceType.URL; |
846 |
|
} |
847 |
|
|
848 |
0 |
if (file.endsWith(".jar")) |
849 |
|
{ |
850 |
0 |
format = FileFormat.Jalview; |
851 |
|
} |
852 |
|
else |
853 |
|
{ |
854 |
0 |
try |
855 |
|
{ |
856 |
0 |
format = new IdentifyFile().identify(file, protocol); |
857 |
|
} catch (FileFormatException e) |
858 |
|
{ |
859 |
|
|
860 |
|
} |
861 |
|
} |
862 |
|
|
863 |
0 |
startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol, |
864 |
|
format); |
865 |
|
|
866 |
|
} |
867 |
|
|
868 |
|
|
869 |
35 |
if (groovyscript != null) |
870 |
|
{ |
871 |
0 |
if (Cache.groovyJarsPresent()) |
872 |
|
{ |
873 |
0 |
System.out.println("Executing script " + groovyscript); |
874 |
0 |
executeGroovyScript(groovyscript, startUpAlframe); |
875 |
|
} |
876 |
|
else |
877 |
|
{ |
878 |
0 |
System.err.println( |
879 |
|
"Sorry. Groovy Support is not available, so ignoring the provided groovy script " |
880 |
|
+ groovyscript); |
881 |
|
} |
882 |
|
} |
883 |
|
|
884 |
35 |
if (desktop != null) |
885 |
|
{ |
886 |
18 |
if (progress != -1) |
887 |
|
{ |
888 |
1 |
desktop.setProgressBar(null, progress); |
889 |
|
} |
890 |
18 |
desktop.setInBatchMode(false); |
891 |
|
} |
892 |
|
} |
893 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
894 |
0 |
private static boolean setCrossPlatformLookAndFeel()... |
895 |
|
{ |
896 |
0 |
return setGenericLookAndFeel(false); |
897 |
|
} |
898 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
899 |
35 |
private static boolean setSystemLookAndFeel()... |
900 |
|
{ |
901 |
35 |
return setGenericLookAndFeel(true); |
902 |
|
} |
903 |
|
|
|
|
| 66.7% |
Uncovered Elements: 3 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
904 |
35 |
private static boolean setGenericLookAndFeel(boolean system)... |
905 |
|
{ |
906 |
35 |
boolean set = false; |
907 |
35 |
try |
908 |
|
{ |
909 |
35 |
UIManager.setLookAndFeel( |
910 |
35 |
system ? UIManager.getSystemLookAndFeelClassName() |
911 |
|
: UIManager.getCrossPlatformLookAndFeelClassName()); |
912 |
35 |
set = true; |
913 |
|
} catch (Exception ex) |
914 |
|
{ |
915 |
0 |
System.err.println("Unexpected Look and Feel Exception"); |
916 |
0 |
ex.printStackTrace(); |
917 |
|
} |
918 |
35 |
return set; |
919 |
|
} |
920 |
|
|
|
|
| 73.3% |
Uncovered Elements: 4 (15) |
Complexity: 6 |
Complexity Density: 0.55 |
|
921 |
35 |
private static boolean setSpecificLookAndFeel(String name,... |
922 |
|
String className, boolean nameStartsWith) |
923 |
|
{ |
924 |
35 |
boolean set = false; |
925 |
35 |
try |
926 |
|
{ |
927 |
35 |
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) |
928 |
|
{ |
929 |
35 |
if (info.getName() != null && nameStartsWith |
930 |
|
? info.getName().toLowerCase() |
931 |
|
.startsWith(name.toLowerCase()) |
932 |
|
: info.getName().toLowerCase().equals(name.toLowerCase())) |
933 |
|
{ |
934 |
35 |
className = info.getClassName(); |
935 |
35 |
break; |
936 |
|
} |
937 |
|
} |
938 |
35 |
UIManager.setLookAndFeel(className); |
939 |
35 |
set = true; |
940 |
|
} catch (Exception ex) |
941 |
|
{ |
942 |
0 |
System.err.println("Unexpected Look and Feel Exception"); |
943 |
0 |
ex.printStackTrace(); |
944 |
|
} |
945 |
35 |
return set; |
946 |
|
} |
947 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
948 |
0 |
private static boolean setGtkLookAndFeel()... |
949 |
|
{ |
950 |
0 |
return setSpecificLookAndFeel("gtk", |
951 |
|
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true); |
952 |
|
} |
953 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
954 |
35 |
private static boolean setMetalLookAndFeel()... |
955 |
|
{ |
956 |
35 |
return setSpecificLookAndFeel("metal", |
957 |
|
"javax.swing.plaf.metal.MetalLookAndFeel", false); |
958 |
|
} |
959 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
960 |
0 |
private static boolean setNimbusLookAndFeel()... |
961 |
|
{ |
962 |
0 |
return setSpecificLookAndFeel("nimbus", |
963 |
|
"javax.swing.plaf.nimbus.NimbusLookAndFeel", false); |
964 |
|
} |
965 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
966 |
0 |
private static boolean setQuaquaLookAndFeel()... |
967 |
|
{ |
968 |
0 |
return setSpecificLookAndFeel("quaqua", |
969 |
|
ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass() |
970 |
|
.getName(), |
971 |
|
false); |
972 |
|
} |
973 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
974 |
0 |
private static boolean setVaquaLookAndFeel()... |
975 |
|
{ |
976 |
0 |
return setSpecificLookAndFeel("vaqua", |
977 |
|
"org.violetlib.aqua.AquaLookAndFeel", false); |
978 |
|
} |
979 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
980 |
0 |
private static boolean setMacLookAndFeel()... |
981 |
|
{ |
982 |
0 |
boolean set = false; |
983 |
0 |
System.setProperty("com.apple.mrj.application.apple.menu.about.name", |
984 |
|
"Jalview"); |
985 |
0 |
System.setProperty("apple.laf.useScreenMenuBar", "true"); |
986 |
0 |
set = setQuaquaLookAndFeel(); |
987 |
0 |
if ((!set) || !UIManager.getLookAndFeel().getClass().toString() |
988 |
|
.toLowerCase().contains("quaqua")) |
989 |
|
{ |
990 |
0 |
set = setVaquaLookAndFeel(); |
991 |
|
} |
992 |
0 |
return set; |
993 |
|
} |
994 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
995 |
0 |
private static void showUsage()... |
996 |
|
{ |
997 |
0 |
System.out.println( |
998 |
|
"Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n" |
999 |
|
+ "-nodisplay\tRun Jalview without User Interface.\n" |
1000 |
|
+ "-props FILE\tUse the given Jalview properties file instead of users default.\n" |
1001 |
|
+ "-colour COLOURSCHEME\tThe colourscheme to be applied to the alignment\n" |
1002 |
|
+ "-annotations FILE\tAdd precalculated annotations to the alignment.\n" |
1003 |
|
+ "-tree FILE\tLoad the given newick format tree file onto the alignment\n" |
1004 |
|
+ "-features FILE\tUse the given file to mark features on the alignment.\n" |
1005 |
|
+ "-fasta FILE\tCreate alignment file FILE in Fasta format.\n" |
1006 |
|
+ "-clustal FILE\tCreate alignment file FILE in Clustal format.\n" |
1007 |
|
+ "-pfam FILE\tCreate alignment file FILE in PFAM format.\n" |
1008 |
|
+ "-msf FILE\tCreate alignment file FILE in MSF format.\n" |
1009 |
|
+ "-pileup FILE\tCreate alignment file FILE in Pileup format\n" |
1010 |
|
+ "-pir FILE\tCreate alignment file FILE in PIR format.\n" |
1011 |
|
+ "-blc FILE\tCreate alignment file FILE in BLC format.\n" |
1012 |
|
+ "-json FILE\tCreate alignment file FILE in JSON format.\n" |
1013 |
|
+ "-jalview FILE\tCreate alignment file FILE in Jalview format.\n" |
1014 |
|
+ "-png FILE\tCreate PNG image FILE from alignment.\n" |
1015 |
|
+ "-svg FILE\tCreate SVG image FILE from alignment.\n" |
1016 |
|
+ "-html FILE\tCreate HTML file from alignment.\n" |
1017 |
|
+ "-biojsMSA FILE\tCreate BioJS MSA Viewer HTML file from alignment.\n" |
1018 |
|
+ "-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n" |
1019 |
|
+ "-eps FILE\tCreate EPS file FILE from alignment.\n" |
1020 |
|
+ "-questionnaire URL\tQueries the given URL for information about any Jalview user questionnaires.\n" |
1021 |
|
+ "-noquestionnaire\tTurn off questionnaire check.\n" |
1022 |
|
+ "-nonews\tTurn off check for Jalview news.\n" |
1023 |
|
+ "-nousagestats\tTurn off google analytics tracking for this session.\n" |
1024 |
|
+ "-sortbytree OR -nosortbytree\tEnable or disable sorting of the given alignment by the given tree\n" |
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
|
1029 |
|
|
1030 |
|
+ "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n" |
1031 |
|
+ "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n" |
1032 |
|
+ "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n" |
1033 |
|
+ "-jvmmempc=PERCENT\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected. See https://www.jalview.org/help/html/memory.html for more details.\n" |
1034 |
|
+ "-jvmmemmax=MAXMEMORY\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), gigabytes(g) or if you're lucky enough, terabytes(t). This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected. See https://www.jalview.org/help/html/memory.html for more details.\n" |
1035 |
|
+ "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n"); |
1036 |
|
} |
1037 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1038 |
17 |
private static void startUsageStats(final Desktop desktop)... |
1039 |
|
{ |
1040 |
|
|
1041 |
|
|
1042 |
|
|
1043 |
17 |
PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop, |
1044 |
|
"USAGESTATS", "Jalview Usage Statistics", |
1045 |
|
"Do you want to help make Jalview better by enabling " |
1046 |
|
+ "the collection of usage statistics with Google Analytics ?" |
1047 |
|
+ "\n\n(you can enable or disable usage tracking in the preferences)", |
1048 |
|
new Runnable() |
1049 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1050 |
0 |
@Override... |
1051 |
|
public void run() |
1052 |
|
{ |
1053 |
0 |
Cache.log.debug( |
1054 |
|
"Initialising googletracker for usage stats."); |
1055 |
0 |
Cache.initGoogleTracker(); |
1056 |
0 |
Cache.log.debug("Tracking enabled."); |
1057 |
|
} |
1058 |
|
}, new Runnable() |
1059 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1060 |
5 |
@Override... |
1061 |
|
public void run() |
1062 |
|
{ |
1063 |
5 |
Cache.log.debug("Not enabling Google Tracking."); |
1064 |
|
} |
1065 |
|
}, null, true); |
1066 |
17 |
desktop.addDialogThread(prompter); |
1067 |
|
} |
1068 |
|
|
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
|
@param |
1073 |
|
|
1074 |
|
@param |
1075 |
|
|
1076 |
|
|
1077 |
|
|
|
|
| 0% |
Uncovered Elements: 65 (65) |
Complexity: 14 |
Complexity Density: 0.29 |
|
1078 |
0 |
private void executeGroovyScript(String groovyscript, AlignFrame af)... |
1079 |
|
{ |
1080 |
|
|
1081 |
|
|
1082 |
|
|
1083 |
0 |
File tfile = null; |
1084 |
|
|
1085 |
|
|
1086 |
|
|
1087 |
0 |
URL sfile = null; |
1088 |
0 |
if (groovyscript.trim().equals("STDIN")) |
1089 |
|
{ |
1090 |
|
|
1091 |
0 |
try |
1092 |
|
{ |
1093 |
0 |
tfile = File.createTempFile("jalview", "groovy"); |
1094 |
0 |
PrintWriter outfile = new PrintWriter( |
1095 |
|
new OutputStreamWriter(new FileOutputStream(tfile))); |
1096 |
0 |
BufferedReader br = new BufferedReader( |
1097 |
|
new InputStreamReader(System.in)); |
1098 |
0 |
String line = null; |
1099 |
0 |
while ((line = br.readLine()) != null) |
1100 |
|
{ |
1101 |
0 |
outfile.write(line + "\n"); |
1102 |
|
} |
1103 |
0 |
br.close(); |
1104 |
0 |
outfile.flush(); |
1105 |
0 |
outfile.close(); |
1106 |
|
|
1107 |
|
} catch (Exception ex) |
1108 |
|
{ |
1109 |
0 |
System.err.println("Failed to read from STDIN into tempfile " |
1110 |
0 |
+ ((tfile == null) ? "(tempfile wasn't created)" |
1111 |
|
: tfile.toString())); |
1112 |
0 |
ex.printStackTrace(); |
1113 |
0 |
return; |
1114 |
|
} |
1115 |
0 |
try |
1116 |
|
{ |
1117 |
0 |
sfile = tfile.toURI().toURL(); |
1118 |
|
} catch (Exception x) |
1119 |
|
{ |
1120 |
0 |
System.err.println( |
1121 |
|
"Unexpected Malformed URL Exception for temporary file created from STDIN: " |
1122 |
|
+ tfile.toURI()); |
1123 |
0 |
x.printStackTrace(); |
1124 |
0 |
return; |
1125 |
|
} |
1126 |
|
} |
1127 |
|
else |
1128 |
|
{ |
1129 |
0 |
try |
1130 |
|
{ |
1131 |
0 |
sfile = new URI(groovyscript).toURL(); |
1132 |
|
} catch (Exception x) |
1133 |
|
{ |
1134 |
0 |
tfile = new File(groovyscript); |
1135 |
0 |
if (!tfile.exists()) |
1136 |
|
{ |
1137 |
0 |
System.err.println("File '" + groovyscript + "' does not exist."); |
1138 |
0 |
return; |
1139 |
|
} |
1140 |
0 |
if (!tfile.canRead()) |
1141 |
|
{ |
1142 |
0 |
System.err.println("File '" + groovyscript + "' cannot be read."); |
1143 |
0 |
return; |
1144 |
|
} |
1145 |
0 |
if (tfile.length() < 1) |
1146 |
|
{ |
1147 |
0 |
System.err.println("File '" + groovyscript + "' is empty."); |
1148 |
0 |
return; |
1149 |
|
} |
1150 |
0 |
try |
1151 |
|
{ |
1152 |
0 |
sfile = tfile.getAbsoluteFile().toURI().toURL(); |
1153 |
|
} catch (Exception ex) |
1154 |
|
{ |
1155 |
0 |
System.err.println("Failed to create a file URL for " |
1156 |
|
+ tfile.getAbsoluteFile()); |
1157 |
0 |
return; |
1158 |
|
} |
1159 |
|
} |
1160 |
|
} |
1161 |
0 |
try |
1162 |
|
{ |
1163 |
0 |
Map<String, java.lang.Object> vbinding = new HashMap<>(); |
1164 |
0 |
vbinding.put("Jalview", this); |
1165 |
0 |
if (af != null) |
1166 |
|
{ |
1167 |
0 |
vbinding.put("currentAlFrame", af); |
1168 |
|
} |
1169 |
0 |
Binding gbinding = new Binding(vbinding); |
1170 |
0 |
GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile }); |
1171 |
0 |
gse.run(sfile.toString(), gbinding); |
1172 |
0 |
if ("STDIN".equals(groovyscript)) |
1173 |
|
{ |
1174 |
|
|
1175 |
|
|
1176 |
0 |
tfile.delete(); |
1177 |
|
} |
1178 |
|
} catch (Exception e) |
1179 |
|
{ |
1180 |
0 |
System.err.println("Exception Whilst trying to execute file " + sfile |
1181 |
|
+ " as a groovy script."); |
1182 |
0 |
e.printStackTrace(System.err); |
1183 |
|
|
1184 |
|
} |
1185 |
|
} |
1186 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
1187 |
434 |
public static boolean isHeadlessMode()... |
1188 |
|
{ |
1189 |
434 |
String isheadless = System.getProperty("java.awt.headless"); |
1190 |
434 |
if (isheadless != null && isheadless.equalsIgnoreCase("true")) |
1191 |
|
{ |
1192 |
37 |
return true; |
1193 |
|
} |
1194 |
397 |
return false; |
1195 |
|
} |
1196 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1197 |
0 |
public AlignFrame[] getAlignFrames()... |
1198 |
|
{ |
1199 |
0 |
return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() } |
1200 |
|
: Desktop.getAlignFrames(); |
1201 |
|
|
1202 |
|
} |
1203 |
|
|
1204 |
|
|
1205 |
|
|
1206 |
|
|
1207 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1208 |
0 |
public void quit()... |
1209 |
|
{ |
1210 |
0 |
if (desktop != null) |
1211 |
|
{ |
1212 |
0 |
desktop.quit(); |
1213 |
|
} |
1214 |
|
else |
1215 |
|
{ |
1216 |
0 |
System.exit(0); |
1217 |
|
} |
1218 |
|
} |
1219 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1220 |
0 |
public static AlignFrame getCurrentAlignFrame()... |
1221 |
|
{ |
1222 |
0 |
return Jalview.currentAlignFrame; |
1223 |
|
} |
1224 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1225 |
413 |
public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)... |
1226 |
|
{ |
1227 |
413 |
Jalview.currentAlignFrame = currentAlignFrame; |
1228 |
|
} |
1229 |
|
} |