/hg/icedtea-web: Splashscreen integrated to javaws and plugin
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Fri Nov 2 04:16:47 PDT 2012
changeset b76eaadf30cc in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=b76eaadf30cc
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Nov 02 12:22:09 2012 +0100
Splashscreen integrated to javaws and plugin
diffstat:
ChangeLog | 37 ++
Makefile.am | 2 +
NEWS | 1 +
launcher/javaws.in | 12 +
netx/javaws_splash.png | Bin
netx/net/sourceforge/jnlp/GuiLaunchHandler.java | 63 ++-
netx/net/sourceforge/jnlp/JNLPSplashScreen.java | 109 +++--
netx/net/sourceforge/jnlp/Launcher.java | 75 +++-
netx/net/sourceforge/jnlp/NetxPanel.java | 36 +-
plugin/icedteanp/java/sun/applet/PluginAppletViewer.java | 181 +++++++++-
tests/reproducers/simple/CountingApplet1/resources/ParallelAppletsTest_1_x_2.html | 2 +-
tests/reproducers/simple/simpletest1/resources/netxPlugin.png | Bin
12 files changed, 417 insertions(+), 101 deletions(-)
diffs (truncated from 981 to 500 lines):
diff -r 34a7d51b30f5 -r b76eaadf30cc ChangeLog
--- a/ChangeLog Wed Oct 31 17:07:58 2012 +0100
+++ b/ChangeLog Fri Nov 02 12:22:09 2012 +0100
@@ -1,3 +1,40 @@
+2012-11-02 Jiri Vanek <jvanek at redhat.com>
+
+ Splashscreen integrated to javaws and plugin
+ * Makefile.am: (edit_launcher_script) added JAVAWS_SPLASH_LOCATION
+ substitution for installed javaws_splash.png.
+ (install-exec-loca) added installation of javaws_splash.png.
+ * NEWS: mentioned splashscreen
+ * launcher/javaws.in: added SPLASH_LOCATION, as path to image with "java"
+ splash which s then shown until internal vector one appear.
+ * netx/net/sourceforge/jnlp/GuiLaunchHandler.java: splashScreen made volatile,
+ (launchInitialized) splashscreen is created and shown
+ * netx/net/sourceforge/jnlp/JNLPSplashScreen.java: (setSplashImageURL)
+ splash bg image is loaded from given url or default is used if not found
+ or not specified by jnlp/applet. (correctSize) width is calculated from
+ bg image or default is used when no image set. Splash is centered to
+ primary monitor.
+ * netx/net/sourceforge/jnlp/Launcher.java: (launchApplet) and
+ (launchApplication) enriched by handling of splashs.
+ (launchError) overloaded and is now handling forwarding of errors to
+ splash. All relevant calls of launchError enriched by appletInstance.
+ * netx/net/sourceforge/jnlp/NetxPanel.java: is now implementing
+ SplashController.This is done by setting and wrapping of splashController
+ variable.
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: is now handling
+ splashscreen for applets in browsers.
+ (framePanel) is now providing panel to be processed (PluginAppletViewer)
+ is now invoking SplashCreator. (replaceSplash) new method which replace
+ splashscreen with error splashscreen. (removeSplash) new method to remove
+ splash when loading is done. (update) is added to call paint directly
+ (SplashCreator) new internal runnable to create splash
+ * tests/reproducers/simple/CountingApplet1/resources/ParallelAppletsTest_1_x_2.html:
+ second jar made XslowX to track two FIXME introduced in this patch -
+ Launcher's createApplet and PluginAppletViewer's framePanel.
+ * netx/javaws_splash.png: Binary image to be shown before java is launched
+ * tests/reproducers/simple/simpletest1/resources/netxPlugin.png: Binary image
+ to ne used for testing custom splashscreens
+
2012-10-31 Jana Fabrikova <jfabriko at redhat.com>
*tests/reproducers/simple/JSToJGet/testcases/JSToJGetTest.java:
diff -r 34a7d51b30f5 -r b76eaadf30cc Makefile.am
--- a/Makefile.am Wed Oct 31 17:07:58 2012 +0100
+++ b/Makefile.am Fri Nov 02 12:22:09 2012 +0100
@@ -178,6 +178,7 @@
edit_launcher_script = sed \
-e 's|[@]LAUNCHER_BOOTCLASSPATH[@]|$(LAUNCHER_BOOTCLASSPATH)|g' \
-e 's|[@]JAVAWS_BIN_LOCATION[@]|$(bindir)/$(javaws)|g' \
+ -e 's|[@]JAVAWS_SPLASH_LOCATION[@]|$(datadir)/$(PACKAGE_NAME)/javaws_splash.png|g' \
-e 's|[@]ITWEB_SETTINGS_BIN_LOCATION[@]|$(bindir)/$(itweb_settings)|g' \
-e 's|[@]JAVA[@]|$(JAVA)|g' \
-e 's|[@]JRE[@]|$(SYSTEM_JRE_DIR)|g'
@@ -208,6 +209,7 @@
${INSTALL_DATA} $(abs_top_builddir)/liveconnect/lib/classes.jar $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/plugin.jar
endif
${INSTALL_DATA} $(NETX_DIR)/lib/classes.jar $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/netx.jar
+ ${INSTALL_DATA} $(NETX_SRCDIR)/javaws_splash.png $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/javaws_splash.png
${INSTALL_PROGRAM} launcher.build/$(javaws) $(DESTDIR)$(bindir)
${INSTALL_DATA} extra-lib/about.jar $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/about.jar
${INSTALL_PROGRAM} launcher.build/$(itweb_settings) $(DESTDIR)$(bindir)
diff -r 34a7d51b30f5 -r b76eaadf30cc NEWS
--- a/NEWS Wed Oct 31 17:07:58 2012 +0100
+++ b/NEWS Fri Nov 02 12:22:09 2012 +0100
@@ -9,6 +9,7 @@
CVE-XXXX-YYYY: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=XXXX-YYYY
New in release 1.4 (2012-XX-XX):
+* Splash screen for javaws and plugin
* Security updates
- CVE-2012-3422, RH840592: Potential read from an uninitialized memory location
- CVE-2012-3423, RH841345: Incorrect handling of not 0-terminated strings
diff -r 34a7d51b30f5 -r b76eaadf30cc launcher/javaws.in
--- a/launcher/javaws.in Wed Oct 31 17:07:58 2012 +0100
+++ b/launcher/javaws.in Fri Nov 02 12:22:09 2012 +0100
@@ -5,6 +5,7 @@
LAUNCHER_FLAGS=-Xms8m
CLASSNAME=net.sourceforge.jnlp.runtime.Boot
BINARY_LOCATION=@JAVAWS_BIN_LOCATION@
+SPLASH_LOCATION=@JAVAWS_SPLASH_LOCATION@
PROGRAM_NAME=javaws
CP=@JRE@/lib/rt.jar
@@ -15,6 +16,10 @@
i=0
j=0
+SPLASH="false"
+if [ "x$ICEDTEA_WEB_SPLASH" = "x" ] ; then
+SPLASH="true"
+fi;
while [ "$#" -gt "0" ]; do
case "$1" in
-J*)
@@ -24,6 +29,9 @@
*)
ARGS[$j]="$1"
j=$((j+1))
+ if [ "$1" = "-headless" ] ; then
+ SPLASH="false"
+ fi
;;
esac
shift
@@ -32,6 +40,10 @@
k=0
COMMAND[k]="${JAVA}"
k=$((k+1))
+if [ "$SPLASH" = "true" ] ; then
+COMMAND[k]="-splash:${SPLASH_LOCATION}"
+k=$((k+1))
+fi;
COMMAND[k]="${LAUNCHER_BOOTCLASSPATH}"
k=$((k+1))
COMMAND[k]="${LAUNCHER_FLAGS}"
diff -r 34a7d51b30f5 -r b76eaadf30cc netx/javaws_splash.png
Binary file netx/javaws_splash.png has changed
diff -r 34a7d51b30f5 -r b76eaadf30cc netx/net/sourceforge/jnlp/GuiLaunchHandler.java
--- a/netx/net/sourceforge/jnlp/GuiLaunchHandler.java Wed Oct 31 17:07:58 2012 +0100
+++ b/netx/net/sourceforge/jnlp/GuiLaunchHandler.java Fri Nov 02 12:22:09 2012 +0100
@@ -1,5 +1,5 @@
/* GuiLaunchHandler.java
- Copyright (C) 2011 Red Hat, Inc.
+ Copyright (C) 2012 Red Hat, Inc.
This file is part of IcedTea.
@@ -54,7 +54,7 @@
*/
public class GuiLaunchHandler extends AbstractLaunchHandler {
- private JNLPSplashScreen splashScreen = null;
+ private volatile JNLPSplashScreen splashScreen = null;
private final Object mutex = new Object();
private UpdatePolicy policy = UpdatePolicy.ALWAYS;
@@ -80,10 +80,11 @@
}
private void closeSplashScreen() {
- synchronized(mutex) {
+ synchronized (mutex) {
if (splashScreen != null) {
if (splashScreen.isSplashScreenValid()) {
splashScreen.setVisible(false);
+ splashScreen.stopAnimation();
}
splashScreen.dispose();
}
@@ -102,40 +103,56 @@
@Override
public void launchInitialized(final JNLPFile file) {
-
+
int preferredWidth = 500;
int preferredHeight = 400;
final URL splashImageURL = file.getInformation().getIconLocation(
IconDesc.SPLASH, preferredWidth, preferredHeight);
+ final ResourceTracker resourceTracker = new ResourceTracker(true);
if (splashImageURL != null) {
- final ResourceTracker resourceTracker = new ResourceTracker(true);
resourceTracker.addResource(splashImageURL, file.getFileVersion(), null, policy);
- synchronized(mutex) {
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- splashScreen = new JNLPSplashScreen(resourceTracker, file);
- }
- });
- } catch (InterruptedException ie) {
- // Wait till splash screen is created
- while (splashScreen == null);
- } catch (InvocationTargetException ite) {
- ite.printStackTrace();
- }
+ }
+ synchronized (mutex) {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
- splashScreen.setSplashImageURL(splashImageURL);
+ @Override
+ public void run() {
+ splashScreen = new JNLPSplashScreen(resourceTracker, file);
+ }
+ });
+ } catch (InterruptedException ie) {
+ // Wait till splash screen is created
+ while (splashScreen == null);
+ } catch (InvocationTargetException ite) {
+ ite.printStackTrace();
}
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ splashScreen.setSplashImageURL(splashImageURL);
+ }
+ });
+ } catch (InterruptedException ie) {
+ // Wait till splash screen is created
+ while (!splashScreen.isSplashImageLoaded());
+ } catch (InvocationTargetException ite) {
+ ite.printStackTrace();
+ }
+
+
}
-
+
SwingUtilities.invokeLater(new Runnable() {
+
@Override
public void run() {
- if (splashImageURL != null) {
- synchronized(mutex) {
+ if (splashScreen != null) {
+ synchronized (mutex) {
if (splashScreen.isSplashScreenValid()) {
splashScreen.setVisible(true);
}
diff -r 34a7d51b30f5 -r b76eaadf30cc netx/net/sourceforge/jnlp/JNLPSplashScreen.java
--- a/netx/net/sourceforge/jnlp/JNLPSplashScreen.java Wed Oct 31 17:07:58 2012 +0100
+++ b/netx/net/sourceforge/jnlp/JNLPSplashScreen.java Fri Nov 02 12:22:09 2012 +0100
@@ -43,19 +43,16 @@
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
-import java.awt.Toolkit;
import java.io.IOException;
import java.net.URL;
-
import javax.imageio.ImageIO;
import javax.swing.JDialog;
-
import net.sourceforge.jnlp.cache.ResourceTracker;
import net.sourceforge.jnlp.runtime.JNLPRuntime;
-import net.sourceforge.jnlp.util.ImageResources;
import net.sourceforge.jnlp.splashscreen.SplashPanel;
import net.sourceforge.jnlp.splashscreen.SplashUtils;
import net.sourceforge.jnlp.splashscreen.parts.InformationElement;
+import net.sourceforge.jnlp.util.ImageResources;
public class JNLPSplashScreen extends JDialog {
@@ -68,6 +65,7 @@
public static final int DEF_WIDTH=635;
public static final int DEF_HEIGHT=480;
private SplashPanel componetSplash;
+ private boolean splashImageLoaded=false;
public JNLPSplashScreen(ResourceTracker resourceTracker, final JNLPFile file) {
@@ -78,61 +76,86 @@
// JNLP file.
this.resourceTracker = resourceTracker;
-
- this.file=file;
+ this.file=file;
}
public void setSplashImageURL(URL url) {
- splashImageUrl = url;
- splashImage = null;
+ splashImageLoaded = false;
try {
- splashImage = ImageIO.read(resourceTracker
- .getCacheFile(splashImageUrl));
+ if (url != null) {
+ splashImageUrl = url;
+ splashImage = null;
+ try {
+ splashImage = ImageIO.read(resourceTracker.getCacheFile(splashImageUrl));
+ if (splashImage == null) {
+ if (JNLPRuntime.isDebug()) {
+ System.err.println("Error loading splash image: " + url);
+ }
+ }
+ } catch (IOException e) {
+ if (JNLPRuntime.isDebug()) {
+ System.err.println("Error loading splash image: " + url);
+ }
+ splashImage = null;
+ } catch (IllegalArgumentException argumentException) {
+ if (JNLPRuntime.isDebug()) {
+ System.err.println("Error loading splash image: " + url);
+ }
+ splashImage = null;
+ }
+ }
+
if (splashImage == null) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Error loading splash image: " + url);
+ this.setLayout(new BorderLayout());
+ SplashPanel splash = SplashUtils.getSplashScreen(DEF_WIDTH, DEF_HEIGHT);
+ if (splash != null) {
+ splash.startAnimation();
+ splash.setInformationElement(InformationElement.createFromJNLP(file));
+ this.add(splash.getSplashComponent());
+ this.componetSplash = splash;
}
- return;
}
- } catch (IOException e) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Error loading splash image: " + url);
- }
- splashImage = null;
- return;
- } catch (IllegalArgumentException argumentException) {
- if (JNLPRuntime.isDebug()) {
- System.err.println("Error loading splash image: " + url);
- }
- splashImage = null;
- return;
+ correctSize();
+ } finally {
+ splashImageLoaded = true;
}
-
- correctSize();
}
+ public boolean isSplashImageLoaded() {
+ return splashImageLoaded;
+ }
+
+
public boolean isSplashScreenValid() {
- return (splashImage != null);
+ return (splashImage != null) || (componetSplash != null);
}
private void correctSize() {
-
- Insets insets = getInsets();
- int minimumWidth = splashImage.getWidth(null) + insets.left
- + insets.right;
- int minimumHeight = splashImage.getHeight(null) + insets.top
- + insets.bottom;
- setMinimumSize(new Dimension(minimumWidth, minimumHeight));
-
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- setLocation((screenSize.width - minimumWidth) / 2,
- (screenSize.height - minimumHeight) / 2);
+ int minimumWidth = DEF_WIDTH;
+ int minimumHeight = DEF_HEIGHT;
+ if (splashImage != null) {
+ Insets insets = getInsets();
+ minimumWidth = splashImage.getWidth(null) + insets.left
+ + insets.right;
+ minimumHeight = splashImage.getHeight(null) + insets.top
+ + insets.bottom;
+ }
+ setMinimumSize(new Dimension(0, 0));
+ setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
+ setSize(new Dimension(minimumWidth, minimumHeight));
+ setPreferredSize(new Dimension(minimumWidth, minimumHeight));
+ // Centering to middle of Toolkit.getDefaultToolkit().getScreenSize()
+ // centers to the middle of all monitors. Let's center to the middle
+ // of the primary monitor instead.
+ // TODO center on the 'current' monitor to meet user expectation
+ setLocationRelativeTo(null);
}
@Override
public void paint(Graphics g) {
if (splashImage == null) {
+ super.paint(g);
return;
}
@@ -141,4 +164,12 @@
g2.drawImage(splashImage, getInsets().left, getInsets().top, null);
}
+
+ public boolean isCustomSplashscreen() {
+ return (componetSplash!=null);
+ }
+
+ public void stopAnimation() {
+ if (isCustomSplashscreen()) componetSplash.stopAnimation();
+ }
}
diff -r 34a7d51b30f5 -r b76eaadf30cc netx/net/sourceforge/jnlp/Launcher.java
--- a/netx/net/sourceforge/jnlp/Launcher.java Wed Oct 31 17:07:58 2012 +0100
+++ b/netx/net/sourceforge/jnlp/Launcher.java Fri Nov 02 12:22:09 2012 +0100
@@ -20,6 +20,7 @@
import java.applet.Applet;
import java.awt.Container;
+import java.awt.SplashScreen;
import java.io.File;
import java.lang.reflect.Method;
import java.net.InetAddress;
@@ -42,6 +43,8 @@
import javax.swing.SwingUtilities;
import javax.swing.text.html.parser.ParserDelegator;
+import net.sourceforge.jnlp.runtime.AppletEnvironment;
+import net.sourceforge.jnlp.splashscreen.SplashUtils;
import sun.awt.SunToolkit;
@@ -543,6 +546,12 @@
}
if (JNLPRuntime.getForksAllowed() && file.needsNewVM()) {
+ if (!JNLPRuntime.isHeadless()){
+ SplashScreen sp = SplashScreen.getSplashScreen();
+ if (sp!=null) {
+ sp.close();
+ }
+ }
List<String> netxArguments = new LinkedList<String>();
netxArguments.add("-Xnofork");
netxArguments.addAll(JNLPRuntime.getInitialArguments());
@@ -652,25 +661,42 @@
* @param enableCodeBase whether to add the codebase URL to the classloader
*/
protected ApplicationInstance launchApplet(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException {
- if (!file.isApplet())
+ if (!file.isApplet()) {
throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplet"), R("LNotAppletInfo")));
-
+ }
+
+ if (JNLPRuntime.getForksAllowed() && file.needsNewVM()) {
+ if (!JNLPRuntime.isHeadless()) {
+ SplashScreen sp = SplashScreen.getSplashScreen();
+ if (sp != null) {
+ sp.close();
+ }
+ }
+ }
+ if (handler != null) {
+ handler.launchInitialized(file);
+ }
+
+ AppletInstance applet = null;
try {
ServiceUtil.checkExistingSingleInstance(file);
- AppletInstance applet = createApplet(file, enableCodeBase, cont);
+ applet = createApplet(file, enableCodeBase, cont);
applet.initialize();
-
applet.getAppletEnvironment().startApplet(); // this should be a direct call to applet instance
return applet;
} catch (InstanceExistsException ieex) {
if (JNLPRuntime.isDebug()) {
System.out.println("Single instance applet is already running.");
}
- throw launchError(new LaunchException(file, ieex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LSingleInstanceExists")));
+ throw launchError(new LaunchException(file, ieex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LSingleInstanceExists")), applet);
} catch (LaunchException lex) {
- throw launchError(lex);
+ throw launchError(lex, applet);
} catch (Exception ex) {
- throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")));
+ throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCLaunching"), R("LCouldNotLaunch"), R("LCouldNotLaunchInfo")), applet);
+ }finally{
+ if (handler != null) {
+ handler.launchStarting(applet);
+ }
}
}
@@ -678,13 +704,13 @@
* Gets an ApplicationInstance, but does not launch the applet.
*/
protected ApplicationInstance getApplet(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException {
- if (!file.isApplet())
+ if (!file.isApplet()) {
throw launchError(new LaunchException(file, null, R("LSFatal"), R("LCClient"), R("LNotApplet"), R("LNotAppletInfo")));
-
+ }
+ AppletInstance applet = null;
try {
ServiceUtil.checkExistingSingleInstance(file);
-
- AppletInstance applet = createApplet(file, enableCodeBase, cont);
+ applet = createApplet(file, enableCodeBase, cont);
applet.initialize();
return applet;
@@ -692,11 +718,11 @@
if (JNLPRuntime.isDebug()) {
System.out.println("Single instance applet is already running.");
}
More information about the distro-pkg-dev
mailing list