From 4032e46810c24dc3f013de296a2133f4651696b9 Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 31 Oct 2008 15:30:34 +0000 Subject: local HelpListener card locked/not activated git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@137 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/bku/gui/AbstractHelpListener.java | 84 ++++++++++++++++++++++ .../main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java | 2 + .../at/gv/egiz/bku/gui/Messages.properties | 4 +- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java (limited to 'BKUCommonGUI/src') 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 new file mode 100644 index 00000000..68d61bef --- /dev/null +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/AbstractHelpListener.java @@ -0,0 +1,84 @@ +/* + * 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 org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author Clemens Orthacker + */ +public abstract class AbstractHelpListener implements ActionListener { + + protected final static Log log = LogFactory.getLog(AbstractHelpListener.class); + protected String helpURLBase; + protected String locale; + + public AbstractHelpListener(URL baseURL, String locale) { + if (baseURL == null || "".equals(baseURL)) { + throw new RuntimeException("no help URL provided"); + } + this.helpURLBase = baseURL.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; + } + } + try { + showDocument(helpURL); + } catch (Exception ex) { + log.error("could not display help document " + helpURL + ": " + ex.getMessage()); + } + } + + private String appendParameter(String url, String paramName, String paramValue) { + if (url.indexOf('?') < 0) { + return url + "?" + paramName + "=" + paramValue; + } else { + return url + "&" + paramName + "=" + paramValue; + } + } + + public abstract void showDocument(URL helpDocument) throws Exception; + +} diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java index 872f1874..4ef1b7d9 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java @@ -35,6 +35,8 @@ public interface BKUGUIFacade { public static final String ERR_DISPLAY_HASHDATA = "error.display.hashdata"; public static final String ERR_WRITE_HASHDATA = "error.write.hashdata"; public static final String ERR_INVALID_HASH = "error.invalid.hash"; + public static final String ERR_CARD_LOCKED = "error.card.locked"; + public static final String ERR_CARD_NOTACTIVATED = "error.card.notactivated"; public static final String MESSAGES_BUNDLE = "at/gv/egiz/bku/gui/Messages"; public static final String DEFAULT_BACKGROUND = "/images/BackgroundChipperling.png"; diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties index 5a427360..1f51de77 100644 --- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties +++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties @@ -58,4 +58,6 @@ error.ws.unreachable=Das Web-Service ist nicht erreichbar: {0} error.pcsc=Java(TM) scheint keine PC/SC Schnittstelle f\u00FCr den Smartcard-Zugriff zur Verf\u00FCgung zu stellen. error.cardterminal=Es konnte kein Smartcard-Leser gefunden werden.

Entweder ist kein Leser angeschlossen oder kein PC/SC Treiber installiert.

error.unknown=Leider trat ein Fehler auf: {0} -error.test=Fehler1 {0} - Fehler2 {1} \ No newline at end of file +error.test=Fehler1 {0} - Fehler2 {1} +error.card.locked=B\u00FCrgerkarte ist gesperrt +error.card.notactivated=B\u00FCrgerkartenfunktion ist nicht aktiviert \ No newline at end of file -- cgit v1.2.3