1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.application;
27
28 import java.security.AccessController;
29 import java.security.PrivilegedAction;
30
31 /**
32 * Class that is extended to define an optional preloader for a
33 * JavaFX Application.
34 * An application may contain a preloader that is used
35 * to improve the application loading experience, especially for applications
36 * that are embedded in a browser or launched in webstart execution mode.
37 *
38 * <p>
39 * A preloader is a small application that is started
40 * before the main application to customize the startup experience.
41 * The preloader:
42 * </p>
43 * <ul>
44 * <li>gets notification of progress of loading application resources</li>
45 * <li>gets notification of errors</li>
46 * <li>gets notification of application initialization and startup</li>
47 * <li>decides when application should become visible</li>
48 * </ul>
49 *
50 * <p>
51 * The default preloader is shown on top of the application Stage, which is not
52 * visible until the preloader is visible. The preloader need to hide itself
53 * to make the application visible. Good practice is to do this no earlier than
54 * right before application.start() is called, as otherwise application itself
55 * is not visible.
56 * </p>
59 * The preloader may also cooperate with the application to achieve advanced
60 * visual effects or share data (e.g. to implement login screen).
61 * The preloader gets a reference to the application and may pull data it
62 * needs for cooperation from the application if the application implements
63 * an interface that the preloader knows about and relies upon. Generally it
64 * is not recommended to design preloaders in such a way that an application
65 * would call them directly, as this will result in bad user experience if
66 * the application is signed and the preloader is not.
67 * </p>
68 *
69 * <p>
70 * If the application does not specify a preloader, then the default preloader
71 * is used. Default preloader appearance can be customized
72 * (set of parameters is TBD).
73 * </p>
74 *
75 * <p>
76 * Custom preloader implementations should follow these rules:
77 * </p>
78 * <ol>
79 * <li>there should be class extending Preloader</li>
80 * <li>classes needed for preloader need to be packaged in the separate jar.
81 * We recommend this jar to be unsigned.</li>
82 * <li>JNLP deployment descriptor should have preloader-class attribute
83 * with full name of the class as value in the javafx-desc element
84 * and jars needed for progress need to have download="progress" type</li>
85 * </ol>
86 *
87 * <p>
88 * Applications may also send custom notification to the preloader using the
89 * {@link #notifyPreloader notifyPreloader} method. This way a preloader may
90 * also show application initialization progress.
91 * </p>
92 *
93 * <p>
94 * Note that preloaders are subject to the same rules as other JavaFX
95 * applications including FX threading rules. In particular, the class
96 * constructor and init() method will be called on a non-FX thread and start()
97 * will be executed on the FX application thread.
98 * This also means that the application constructor/init() will run concurrently
99 * with preloader start().
100 * </p>
101 *
102 * <p>
103 * Callbacks on preloader notification will be delivered on the FX
104 * application thread.
198 // * </p>
199 // *
200 // * @param info the UI notification
201 // */
202 // public void handleUINotification(UINotification info) {
203 // // TODO RT-19601: not used for now pending completion of JRE work
204 //// System.err.println("Preloader: handleUINotification = " + info);
205 // }
206
207 // ------------------------------------------------------------------------
208
209 /**
210 * Marker interface for all Preloader notification.
211 * @since JavaFX 2.0
212 */
213 public static interface PreloaderNotification {
214 }
215
216 /**
217 * Preloader notification that reports an error.
218 * This is delivered to preloader in case of problem with applet startup.
219 * @since JavaFX 2.0
220 */
221 public static class ErrorNotification implements PreloaderNotification {
222 private String location;
223 private String details = "";
224 private Throwable cause;
225
226 /**
227 * Constructs an error notification.
228 *
229 * @param location the URL associated with an error (if any); may be null
230 * @param details a string describing the error; must be non-null
231 * @param cause the cause of the error; may be null
232 */
233 public ErrorNotification(String location, String details, Throwable cause) {
234 if (details == null) throw new NullPointerException();
235
236 this.location = location;
237 this.details = details;
238 this.cause = cause;
|
1 /*
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.application;
27
28 import java.security.AccessController;
29 import java.security.PrivilegedAction;
30
31 /**
32 * Class that is extended to define an optional preloader for a
33 * JavaFX Application.
34 * An application may contain a preloader that is used
35 * to improve the application loading experience.
36 *
37 * <p>
38 * A preloader is a small application that is started
39 * before the main application to customize the startup experience.
40 * The preloader:
41 * </p>
42 * <ul>
43 * <li>gets notification of progress of loading application resources</li>
44 * <li>gets notification of errors</li>
45 * <li>gets notification of application initialization and startup</li>
46 * <li>decides when application should become visible</li>
47 * </ul>
48 *
49 * <p>
50 * The default preloader is shown on top of the application Stage, which is not
51 * visible until the preloader is visible. The preloader need to hide itself
52 * to make the application visible. Good practice is to do this no earlier than
53 * right before application.start() is called, as otherwise application itself
54 * is not visible.
55 * </p>
58 * The preloader may also cooperate with the application to achieve advanced
59 * visual effects or share data (e.g. to implement login screen).
60 * The preloader gets a reference to the application and may pull data it
61 * needs for cooperation from the application if the application implements
62 * an interface that the preloader knows about and relies upon. Generally it
63 * is not recommended to design preloaders in such a way that an application
64 * would call them directly, as this will result in bad user experience if
65 * the application is signed and the preloader is not.
66 * </p>
67 *
68 * <p>
69 * If the application does not specify a preloader, then the default preloader
70 * is used. Default preloader appearance can be customized
71 * (set of parameters is TBD).
72 * </p>
73 *
74 * <p>
75 * Custom preloader implementations should follow these rules:
76 * </p>
77 * <ol>
78 * <li>a custom preloader class should extend Preloader</li>
79 * <li>classes needed for preloader need to be packaged in the separate jar.</li>
80 * </ol>
81 *
82 * <p>
83 * Applications may also send custom notification to the preloader using the
84 * {@link #notifyPreloader notifyPreloader} method. This way a preloader may
85 * also show application initialization progress.
86 * </p>
87 *
88 * <p>
89 * Note that preloaders are subject to the same rules as other JavaFX
90 * applications including FX threading rules. In particular, the class
91 * constructor and init() method will be called on a non-FX thread and start()
92 * will be executed on the FX application thread.
93 * This also means that the application constructor/init() will run concurrently
94 * with preloader start().
95 * </p>
96 *
97 * <p>
98 * Callbacks on preloader notification will be delivered on the FX
99 * application thread.
193 // * </p>
194 // *
195 // * @param info the UI notification
196 // */
197 // public void handleUINotification(UINotification info) {
198 // // TODO RT-19601: not used for now pending completion of JRE work
199 //// System.err.println("Preloader: handleUINotification = " + info);
200 // }
201
202 // ------------------------------------------------------------------------
203
204 /**
205 * Marker interface for all Preloader notification.
206 * @since JavaFX 2.0
207 */
208 public static interface PreloaderNotification {
209 }
210
211 /**
212 * Preloader notification that reports an error.
213 * This is delivered to preloader in case of problem with application startup.
214 * @since JavaFX 2.0
215 */
216 public static class ErrorNotification implements PreloaderNotification {
217 private String location;
218 private String details = "";
219 private Throwable cause;
220
221 /**
222 * Constructs an error notification.
223 *
224 * @param location the URL associated with an error (if any); may be null
225 * @param details a string describing the error; must be non-null
226 * @param cause the cause of the error; may be null
227 */
228 public ErrorNotification(String location, String details, Throwable cause) {
229 if (details == null) throw new NullPointerException();
230
231 this.location = location;
232 this.details = details;
233 this.cause = cause;
|