From 8171050e1b21733a5e55ce97ebc9134f6afb1abb Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 5 Nov 2008 17:22:51 +0000 Subject: java.awt.Desktop BROWSE for help and hashdatadisplay git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@152 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../gv/egiz/bku/online/applet/AppletBKUWorker.java | 2 +- .../egiz/bku/online/applet/AppletHelpListener.java | 35 +++++++++++++++------- .../at/gv/egiz/bku/online/applet/BKUApplet.java | 6 +--- .../applet/ExternalDisplaySignRequestHandler.java | 27 ++++++++++++----- BKUApplet/src/test/resources/appletTest.html | 2 +- .../gv/egiz/bku/local/gui/LocalHelpListener.java | 1 + BKUOnline/src/main/webapp/helpfiles/index.html | 2 +- 7 files changed, 50 insertions(+), 25 deletions(-) diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java index 2141165b..cf842d55 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletBKUWorker.java @@ -199,7 +199,7 @@ public class AppletBKUWorker extends AbstractBKUWorker implements Runnable { //if (HASHDATADISPLAY_EXTERNAL.equals(displayStyle)) { URL hashDataURL = params.getURLParameter(BKUApplet.HASHDATA_URL, sessionId); log.debug("register SignRequestHandler for HashDataURL " + hashDataURL); - addRequestHandler(SignRequest.class, new ExternalDisplaySignRequestHandler(ctx, hashDataURL)); + addRequestHandler(SignRequest.class, new ExternalDisplaySignRequestHandler(hashDataURL)); // } } } diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHelpListener.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHelpListener.java index 4040431f..743dc7ef 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHelpListener.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHelpListener.java @@ -18,30 +18,45 @@ package at.gv.egiz.bku.online.applet; import at.gv.egiz.bku.gui.AbstractHelpListener; -import java.applet.AppletContext; +import java.awt.Desktop; import java.net.URL; import java.util.Locale; /** - * + * Now uses java.awt.Desktop, which deprecates + * the distinction between local and applet help listener + * TODO: integrate in AbstractHelpListener + * + * @deprecated * @author clemens */ public class AppletHelpListener extends AbstractHelpListener { - protected AppletContext ctx; +// protected AppletContext ctx; + protected Desktop desktop; - public AppletHelpListener(AppletContext ctx, URL helpURL, Locale locale) { + public AppletHelpListener(URL helpURL, Locale locale) { super(helpURL, locale); - if (ctx == null) { - throw new RuntimeException("no applet context provided"); +// if (ctx == null) { +// throw new RuntimeException("no applet context provided"); +// } +// this.ctx = ctx; + if (Desktop.isDesktopSupported()) { + this.desktop = Desktop.getDesktop(); } - this.ctx = ctx; } @Override public void showDocument(URL helpDocument) throws Exception { - ctx.showDocument(helpDocument, "_blank"); +// ctx.showDocument(helpDocument, "_blank"); + if (desktop == null) { + log.error("Failed to open default browser: Desktop API not available (libgnome installed?)"); + } else { + if (!desktop.isSupported(Desktop.Action.BROWSE)) { + log.error("Failed to open default browser: The system provides the Desktop API, but does not support the BROWSE action"); + } else { + Desktop.getDesktop().browse(helpDocument.toURI()); + } + } } - - } diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java index 4eab7e89..482273b0 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java @@ -16,14 +16,10 @@ */ package at.gv.egiz.bku.online.applet; -import at.gv.egiz.bku.smccstal.AbstractBKUWorker; import java.net.MalformedURLException; import java.net.URL; import java.util.Locale; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.net.ssl.HttpsURLConnection; import javax.swing.JApplet; @@ -105,7 +101,7 @@ public class BKUApplet extends JApplet implements AppletParameterProvider { log.debug("setting locale to " + getLocale()); BKUGUIFacade gui = BKUGUIFactory.createGUI(guiStyle); - AppletHelpListener helpListener = new AppletHelpListener(getAppletContext(), helpURL, getLocale()); + AppletHelpListener helpListener = new AppletHelpListener(helpURL, getLocale()); //getAppletContext(), gui.init(getContentPane(), getLocale(), backgroundImgURL, helpListener); worker = new AppletBKUWorker(gui, getAppletContext(), this); diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java index 2c9fde71..e4567a6c 100644 --- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java +++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalDisplaySignRequestHandler.java @@ -17,7 +17,6 @@ package at.gv.egiz.bku.online.applet; -import java.applet.AppletContext; import java.net.URL; import java.util.List; @@ -26,28 +25,42 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.smccstal.SignRequestHandler; import at.gv.egiz.stal.signedinfo.ReferenceType; +import java.awt.Desktop; /** * - * @author clemens + * @author Clemens Orthacker */ public class ExternalDisplaySignRequestHandler extends SignRequestHandler { private static final Log log = LogFactory.getLog(ExternalDisplaySignRequestHandler.class); - AppletContext ctx; - URL hashDataURL; +// AppletContext ctx; + protected URL hashDataURL; + protected Desktop desktop; - public ExternalDisplaySignRequestHandler(AppletContext ctx, URL hashDataURL) { - this.ctx = ctx; + public ExternalDisplaySignRequestHandler(URL hashDataURL) { +// this.ctx = ctx; this.hashDataURL = hashDataURL; + if (Desktop.isDesktopSupported()) { + desktop = Desktop.getDesktop(); + } } @Override public void displayHashDataInputs(List signedReferences) throws Exception { //TODO pass reference Id's to servlet (TODO servlet) log.debug("displaying hashdata inputs at " + hashDataURL); - ctx.showDocument(hashDataURL, "_blank"); +// ctx.showDocument(hashDataURL, "_blank"); + if (desktop == null) { + log.error("Failed to open default browser: Desktop API not available (libgnome installed?)"); + } else { + if (!desktop.isSupported(Desktop.Action.BROWSE)) { + log.error("Failed to open default browser: The system provides the Desktop API, but does not support the BROWSE action"); + } else { + Desktop.getDesktop().browse(hashDataURL.toURI()); + } + } } } diff --git a/BKUApplet/src/test/resources/appletTest.html b/BKUApplet/src/test/resources/appletTest.html index daf8445b..5aec1998 100644 --- a/BKUApplet/src/test/resources/appletTest.html +++ b/BKUApplet/src/test/resources/appletTest.html @@ -23,7 +23,7 @@ - + diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java index e32c9c3d..2251a474 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/gui/LocalHelpListener.java @@ -25,6 +25,7 @@ import java.util.Locale; /** * + * @deprecated see AppletHelpListener * @author Clemens Orthacker */ public class LocalHelpListener extends AbstractHelpListener { diff --git a/BKUOnline/src/main/webapp/helpfiles/index.html b/BKUOnline/src/main/webapp/helpfiles/index.html index 84db59c6..49aaed66 100644 --- a/BKUOnline/src/main/webapp/helpfiles/index.html +++ b/BKUOnline/src/main/webapp/helpfiles/index.html @@ -11,7 +11,7 @@ -

No help item provided

+

Default help page if no help item is provided

-- cgit v1.2.3