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 --- .../egiz/bku/online/applet/AppletHelpListener.java | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/AppletHelpListener.java') 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()); + } + } } - - } -- cgit v1.2.3