diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-11-05 17:22:51 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-11-05 17:22:51 +0000 |
commit | 8171050e1b21733a5e55ce97ebc9134f6afb1abb (patch) | |
tree | 974fbcc2723e367339e67db86e8e736aad9990b8 /BKUApplet/src/main | |
parent | 2cf6fcb31e85b0e3b367121219932ec86b205da8 (diff) | |
download | mocca-8171050e1b21733a5e55ce97ebc9134f6afb1abb.tar.gz mocca-8171050e1b21733a5e55ce97ebc9134f6afb1abb.tar.bz2 mocca-8171050e1b21733a5e55ce97ebc9134f6afb1abb.zip |
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
Diffstat (limited to 'BKUApplet/src/main')
4 files changed, 47 insertions, 23 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 <clemens.orthacker@iaik.tugraz.at> */ 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<ReferenceType> 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()); + } + } } } |