-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
package org.xwt;
import java.net.*;
public static java.net.InetAddress originAddr = null;
public static String originHost = null;
public static String origin = null;
+ public static String initialTemplate = null;
- public static final Res builtin = new Res.Zip(new Res.Builtin());
+ public static final Stream builtin = new Stream.Zip(new Stream.Builtin());
public static Picture scarImage = null;
public static void printUsage() {
System.err.println("Usage: xwt [-s] [-v] [-l <port>/<url>] source-location [initial-template]");
System.err.println("");
System.err.println("Options:");
- // FEATURE: reintroduce
- //System.err.println(" -s show rendering activity with red rectangles");
System.err.println(" -v verbose logging");
- // FEATURE: reintroduce
- //System.err.println(" -l serve logs via HTTP on 127.0.0.1:<port>/<url>");
+ System.err.println(" -s [not yet supported]");
+ System.err.println(" -l [not yet supported]");
System.err.println("");
System.err.println("Source-location is one of the following:");
System.err.println(" - the path to an xwar file");
System.err.println(" - the path to a directory to be used as an xwar");
System.err.println(" - the http url of an xwar");
System.err.println("");
- System.err.println("Initial-template is the resource name of the template to load; defaults to 'main'");
+ System.err.println("Initial-template is the path of the template to load; defaults to 'main'");
Runtime.getRuntime().exit(-1);
}
- /** common entry point */
public static void main(String[] args) throws Exception {
int startargs = 0;
while (true) {
if (startargs > args.length - 1) printUsage();
else if (args[startargs].equals("-v")) Log.verbose = true;
- else if (args[startargs].equals("-l")) startargs++;
else break;
startargs++;
}
Platform.forceLoad();
- if (Log.on) for(int i=0; i<args.length; i++) Log.log(Main.class, "argument " + i + ": " + args[i]);
+ if (Log.on) for(int i=0; i<args.length; i++) Log.info(Main.class, "argument " + i + ": " + args[i]);
- String initialTemplateName = args.length > startargs + 1 ? args[startargs + 1] : "main";
- initialTemplateName = initialTemplateName.replace('/', '.');
+ initialTemplate = args.length > startargs + 1 ? args[startargs + 1] : "main";
origin = args[startargs];
- Res rr;
- final String initialTemplate;
-
+ Stream rr;
+ final String startupTemplate;
if (origin.startsWith("http://") || origin.startsWith("https://")) {
originHost = origin.substring(origin.indexOf('/') + 2);
originHost = originHost.substring(0, originHost.indexOf('/') == -1 ? originHost.length() : originHost.indexOf('/'));
if (originHost.indexOf('@') != -1) originHost = originHost.substring(originHost.indexOf('@') + 1);
originAddr = InetAddress.getByName(originHost);
rr = builtin;
- initialTemplate = "org/xwt/builtin/splash.xwt";
+ startupTemplate = "org.xwt.builtin.splash";
} else {
- // HACK because MSIE turns \'s into /'s in file URLs... argh!!
- if (Platform.platform.getClass().getName().endsWith("Win32")) origin = origin.replace('/', '\\');
- final String final_origin = origin;
- rr = new Res.File(origin);
- if (!new File(origin).isDirectory()) rr = new Res.Zip(rr);
- initialTemplate = initialTemplateName;
+ rr = new Stream.File(origin);
+ if (!new File(origin).isDirectory()) rr = new Stream.Zip(rr);
+ startupTemplate = initialTemplate;
}
- if (Log.on) Log.log(Main.class, "loading xwar");
+ if (Log.on) Log.info(Main.class, "loading xwar");
final XWT xwt = new XWT(rr);
- final Res final_rr = rr;
+ final JS final_rr = (JS)xwt.get("");
- Picture.fromRes((Res)Main.builtin.get("org/xwt/builtin/scar.png"), new Callback() {
- public Object call(Object arg) {
- scarImage = (Picture)arg;
- Scheduler.add(new Scheduler.Task() { public void perform() {
- Template.getTemplate(((Res)final_rr.get(initialTemplate))).apply(new Box(), null, xwt);
- } });
- return null;
- } });
+ scarImage =
+ Picture.load((Stream)Main.builtin.get("org/xwt/builtin/scar.png"),
+ new Scheduler.Task() { public void perform() throws Exception {
+ xwt.resolveString(startupTemplate, false).call(new Box(), null, null, null, 1);
+ } });
- new Thread() { public void run() { Scheduler.init(); } }.start();
- Platform.running();
+ Scheduler.init();
}
-
}