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.awt.Color; |
24 |
|
import java.io.BufferedReader; |
25 |
|
import java.io.File; |
26 |
|
import java.io.FileNotFoundException; |
27 |
|
import java.io.FileOutputStream; |
28 |
|
import java.io.IOException; |
29 |
|
import java.io.InputStreamReader; |
30 |
|
import java.io.OutputStream; |
31 |
|
import java.io.OutputStreamWriter; |
32 |
|
import java.io.PrintStream; |
33 |
|
import java.io.PrintWriter; |
34 |
|
import java.net.MalformedURLException; |
35 |
|
import java.net.URI; |
36 |
|
import java.net.URISyntaxException; |
37 |
|
import java.net.URL; |
38 |
|
import java.util.ArrayList; |
39 |
|
import java.util.HashMap; |
40 |
|
import java.util.List; |
41 |
|
import java.util.Locale; |
42 |
|
import java.util.Map; |
43 |
|
import java.util.Properties; |
44 |
|
import java.util.Vector; |
45 |
|
import java.util.logging.ConsoleHandler; |
46 |
|
import java.util.logging.Level; |
47 |
|
import java.util.logging.Logger; |
48 |
|
import java.util.stream.Collectors; |
49 |
|
|
50 |
|
import javax.swing.JDialog; |
51 |
|
import javax.swing.JFrame; |
52 |
|
import javax.swing.JInternalFrame; |
53 |
|
import javax.swing.JOptionPane; |
54 |
|
import javax.swing.SwingUtilities; |
55 |
|
import javax.swing.UIManager; |
56 |
|
import javax.swing.UIManager.LookAndFeelInfo; |
57 |
|
import javax.swing.UnsupportedLookAndFeelException; |
58 |
|
|
59 |
|
import com.formdev.flatlaf.FlatLightLaf; |
60 |
|
import com.formdev.flatlaf.themes.FlatMacLightLaf; |
61 |
|
import com.formdev.flatlaf.util.SystemInfo; |
62 |
|
|
63 |
|
|
64 |
|
import groovy.lang.Binding; |
65 |
|
import groovy.util.GroovyScriptEngine; |
66 |
|
import jalview.bin.argparser.Arg; |
67 |
|
import jalview.bin.argparser.Arg.Opt; |
68 |
|
import jalview.bin.argparser.Arg.Type; |
69 |
|
import jalview.bin.argparser.ArgParser; |
70 |
|
import jalview.bin.argparser.BootstrapArgs; |
71 |
|
import jalview.bin.groovy.JalviewObject; |
72 |
|
import jalview.bin.groovy.JalviewObjectI; |
73 |
|
import jalview.ext.so.SequenceOntology; |
74 |
|
import jalview.gui.AlignFrame; |
75 |
|
import jalview.gui.Desktop; |
76 |
|
import jalview.gui.JvOptionPane; |
77 |
|
import jalview.gui.PromptUserConfig; |
78 |
|
import jalview.gui.QuitHandler; |
79 |
|
import jalview.gui.QuitHandler.QResponse; |
80 |
|
import jalview.gui.StructureViewerBase; |
81 |
|
import jalview.io.AppletFormatAdapter; |
82 |
|
import jalview.io.BioJsHTMLOutput; |
83 |
|
import jalview.io.DataSourceType; |
84 |
|
import jalview.io.FileFormat; |
85 |
|
import jalview.io.FileFormatException; |
86 |
|
import jalview.io.FileFormatI; |
87 |
|
import jalview.io.FileFormats; |
88 |
|
import jalview.io.FileLoader; |
89 |
|
import jalview.io.HtmlSvgOutput; |
90 |
|
import jalview.io.IdentifyFile; |
91 |
|
import jalview.io.NewickFile; |
92 |
|
import jalview.io.exceptions.ImageOutputException; |
93 |
|
import jalview.io.gff.SequenceOntologyFactory; |
94 |
|
import jalview.schemes.ColourSchemeI; |
95 |
|
import jalview.schemes.ColourSchemeProperty; |
96 |
|
import jalview.util.ChannelProperties; |
97 |
|
import jalview.util.HttpUtils; |
98 |
|
import jalview.util.LaunchUtils; |
99 |
|
import jalview.util.MessageManager; |
100 |
|
import jalview.util.Platform; |
101 |
|
import jalview.util.UserAgent; |
102 |
|
import jalview.ws.jws2.Jws2Discoverer; |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
@author |
117 |
|
@version |
118 |
|
|
|
|
| 52.8% |
Uncovered Elements: 516 (1,094) |
Complexity: 294 |
Complexity Density: 0.41 |
|
119 |
|
public class Jalview implements JalviewObjectI |
120 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
121 |
55 |
static... |
122 |
|
{ |
123 |
55 |
Platform.getURLCommandArguments(); |
124 |
55 |
Platform.addJ2SDirectDatabaseCall("https://www.jalview.org"); |
125 |
55 |
Platform.addJ2SDirectDatabaseCall("http://www.jalview.org"); |
126 |
55 |
Platform.addJ2SDirectDatabaseCall("http://www.compbio.dundee.ac.uk"); |
127 |
55 |
Platform.addJ2SDirectDatabaseCall("https://www.compbio.dundee.ac.uk"); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
private static Jalview instance; |
134 |
|
|
135 |
|
private Desktop desktop; |
136 |
|
|
137 |
|
protected Commands cmds; |
138 |
|
|
139 |
|
public AlignFrame currentAlignFrame = null; |
140 |
|
|
141 |
|
private ArgParser argparser = null; |
142 |
|
|
143 |
|
private BootstrapArgs bootstrapArgs = null; |
144 |
|
|
145 |
|
private boolean QUIET = false; |
146 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
147 |
373 |
public static boolean quiet()... |
148 |
|
{ |
149 |
373 |
return Jalview.getInstance() != null && Jalview.getInstance().QUIET; |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
@author |
156 |
|
|
157 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
158 |
|
class FeatureFetcher |
159 |
|
{ |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
private int queued = 0; |
166 |
|
|
167 |
|
private int running = 0; |
168 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
169 |
0 |
public FeatureFetcher()... |
170 |
|
{ |
171 |
|
|
172 |
|
} |
173 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
174 |
0 |
public void addFetcher(final AlignFrame af,... |
175 |
|
final Vector<String> dasSources) |
176 |
|
{ |
177 |
0 |
final long id = System.currentTimeMillis(); |
178 |
0 |
queued++; |
179 |
0 |
final FeatureFetcher us = this; |
180 |
0 |
new Thread(new Runnable() |
181 |
|
{ |
182 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
183 |
0 |
@Override... |
184 |
|
public void run() |
185 |
|
{ |
186 |
0 |
synchronized (us) |
187 |
|
{ |
188 |
0 |
queued--; |
189 |
0 |
running++; |
190 |
|
} |
191 |
|
|
192 |
0 |
af.setProgressBar(MessageManager |
193 |
|
.getString("status.das_features_being_retrived"), id); |
194 |
0 |
af.featureSettings_actionPerformed(null); |
195 |
0 |
af.setProgressBar(null, id); |
196 |
0 |
synchronized (us) |
197 |
|
{ |
198 |
0 |
running--; |
199 |
|
} |
200 |
|
} |
201 |
|
}).start(); |
202 |
|
} |
203 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
204 |
0 |
public synchronized boolean allFinished()... |
205 |
|
{ |
206 |
0 |
return queued == 0 && running == 0; |
207 |
|
} |
208 |
|
|
209 |
|
} |
210 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
211 |
3982 |
public static Jalview getInstance()... |
212 |
|
{ |
213 |
3982 |
return instance; |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
@param |
220 |
|
|
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
222 |
95 |
public static void main(String[] args)... |
223 |
|
{ |
224 |
|
|
225 |
95 |
instance = new Jalview(); |
226 |
95 |
instance.doMain(args); |
227 |
|
} |
228 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
229 |
0 |
private static void logClass(String name)... |
230 |
|
{ |
231 |
|
|
232 |
0 |
ConsoleHandler consoleHandler = new ConsoleHandler(); |
233 |
0 |
consoleHandler.setLevel(Level.ALL); |
234 |
0 |
Logger logger = Logger.getLogger(name); |
235 |
0 |
logger.setLevel(Level.ALL); |
236 |
0 |
logger.addHandler(consoleHandler); |
237 |
|
} |
238 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
239 |
0 |
@SuppressWarnings("unused")... |
240 |
|
private static void setLogging() |
241 |
|
{ |
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
{ |
248 |
0 |
Console.outPrintln("not in js"); |
249 |
|
} |
250 |
|
|
251 |
|
|
252 |
0 |
if (!Platform.isJS()) |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
{ |
259 |
0 |
Logger.getLogger("").setLevel(Level.ALL); |
260 |
0 |
logClass("java.awt.EventDispatchThread"); |
261 |
0 |
logClass("java.awt.EventQueue"); |
262 |
0 |
logClass("java.awt.Component"); |
263 |
0 |
logClass("java.awt.focus.Component"); |
264 |
0 |
logClass("java.awt.focus.DefaultKeyboardFocusManager"); |
265 |
|
} |
266 |
|
|
267 |
|
} |
268 |
|
|
269 |
|
|
270 |
|
@param |
271 |
|
|
|
|
| 65.6% |
Uncovered Elements: 189 (550) |
Complexity: 145 |
Complexity Density: 0.41 |
|
272 |
131 |
void doMain(String[] args)... |
273 |
|
{ |
274 |
131 |
if (args == null || args.length == 0 || (args.length == 1 |
275 |
|
&& (args[0] == null || args[0].length() == 0))) |
276 |
|
{ |
277 |
9 |
args = new String[] {}; |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
131 |
bootstrapArgs = BootstrapArgs.getBootstrapArgs(args); |
282 |
|
|
283 |
131 |
boolean usingLogfile = false; |
284 |
131 |
if (!Platform.isJS()) |
285 |
|
{ |
286 |
|
|
287 |
131 |
System.setProperty("log4j2.isWebapp", "false"); |
288 |
|
|
289 |
|
|
290 |
131 |
String logfilename = System.getProperty("installer.logfile"); |
291 |
131 |
boolean append = Boolean |
292 |
|
.parseBoolean(System.getProperty("installer.logfile_append")); |
293 |
|
|
294 |
131 |
usingLogfile = Console.setLogFile(logfilename, append); |
295 |
|
|
296 |
|
|
297 |
131 |
if (!usingLogfile && bootstrapArgs.contains(Arg.QUIET)) |
298 |
|
{ |
299 |
0 |
QUIET = true; |
300 |
0 |
OutputStream devNull = new OutputStream() |
301 |
|
{ |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
302 |
0 |
@Override... |
303 |
|
public void write(int b) |
304 |
|
{ |
305 |
|
|
306 |
|
} |
307 |
|
}; |
308 |
0 |
System.setOut(new PrintStream(devNull)); |
309 |
|
|
310 |
0 |
if (bootstrapArgs.getList(Arg.QUIET).size() > 1) |
311 |
|
{ |
312 |
0 |
System.setErr(new PrintStream(devNull)); |
313 |
|
} |
314 |
|
} |
315 |
|
|
316 |
131 |
if (bootstrapArgs.contains(Arg.HELP) |
317 |
|
|| bootstrapArgs.contains(Arg.VERSION)) |
318 |
|
{ |
319 |
0 |
QUIET = true; |
320 |
|
} |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
131 |
if (bootstrapArgs.contains(Arg.P)) |
325 |
|
{ |
326 |
0 |
for (String kev : bootstrapArgs.getValueList(Arg.P)) |
327 |
|
{ |
328 |
0 |
if (kev == null) |
329 |
|
{ |
330 |
0 |
continue; |
331 |
|
} |
332 |
0 |
int equalsIndex = kev.indexOf(ArgParser.EQUALS); |
333 |
0 |
if (equalsIndex > -1) |
334 |
|
{ |
335 |
0 |
String key = kev.substring(0, equalsIndex); |
336 |
0 |
String val = kev.substring(equalsIndex + 1); |
337 |
0 |
Cache.setSessionProperty(key, val); |
338 |
|
} |
339 |
|
} |
340 |
|
} |
341 |
|
|
342 |
|
|
343 |
|
|
344 |
131 |
String appdirString = System.getProperty("launcher.appdir"); |
345 |
131 |
if (appdirString != null && appdirString.length() > 0) |
346 |
|
{ |
347 |
0 |
new Thread() |
348 |
|
{ |
349 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
350 |
0 |
@Override... |
351 |
|
public void run() |
352 |
|
{ |
353 |
0 |
GetdownLauncherUpdate.main(new String[] { appdirString }); |
354 |
|
} |
355 |
|
}.start(); |
356 |
|
} |
357 |
|
|
358 |
131 |
if ((usingLogfile || !quiet()) || !bootstrapArgs.outputToStdout() |
359 |
|
|| bootstrapArgs.contains(Arg.VERSION)) |
360 |
|
{ |
361 |
131 |
if (usingLogfile) |
362 |
|
{ |
363 |
0 |
Console.outPrintln("-------"); |
364 |
|
} |
365 |
131 |
Console.outPrint(Cache.getVersionDetailsForConsole()); |
366 |
131 |
if (usingLogfile) |
367 |
|
{ |
368 |
0 |
Console.outPrintln("-------"); |
369 |
|
} |
370 |
|
} |
371 |
|
|
372 |
131 |
if (Platform.isLinux() && LaunchUtils.getJavaVersion() < 11) |
373 |
|
{ |
374 |
0 |
System.setProperty("flatlaf.uiScale", "1"); |
375 |
|
} |
376 |
|
|
377 |
|
|
378 |
131 |
Properties bootstrapProperties = Cache |
379 |
|
.bootstrapProperties(bootstrapArgs.getValue(Arg.PROPS)); |
380 |
|
|
381 |
|
|
382 |
131 |
Cache.loadBuildProperties( |
383 |
|
!quiet() || bootstrapArgs.contains(Arg.VERSION)); |
384 |
|
|
385 |
|
|
386 |
131 |
if (bootstrapArgs.contains(Arg.VERSION)) |
387 |
|
{ |
388 |
0 |
Jalview.exit(null, ExitCode.OK); |
389 |
|
} |
390 |
|
|
391 |
|
|
392 |
131 |
ArgsParser aparser = new ArgsParser(args); |
393 |
|
|
394 |
|
|
395 |
131 |
boolean headless = false; |
396 |
|
|
397 |
131 |
boolean headlessArg = false; |
398 |
|
|
399 |
131 |
try |
400 |
|
{ |
401 |
131 |
String logLevel = null; |
402 |
131 |
if (bootstrapArgs.contains(Arg.TRACE)) |
403 |
|
{ |
404 |
0 |
logLevel = "TRACE"; |
405 |
|
} |
406 |
131 |
else if (bootstrapArgs.contains(Arg.DEBUG)) |
407 |
|
{ |
408 |
10 |
logLevel = bootstrapArgs.getBoolean(Arg.DEBUG) ? "DEBUG" : "INFO"; |
409 |
|
} |
410 |
131 |
if (logLevel == null && !(bootstrapProperties == null)) |
411 |
|
{ |
412 |
121 |
logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL); |
413 |
|
} |
414 |
131 |
Console.initLogger(logLevel); |
415 |
|
} catch (NoClassDefFoundError error) |
416 |
|
{ |
417 |
0 |
error.printStackTrace(); |
418 |
0 |
String message = "\nEssential logging libraries not found." |
419 |
|
+ "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview"; |
420 |
0 |
Jalview.exit(message, ExitCode.OK); |
421 |
|
} |
422 |
|
|
423 |
|
|
424 |
131 |
Runtime.getRuntime().addShutdownHook(new Thread() |
425 |
|
{ |
|
|
| 84.2% |
Uncovered Elements: 3 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
426 |
126 |
@Override... |
427 |
|
public void run() |
428 |
|
{ |
429 |
126 |
Console.debug("Running shutdown hook"); |
430 |
126 |
QuitHandler.startForceQuit(); |
431 |
124 |
boolean closeExternal = Cache |
432 |
|
.getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false) |
433 |
|
|| Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false); |
434 |
124 |
StructureViewerBase.setQuitClose(closeExternal); |
435 |
117 |
if (desktop != null) |
436 |
|
{ |
437 |
74 |
for (JInternalFrame frame : Desktop.desktop.getAllFrames()) |
438 |
|
{ |
439 |
4 |
if (frame instanceof StructureViewerBase) |
440 |
|
{ |
441 |
1 |
((StructureViewerBase) frame).closeViewer(closeExternal); |
442 |
|
} |
443 |
|
} |
444 |
|
} |
445 |
|
|
446 |
115 |
if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT) |
447 |
|
{ |
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
|
452 |
|
|
453 |
0 |
Console.debug("Checking for saving files"); |
454 |
0 |
QuitHandler.getQuitResponse(false); |
455 |
|
} |
456 |
|
else |
457 |
|
{ |
458 |
116 |
Console.debug("Nothing more to do"); |
459 |
|
} |
460 |
116 |
Console.debug("Exiting, bye!"); |
461 |
|
|
462 |
|
} |
463 |
|
}); |
464 |
|
|
465 |
131 |
String usrPropsFile = bootstrapArgs.contains(Arg.PROPS) |
466 |
|
? bootstrapArgs.getValue(Arg.PROPS) |
467 |
|
: aparser.getValue("props"); |
468 |
|
|
469 |
|
|
470 |
131 |
Cache.loadProperties(usrPropsFile); |
471 |
131 |
if (usrPropsFile != null) |
472 |
|
{ |
473 |
30 |
Console.outPrintln( |
474 |
|
"CMD [-props " + usrPropsFile + "] executed successfully!"); |
475 |
30 |
testoutput(bootstrapArgs, Arg.PROPS, |
476 |
|
"test/jalview/bin/testProps.jvprops", usrPropsFile); |
477 |
|
} |
478 |
|
|
479 |
|
|
480 |
131 |
if (bootstrapArgs.contains(Arg.ARGFILE)) |
481 |
|
{ |
482 |
8 |
argparser = ArgParser.parseArgFiles( |
483 |
|
bootstrapArgs.getValueList(Arg.ARGFILE), |
484 |
|
bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS), |
485 |
|
bootstrapArgs); |
486 |
|
} |
487 |
|
else |
488 |
|
{ |
489 |
123 |
argparser = new ArgParser(args, |
490 |
|
bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS), |
491 |
|
bootstrapArgs); |
492 |
|
} |
493 |
|
|
494 |
131 |
if (!Platform.isJS()) |
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
{ |
501 |
131 |
if (bootstrapArgs.contains(Arg.HELP)) |
502 |
|
{ |
503 |
0 |
List<Map.Entry<Type, String>> helpArgs = bootstrapArgs |
504 |
|
.getList(Arg.HELP); |
505 |
0 |
Console.outPrintln(Arg.usage(helpArgs.stream().map(e -> e.getKey()) |
506 |
|
.collect(Collectors.toList()))); |
507 |
0 |
Jalview.exit(null, ExitCode.OK); |
508 |
|
} |
509 |
131 |
if (aparser.contains("help") || aparser.contains("h")) |
510 |
|
{ |
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
0 |
Console.outPrintln(Arg.usage()); |
516 |
0 |
Jalview.exit(null, ExitCode.OK); |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
131 |
headlessArg = bootstrapArgs.isHeadless(); |
521 |
131 |
if (headlessArg) |
522 |
|
{ |
523 |
32 |
System.setProperty("java.awt.headless", "true"); |
524 |
|
} |
525 |
|
|
526 |
131 |
if (aparser.contains("nodisplay") || aparser.contains("nogui") |
527 |
|
|| aparser.contains("headless")) |
528 |
|
{ |
529 |
17 |
System.setProperty("java.awt.headless", "true"); |
530 |
17 |
headless = true; |
531 |
|
} |
532 |
|
|
533 |
|
|
534 |
|
|
535 |
131 |
System.setProperty("com.sun.security.enableAIAcaIssuers", "true"); |
536 |
|
|
537 |
131 |
String jabawsUrl = bootstrapArgs.getValue(Arg.JABAWS); |
538 |
131 |
if (jabawsUrl == null) |
539 |
130 |
jabawsUrl = aparser.getValue("jabaws"); |
540 |
131 |
if (jabawsUrl != null) |
541 |
|
{ |
542 |
2 |
try |
543 |
|
{ |
544 |
2 |
Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl); |
545 |
2 |
Console.outPrintln( |
546 |
|
"CMD [-jabaws " + jabawsUrl + "] executed successfully!"); |
547 |
2 |
testoutput(bootstrapArgs, Arg.JABAWS, |
548 |
|
"http://www.compbio.dundee.ac.uk/jabaws", jabawsUrl); |
549 |
|
} catch (MalformedURLException e) |
550 |
|
{ |
551 |
0 |
jalview.bin.Console.errPrintln( |
552 |
|
"Invalid jabaws parameter: " + jabawsUrl + " ignored"); |
553 |
|
} |
554 |
|
} |
555 |
|
} |
556 |
|
|
557 |
131 |
List<String> setprops = new ArrayList<>(); |
558 |
131 |
if (bootstrapArgs.contains(Arg.SETPROP)) |
559 |
|
{ |
560 |
0 |
setprops = bootstrapArgs.getValueList(Arg.SETPROP); |
561 |
|
} |
562 |
|
else |
563 |
|
{ |
564 |
131 |
String sp = aparser.getValue("setprop"); |
565 |
131 |
while (sp != null) |
566 |
|
{ |
567 |
0 |
setprops.add(sp); |
568 |
0 |
sp = aparser.getValue("setprop"); |
569 |
|
} |
570 |
|
} |
571 |
131 |
for (String setprop : setprops) |
572 |
|
{ |
573 |
0 |
int p = setprop.indexOf('='); |
574 |
0 |
if (p == -1) |
575 |
|
{ |
576 |
0 |
System.err |
577 |
|
.println("Ignoring invalid setprop argument : " + setprop); |
578 |
|
} |
579 |
|
else |
580 |
|
{ |
581 |
0 |
jalview.bin.Console |
582 |
|
.errPrintln("Executing setprop argument: " + setprop); |
583 |
0 |
if (Platform.isJS()) |
584 |
|
{ |
585 |
0 |
Cache.setProperty(setprop.substring(0, p), |
586 |
|
setprop.substring(p + 1)); |
587 |
|
} |
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
} |
592 |
|
} |
593 |
131 |
if (System.getProperty("java.awt.headless") != null |
594 |
|
&& System.getProperty("java.awt.headless").equals("true")) |
595 |
|
{ |
596 |
55 |
headless = true; |
597 |
|
} |
598 |
131 |
System.setProperty("http.agent", UserAgent.getUserAgent()); |
599 |
|
|
600 |
|
|
601 |
131 |
try |
602 |
|
{ |
603 |
131 |
Console.initLogger(); |
604 |
|
} catch (NoClassDefFoundError error) |
605 |
|
{ |
606 |
0 |
error.printStackTrace(); |
607 |
0 |
String message = "\nEssential logging libraries not found." |
608 |
|
+ "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview"; |
609 |
0 |
Jalview.exit(message, ExitCode.NO_LOGGING); |
610 |
|
} |
611 |
131 |
desktop = null; |
612 |
|
|
613 |
131 |
if (!(headless || headlessArg)) |
614 |
76 |
setLookAndFeel(); |
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
|
619 |
|
|
620 |
130 |
boolean soDefault = !Platform.isJS(); |
621 |
130 |
if (Cache.getDefault("USE_FULL_SO", soDefault)) |
622 |
|
{ |
623 |
130 |
SequenceOntologyFactory.setInstance(new SequenceOntology()); |
624 |
|
} |
625 |
|
|
626 |
130 |
if (!(headless || headlessArg)) |
627 |
|
{ |
628 |
75 |
Desktop.nosplash = "false".equals(bootstrapArgs.getValue(Arg.SPLASH)) |
629 |
|
|| aparser.contains("nosplash") |
630 |
|
|| Cache.getDefault("SPLASH", "true").equals("false"); |
631 |
75 |
desktop = new Desktop(); |
632 |
75 |
desktop.setInBatchMode(true); |
633 |
|
|
634 |
75 |
mixedCliWarning(); |
635 |
|
|
636 |
75 |
try |
637 |
|
{ |
638 |
75 |
JalviewTaskbar.setTaskbar(this); |
639 |
|
} catch (Exception e) |
640 |
|
{ |
641 |
0 |
Console.info("Cannot set Taskbar"); |
642 |
0 |
Console.error(e.getMessage()); |
643 |
|
|
644 |
|
} catch (Throwable t) |
645 |
|
{ |
646 |
0 |
Console.info("Cannot set Taskbar"); |
647 |
0 |
Console.error(t.getMessage()); |
648 |
|
|
649 |
|
} |
650 |
|
|
651 |
|
|
652 |
75 |
Cache.setProxyPropertiesFromPreferences(); |
653 |
|
|
654 |
75 |
desktop.setVisible(true); |
655 |
|
|
656 |
75 |
if (!Platform.isJS()) |
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
{ |
663 |
|
|
664 |
75 |
String appName = ChannelProperties.getProperty("app_name"); |
665 |
|
|
666 |
|
|
667 |
|
|
668 |
|
|
669 |
|
|
670 |
75 |
if (!LaunchUtils.checkJavaVersion()) |
671 |
|
{ |
672 |
0 |
Console.warn("The Java version being used (Java " |
673 |
|
+ LaunchUtils.getJavaVersion() |
674 |
|
+ ") may lead to problems. This installation of " |
675 |
|
+ appName + " should be used with Java " |
676 |
|
+ LaunchUtils.getJavaCompileVersion() + "."); |
677 |
|
|
678 |
0 |
if (!LaunchUtils |
679 |
|
.getBooleanUserPreference("IGNORE_JVM_WARNING_POPUP")) |
680 |
|
{ |
681 |
0 |
Object[] options = { |
682 |
|
MessageManager.getString("label.continue") }; |
683 |
0 |
JOptionPane.showOptionDialog(null, |
684 |
|
MessageManager.formatMessage( |
685 |
|
"warning.wrong_jvm_version_message", |
686 |
|
LaunchUtils.getJavaVersion(), |
687 |
|
LaunchUtils.getJavaCompileVersion()), |
688 |
|
MessageManager |
689 |
|
.getString("warning.wrong_jvm_version_title"), |
690 |
|
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, |
691 |
|
null, options, options[0]); |
692 |
|
} |
693 |
|
} |
694 |
|
|
695 |
|
|
696 |
|
|
697 |
|
|
698 |
|
|
699 |
75 |
String installerappdirString = System |
700 |
|
.getProperty("installer.appdir"); |
701 |
75 |
if (Platform.isMac() && installerappdirString != null |
702 |
|
&& installerappdirString.startsWith("/Volumes/")) |
703 |
|
{ |
704 |
0 |
Console.warn("You appear to be running " + appName |
705 |
|
+ " from the Installer volume. Please drag and drop the " |
706 |
|
+ appName + " icon into the Applications folder."); |
707 |
|
|
708 |
0 |
Object[] options = { MessageManager.getString("action.quit") }; |
709 |
0 |
JOptionPane.showOptionDialog(null, MessageManager.formatMessage( |
710 |
|
"warning.running_from_installer_volume_message", appName), |
711 |
|
MessageManager.getString( |
712 |
|
"warning.running_from_installer_volume_title"), |
713 |
|
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, |
714 |
|
null, options, options[0]); |
715 |
0 |
quit(); |
716 |
|
} |
717 |
|
|
718 |
75 |
boolean webservicediscovery = bootstrapArgs |
719 |
|
.getBoolean(Arg.WEBSERVICEDISCOVERY); |
720 |
75 |
if (aparser.contains("nowebservicediscovery")) |
721 |
0 |
webservicediscovery = false; |
722 |
75 |
if (webservicediscovery) |
723 |
|
{ |
724 |
65 |
desktop.startServiceDiscovery(); |
725 |
|
} |
726 |
|
else |
727 |
|
{ |
728 |
10 |
testoutput(argparser, Arg.WEBSERVICEDISCOVERY); |
729 |
|
} |
730 |
|
|
731 |
75 |
boolean usagestats = !bootstrapArgs.getBoolean(Arg.NOUSAGESTATS); |
732 |
75 |
if (aparser.contains("nousagestats")) |
733 |
1 |
usagestats = false; |
734 |
75 |
if (usagestats) |
735 |
|
{ |
736 |
69 |
startUsageStats(desktop); |
737 |
69 |
testoutput(argparser, Arg.NOUSAGESTATS); |
738 |
|
} |
739 |
|
else |
740 |
|
{ |
741 |
6 |
Console.outPrintln("CMD [-nousagestats] executed successfully!"); |
742 |
6 |
testoutput(argparser, Arg.NOUSAGESTATS); |
743 |
|
} |
744 |
|
|
745 |
75 |
boolean questionnaire = bootstrapArgs.getBoolean(Arg.QUESTIONNAIRE); |
746 |
75 |
if (aparser.contains("noquestionnaire")) |
747 |
1 |
questionnaire = false; |
748 |
75 |
if (questionnaire) |
749 |
|
{ |
750 |
67 |
String url = aparser.getValue("questionnaire"); |
751 |
67 |
if (url != null) |
752 |
|
{ |
753 |
|
|
754 |
|
|
755 |
0 |
Console.debug("Starting questionnaire url at " + url); |
756 |
0 |
desktop.checkForQuestionnaire(url); |
757 |
0 |
Console.outPrintln("CMD questionnaire[-" + url |
758 |
|
+ "] executed successfully!"); |
759 |
|
} |
760 |
|
else |
761 |
|
{ |
762 |
67 |
if (Cache.getProperty("NOQUESTIONNAIRES") == null) |
763 |
|
{ |
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
|
769 |
36 |
String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl"; |
770 |
36 |
Console.debug( |
771 |
|
"Starting questionnaire with default url: " + defurl); |
772 |
36 |
desktop.checkForQuestionnaire(defurl); |
773 |
|
} |
774 |
|
} |
775 |
|
} |
776 |
|
else |
777 |
|
{ |
778 |
8 |
Console.outPrintln( |
779 |
|
"CMD [-noquestionnaire] executed successfully!"); |
780 |
8 |
testoutput(argparser, Arg.QUESTIONNAIRE); |
781 |
|
} |
782 |
|
|
783 |
75 |
if ((!aparser.contains("nonews") |
784 |
|
&& Cache.getProperty("NONEWS") == null |
785 |
|
&& !"false".equals(bootstrapArgs.getValue(Arg.NEWS))) |
786 |
|
|| "true".equals(bootstrapArgs.getValue(Arg.NEWS))) |
787 |
|
{ |
788 |
42 |
desktop.checkForNews(); |
789 |
|
} |
790 |
|
|
791 |
75 |
if (!aparser.contains("nohtmltemplates") |
792 |
|
&& Cache.getProperty("NOHTMLTEMPLATES") == null) |
793 |
|
{ |
794 |
75 |
BioJsHTMLOutput.updateBioJS(); |
795 |
|
} |
796 |
|
} |
797 |
|
} |
798 |
|
else |
799 |
|
{ |
800 |
|
|
801 |
55 |
if (getArgParser().isMixedStyle()) |
802 |
|
{ |
803 |
0 |
String warning = MessageManager.formatMessage( |
804 |
|
"warning.using_mixed_command_line_arguments", |
805 |
|
getArgParser().getMixedExamples()); |
806 |
0 |
Console.warn(warning); |
807 |
0 |
Jalview.exit( |
808 |
|
"Exiting due to mixed old and new command line arguments", |
809 |
|
ExitCode.INVALID_ARGUMENT); |
810 |
|
} |
811 |
55 |
if (getArgParser().isOldStyle()) |
812 |
|
{ |
813 |
17 |
String warning = MessageManager |
814 |
|
.getString("warning.using_old_command_line_arguments") |
815 |
|
.replace("\n", " ") |
816 |
|
+ "https://www.jalview.org/help/html/features/commandline.html"; |
817 |
17 |
Console.warn(warning); |
818 |
|
} |
819 |
|
|
820 |
|
} |
821 |
|
|
822 |
|
|
823 |
130 |
cmds = new Commands(argparser, headlessArg); |
824 |
130 |
cmds.processArgs(); |
825 |
125 |
boolean commandsSuccess = cmds.argsWereParsed(); |
826 |
|
|
827 |
125 |
if (commandsSuccess) |
828 |
|
{ |
829 |
77 |
if (headlessArg) |
830 |
|
{ |
831 |
32 |
if (argparser.getBoolean(Arg.NOQUIT)) |
832 |
|
{ |
833 |
6 |
Console.warn( |
834 |
|
"Completed " + Arg.HEADLESS.getName() + " commands, but " |
835 |
|
+ Arg.NOQUIT + " is set so not quitting!"); |
836 |
|
} |
837 |
|
else |
838 |
|
{ |
839 |
26 |
Jalview.exit("Successfully completed commands in headless mode", |
840 |
|
ExitCode.OK); |
841 |
|
} |
842 |
|
} |
843 |
51 |
Console.info("Successfully completed commands"); |
844 |
|
} |
845 |
|
else |
846 |
|
{ |
847 |
48 |
if (headlessArg) |
848 |
|
{ |
849 |
0 |
Jalview.exit("Error when running Commands in headless mode", |
850 |
|
ExitCode.ERROR_RUNNING_COMMANDS); |
851 |
|
} |
852 |
48 |
Console.warn("Error when running commands"); |
853 |
|
} |
854 |
|
|
855 |
|
|
856 |
|
|
857 |
99 |
if (headless && !Platform.isJS() && !LaunchUtils.checkJavaVersion()) |
858 |
|
{ |
859 |
0 |
Console.warn("The Java version being used (Java " |
860 |
|
+ LaunchUtils.getJavaVersion() |
861 |
|
+ ") may lead to problems. This installation of Jalview should be used with Java " |
862 |
|
+ LaunchUtils.getJavaCompileVersion() + "."); |
863 |
|
} |
864 |
|
|
865 |
99 |
String file = null, data = null; |
866 |
|
|
867 |
99 |
FileFormatI format = null; |
868 |
|
|
869 |
99 |
DataSourceType protocol = null; |
870 |
|
|
871 |
99 |
FileLoader fileLoader = new FileLoader(!headless); |
872 |
|
|
873 |
99 |
String groovyscript = null; |
874 |
|
|
875 |
|
|
876 |
99 |
groovyscript = aparser.getValue("groovy", true); |
877 |
99 |
file = aparser.getValue("open", true); |
878 |
|
|
879 |
99 |
if (file == null && desktop == null && !commandsSuccess) |
880 |
|
{ |
881 |
0 |
Jalview.exit("No files to open!", ExitCode.NO_FILES); |
882 |
|
} |
883 |
|
|
884 |
99 |
long progress = -1; |
885 |
|
|
886 |
99 |
if (file != null) |
887 |
|
{ |
888 |
18 |
if (!headless) |
889 |
|
{ |
890 |
1 |
desktop.setProgressBar( |
891 |
|
MessageManager |
892 |
|
.getString("status.processing_commandline_args"), |
893 |
|
progress = System.currentTimeMillis()); |
894 |
|
} |
895 |
18 |
Console.outPrintln("CMD [-open " + file + "] executed successfully!"); |
896 |
|
|
897 |
18 |
if (!Platform.isJS()) |
898 |
|
|
899 |
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
|
{ |
904 |
18 |
if (!HttpUtils.startsWithHttpOrHttps(file)) |
905 |
|
{ |
906 |
18 |
if (!(new File(file)).exists()) |
907 |
|
{ |
908 |
0 |
if (headless) |
909 |
|
{ |
910 |
0 |
Jalview.exit( |
911 |
|
"Can't find file '" + file + "' in headless mode", |
912 |
|
ExitCode.FILE_NOT_FOUND); |
913 |
|
} |
914 |
0 |
Console.warn("Can't find file'" + file + "'"); |
915 |
|
} |
916 |
|
} |
917 |
|
} |
918 |
|
|
919 |
18 |
protocol = AppletFormatAdapter.checkProtocol(file); |
920 |
|
|
921 |
18 |
try |
922 |
|
{ |
923 |
18 |
format = new IdentifyFile().identify(file, protocol); |
924 |
|
} catch (FileNotFoundException e) |
925 |
|
{ |
926 |
0 |
Console.error("File at '" + file + "' not found", e); |
927 |
|
} catch (FileFormatException e) |
928 |
|
{ |
929 |
0 |
Console.error("File '" + file + "' format not recognised", e); |
930 |
|
} |
931 |
|
|
932 |
18 |
AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol, |
933 |
|
format); |
934 |
18 |
if (af == null) |
935 |
|
{ |
936 |
0 |
Console.outPrintln("error"); |
937 |
|
} |
938 |
|
else |
939 |
|
{ |
940 |
18 |
setCurrentAlignFrame(af); |
941 |
18 |
data = aparser.getValue("colour", true); |
942 |
18 |
if (data != null) |
943 |
|
{ |
944 |
1 |
data.replaceAll("%20", " "); |
945 |
|
|
946 |
1 |
ColourSchemeI cs = ColourSchemeProperty.getColourScheme( |
947 |
|
af.getViewport(), af.getViewport().getAlignment(), data); |
948 |
|
|
949 |
1 |
if (cs != null) |
950 |
|
{ |
951 |
1 |
Console.outPrintln( |
952 |
|
"CMD [-colour " + data + "] executed successfully!"); |
953 |
|
} |
954 |
1 |
af.changeColour(cs); |
955 |
|
} |
956 |
|
|
957 |
|
|
958 |
18 |
data = aparser.getValue("groups", true); |
959 |
18 |
if (data != null) |
960 |
|
{ |
961 |
0 |
af.parseFeaturesFile(data, |
962 |
|
AppletFormatAdapter.checkProtocol(data)); |
963 |
|
|
964 |
0 |
Console.outPrintln( |
965 |
|
"CMD groups[-" + data + "] executed successfully!"); |
966 |
|
} |
967 |
18 |
data = aparser.getValue("features", true); |
968 |
18 |
if (data != null) |
969 |
|
{ |
970 |
1 |
af.parseFeaturesFile(data, |
971 |
|
AppletFormatAdapter.checkProtocol(data)); |
972 |
|
|
973 |
1 |
Console.outPrintln( |
974 |
|
"CMD [-features " + data + "] executed successfully!"); |
975 |
|
} |
976 |
|
|
977 |
18 |
data = aparser.getValue("annotations", true); |
978 |
18 |
if (data != null) |
979 |
|
{ |
980 |
1 |
af.loadJalviewDataFile(data, null, null, null); |
981 |
|
|
982 |
1 |
Console.outPrintln( |
983 |
|
"CMD [-annotations " + data + "] executed successfully!"); |
984 |
|
} |
985 |
|
|
986 |
18 |
if (aparser.contains("sortbytree")) |
987 |
|
{ |
988 |
1 |
af.getViewport().setSortByTree(true); |
989 |
1 |
if (af.getViewport().getSortByTree()) |
990 |
|
{ |
991 |
1 |
Console.outPrintln("CMD [-sortbytree] executed successfully!"); |
992 |
|
} |
993 |
|
} |
994 |
18 |
if (aparser.contains("no-annotation")) |
995 |
|
{ |
996 |
0 |
af.getViewport().setShowAnnotation(false); |
997 |
0 |
if (!af.getViewport().isShowAnnotation()) |
998 |
|
{ |
999 |
0 |
Console.outPrintln("CMD no-annotation executed successfully!"); |
1000 |
|
} |
1001 |
|
} |
1002 |
18 |
if (aparser.contains("nosortbytree")) |
1003 |
|
{ |
1004 |
1 |
af.getViewport().setSortByTree(false); |
1005 |
1 |
if (!af.getViewport().getSortByTree()) |
1006 |
|
{ |
1007 |
1 |
Console.outPrintln( |
1008 |
|
"CMD [-nosortbytree] executed successfully!"); |
1009 |
|
} |
1010 |
|
} |
1011 |
18 |
data = aparser.getValue("tree", true); |
1012 |
18 |
if (data != null) |
1013 |
|
{ |
1014 |
1 |
try |
1015 |
|
{ |
1016 |
1 |
Console.outPrintln( |
1017 |
|
"CMD [-tree " + data + "] executed successfully!"); |
1018 |
1 |
NewickFile nf = new NewickFile(data, |
1019 |
|
AppletFormatAdapter.checkProtocol(data)); |
1020 |
1 |
af.getViewport() |
1021 |
|
.setCurrentTree(af.showNewickTree(nf, data).getTree()); |
1022 |
|
} catch (IOException ex) |
1023 |
|
{ |
1024 |
0 |
jalview.bin.Console.errPrintln("Couldn't add tree " + data); |
1025 |
0 |
ex.printStackTrace(System.err); |
1026 |
|
} |
1027 |
|
} |
1028 |
|
|
1029 |
18 |
if (groovyscript != null) |
1030 |
|
{ |
1031 |
|
|
1032 |
|
|
1033 |
0 |
Console.outPrintln("Executing script " + groovyscript); |
1034 |
0 |
executeGroovyScript(groovyscript, af); |
1035 |
0 |
Console.outPrintln("CMD groovy[" + groovyscript |
1036 |
|
+ "] executed successfully!"); |
1037 |
0 |
groovyscript = null; |
1038 |
|
} |
1039 |
18 |
String imageName = "unnamed.png"; |
1040 |
34 |
while (aparser.getSize() > 1) |
1041 |
|
{ |
1042 |
16 |
try |
1043 |
|
{ |
1044 |
16 |
String outputFormat = aparser.nextValue(); |
1045 |
16 |
file = aparser.nextValue(); |
1046 |
|
|
1047 |
16 |
if (outputFormat.equalsIgnoreCase("png")) |
1048 |
|
{ |
1049 |
1 |
Console.outPrintln("Creating PNG image: " + file); |
1050 |
1 |
af.createPNG(new File(file)); |
1051 |
1 |
imageName = (new File(file)).getName(); |
1052 |
1 |
continue; |
1053 |
|
} |
1054 |
15 |
else if (outputFormat.equalsIgnoreCase("svg")) |
1055 |
|
{ |
1056 |
1 |
Console.outPrintln("Creating SVG image: " + file); |
1057 |
1 |
File imageFile = new File(file); |
1058 |
1 |
imageName = imageFile.getName(); |
1059 |
1 |
af.createSVG(imageFile); |
1060 |
1 |
continue; |
1061 |
|
} |
1062 |
14 |
else if (outputFormat.equalsIgnoreCase("html")) |
1063 |
|
{ |
1064 |
1 |
File imageFile = new File(file); |
1065 |
1 |
imageName = imageFile.getName(); |
1066 |
1 |
HtmlSvgOutput htmlSVG = new HtmlSvgOutput(af.alignPanel); |
1067 |
|
|
1068 |
1 |
Console.outPrintln("Creating HTML image: " + file); |
1069 |
1 |
htmlSVG.exportHTML(file); |
1070 |
1 |
continue; |
1071 |
|
} |
1072 |
13 |
else if (outputFormat.equalsIgnoreCase("biojsmsa")) |
1073 |
|
{ |
1074 |
0 |
if (file == null) |
1075 |
|
{ |
1076 |
0 |
jalview.bin.Console.errPrintln( |
1077 |
|
"The output html file must not be null"); |
1078 |
0 |
return; |
1079 |
|
} |
1080 |
0 |
try |
1081 |
|
{ |
1082 |
0 |
BioJsHTMLOutput.refreshVersionInfo( |
1083 |
|
BioJsHTMLOutput.BJS_TEMPLATES_LOCAL_DIRECTORY); |
1084 |
|
} catch (URISyntaxException e) |
1085 |
|
{ |
1086 |
0 |
e.printStackTrace(); |
1087 |
|
} |
1088 |
0 |
BioJsHTMLOutput bjs = new BioJsHTMLOutput(af.alignPanel); |
1089 |
0 |
Console.outPrintln( |
1090 |
|
"Creating BioJS MSA Viwer HTML file: " + file); |
1091 |
0 |
bjs.exportHTML(file); |
1092 |
0 |
continue; |
1093 |
|
} |
1094 |
13 |
else if (outputFormat.equalsIgnoreCase("imgMap")) |
1095 |
|
{ |
1096 |
0 |
Console.outPrintln("Creating image map: " + file); |
1097 |
0 |
af.createImageMap(new File(file), imageName); |
1098 |
0 |
continue; |
1099 |
|
} |
1100 |
13 |
else if (outputFormat.equalsIgnoreCase("eps")) |
1101 |
|
{ |
1102 |
5 |
File outputFile = new File(file); |
1103 |
5 |
Console.outPrintln( |
1104 |
|
"Creating EPS file: " + outputFile.getAbsolutePath()); |
1105 |
5 |
af.createEPS(outputFile); |
1106 |
5 |
continue; |
1107 |
|
} |
1108 |
|
|
1109 |
8 |
FileFormatI outFormat = null; |
1110 |
8 |
try |
1111 |
|
{ |
1112 |
8 |
outFormat = FileFormats.getInstance().forName(outputFormat); |
1113 |
|
} catch (Exception formatP) |
1114 |
|
{ |
1115 |
0 |
Console.outPrintln("Couldn't parse " + outFormat |
1116 |
|
+ " as a valid Jalview format string."); |
1117 |
|
} |
1118 |
8 |
if (outFormat != null) |
1119 |
|
{ |
1120 |
8 |
if (!outFormat.isWritable()) |
1121 |
|
{ |
1122 |
0 |
Console.outPrintln( |
1123 |
|
"This version of Jalview does not support alignment export as " |
1124 |
|
+ outputFormat); |
1125 |
|
} |
1126 |
|
else |
1127 |
|
{ |
1128 |
8 |
af.saveAlignment(file, outFormat); |
1129 |
8 |
if (af.isSaveAlignmentSuccessful()) |
1130 |
|
{ |
1131 |
8 |
Console.outPrintln("Written alignment in " |
1132 |
|
+ outFormat.getName() + " format to " + file); |
1133 |
|
} |
1134 |
|
else |
1135 |
|
{ |
1136 |
0 |
Console.outPrintln("Error writing file " + file + " in " |
1137 |
|
+ outFormat.getName() + " format!!"); |
1138 |
|
} |
1139 |
|
} |
1140 |
|
} |
1141 |
|
} catch (ImageOutputException ioexc) |
1142 |
|
{ |
1143 |
0 |
Console.outPrintln( |
1144 |
|
"Unexpected error whilst exporting image to " + file); |
1145 |
0 |
ioexc.printStackTrace(); |
1146 |
|
} |
1147 |
|
|
1148 |
|
} |
1149 |
|
|
1150 |
18 |
while (aparser.getSize() > 0) |
1151 |
|
{ |
1152 |
0 |
Console.outPrintln("Unknown arg: " + aparser.nextValue()); |
1153 |
|
} |
1154 |
|
} |
1155 |
|
} |
1156 |
|
|
1157 |
99 |
AlignFrame startUpAlframe = null; |
1158 |
|
|
1159 |
|
|
1160 |
|
|
1161 |
|
|
1162 |
99 |
if (!Platform.isJS() && !headless && file == null |
1163 |
|
&& Cache.getDefault("SHOW_STARTUP_FILE", true) |
1164 |
|
&& !cmds.commandArgsProvided() |
1165 |
|
&& !bootstrapArgs.getBoolean(Arg.NOSTARTUPFILE)) |
1166 |
|
|
1167 |
|
|
1168 |
|
|
1169 |
|
|
1170 |
|
|
1171 |
|
|
1172 |
|
|
1173 |
|
{ |
1174 |
0 |
file = Cache.getDefault("STARTUP_FILE", |
1175 |
|
Cache.getDefault("www.jalview.org", "https://www.jalview.org") |
1176 |
|
+ "/examples/exampleFile_2_7.jvp"); |
1177 |
0 |
if (file.equals("http://www.jalview.org/examples/exampleFile_2_3.jar") |
1178 |
|
|| file.equals( |
1179 |
|
"http://www.jalview.org/examples/exampleFile_2_7.jar")) |
1180 |
|
{ |
1181 |
0 |
file.replace("http:", "https:"); |
1182 |
|
|
1183 |
0 |
file.replace("_2_3", "_2_7"); |
1184 |
0 |
file.replace("2_7.jar", "2_7.jvp"); |
1185 |
|
|
1186 |
0 |
Cache.removeProperty("STARTUP_FILE"); |
1187 |
|
} |
1188 |
|
|
1189 |
0 |
protocol = AppletFormatAdapter.checkProtocol(file); |
1190 |
|
|
1191 |
0 |
if (file.endsWith(".jar")) |
1192 |
|
{ |
1193 |
0 |
format = FileFormat.Jalview; |
1194 |
|
} |
1195 |
|
else |
1196 |
|
{ |
1197 |
0 |
try |
1198 |
|
{ |
1199 |
0 |
format = new IdentifyFile().identify(file, protocol); |
1200 |
|
} catch (FileNotFoundException e) |
1201 |
|
{ |
1202 |
0 |
Console.error("File at '" + file + "' not found", e); |
1203 |
|
} catch (FileFormatException e) |
1204 |
|
{ |
1205 |
0 |
Console.error("File '" + file + "' format not recognised", e); |
1206 |
|
} |
1207 |
|
} |
1208 |
|
|
1209 |
0 |
startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol, |
1210 |
|
format); |
1211 |
|
|
1212 |
|
|
1213 |
0 |
Console.debug("Resetting up-to-date flag for startup file"); |
1214 |
0 |
startUpAlframe.getViewport().setSavedUpToDate(true); |
1215 |
|
|
1216 |
|
} |
1217 |
|
|
1218 |
|
|
1219 |
99 |
if (groovyscript != null) |
1220 |
|
{ |
1221 |
0 |
if (Cache.groovyJarsPresent()) |
1222 |
|
{ |
1223 |
0 |
Console.outPrintln("Executing script " + groovyscript); |
1224 |
0 |
executeGroovyScript(groovyscript, startUpAlframe); |
1225 |
|
} |
1226 |
|
else |
1227 |
|
{ |
1228 |
0 |
jalview.bin.Console.errPrintln( |
1229 |
|
"Sorry. Groovy Support is not available, so ignoring the provided groovy script " |
1230 |
|
+ groovyscript); |
1231 |
|
} |
1232 |
|
} |
1233 |
|
|
1234 |
99 |
if (desktop != null) |
1235 |
|
{ |
1236 |
70 |
if (progress != -1) |
1237 |
|
{ |
1238 |
1 |
desktop.setProgressBar(null, progress); |
1239 |
|
} |
1240 |
70 |
desktop.setInBatchMode(false); |
1241 |
|
} |
1242 |
|
|
1243 |
99 |
cliWarning(); |
1244 |
|
} |
1245 |
|
|
|
|
| 27.1% |
Uncovered Elements: 62 (85) |
Complexity: 23 |
Complexity Density: 0.4 |
|
1246 |
76 |
private static void setLookAndFeel()... |
1247 |
|
{ |
1248 |
76 |
if (!Platform.isJS()) |
1249 |
|
|
1250 |
|
|
1251 |
|
|
1252 |
|
|
1253 |
|
|
1254 |
|
{ |
1255 |
|
|
1256 |
|
|
1257 |
|
|
1258 |
|
|
1259 |
|
|
1260 |
76 |
String lafProp = System.getProperty("laf"); |
1261 |
76 |
String lafSetting = Cache.getDefault("PREFERRED_LAF", null); |
1262 |
76 |
String laf = "none"; |
1263 |
76 |
if (lafProp != null) |
1264 |
|
{ |
1265 |
0 |
laf = lafProp; |
1266 |
|
} |
1267 |
76 |
else if (lafSetting != null) |
1268 |
|
{ |
1269 |
0 |
laf = lafSetting; |
1270 |
|
} |
1271 |
76 |
boolean lafSet = false; |
1272 |
76 |
switch (laf) |
1273 |
|
{ |
1274 |
0 |
case "crossplatform": |
1275 |
0 |
lafSet = setCrossPlatformLookAndFeel(); |
1276 |
0 |
if (!lafSet) |
1277 |
|
{ |
1278 |
0 |
Console.error("Could not set requested laf=" + laf); |
1279 |
|
} |
1280 |
0 |
break; |
1281 |
0 |
case "system": |
1282 |
0 |
lafSet = setSystemLookAndFeel(); |
1283 |
0 |
if (!lafSet) |
1284 |
|
{ |
1285 |
0 |
Console.error("Could not set requested laf=" + laf); |
1286 |
|
} |
1287 |
0 |
break; |
1288 |
0 |
case "gtk": |
1289 |
0 |
lafSet = setGtkLookAndFeel(); |
1290 |
0 |
if (!lafSet) |
1291 |
|
{ |
1292 |
0 |
Console.error("Could not set requested laf=" + laf); |
1293 |
|
} |
1294 |
0 |
break; |
1295 |
0 |
case "metal": |
1296 |
0 |
lafSet = setMetalLookAndFeel(); |
1297 |
0 |
if (!lafSet) |
1298 |
|
{ |
1299 |
0 |
Console.error("Could not set requested laf=" + laf); |
1300 |
|
} |
1301 |
0 |
break; |
1302 |
0 |
case "nimbus": |
1303 |
0 |
lafSet = setNimbusLookAndFeel(); |
1304 |
0 |
if (!lafSet) |
1305 |
|
{ |
1306 |
0 |
Console.error("Could not set requested laf=" + laf); |
1307 |
|
} |
1308 |
0 |
break; |
1309 |
0 |
case "flat": |
1310 |
0 |
lafSet = setFlatLookAndFeel(); |
1311 |
0 |
if (!lafSet) |
1312 |
|
{ |
1313 |
0 |
Console.error("Could not set requested laf=" + laf); |
1314 |
|
} |
1315 |
0 |
break; |
1316 |
0 |
case "mac": |
1317 |
0 |
lafSet = setMacLookAndFeel(); |
1318 |
0 |
if (!lafSet) |
1319 |
|
{ |
1320 |
0 |
Console.error("Could not set requested laf=" + laf); |
1321 |
|
} |
1322 |
0 |
break; |
1323 |
76 |
case "none": |
1324 |
76 |
break; |
1325 |
0 |
default: |
1326 |
0 |
Console.error("Requested laf=" + laf + " not implemented"); |
1327 |
|
} |
1328 |
76 |
if (!lafSet) |
1329 |
|
{ |
1330 |
|
|
1331 |
76 |
lafSet = setFlatLookAndFeel(); |
1332 |
75 |
if (!lafSet) |
1333 |
|
{ |
1334 |
0 |
setSystemLookAndFeel(); |
1335 |
|
} |
1336 |
75 |
if (Platform.isLinux()) |
1337 |
|
{ |
1338 |
75 |
setLinuxLookAndFeel(); |
1339 |
|
} |
1340 |
75 |
if (Platform.isMac()) |
1341 |
|
{ |
1342 |
0 |
setMacLookAndFeel(); |
1343 |
|
} |
1344 |
|
} |
1345 |
|
} |
1346 |
|
} |
1347 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
1348 |
0 |
private static boolean setCrossPlatformLookAndFeel()... |
1349 |
|
{ |
1350 |
0 |
boolean set = false; |
1351 |
0 |
try |
1352 |
|
{ |
1353 |
0 |
UIManager.setLookAndFeel( |
1354 |
|
UIManager.getCrossPlatformLookAndFeelClassName()); |
1355 |
0 |
set = true; |
1356 |
|
} catch (Exception ex) |
1357 |
|
{ |
1358 |
0 |
Console.error("Unexpected Look and Feel Exception"); |
1359 |
0 |
Console.error(ex.getMessage()); |
1360 |
0 |
Console.debug(Cache.getStackTraceString(ex)); |
1361 |
|
} |
1362 |
0 |
return set; |
1363 |
|
} |
1364 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
1365 |
0 |
private static boolean setSystemLookAndFeel()... |
1366 |
|
{ |
1367 |
0 |
boolean set = false; |
1368 |
0 |
try |
1369 |
|
{ |
1370 |
0 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
1371 |
0 |
set = true; |
1372 |
|
} catch (Exception ex) |
1373 |
|
{ |
1374 |
0 |
Console.error("Unexpected Look and Feel Exception"); |
1375 |
0 |
Console.error(ex.getMessage()); |
1376 |
0 |
Console.debug(Cache.getStackTraceString(ex)); |
1377 |
|
} |
1378 |
0 |
return set; |
1379 |
|
} |
1380 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.5 |
|
1381 |
0 |
private static boolean setSpecificLookAndFeel(String name,... |
1382 |
|
String className, boolean nameStartsWith) |
1383 |
|
{ |
1384 |
0 |
boolean set = false; |
1385 |
0 |
try |
1386 |
|
{ |
1387 |
0 |
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) |
1388 |
|
{ |
1389 |
0 |
if (info.getName() != null && nameStartsWith |
1390 |
|
? info.getName().toLowerCase(Locale.ROOT) |
1391 |
|
.startsWith(name.toLowerCase(Locale.ROOT)) |
1392 |
|
: info.getName().toLowerCase(Locale.ROOT) |
1393 |
|
.equals(name.toLowerCase(Locale.ROOT))) |
1394 |
|
{ |
1395 |
0 |
className = info.getClassName(); |
1396 |
0 |
break; |
1397 |
|
} |
1398 |
|
} |
1399 |
0 |
UIManager.setLookAndFeel(className); |
1400 |
0 |
set = true; |
1401 |
|
} catch (Exception ex) |
1402 |
|
{ |
1403 |
0 |
Console.error("Unexpected Look and Feel Exception"); |
1404 |
0 |
Console.error(ex.getMessage()); |
1405 |
0 |
Console.debug(Cache.getStackTraceString(ex)); |
1406 |
|
} |
1407 |
0 |
return set; |
1408 |
|
} |
1409 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1410 |
0 |
private static boolean setGtkLookAndFeel()... |
1411 |
|
{ |
1412 |
0 |
return setSpecificLookAndFeel("gtk", |
1413 |
|
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel", true); |
1414 |
|
} |
1415 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1416 |
0 |
private static boolean setMetalLookAndFeel()... |
1417 |
|
{ |
1418 |
0 |
return setSpecificLookAndFeel("metal", |
1419 |
|
"javax.swing.plaf.metal.MetalLookAndFeel", false); |
1420 |
|
} |
1421 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1422 |
0 |
private static boolean setNimbusLookAndFeel()... |
1423 |
|
{ |
1424 |
0 |
return setSpecificLookAndFeel("nimbus", |
1425 |
|
"javax.swing.plaf.nimbus.NimbusLookAndFeel", false); |
1426 |
|
} |
1427 |
|
|
|
|
| 41.9% |
Uncovered Elements: 43 (74) |
Complexity: 12 |
Complexity Density: 0.19 |
|
1428 |
151 |
private static boolean setFlatLookAndFeel()... |
1429 |
|
{ |
1430 |
151 |
boolean set = false; |
1431 |
151 |
if (SystemInfo.isMacOS) |
1432 |
|
{ |
1433 |
0 |
try |
1434 |
|
{ |
1435 |
0 |
UIManager.setLookAndFeel( |
1436 |
|
"com.formdev.flatlaf.themes.FlatMacLightLaf"); |
1437 |
0 |
set = true; |
1438 |
0 |
Console.debug("Using FlatMacLightLaf"); |
1439 |
|
} catch (ClassNotFoundException | InstantiationException |
1440 |
|
| IllegalAccessException | UnsupportedLookAndFeelException e) |
1441 |
|
{ |
1442 |
0 |
Console.debug("Exception loading FlatLightLaf", e); |
1443 |
|
} |
1444 |
0 |
System.setProperty("apple.laf.useScreenMenuBar", "true"); |
1445 |
0 |
System.setProperty("apple.awt.application.name", |
1446 |
|
ChannelProperties.getProperty("app_name")); |
1447 |
0 |
System.setProperty("apple.awt.application.appearance", "system"); |
1448 |
0 |
if (SystemInfo.isMacFullWindowContentSupported |
1449 |
|
&& Desktop.desktop != null) |
1450 |
|
{ |
1451 |
0 |
Console.debug("Setting transparent title bar"); |
1452 |
0 |
Desktop.desktop.getRootPane() |
1453 |
|
.putClientProperty("apple.awt.fullWindowContent", true); |
1454 |
0 |
Desktop.desktop.getRootPane() |
1455 |
|
.putClientProperty("apple.awt.transparentTitleBar", true); |
1456 |
0 |
Desktop.desktop.getRootPane() |
1457 |
|
.putClientProperty("apple.awt.fullscreenable", true); |
1458 |
|
} |
1459 |
0 |
SwingUtilities.invokeLater(() -> { |
1460 |
0 |
FlatMacLightLaf.setup(); |
1461 |
|
}); |
1462 |
0 |
Console.debug("Using FlatMacLightLaf"); |
1463 |
0 |
set = true; |
1464 |
|
} |
1465 |
151 |
if (!set) |
1466 |
|
{ |
1467 |
151 |
try |
1468 |
|
{ |
1469 |
151 |
UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); |
1470 |
150 |
set = true; |
1471 |
150 |
Console.debug("Using FlatLightLaf"); |
1472 |
|
} catch (ClassNotFoundException | InstantiationException |
1473 |
|
| IllegalAccessException | UnsupportedLookAndFeelException e) |
1474 |
|
{ |
1475 |
0 |
Console.debug("Exception loading FlatLightLaf", e); |
1476 |
|
} |
1477 |
|
|
1478 |
150 |
SwingUtilities.invokeLater(() -> { |
1479 |
150 |
FlatLightLaf.setup(); |
1480 |
|
}); |
1481 |
150 |
Console.debug("Using FlatLightLaf"); |
1482 |
150 |
set = true; |
1483 |
|
} |
1484 |
0 |
else if (SystemInfo.isLinux) |
1485 |
|
{ |
1486 |
0 |
try |
1487 |
|
{ |
1488 |
0 |
UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); |
1489 |
0 |
set = true; |
1490 |
0 |
Console.debug("Using FlatLightLaf"); |
1491 |
|
} catch (ClassNotFoundException | InstantiationException |
1492 |
|
| IllegalAccessException | UnsupportedLookAndFeelException e) |
1493 |
|
{ |
1494 |
0 |
Console.debug("Exception loading FlatLightLaf", e); |
1495 |
|
} |
1496 |
|
|
1497 |
0 |
JFrame.setDefaultLookAndFeelDecorated(true); |
1498 |
0 |
JDialog.setDefaultLookAndFeelDecorated(true); |
1499 |
0 |
SwingUtilities.invokeLater(() -> { |
1500 |
0 |
FlatLightLaf.setup(); |
1501 |
|
}); |
1502 |
0 |
Console.debug("Using FlatLightLaf"); |
1503 |
0 |
set = true; |
1504 |
|
} |
1505 |
|
|
1506 |
150 |
if (!set) |
1507 |
|
{ |
1508 |
0 |
try |
1509 |
|
{ |
1510 |
0 |
UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); |
1511 |
0 |
set = true; |
1512 |
0 |
Console.debug("Using FlatLightLaf"); |
1513 |
|
} catch (ClassNotFoundException | InstantiationException |
1514 |
|
| IllegalAccessException | UnsupportedLookAndFeelException e) |
1515 |
|
{ |
1516 |
0 |
Console.debug("Exception loading FlatLightLaf", e); |
1517 |
|
} |
1518 |
|
} |
1519 |
|
|
1520 |
150 |
if (set) |
1521 |
|
{ |
1522 |
150 |
UIManager.put("TabbedPane.tabType", "card"); |
1523 |
150 |
UIManager.put("TabbedPane.showTabSeparators", true); |
1524 |
150 |
UIManager.put("TabbedPane.showContentSeparator", true); |
1525 |
|
|
1526 |
150 |
UIManager.put("TabbedPane.tabsOverlapBorder", true); |
1527 |
150 |
UIManager.put("TabbedPane.hasFullBorder", true); |
1528 |
150 |
UIManager.put("TabbedPane.tabLayoutPolicy", "scroll"); |
1529 |
150 |
UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded"); |
1530 |
150 |
UIManager.put("TabbedPane.smoothScrolling", true); |
1531 |
150 |
UIManager.put("TabbedPane.tabWidthMode", "compact"); |
1532 |
150 |
UIManager.put("TabbedPane.selectedBackground", Color.white); |
1533 |
150 |
UIManager.put("TabbedPane.background", new Color(236, 236, 236)); |
1534 |
150 |
UIManager.put("TabbedPane.hoverColor", Color.lightGray); |
1535 |
|
} |
1536 |
|
|
1537 |
150 |
Desktop.setLiveDragMode(Cache.getDefault("FLAT_LIVE_DRAG_MODE", true)); |
1538 |
150 |
return set; |
1539 |
|
} |
1540 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1541 |
0 |
private static boolean setMacLookAndFeel()... |
1542 |
|
{ |
1543 |
0 |
boolean set = false; |
1544 |
0 |
System.setProperty("com.apple.mrj.application.apple.menu.about.name", |
1545 |
|
ChannelProperties.getProperty("app_name")); |
1546 |
0 |
System.setProperty("apple.laf.useScreenMenuBar", "true"); |
1547 |
|
|
1548 |
|
|
1549 |
|
|
1550 |
|
|
1551 |
|
|
1552 |
|
|
1553 |
|
|
1554 |
|
|
1555 |
|
|
1556 |
0 |
set = setFlatLookAndFeel(); |
1557 |
0 |
return set; |
1558 |
|
} |
1559 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
1560 |
75 |
private static boolean setLinuxLookAndFeel()... |
1561 |
|
{ |
1562 |
75 |
boolean set = false; |
1563 |
75 |
set = setFlatLookAndFeel(); |
1564 |
75 |
if (!set) |
1565 |
0 |
set = setMetalLookAndFeel(); |
1566 |
|
|
1567 |
75 |
if (!set) |
1568 |
0 |
set = setNimbusLookAndFeel(); |
1569 |
75 |
return set; |
1570 |
|
} |
1571 |
|
|
1572 |
|
|
1573 |
|
|
1574 |
|
|
1575 |
|
|
1576 |
|
|
1577 |
|
|
1578 |
|
|
1579 |
|
|
1580 |
|
|
1581 |
|
|
1582 |
|
|
1583 |
|
|
1584 |
|
|
1585 |
|
|
1586 |
|
|
1587 |
|
|
1588 |
|
|
1589 |
|
|
1590 |
|
|
1591 |
|
|
1592 |
|
|
1593 |
|
|
1594 |
|
|
1595 |
|
|
1596 |
|
|
1597 |
|
|
1598 |
|
|
1599 |
|
|
1600 |
|
|
1601 |
|
|
1602 |
|
|
1603 |
|
|
1604 |
|
|
1605 |
|
|
1606 |
|
|
1607 |
|
|
1608 |
|
|
1609 |
|
|
1610 |
|
|
1611 |
|
|
1612 |
|
|
1613 |
|
|
1614 |
|
|
1615 |
|
|
1616 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1617 |
69 |
private static void startUsageStats(final Desktop desktop)... |
1618 |
|
{ |
1619 |
|
|
1620 |
|
|
1621 |
|
|
1622 |
69 |
PromptUserConfig prompter = new PromptUserConfig(Desktop.desktop, |
1623 |
|
"USAGESTATS", |
1624 |
|
MessageManager.getString("prompt.analytics_title"), |
1625 |
|
MessageManager.getString("prompt.analytics"), new Runnable() |
1626 |
|
{ |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1627 |
0 |
@Override... |
1628 |
|
public void run() |
1629 |
|
{ |
1630 |
0 |
Console.debug("Initialising analytics for usage stats."); |
1631 |
0 |
Cache.initAnalytics(); |
1632 |
0 |
Console.debug("Tracking enabled."); |
1633 |
|
} |
1634 |
|
}, new Runnable() |
1635 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1636 |
27 |
@Override... |
1637 |
|
public void run() |
1638 |
|
{ |
1639 |
27 |
Console.debug("Not enabling analytics."); |
1640 |
|
} |
1641 |
|
}, null, true); |
1642 |
69 |
desktop.addDialogThread(prompter); |
1643 |
|
} |
1644 |
|
|
1645 |
|
|
1646 |
|
|
1647 |
|
|
1648 |
|
@param |
1649 |
|
|
1650 |
|
@param |
1651 |
|
|
1652 |
|
|
1653 |
|
|
|
|
| 0% |
Uncovered Elements: 65 (65) |
Complexity: 14 |
Complexity Density: 0.29 |
|
1654 |
0 |
protected void executeGroovyScript(String groovyscript, AlignFrame af)... |
1655 |
|
{ |
1656 |
|
|
1657 |
|
|
1658 |
|
|
1659 |
0 |
File tfile = null; |
1660 |
|
|
1661 |
|
|
1662 |
|
|
1663 |
0 |
URL sfile = null; |
1664 |
0 |
if (groovyscript.trim().equals("STDIN")) |
1665 |
|
{ |
1666 |
|
|
1667 |
0 |
try |
1668 |
|
{ |
1669 |
0 |
tfile = File.createTempFile("jalview", "groovy"); |
1670 |
0 |
PrintWriter outfile = new PrintWriter( |
1671 |
|
new OutputStreamWriter(new FileOutputStream(tfile))); |
1672 |
0 |
BufferedReader br = new BufferedReader( |
1673 |
|
new InputStreamReader(System.in)); |
1674 |
0 |
String line = null; |
1675 |
0 |
while ((line = br.readLine()) != null) |
1676 |
|
{ |
1677 |
0 |
outfile.write(line + "\n"); |
1678 |
|
} |
1679 |
0 |
br.close(); |
1680 |
0 |
outfile.flush(); |
1681 |
0 |
outfile.close(); |
1682 |
|
|
1683 |
|
} catch (Exception ex) |
1684 |
|
{ |
1685 |
0 |
jalview.bin.Console |
1686 |
|
.errPrintln("Failed to read from STDIN into tempfile " |
1687 |
0 |
+ ((tfile == null) ? "(tempfile wasn't created)" |
1688 |
|
: tfile.toString())); |
1689 |
0 |
ex.printStackTrace(); |
1690 |
0 |
return; |
1691 |
|
} |
1692 |
0 |
try |
1693 |
|
{ |
1694 |
0 |
sfile = tfile.toURI().toURL(); |
1695 |
|
} catch (Exception x) |
1696 |
|
{ |
1697 |
0 |
jalview.bin.Console.errPrintln( |
1698 |
|
"Unexpected Malformed URL Exception for temporary file created from STDIN: " |
1699 |
|
+ tfile.toURI()); |
1700 |
0 |
x.printStackTrace(); |
1701 |
0 |
return; |
1702 |
|
} |
1703 |
|
} |
1704 |
|
else |
1705 |
|
{ |
1706 |
0 |
try |
1707 |
|
{ |
1708 |
0 |
sfile = new URI(groovyscript).toURL(); |
1709 |
|
} catch (Exception x) |
1710 |
|
{ |
1711 |
0 |
tfile = new File(groovyscript); |
1712 |
0 |
if (!tfile.exists()) |
1713 |
|
{ |
1714 |
0 |
jalview.bin.Console.errPrintln( |
1715 |
|
"File '" + groovyscript + "' does not exist."); |
1716 |
0 |
return; |
1717 |
|
} |
1718 |
0 |
if (!tfile.canRead()) |
1719 |
|
{ |
1720 |
0 |
jalview.bin.Console.errPrintln( |
1721 |
|
"File '" + groovyscript + "' cannot be read."); |
1722 |
0 |
return; |
1723 |
|
} |
1724 |
0 |
if (tfile.length() < 1) |
1725 |
|
{ |
1726 |
0 |
jalview.bin.Console |
1727 |
|
.errPrintln("File '" + groovyscript + "' is empty."); |
1728 |
0 |
return; |
1729 |
|
} |
1730 |
0 |
try |
1731 |
|
{ |
1732 |
0 |
sfile = tfile.getAbsoluteFile().toURI().toURL(); |
1733 |
|
} catch (Exception ex) |
1734 |
|
{ |
1735 |
0 |
jalview.bin.Console.errPrintln("Failed to create a file URL for " |
1736 |
|
+ tfile.getAbsoluteFile()); |
1737 |
0 |
return; |
1738 |
|
} |
1739 |
|
} |
1740 |
|
} |
1741 |
0 |
try |
1742 |
|
{ |
1743 |
0 |
JalviewObjectI j = new JalviewObject(this); |
1744 |
0 |
Map<String, java.lang.Object> vbinding = new HashMap<>(); |
1745 |
0 |
vbinding.put(JalviewObjectI.jalviewObjectName, j); |
1746 |
0 |
vbinding.put(JalviewObjectI.currentAlFrameName, |
1747 |
0 |
af != null ? af : getCurrentAlignFrame()); |
1748 |
0 |
Binding gbinding = new Binding(vbinding); |
1749 |
0 |
GroovyScriptEngine gse = new GroovyScriptEngine(new URL[] { sfile }); |
1750 |
0 |
gse.run(sfile.toString(), gbinding); |
1751 |
0 |
if ("STDIN".equals(groovyscript)) |
1752 |
|
{ |
1753 |
|
|
1754 |
|
|
1755 |
0 |
tfile.delete(); |
1756 |
|
} |
1757 |
|
} catch (Exception e) |
1758 |
|
{ |
1759 |
0 |
jalview.bin.Console |
1760 |
|
.errPrintln("Exception Whilst trying to execute file " + sfile |
1761 |
|
+ " as a groovy script."); |
1762 |
0 |
e.printStackTrace(System.err); |
1763 |
|
} |
1764 |
|
} |
1765 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
1766 |
1115 |
public static boolean isHeadlessMode()... |
1767 |
|
{ |
1768 |
1115 |
String isheadless = System.getProperty("java.awt.headless"); |
1769 |
1115 |
if (isheadless != null && isheadless.equalsIgnoreCase("true")) |
1770 |
|
{ |
1771 |
220 |
return true; |
1772 |
|
} |
1773 |
895 |
return false; |
1774 |
|
} |
1775 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
1776 |
0 |
@Override... |
1777 |
|
public AlignFrame[] getAlignFrames() |
1778 |
|
{ |
1779 |
0 |
return desktop == null ? new AlignFrame[] { getCurrentAlignFrame() } |
1780 |
|
: Desktop.getDesktopAlignFrames(); |
1781 |
|
} |
1782 |
|
|
1783 |
|
|
1784 |
|
|
1785 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1786 |
0 |
@Override... |
1787 |
|
public void quit() |
1788 |
|
{ |
1789 |
|
|
1790 |
0 |
Jalview.exit("Quitting now. Bye!", ExitCode.OK); |
1791 |
|
} |
1792 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1793 |
0 |
@Override... |
1794 |
|
public AlignFrame getCurrentAlignFrame() |
1795 |
|
{ |
1796 |
0 |
return currentAlignFrame; |
1797 |
|
} |
1798 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1799 |
1034 |
public void setCurrentAlignFrame(AlignFrame af)... |
1800 |
|
{ |
1801 |
1034 |
this.currentAlignFrame = af; |
1802 |
|
} |
1803 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1804 |
327 |
public Commands getCommands()... |
1805 |
|
{ |
1806 |
327 |
return cmds; |
1807 |
|
} |
1808 |
|
|
|
|
| 48.1% |
Uncovered Elements: 14 (27) |
Complexity: 8 |
Complexity Density: 0.62 |
|
1809 |
27 |
public static void exit(String message, ExitCode ec)... |
1810 |
|
{ |
1811 |
27 |
int exitcode = ec == ExitCode.OK ? 0 : ec.ordinal() + 1; |
1812 |
27 |
if (Console.log == null) |
1813 |
|
{ |
1814 |
|
|
1815 |
0 |
if (message != null) |
1816 |
|
{ |
1817 |
0 |
if (exitcode == 0) |
1818 |
|
{ |
1819 |
0 |
Console.outPrintln(message); |
1820 |
|
} |
1821 |
|
else |
1822 |
|
{ |
1823 |
0 |
jalview.bin.Console.errPrintln(message); |
1824 |
|
} |
1825 |
|
} |
1826 |
|
} |
1827 |
|
else |
1828 |
|
{ |
1829 |
27 |
Console.debug("Using Jalview.exit"); |
1830 |
27 |
if (message != null) |
1831 |
|
{ |
1832 |
27 |
if (exitcode == 0) |
1833 |
|
{ |
1834 |
27 |
Console.info(message); |
1835 |
|
} |
1836 |
|
else |
1837 |
|
{ |
1838 |
0 |
Console.error(message); |
1839 |
|
} |
1840 |
|
} |
1841 |
|
} |
1842 |
27 |
if (exitcode > -1) |
1843 |
|
{ |
1844 |
27 |
System.exit(exitcode); |
1845 |
|
} |
1846 |
|
} |
1847 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
1848 |
|
public enum ExitCode |
1849 |
|
{ |
1850 |
|
|
1851 |
|
OK, FILE_NOT_FOUND, FILE_NOT_READABLE, NO_FILES, INVALID_FORMAT, |
1852 |
|
INVALID_ARGUMENT, INVALID_VALUE, MIXED_CLI_ARGUMENTS, |
1853 |
|
ERROR_RUNNING_COMMANDS, NO_LOGGING, GROOVY_ERROR; |
1854 |
|
} |
1855 |
|
|
1856 |
|
|
1857 |
|
|
1858 |
|
|
1859 |
|
|
1860 |
|
|
1861 |
|
|
1862 |
|
|
1863 |
|
|
1864 |
|
|
1865 |
|
|
1866 |
|
|
1867 |
|
|
1868 |
|
|
1869 |
|
|
1870 |
|
@param |
1871 |
|
|
1872 |
|
@param |
1873 |
|
|
1874 |
|
@param |
1875 |
|
|
1876 |
|
@param |
1877 |
|
|
|
|
| 63.2% |
Uncovered Elements: 7 (19) |
Complexity: 8 |
Complexity Density: 0.73 |
|
1878 |
149 |
protected static void testoutput(ArgParser ap, Arg a, String s1,... |
1879 |
|
String s2) |
1880 |
|
{ |
1881 |
149 |
BootstrapArgs bsa = ap.getBootstrapArgs(); |
1882 |
149 |
if (!bsa.getBoolean(Arg.TESTOUTPUT)) |
1883 |
127 |
return; |
1884 |
22 |
if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2)))) |
1885 |
|
{ |
1886 |
0 |
Console.debug("testoutput with unmatching values '" + s1 + "' and '" |
1887 |
|
+ s2 + "' for arg " + a.argString()); |
1888 |
0 |
return; |
1889 |
|
} |
1890 |
22 |
boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a) |
1891 |
|
: ap.isSet(a); |
1892 |
22 |
if (!isset) |
1893 |
|
{ |
1894 |
0 |
Console.warn("Arg '" + a.getName() + "' not set at all"); |
1895 |
0 |
return; |
1896 |
|
} |
1897 |
22 |
testoutput(true, a, s1, s2); |
1898 |
|
} |
1899 |
|
|
1900 |
|
|
1901 |
|
|
1902 |
|
|
1903 |
|
|
1904 |
|
|
1905 |
|
|
|
|
| 57.9% |
Uncovered Elements: 8 (19) |
Complexity: 8 |
Complexity Density: 0.73 |
|
1906 |
32 |
protected static void testoutput(BootstrapArgs bsa, Arg a, String s1,... |
1907 |
|
String s2) |
1908 |
|
{ |
1909 |
32 |
if (!bsa.getBoolean(Arg.TESTOUTPUT)) |
1910 |
30 |
return; |
1911 |
2 |
if (!((s1 == null && s2 == null) || (s1 != null && s1.equals(s2)))) |
1912 |
|
{ |
1913 |
0 |
Console.debug("testoutput with unmatching values '" + s1 + "' and '" |
1914 |
|
+ s2 + "' for arg " + a.argString()); |
1915 |
0 |
return; |
1916 |
|
} |
1917 |
2 |
if (!a.hasOption(Opt.BOOTSTRAP)) |
1918 |
|
{ |
1919 |
0 |
Console.error("Non-bootstrap Arg '" + a.getName() |
1920 |
|
+ "' given to testoutput(BootstrapArgs bsa, Arg a, String s1, String s2) with only BootstrapArgs"); |
1921 |
|
} |
1922 |
2 |
if (!bsa.contains(a)) |
1923 |
|
{ |
1924 |
0 |
Console.warn("Arg '" + a.getName() + "' not set at all"); |
1925 |
0 |
return; |
1926 |
|
} |
1927 |
2 |
testoutput(true, a, s1, s2); |
1928 |
|
} |
1929 |
|
|
1930 |
|
|
1931 |
|
@param |
1932 |
|
|
1933 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 6 |
Complexity Density: 3 |
|
1934 |
24 |
private static void testoutput(boolean yes, Arg a, String s1, String s2)... |
1935 |
|
{ |
1936 |
24 |
if (yes && ((s1 == null && s2 == null) |
1937 |
|
|| (s1 != null && s1.equals(s2)))) |
1938 |
|
{ |
1939 |
24 |
Console.outPrintln("[TESTOUTPUT] arg " + a.argString() + "='" + s1 |
1940 |
|
+ "' was set"); |
1941 |
|
} |
1942 |
|
} |
1943 |
|
|
1944 |
|
|
1945 |
|
|
1946 |
|
|
|
|
| 80% |
Uncovered Elements: 5 (25) |
Complexity: 7 |
Complexity Density: 0.54 |
|
1947 |
94 |
protected static void testoutput(ArgParser ap, Arg a)... |
1948 |
|
{ |
1949 |
94 |
if (ap == null) |
1950 |
0 |
return; |
1951 |
94 |
BootstrapArgs bsa = ap.getBootstrapArgs(); |
1952 |
94 |
if (bsa == null) |
1953 |
2 |
return; |
1954 |
92 |
if (!bsa.getBoolean(Arg.TESTOUTPUT)) |
1955 |
89 |
return; |
1956 |
3 |
boolean val = a.hasOption(Opt.BOOTSTRAP) ? bsa.getBoolean(a) |
1957 |
|
: ap.getBoolean(a); |
1958 |
3 |
boolean isset = a.hasOption(Opt.BOOTSTRAP) ? bsa.contains(a) |
1959 |
|
: ap.isSet(a); |
1960 |
3 |
if (!isset) |
1961 |
|
{ |
1962 |
0 |
Console.warn("Arg '" + a.getName() + "' not set at all"); |
1963 |
0 |
return; |
1964 |
|
} |
1965 |
3 |
testoutput(val, a); |
1966 |
|
} |
1967 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
1968 |
0 |
protected static void testoutput(BootstrapArgs bsa, Arg a)... |
1969 |
|
{ |
1970 |
0 |
if (!bsa.getBoolean(Arg.TESTOUTPUT)) |
1971 |
0 |
return; |
1972 |
0 |
if (!a.hasOption(Opt.BOOTSTRAP)) |
1973 |
|
{ |
1974 |
0 |
Console.warn("Non-bootstrap Arg '" + a.getName() |
1975 |
|
+ "' given to testoutput(BootstrapArgs bsa, Arg a) with only BootstrapArgs"); |
1976 |
|
|
1977 |
|
} |
1978 |
0 |
if (!bsa.contains(a)) |
1979 |
|
{ |
1980 |
0 |
Console.warn("Arg '" + a.getName() + "' not set at all"); |
1981 |
0 |
return; |
1982 |
|
} |
1983 |
0 |
testoutput(bsa.getBoolean(a), a); |
1984 |
|
} |
1985 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.83 |
|
1986 |
3 |
private static void testoutput(boolean yes, Arg a)... |
1987 |
|
{ |
1988 |
3 |
String message = null; |
1989 |
3 |
if (a.hasOption(Opt.BOOLEAN)) |
1990 |
|
{ |
1991 |
2 |
message = (yes ? a.argString() : a.negateArgString()) + " was set"; |
1992 |
|
} |
1993 |
1 |
else if (a.hasOption(Opt.UNARY)) |
1994 |
|
{ |
1995 |
1 |
message = a.argString() + (yes ? " was set" : " was not set"); |
1996 |
|
} |
1997 |
3 |
Console.outPrintln("[TESTOUTPUT] arg " + message); |
1998 |
|
} |
1999 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2000 |
533 |
public ArgParser getArgParser()... |
2001 |
|
{ |
2002 |
533 |
return argparser; |
2003 |
|
} |
2004 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2005 |
1104 |
public BootstrapArgs getBootstrapArgs()... |
2006 |
|
{ |
2007 |
1104 |
return bootstrapArgs; |
2008 |
|
} |
2009 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
2010 |
27 |
public static boolean isBatchMode()... |
2011 |
|
{ |
2012 |
27 |
return getInstance() != null && (getInstance().desktop == null |
2013 |
|
|| getInstance().desktop.isInBatchMode()); |
2014 |
|
} |
2015 |
|
|
2016 |
|
|
2017 |
|
|
2018 |
|
|
|
|
| 50% |
Uncovered Elements: 5 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
2019 |
75 |
private void mixedCliWarning()... |
2020 |
|
{ |
2021 |
75 |
Jalview j = Jalview.getInstance(); |
2022 |
75 |
boolean mixedStyle = j.getArgParser() != null |
2023 |
|
&& j.getArgParser().isMixedStyle(); |
2024 |
75 |
String title = MessageManager.getString("label.command_line_arguments"); |
2025 |
75 |
if (mixedStyle) |
2026 |
|
{ |
2027 |
0 |
String warning = MessageManager.formatMessage( |
2028 |
|
"warning.using_mixed_command_line_arguments", |
2029 |
|
j.getArgParser().getMixedExamples()); |
2030 |
0 |
String quit = MessageManager.getString("action.quit"); |
2031 |
|
|
2032 |
0 |
Desktop.instance.nonBlockingDialog(title, warning, null, quit, |
2033 |
|
JvOptionPane.WARNING_MESSAGE, false, false, true, 30000); |
2034 |
|
|
2035 |
0 |
Jalview.exit( |
2036 |
|
"Exiting due to mixed old and new command line arguments.", |
2037 |
|
ExitCode.MIXED_CLI_ARGUMENTS); |
2038 |
|
} |
2039 |
|
} |
2040 |
|
|
|
|
| 55.2% |
Uncovered Elements: 13 (29) |
Complexity: 7 |
Complexity Density: 0.37 |
|
2041 |
99 |
private void cliWarning()... |
2042 |
|
{ |
2043 |
99 |
Jalview j = Jalview.getInstance(); |
2044 |
99 |
Commands c = j.getCommands(); |
2045 |
99 |
boolean oldStyle = j.getArgParser() != null |
2046 |
|
&& j.getArgParser().isOldStyle(); |
2047 |
99 |
String title = MessageManager.getString("label.command_line_arguments"); |
2048 |
99 |
if (oldStyle) |
2049 |
|
{ |
2050 |
18 |
String warning = MessageManager |
2051 |
|
.getString("warning.using_old_command_line_arguments"); |
2052 |
18 |
String url = "<a href=\"https://www.jalview.org/help/html/features/commandline.html\">https://www.jalview.org/help/html/features/commandline.html</a>"; |
2053 |
18 |
if (Desktop.instance != null) |
2054 |
|
{ |
2055 |
1 |
String cont = MessageManager.getString("label.continue"); |
2056 |
|
|
2057 |
1 |
Desktop.instance.nonBlockingDialog(title, warning, url, cont, |
2058 |
|
JvOptionPane.WARNING_MESSAGE, false, true, true, 30000); |
2059 |
|
} |
2060 |
|
} |
2061 |
98 |
if (j.getCommands() != null && j.getCommands().getErrors().size() > 0) |
2062 |
|
{ |
2063 |
0 |
if (Desktop.instance != null) |
2064 |
|
{ |
2065 |
0 |
String message = MessageManager |
2066 |
|
.getString("warning.the_following_errors"); |
2067 |
0 |
String ok = MessageManager.getString("action.ok"); |
2068 |
0 |
int shortest = 60; |
2069 |
0 |
List<String> errors = j.getCommands().getErrors(); |
2070 |
0 |
for (int i = 0; i < errors.size(); i++) |
2071 |
|
{ |
2072 |
0 |
shortest = Math.min(shortest, errors.get(i).length()); |
2073 |
|
} |
2074 |
0 |
Desktop.instance.nonBlockingDialog( |
2075 |
|
Math.max(message.length(), Math.min(60, shortest)), |
2076 |
|
Math.min(errors.size(), 20), title, message, |
2077 |
|
j.getCommands().errorsToString(), ok, |
2078 |
|
JvOptionPane.WARNING_MESSAGE, true, false, true, -1); |
2079 |
|
} |
2080 |
|
} |
2081 |
|
} |
2082 |
|
|
2083 |
|
} |