{
}
- static
- {
- Platform.getURLCommandArguments();
- }
-
private boolean headless;
private Desktop desktop;
public String appletResourcePath;
- JalviewJSApp app; // JalviewJS-specific JavaScript interface
-
+ public String j2sAppletID;
+
private boolean noCalculation, noMenuBar, noStatus;
private boolean noAnnotation;
static
{
- if (!Platform.isJS())
- /**
- * Java only
- *
- * @j2sIgnore
- */
+ if (Platform.isJS()) {
+ Platform.getURLCommandArguments();
+ } else /** @j2sIgnore */
{
// grab all the rights we can for the JVM
Policy.setPolicy(new Policy()
if (isJS)
{
- app = new JalviewJSApp(aparser);
- Preferences.setAppletDefaults();
- Cache.loadProperties(usrPropsFile); // again, because we
- // might be changing defaults here?
- appletResourcePath = (String) aparser.getAppletValue("resourcepath", null, true);
+ j2sAppletID = Platform.getAppID(null);
+ Preferences.setAppletDefaults();
+ Cache.loadProperties(usrPropsFile); // again, because we
+ // might be changing defaults here?
+ appletResourcePath = (String) aparser.getAppletValue("resourcepath",
+ null, true);
}
else
/**
* configure 'full' SO model if preferences say to, else use the default (full SO)
* - as JS currently doesn't have OBO parsing, it must use 'Lite' version
*/
- boolean soDefault = !Platform.isJS();
+ boolean soDefault = !isJS;
if (Cache.getDefault("USE_FULL_SO", soDefault))
{
SequenceOntologyFactory.setSequenceOntology(new SequenceOntology());
}
desktop.setVisible(true);
- if (!Platform.isJS())
+ if (!isJS)
/**
* Java only
*
BioJsHTMLOutput.updateBioJS();
}
}
-
parseArguments(aparser, true);
-
}
/**
+ * Parse all command-line String[] arguments as well as all JavaScript-derived parameters from Info.
+ *
+ * We allow for this method to be run from JavaScript. Basically allowing simple scripting.
*
* @param aparser
* @param isStartup
String file = aparser.getValue("open", true);
- if (file == null && desktop == null)
+ if (!isJS && file == null && desktop == null)
{
System.out.println("No files to open!");
System.exit(1);
}
+ // time to open a file.
+
long progress = -1;
DataSourceType protocol = null;
FileLoader fileLoader = new FileLoader(!headless);
FileFormatI format = null;
// Finally, deal with the remaining input data.
+ JalviewJSApp jsApp = null;
+ AlignFrame af = null;
+
if (file != null)
{
if (!headless)
}
}
}
- String fileFormat = (isJS ? (String) aparser.getAppletValue("format", null, true)
+ String fileFormat = (isJS
+ ? (String) aparser.getAppletValue("format", null, true)
: null);
protocol = AppletFormatAdapter.checkProtocol(file);
try
System.out.println("CMD [nocalculation] executed successfully!");
}
- AlignFrame af = new FileLoader(!headless).LoadFileWaitTillLoaded(file,
- protocol, format);
+ af = new FileLoader(!headless).LoadFileWaitTillLoaded(file, protocol,
+ format);
if (af == null)
{
System.out.println("error");
// TODO - load PDB structure(s) to alignment JAL-629
// (associate with identical sequence in alignment, or a specified
// sequence)
-
+
if (isJS)
{
- app.load(af);
+ jsApp = new JalviewJSApp(aparser);
+ jsApp.load(af);
}
else
/**
}
}
}
-
- AlignFrame startUpAlframe = null;
- // We'll only open the default file if the desktop is visible.
- // And the user
- // ////////////////////
-
- if (!isJS && !headless && file == null
- && Cache.getDefault("SHOW_STARTUP_FILE", true))
- /**
- * Java only
- *
- * @j2sIgnore
- */
+ else
{
- file = Cache.getDefault("STARTUP_FILE",
- Cache.getDefault("www.jalview.org", "http://www.jalview.org")
- + "/examples/exampleFile_2_7.jar");
- if (file.equals(
- "http://www.jalview.org/examples/exampleFile_2_3.jar"))
+ if (!isJS && !headless && Cache.getDefault("SHOW_STARTUP_FILE", true))
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
{
- // hardwire upgrade of the startup file
- file.replace("_2_3.jar", "_2_7.jar");
- // and remove the stale setting
- Cache.removeProperty("STARTUP_FILE");
- }
- protocol = DataSourceType.FILE;
+ // We'll only open the default file if the desktop is visible.
+ // And the user
+ // ////////////////////
- if (file.indexOf("http:") > -1)
- {
- protocol = DataSourceType.URL;
- }
+ file = Cache.getDefault("STARTUP_FILE",
+ Cache.getDefault("www.jalview.org",
+ "http://www.jalview.org")
+ + "/examples/exampleFile_2_7.jar");
+ if (file.equals(
+ "http://www.jalview.org/examples/exampleFile_2_3.jar"))
+ {
+ // hardwire upgrade of the startup file
+ file.replace("_2_3.jar", "_2_7.jar");
+ // and remove the stale setting
+ Cache.removeProperty("STARTUP_FILE");
+ }
- if (file.endsWith(".jar"))
- {
- format = FileFormat.Jalview;
- }
- else
- {
- try
+ protocol = DataSourceType.FILE;
+
+ if (file.indexOf("http:") > -1)
{
- format = new IdentifyFile().identify(file, protocol);
- } catch (FileFormatException e)
+ protocol = DataSourceType.URL;
+ }
+
+ if (file.endsWith(".jar"))
{
- // TODO what?
+ format = FileFormat.Jalview;
+ }
+ else
+ {
+ try
+ {
+ format = new IdentifyFile().identify(file, protocol);
+ } catch (FileFormatException e)
+ {
+ // TODO what?
+ }
}
- }
- startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
- format);
+ af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format);
+ }
}
-
// extract groovy arguments before anything else.
// Once all other stuff is done, execute any groovy scripts (in order)
- if (groovyscript != null)
+ if (!isJS && groovyscript != null)
{
if (Cache.groovyJarsPresent())
{
System.out.println("Executing script " + groovyscript);
- executeGroovyScript(groovyscript, startUpAlframe);
+ executeGroovyScript(groovyscript, af);
}
else
{
if (isJS && isStartup)
{
- app.callInitCallback();
+ jsApp.callInitCallback();
}
}
"Creating image map: " + imageFile.getAbsolutePath());
continue;
}
- if (!Platform.isJS())
+ if (!Platform.isJS()) /** @j2sIgnore */
{
// skipping outputFormat?
System.out.println("Unknown arg: " + outputFormat);
+ " format!!");
}
}
- while (aparser.getSize() > 0)
- {
- System.out.println("Unknown arg: " + aparser.nextValue());
- }
break;
}
-
+ while (aparser.getSize() > 0)
+ {
+ System.out.println("Unknown arg: " + aparser.nextValue());
+ }
}
private static void showUsage()
}
- /**
- * Get the SwingJS applet ID and combine that with the frameType
- *
- * @param frameType
- * "alignment", "desktop", etc., or null
- * @return
- */
- public static String getAppID(String frameType)
- {
- return (Platform.isJS() ? getInstance().app.getAppID(frameType) : null);
- }
-
- public String doSendCallback(Object callback, Object[] data) {
- return (Platform.isJS() ? app.doSendCallback(callback, data) : null);
- }
-
public void notifyWorker(AlignCalcWorkerI worker, String status)
{
// System.out.println("Jalview worker " + worker.getClass().getSimpleName()
// + " " + status);
}
-
- public Object arrayToSeparatorList(String[] seqs)
- {
- return (Platform.isJS() ? app.arrayToSeparatorList(seqs) : null);
- }
-
}