bootstrap.js revision 953:221a84ef44c0
1107273Srwatson/*
2193391Srwatson * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3140879Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4172930Srwatson *
5107273Srwatson * This code is free software; you can redistribute it and/or modify it
6107273Srwatson * under the terms of the GNU General Public License version 2 only, as
7107273Srwatson * published by the Free Software Foundation.  Oracle designates this
8107273Srwatson * particular file as subject to the "Classpath" exception as provided
9107273Srwatson * by Oracle in the LICENSE file that accompanied this code.
10107273Srwatson *
11107273Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT
12107273Srwatson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13107273Srwatson * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14172930Srwatson * version 2 for more details (a copy is included in the LICENSE file that
15172930Srwatson * accompanied this code).
16172930Srwatson *
17107273Srwatson * You should have received a copy of the GNU General Public License version
18107273Srwatson * 2 along with this work; if not, write to the Free Software Foundation,
19107273Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20107273Srwatson *
21107273Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22107273Srwatson * or visit www.oracle.com if you need additional information or have any
23107273Srwatson * questions.
24107273Srwatson */
25107273Srwatson
26107273Srwatson// Check for fx presence.
27107273Srwatsonif (typeof javafx.application.Application != "function") {
28107273Srwatson    print("JavaFX is not available.");
29107273Srwatson    exit(1);
30107273Srwatson}
31107273Srwatson
32107273Srwatson// Extend the javafx.application.Application class overriding init, start and stop.
33107273Srwatsoncom.sun.javafx.application.LauncherImpl.launchApplication((Java.extend(javafx.application.Application, {
34107273Srwatson    // Overridden javafx.application.Application.init();
35107273Srwatson    init: function() {
36107273Srwatson        // Java FX packages and classes must be defined here because
37107273Srwatson        // they may not be viable until launch time due to clinit ordering.
38107273Srwatson    },
39107273Srwatson
40107273Srwatson    // Overridden javafx.application.Application.start(Stage stage);
41107273Srwatson    start: function(stage) {
42107273Srwatson        // Set up stage global.
43168951Srwatson        $STAGE = stage;
44107273Srwatson
45107273Srwatson        // Load user FX scripts.
46107273Srwatson        for each (var script in $SCRIPTS) {
47107273Srwatson            load(script);
48107273Srwatson        }
49107273Srwatson
50107273Srwatson        // Call the global init function if present.
51107273Srwatson        if ($GLOBAL.init) {
52107273Srwatson            init();
53107273Srwatson        }
54145076Scsjp
55107273Srwatson        // Call the global start function if present.  Otherwise show the stage.
56164033Srwatson        if ($GLOBAL.start) {
57107273Srwatson            start(stage);
58116701Srwatson        } else {
59107273Srwatson            stage.show();
60107273Srwatson        }
61107273Srwatson    },
62107273Srwatson
63107273Srwatson    // Overridden javafx.application.Application.stop();
64107273Srwatson    stop: function() {
65107273Srwatson        // Call the global stop function if present.
66107273Srwatson        if ($GLOBAL.stop) {
67150340Sphk            stop();
68107273Srwatson        }
69107273Srwatson    }
70107273Srwatson
71107273Srwatson    // No arguments passed to application (handled thru $ARG.)
72107273Srwatson})).class, new (Java.type("java.lang.String[]"))(0));
73107273Srwatson