summaryrefslogtreecommitdiff
path: root/BKUApplet/src/main/java/at
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-10-30 17:43:40 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-10-30 17:43:40 +0000
commit036dd1a8054c5dc818d01e238eb9480d67da478d (patch)
tree02c54e7faf839bb45abe11fe57bc3c8554b67a02 /BKUApplet/src/main/java/at
parentaa173374fd701285154f765826e34b9c0c8b8dc7 (diff)
downloadmocca-036dd1a8054c5dc818d01e238eb9480d67da478d.tar.gz
mocca-036dd1a8054c5dc818d01e238eb9480d67da478d.tar.bz2
mocca-036dd1a8054c5dc818d01e238eb9480d67da478d.zip
Help Icon
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@130 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUApplet/src/main/java/at')
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUApplet.java158
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java24
-rw-r--r--BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalHelpListener.java70
3 files changed, 168 insertions, 84 deletions
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 97b5869f..470534da 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
@@ -21,6 +21,8 @@ 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;
@@ -36,79 +38,105 @@ import at.gv.egiz.bku.gui.BKUGUIFactory;
*/
public class BKUApplet extends JApplet {
- private static Log log = LogFactory.getLog(BKUApplet.class);
- public static final String GUI_STYLE = "GuiStyle";
- public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
- public final static String LOCALE_PARAM_KEY = "Locale";
- public final static String LOGO_URL_KEY = "LogoURL";
- public final static String WSDL_URL = "WSDL_URL";
- public static final String HASHDATA_DISPLAY = "HashDataDisplay";
- public final static String HASHDATA_URL = "HashDataURL";
- public final static String SESSION_ID = "SessionID";
- public static final String BACKGROUND_PARAM = "Background";
- public static final String REDIRECT_URL = "RedirectURL";
- public static final String REDIRECT_TARGET = "RedirectTarget";
-
- public static final String HASHDATA_DISPLAY_INTERNAL = "internal";
-
- protected ResourceBundle resourceBundle;
- protected BKUWorker worker;
- protected Thread workerThread;
+ private static Log log = LogFactory.getLog(BKUApplet.class);
+ public static final String GUI_STYLE = "GuiStyle";
+ public final static String RESOURCE_BUNDLE_BASE = "at/gv/egiz/bku/online/applet/Messages";
+ public final static String LOCALE_PARAM_KEY = "Locale";
+ public final static String LOGO_URL_KEY = "LogoURL";
+ public final static String WSDL_URL = "WSDL_URL";
+ public static final String HASHDATA_DISPLAY = "HashDataDisplay";
+ public final static String HASHDATA_URL = "HashDataURL";
+ public final static String HELP_URL = "HelpURL";
+ public final static String SESSION_ID = "SessionID";
+ public static final String BACKGROUND_PARAM = "Background";
+ public static final String REDIRECT_URL = "RedirectURL";
+ public static final String REDIRECT_TARGET = "RedirectTarget";
+ public static final String HASHDATA_DISPLAY_INTERNAL = "internal";
+ protected ResourceBundle resourceBundle;
+ protected BKUWorker worker;
+ protected Thread workerThread;
- public BKUApplet() {
- }
+ public BKUApplet() {
+ }
- public void init() {
- log.info("Welcome to MOCCA\n");
- log.debug("Called init()");
- HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
- String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
- if (localeString != null) {
- resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
+ @Override
+ public void init() {
+ log.info("Welcome to MOCCA\n");
+ log.debug("Called init()");
+ HttpsURLConnection.setDefaultSSLSocketFactory(InternalSSLSocketFactory.getInstance());
+ String localeString = getMyAppletParameter(LOCALE_PARAM_KEY);
+ if (localeString != null) {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE,
new Locale(localeString));
- } else {
- resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
- }
- String backgroundString = getMyAppletParameter(BACKGROUND_PARAM);
- URL background = null;
- if (backgroundString != null) {
- try {
- background = new URL(backgroundString);
- } catch (MalformedURLException ex) {
- log.warn(ex.getMessage() + ", using default background");
- }
- }
- String guiStyle = getMyAppletParameter(GUI_STYLE);
- BKUGUIFacade gui = BKUGUIFactory.createGUI(guiStyle);
- gui.init(getContentPane(), localeString, background);
- worker = new BKUWorker(gui, this, resourceBundle);
+ } else {
+ resourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE);
}
-
- public void start() {
- log.debug("Called start()");
- workerThread = new Thread(worker);
- workerThread.start();
+ String backgroundString = getMyAppletParameter(BACKGROUND_PARAM);
+ URL background = null;
+ if (backgroundString != null) {
+ try {
+ background = new URL(backgroundString);
+ } catch (MalformedURLException ex) {
+ log.warn(ex.getMessage() + ", using default background");
+ }
}
-
- public void stop() {
- log.debug("Called stop()");
- if ((workerThread != null) && (workerThread.isAlive())) {
- workerThread.interrupt();
- }
+ String guiStyle = getMyAppletParameter(GUI_STYLE);
+ BKUGUIFacade gui = BKUGUIFactory.createGUI(guiStyle);
+ ExternalHelpListener helpListener = null;
+ try {
+ URL helpURL = getMyAppletParameterURL(HELP_URL);
+ helpListener = new ExternalHelpListener(getAppletContext(), helpURL, localeString);
+ } catch (MalformedURLException ex) {
+ log.error("invalid help URL: " + ex.getMessage());
}
+ gui.init(getContentPane(), localeString, background, helpListener);
+ worker = new BKUWorker(gui, this, resourceBundle);
+ }
- public void destroy() {
- log.debug("Called destroy()");
+ @Override
+ public void start() {
+ log.debug("Called start()");
+ workerThread = new Thread(worker);
+ workerThread.start();
+ }
+
+ @Override
+ public void stop() {
+ log.debug("Called stop()");
+ if ((workerThread != null) && (workerThread.isAlive())) {
+ workerThread.interrupt();
}
+ }
+
+ @Override
+ public void destroy() {
+ log.debug("Called destroy()");
+ }
+
+ /**
+ * Applet configuration parameters
+ *
+ * @param paramKey
+ * @return
+ */
+ String getMyAppletParameter(String paramKey) {
+ log.info("Getting parameter: " + paramKey + ": " + getParameter(paramKey));
+ return getParameter(paramKey);
+ }
- /**
- * Applet configuration parameters
- *
- * @param paramKey
- * @return
- */
- public String getMyAppletParameter(String paramKey) {
- log.info("Getting parameter: " + paramKey + ": " + getParameter(paramKey));
- return getParameter(paramKey);
+ URL getMyAppletParameterURL(String param) throws MalformedURLException {
+ String hashDataParam = getMyAppletParameter(param); //BKUApplet.HASHDATA_URL);
+ if (hashDataParam != null) {
+ URL codebase = getCodeBase();
+ try {
+ return new URL(codebase, hashDataParam);
+ } catch (MalformedURLException ex) {
+ log.error("Paremeter " + param + " is not a valid URL.", ex);
+ throw new MalformedURLException(ex.getMessage());
+ }
+ } else {
+ log.error("Paremeter " + param + " not set");
+ throw new MalformedURLException(param + " not set");
}
+ }
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
index f708826d..78f3dc12 100644
--- a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/BKUWorker.java
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
@@ -46,6 +48,7 @@ import at.gv.egiz.stal.service.types.ObjectFactory;
import at.gv.egiz.stal.service.types.RequestType;
import at.gv.egiz.stal.service.types.ResponseType;
import at.gv.egiz.stal.util.STALTranslator;
+import javax.naming.ConfigurationException;
public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
ActionListener, SMCCSTALRequestHandler {
@@ -68,7 +71,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
public BKUWorker(BKUGUIFacade gui, BKUApplet parent,
ResourceBundle errorMessageBundle) {
if ((gui == null) || (parent == null) || (errorMessageBundle == null)) {
- throw new NullPointerException("Parameter must not be set to null");
+ throw new NullPointerException("Parameter must not be set to null");
}
this.gui = gui;
this.parent = parent;
@@ -117,23 +120,6 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
return stal.getSTALPort();
}
- private URL getHashDataURL() throws MalformedURLException {
- String hashDataParam = parent.getMyAppletParameter(BKUApplet.HASHDATA_URL);
- URL codebase = parent.getCodeBase();
- if (hashDataParam != null) {
- try {
- return new URL(codebase, hashDataParam);
-// log.debug("Found HashDataInputServlet URL: " + hashDataURL);
- } catch (MalformedURLException ex) {
- log.fatal("Paremeter " + BKUApplet.HASHDATA_URL + " is not a vailid URL.", ex);
- throw new MalformedURLException(ex.getMessage());
- }
- } else {
- log.fatal("Paremeter " + BKUApplet.HASHDATA_URL + " not set");
- throw new MalformedURLException(BKUApplet.HASHDATA_URL + " not set");
- }
- }
-
@Override
public void run() {
gui.showWelcomeDialog();
@@ -165,7 +151,7 @@ public class BKUWorker extends AbstractSMCCSTAL implements Runnable,
log.debug("register SignRequestHandler for STAL port " + BKUApplet.WSDL_URL);
addRequestHandler(at.gv.egiz.stal.SignRequest.class, new WebServiceSignRequestHandler(sessionId, stalPort));
} else { //if (HASHDATADISPLAY_EXTERNAL.equals(displayStyle)) {
- URL hashDataURL = getHashDataURL();
+ URL hashDataURL = parent.getMyAppletParameterURL(BKUApplet.HASHDATA_URL);
log.debug("register SignRequestHandler for HashDataURL " + hashDataURL);
addRequestHandler(at.gv.egiz.stal.SignRequest.class, new ExternalDisplaySignRequestHandler(parent.getAppletContext(), hashDataURL));
}
diff --git a/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalHelpListener.java b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalHelpListener.java
new file mode 100644
index 00000000..4d6d5851
--- /dev/null
+++ b/BKUApplet/src/main/java/at/gv/egiz/bku/online/applet/ExternalHelpListener.java
@@ -0,0 +1,70 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package at.gv.egiz.bku.online.applet;
+
+import java.applet.AppletContext;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author clemens
+ */
+public class ExternalHelpListener implements ActionListener {
+
+ protected final static Log log = LogFactory.getLog(ExternalHelpListener.class);
+ protected AppletContext ctx;
+ protected String helpURLBase;
+ protected String locale;
+
+ public ExternalHelpListener(AppletContext ctx, URL helpURL, String locale) {
+ if (ctx == null) {
+ throw new RuntimeException("no applet context provided");
+ }
+ if (helpURL == null || "".equals(helpURL)) {
+ throw new RuntimeException("no help URL provided");
+ }
+ this.ctx = ctx;
+ this.helpURLBase = helpURL.toString();
+ this.locale = locale;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ log.debug("received help action: " + e.getActionCommand());
+ URL helpURL;
+ try {
+ String urlString = helpURLBase;
+ if (locale != null) {
+ urlString = appendParameter(urlString, "locale", locale);
+ }
+ if (e.getActionCommand() != null && !"".equals(e.getActionCommand())) {
+ urlString = appendParameter(urlString, "topic", e.getActionCommand());
+ }
+ helpURL = new URL(urlString);
+ } catch (MalformedURLException ex) {
+ try {
+ log.error("failed to create help URL: " + ex.getMessage());
+ helpURL = new URL(helpURLBase);
+ } catch (MalformedURLException ex1) {
+ log.error("failed to create default help URL, requested help will not be displayed");
+ return;
+ }
+ }
+ ctx.showDocument(helpURL, "_blank");
+ }
+
+ private String appendParameter(String url, String paramName, String paramValue) {
+ if (url.indexOf('?') < 0) {
+ return url + "?" + paramName + "=" + paramValue;
+ } else {
+ return url + "&" + paramName + "=" + paramValue;
+ }
+ }
+}