summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-13 18:24:57 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-11-13 18:24:57 +0000
commit9662ac90b6aa84bc54543d3c8670ba6c8e42bbac (patch)
tree4b47426d3cf67ff9deee1e741fa9740b54b988fc /BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java
parent35356a68fcecb6492a90f7cd01ff846f2393fdaa (diff)
downloadmocca-9662ac90b6aa84bc54543d3c8670ba6c8e42bbac.tar.gz
mocca-9662ac90b6aa84bc54543d3c8670ba6c8e42bbac.tar.bz2
mocca-9662ac90b6aa84bc54543d3c8670ba6c8e42bbac.zip
FRAME HashDataDisplay
FRAME Help git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@165 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java41
1 files changed, 28 insertions, 13 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 a249a376..f46f5227 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
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package at.gv.egiz.bku.gui;
import java.awt.event.ActionEvent;
@@ -22,19 +21,24 @@ import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
+import java.util.ResourceBundle;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- *
+ * Implement the showDocument(URL) method to provide an actual HelpListener.
+ * This class does not keep a GUI reference and subclasses should not interfere with the GUI.
+ * Therefore, any errors occurring in showDocument() should be handled/displayed within
+ * showDocument() and exceptions thrown from showDocument() are logged, not displayed in the GUI.
+ *
* @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
*/
public abstract class AbstractHelpListener implements ActionListener {
protected final static Log log = LogFactory.getLog(AbstractHelpListener.class);
-// protected String helpURLBase;
protected URL baseURL;
protected Locale locale;
+ protected ResourceBundle messages;
public AbstractHelpListener(URL baseURL, Locale locale) {
if (baseURL == null || "".equals(baseURL)) {
@@ -42,6 +46,11 @@ public abstract class AbstractHelpListener implements ActionListener {
}
this.baseURL = baseURL;
this.locale = locale;
+ if (locale != null) {
+ messages = ResourceBundle.getBundle(BKUGUIFacade.MESSAGES_BUNDLE, locale);
+ } else {
+ messages = ResourceBundle.getBundle(BKUGUIFacade.MESSAGES_BUNDLE);
+ }
}
@Override
@@ -49,30 +58,36 @@ public abstract class AbstractHelpListener implements ActionListener {
log.debug("received help action: " + e.getActionCommand());
URL helpURL = constructHelpURL(baseURL, e.getActionCommand());
try {
- showDocument(helpURL);
+ showDocument(helpURL, e.getActionCommand());
} catch (Exception ex) {
log.error("could not display help document " + helpURL + ": " + ex.getMessage());
}
}
-
- private URL constructHelpURL(URL baseURL, String helpItem) {
+
+ private URL constructHelpURL(URL baseURL, String helpTopic) {
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");
+ }
+ if (helpTopic != null && !"".equals(helpTopic)) {
+ helpURL = new URL(helpURL, helpTopic + ".html");
log.trace("constructing help URL: " + helpURL);
}
} catch (MalformedURLException ex) {
- log.error("Failed to construct help URL for help item " + helpItem + ": " + ex.getMessage());
+ log.error("Failed to construct help URL for help item " + helpTopic + ": " + ex.getMessage());
}
return helpURL;
}
-
- public abstract void showDocument(URL helpDocument) throws Exception;
-
+
+ /**
+ * Errors from HelpListeners should not (are not) displayed in the applet,
+ * but should rather be in the HelpListener specific way.
+ * Therefore, implementations SHOULD NOT throw exceptions (these are only logged).
+ * @param helpDocument
+ * @throws java.lang.Exception
+ */
+ public abstract void showDocument(URL helpDocument, String helpTopic) throws Exception;
}