summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2010-07-28 09:05:04 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2010-07-28 09:05:04 +0000
commitaf24a20257f4958ef5335d471a7fe2c93f475a35 (patch)
treef7f4b2da3f123433d78a1c950d1150b9adf60356 /BKUCommonGUI/src/main
parentc84ee7bc9459bf4966144d29efc4e91b6497a28e (diff)
downloadmocca-af24a20257f4958ef5335d471a7fe2c93f475a35.tar.gz
mocca-af24a20257f4958ef5335d471a7fe2c93f475a35.tar.bz2
mocca-af24a20257f4958ef5335d471a7fe2c93f475a35.zip
Resolved issue [#MOCCA-745] (Two simultaneous requests within the same session cause failure in both requests).
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@790 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src/main')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpListener.java48
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerHelpListener.java8
2 files changed, 32 insertions, 24 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpListener.java
index 2f6f1738..a0ab2d77 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpListener.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpListener.java
@@ -20,6 +20,8 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;
import org.slf4j.Logger;
@@ -30,14 +32,16 @@ public class HelpListener implements MouseListener, KeyListener, HelpURLProvider
public static final String MESSAGE_BUNDLE = "at/gv/egiz/bku/gui/Messages";
private final Logger log = LoggerFactory.getLogger(HelpListener.class);
- private String helpURL;
+
+ private URL baseURL;
+
protected String helpTopic;
protected ResourceBundle messageBundle;
- public HelpListener(String baseHelpURL, Locale locale) {
-
- helpURL = baseHelpURL;
+ public HelpListener(URL baseURL, Locale locale) {
+ this.baseURL = baseURL;
+
if (locale != null) {
log.trace("Check for support of requested help locale {}.", locale);
messageBundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, locale);
@@ -45,14 +49,18 @@ public class HelpListener implements MouseListener, KeyListener, HelpURLProvider
messageBundle = ResourceBundle.getBundle(MESSAGE_BUNDLE);
}
- if ("".equals(messageBundle.getLocale().getLanguage())) {
- log.trace("Using help locale 'default'.");
- } else {
- log.trace("Using help locale '{}'.", messageBundle.getLocale());
- helpURL += messageBundle.getLocale().getLanguage() + '/';
- }
-
- log.debug("Setting help context to {}.", helpURL);
+ String language = messageBundle.getLocale().getLanguage();
+ log.trace("Using help language '{}'.", language);
+ if (!language.isEmpty()) {
+ try {
+ baseURL = new URL(baseURL, language + "/");
+ } catch (MalformedURLException e) {
+ log.info("Failed to build baseURL using language {}. " +
+ "Using default language.", language, e);
+ }
+ }
+ log.debug("Setting help context to {}.", baseURL);
+
}
@Override
@@ -63,15 +71,15 @@ public class HelpListener implements MouseListener, KeyListener, HelpURLProvider
@Override
public synchronized String getHelpURL() {
- if (helpTopic == null) {
- log.debug("No help topic set, return index.");
- return helpURL + "index.html";
+ try {
+ URL helpURL = new URL(baseURL, (helpTopic != null) ? "index.html" : helpTopic + ".html");
+ log.debug("Return help url: {}.", helpURL);
+ return helpURL.toString();
+ } catch (MalformedURLException e) {
+ log.info("Failed to build helpURL. Returning base URL: {}.", baseURL, e);
+ return baseURL.toString();
}
- StringBuilder url = new StringBuilder(helpURL);
- url.append(helpTopic);
- url.append(".html");
- log.debug("Return help url: {}.", url.toString());
- return url.toString();
+
}
/**
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerHelpListener.java
index 3d01c404..3c35e7b6 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerHelpListener.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ViewerHelpListener.java
@@ -33,12 +33,12 @@ public class ViewerHelpListener extends HelpListener {
protected AppletContext appletCtx;
- public ViewerHelpListener(String helpURL, Locale locale) {
- super(helpURL, locale);
+ public ViewerHelpListener(URL baseURL, Locale locale) {
+ super(baseURL, locale);
}
- public ViewerHelpListener(AppletContext ctx, String helpURL, Locale locale) {
- super(helpURL, locale);
+ public ViewerHelpListener(AppletContext ctx, URL baseURL, Locale locale) {
+ super(baseURL, locale);
this.appletCtx = ctx;
}