public static java.net.InetAddress originAddr = null;
public static String originHost = null;
public static String origin = null;
-
- public static Res builtin = null;
+
+ public static final Res builtin = new Res.Zip(new Res.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("");
System.err.println("Source-location is one of the following:");
System.err.println(" - the path to an xwar file");
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]);
- Res zip = new Res() { public InputStream getInputStream(String path) { return Platform.getBuiltinInputStream(); } };
- builtin = new Res.Zip(zip);
-
String initialTemplateName = args.length > startargs + 1 ? args[startargs + 1] : "main";
- initialTemplateName = initialTemplateName.replace('/', '.');
+ initialTemplateName = initialTemplateName.replace('.', '/');
origin = args[startargs];
Res rr;
rr = builtin;
initialTemplate = "org/xwt/builtin/splash.xwt";
} 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;
final XWT xwt = new XWT(rr);
final Res final_rr = rr;
- new Thread(new Runnable() {
- public void run() {
- Message.Q.startQ();
- ThreadMessage.newthread(new JS.Callable() {
- public Object call(JS.Array args) {
- Template.getTemplate(((Res)final_rr.get(initialTemplate))).apply(new Box(), null, xwt);
- return null;
- }
- });
- }
- }).start();
-
- Platform.running();
- }
+ scarImage =
+ Picture.load((Res)Main.builtin.get("org/xwt/builtin/scar.png"),
+ new Scheduler.Task() { public void perform() throws JSExn {
+ Template.getTemplate(((Res)final_rr.get(initialTemplate))).apply(new Box(), xwt);
+ } });
+ Scheduler.init();
+ }
}