base.js revision 953:221a84ef44c0
1193323Sed/*
2193323Sed * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3193323Sed * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4193323Sed *
5193323Sed * This code is free software; you can redistribute it and/or modify it
6193323Sed * under the terms of the GNU General Public License version 2 only, as
7193323Sed * published by the Free Software Foundation.  Oracle designates this
8193323Sed * particular file as subject to the "Classpath" exception as provided
9193323Sed * by Oracle in the LICENSE file that accompanied this code.
10252723Sdim *
11193323Sed * This code is distributed in the hope that it will be useful, but WITHOUT
12235633Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13263509Sdim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14252723Sdim * version 2 for more details (a copy is included in the LICENSE file that
15252723Sdim * accompanied this code).
16252723Sdim *
17193323Sed * You should have received a copy of the GNU General Public License version
18193323Sed * 2 along with this work; if not, write to the Free Software Foundation,
19193323Sed * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20193323Sed *
21193323Sed * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22193323Sed * or visit www.oracle.com if you need additional information or have any
23193323Sed * questions.
24235633Sdim */
25193323Sed
26193323Sedvar JFX_BASE_CLASSES     = [];
27193323Sedvar JFX_GRAPHICS_CLASSES = [];
28193323Sedvar JFX_CONTROLS_CLASSES = [];
29193323Sedvar JFX_FXML_CLASSES     = [];
30210299Sedvar JFX_WEB_CLASSES      = [];
31193323Sedvar JFX_MEDIA_CLASSES    = [];
32193323Sedvar JFX_SWING_CLASSES    = [];
33193323Sedvar JFX_SWT_CLASSES      = [];
34198090Srdivacky
35198090Srdivackyfunction LOAD_FX_CLASSES(clsList) {
36193323Sed    for each (var cls in clsList) {
37193323Sed        // Ex. Stage = Java.type("javafx.stage.Stage");
38193323Sed        this[cls[cls.length - 1]] = Java.type(cls.join("."));
39193323Sed    }
40193323Sed}
41210299Sed
42235633Sdim(function() {
43193323Sed    var System           = Java.type("java.lang.System");
44193323Sed    var ZipFile          = Java.type("java.util.zip.ZipFile");
45193323Sed
46193323Sed    var SUFFIX_LENGTH    = ".class".length;
47235633Sdim
48193323Sed    try {
49193323Sed        var jfxrtJar = new ZipFile(System.getProperty("java.home") + "/lib/ext/jfxrt.jar");
50193323Sed    } catch (ex) {
51235633Sdim        throw new Error("JavaFX runtime not found");
52235633Sdim    }
53235633Sdim
54235633Sdim    var entries = jfxrtJar.entries();
55235633Sdim
56193323Sed    while (entries.hasMoreElements()) {
57193323Sed        var entry = entries.nextElement();
58193323Sed
59193323Sed        if (entry.isDirectory()) {
60193323Sed            continue;
61210299Sed        }
62193323Sed
63193323Sed        var name = entry.name;
64193323Sed
65193323Sed        if (!name.endsWith(".class")) {
66193323Sed            continue;
67193323Sed        }
68193323Sed
69193323Sed        name = name.substring(0, name.length - SUFFIX_LENGTH);
70193323Sed        cls = name.split("/");
71193323Sed
72193323Sed        if (cls[0] != "javafx") {
73193323Sed            continue;
74193323Sed        }
75235633Sdim
76235633Sdim        var last = cls[cls.length - 1];
77235633Sdim        var nested = last.lastIndexOf("$");
78193323Sed
79193323Sed        // If class name ends with $nnn
80193323Sed        if (nested != -1 && !(last.substring(nested) - 0)) {
81193323Sed            continue;
82193323Sed        }
83193323Sed
84252723Sdim        switch (cls[1]) {
85252723Sdim        case "stage":
86252723Sdim            if (cls[2] == "Stage") {
87252723Sdim                JFX_BASE_CLASSES.push(cls);
88252723Sdim            } else {
89252723Sdim                JFX_GRAPHICS_CLASSES.push(cls);
90252723Sdim            }
91252723Sdim            break;
92252723Sdim
93252723Sdim        case "scene":
94252723Sdim            switch (cls[2]) {
95252723Sdim            case "Scene":
96252723Sdim            case "Group":
97252723Sdim                JFX_BASE_CLASSES.push(cls);
98193323Sed                break;
99193323Sed
100235633Sdim            case "chart":
101235633Sdim            case "control":
102235633Sdim                JFX_CONTROLS_CLASSES.push(cls);
103193323Sed                break;
104193323Sed
105193323Sed            case "web":
106193323Sed                JFX_WEB_CLASSES.push(cls);
107235633Sdim                break;
108235633Sdim
109235633Sdim            case "media":
110235633Sdim                JFX_MEDIA_CLASSES.push(cls);
111193323Sed                break;
112210299Sed
113210299Sed            default:
114193323Sed                JFX_GRAPHICS_CLASSES.push(cls);
115193323Sed                break;
116193323Sed            }
117193323Sed            break;
118193323Sed
119198090Srdivacky        case "beans":
120198090Srdivacky        case "collections":
121193323Sed        case "events":
122193323Sed        case "util":
123193323Sed            JFX_BASE_CLASSES.push(cls);
124193323Sed            break;
125193323Sed
126210299Sed        case "animation":
127235633Sdim        case "application":
128193323Sed        case "concurrent":
129193323Sed        case "css":
130210299Sed        case "geometry":
131218893Sdim            JFX_GRAPHICS_CLASSES.push(cls);
132193323Sed            break;
133210299Sed
134193323Sed        case "fxml":
135193323Sed            JFX_FXML_CLASSES.push(cls);
136210299Sed            break;
137235633Sdim
138252723Sdim        case "embed":
139252723Sdim            if (cls[2] == "swing") {
140252723Sdim                JFX_SWING_CLASSES.push(cls);
141252723Sdim            } else {
142252723Sdim                JFX_SWT_CLASSES.push(cls);
143252723Sdim            }
144193323Sed            break;
145210299Sed        }
146235633Sdim    }
147193323Sed})();
148193323Sed
149193323SedLOAD_FX_CLASSES(JFX_BASE_CLASSES);
150