From b1c8641a63a67e3c64d948f9e8dce5c01e11e2dd Mon Sep 17 00:00:00 2001 From: mcentner Date: Wed, 5 May 2010 15:29:01 +0000 Subject: Merged feature branch mocca-1.2.13-id@r724 back to trunk. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@725 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/bku/gui/AbstractHelpListener.java | 103 --------------------- 1 file changed, 103 deletions(-) delete mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java') 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 deleted file mode 100644 index 6fd1ffea..00000000 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2008 Federal Chancellery Austria and - * Graz University of Technology - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * 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; -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. - *
- * The help URL is build as [baseURL]/[locale]/[helpTopic].html - * (note that no session information is contained). - * - * @author Clemens Orthacker - */ -public abstract class AbstractHelpListener implements ActionListener { - - /** - * any locale not in the list will be mapped to 'de' - */ - public static final String[] SUPPORTED_LANGUAGES = new String[] { "de" }; - - protected final static Log log = LogFactory.getLog(AbstractHelpListener.class); - protected URL baseURL; - protected Locale locale; - protected ResourceBundle messages; - - public AbstractHelpListener(URL baseURL, Locale locale) { - if (baseURL == null || "".equals(baseURL.toString())) { - throw new RuntimeException("no help URL provided"); - } - this.baseURL = baseURL; - this.locale = locale; - if (locale != null) { - messages = ResourceBundle.getBundle(BKUGUIFacade.MESSAGES_BUNDLE, locale); - } else { - messages = ResourceBundle.getBundle(BKUGUIFacade.MESSAGES_BUNDLE); - } - } - - @Override - public void actionPerformed(ActionEvent e) { - log.debug("received help action: " + e.getActionCommand()); - URL helpURL = constructHelpURL(baseURL, e.getActionCommand()); - try { - showDocument(helpURL, e.getActionCommand()); - } catch (Exception ex) { - log.error("could not display help document " + helpURL + ": " + ex.getMessage()); - } - } - - private URL constructHelpURL(URL baseURL, String helpTopic) { - URL helpURL = baseURL; - log.trace("constructing help URL: " + helpURL); - try { - // not localized for now - //check if locale.getLanguage() supported and add default if not -// if (locale != null) { -// helpURL = new URL(helpURL, locale.toString() + "/"); -// log.trace("constructing help URL: " + helpURL); -// } - if (helpTopic != null && !"".equals(helpTopic)) { - helpURL = new URL(helpURL, "de/" + helpTopic + ".html"); - log.trace("constructing help URL: " + helpURL); - } - } catch (MalformedURLException ex) { - log.error("Failed to construct help URL for help item " + helpTopic + ": " + ex.getMessage()); - } - return helpURL; - } - - /** - * 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; -} -- cgit v1.2.3