summaryrefslogtreecommitdiff
path: root/BKUCommonGUI
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-05 14:42:05 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-05 14:42:05 +0000
commit2cf6fcb31e85b0e3b367121219932ec86b205da8 (patch)
tree45f3214a803d25f0b60cad34bd0a8b0b8c24ec5f /BKUCommonGUI
parent2b6acde30512e7303ed08c9c4e2276529491a69e (diff)
downloadmocca-2cf6fcb31e85b0e3b367121219932ec86b205da8.tar.gz
mocca-2cf6fcb31e85b0e3b367121219932ec86b205da8.tar.bz2
mocca-2cf6fcb31e85b0e3b367121219932ec86b205da8.zip
help jsp
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@151 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java45
1 files changed, 19 insertions, 26 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java
index 6e3167c1..a249a376 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java
@@ -32,39 +32,22 @@ import org.apache.commons.logging.LogFactory;
public abstract class AbstractHelpListener implements ActionListener {
protected final static Log log = LogFactory.getLog(AbstractHelpListener.class);
- protected String helpURLBase;
+// protected String helpURLBase;
+ protected URL baseURL;
protected Locale locale;
public AbstractHelpListener(URL baseURL, Locale locale) {
if (baseURL == null || "".equals(baseURL)) {
throw new RuntimeException("no help URL provided");
}
- this.helpURLBase = baseURL.toString();
+ this.baseURL = baseURL;
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.toString());
- }
- 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;
- }
- }
+ URL helpURL = constructHelpURL(baseURL, e.getActionCommand());
try {
showDocument(helpURL);
} catch (Exception ex) {
@@ -72,12 +55,22 @@ public abstract class AbstractHelpListener implements ActionListener {
}
}
- private String appendParameter(String url, String paramName, String paramValue) {
- if (url.indexOf('?') < 0) {
- return url + "?" + paramName + "=" + paramValue;
- } else {
- return url + "&" + paramName + "=" + paramValue;
+ private URL constructHelpURL(URL baseURL, String helpItem) {
+ URL helpURL = baseURL;
+ log.trace("constructing help URL: " + helpURL);
+ try {
+ if (locale != null) {
+ helpURL = new URL(helpURL, locale.toString() + "/");
+ log.trace("constructing help URL: " + helpURL);
+ }
+ if (helpItem != null && !"".equals(helpItem)) {
+ helpURL = new URL(helpURL, helpItem + ".html");
+ log.trace("constructing help URL: " + helpURL);
+ }
+ } catch (MalformedURLException ex) {
+ log.error("Failed to construct help URL for help item " + helpItem + ": " + ex.getMessage());
}
+ return helpURL;
}
public abstract void showDocument(URL helpDocument) throws Exception;