From e4b8cec0f43af3aa4272e56e8133cc70512149a2 Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 2 Jun 2010 15:04:20 +0000 Subject: default locale: en, help pages fixed git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@748 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 30 ++++------ .../java/at/gv/egiz/bku/gui/DeafHelpListener.java | 67 --------------------- .../main/java/at/gv/egiz/bku/gui/HelpListener.java | 70 ++++++++++++++++------ .../main/java/at/gv/egiz/bku/gui/HelpViewer.java | 24 ++++---- .../at/gv/egiz/bku/gui/ViewerHelpListener.java | 24 -------- 5 files changed, 75 insertions(+), 140 deletions(-) delete mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DeafHelpListener.java (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz') diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java index d806c5fa..578df527 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java @@ -2290,26 +2290,20 @@ public class BKUGUIImpl implements BKUGUIFacade { * @param locale */ protected void loadMessageBundle(Locale locale) { - if (locale != null) { - // see [#378] Ignoring post parameter 'locale': bundle resolve-order + if (locale != null) { + // see [#378] Ignoring post parameter 'locale': bundle resolve-order // not correct?! - Locale lang = new Locale(locale.getLanguage().substring(0, 2)); - log.debug("Loading message bundle for language: {}.", lang.toString()); - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); - } else { - log.debug("Loading default language message bundle."); - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); - } + log.debug("Loading message bundle for language: {}.", locale); + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, locale); + } else { + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); + } - if (log.isDebugEnabled()) { - if (messages.getLocale() == null - || "".equals(messages.getLocale().getLanguage())) { - log.info("Fallback to default locale message bundle."); - } else { - log.info("Applet message bundle loaded for {}.", - messages.getLocale()); - } - } + if ("".equals(messages.getLocale().getLanguage())) { + log.debug("Using locale 'default'."); + } else { + log.debug("Using locale '{}'.", messages.getLocale()); + } } protected int initButtonSize() { diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DeafHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DeafHelpListener.java deleted file mode 100644 index a4ce79b0..00000000 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DeafHelpListener.java +++ /dev/null @@ -1,67 +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.KeyEvent; -import java.awt.event.MouseEvent; -import java.util.Locale; - -public class DeafHelpListener extends HelpListener { - - // localization in helpListener (pass message bundle, getLocale, add language to helpContext) or outside? - public DeafHelpListener(String helpURL, Locale locale) { - super(helpURL, locale); - } - - @Override - public boolean implementsListener() { - return false; - } - - @Override - public void mouseClicked(MouseEvent arg0) { - } - - @Override - public void keyPressed(KeyEvent arg0) { - } - - @Override - public void mousePressed(MouseEvent e) { - } - - @Override - public void mouseReleased(MouseEvent e) { - } - - @Override - public void mouseEntered(MouseEvent e) { - } - - @Override - public void mouseExited(MouseEvent e) { - } - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - } - -} 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 dc597656..2f6f1738 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 @@ -16,14 +16,16 @@ */ package at.gv.egiz.bku.gui; +import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Locale; import java.util.ResourceBundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class HelpListener implements MouseListener, KeyListener, HelpURLProvider { +public class HelpListener implements MouseListener, KeyListener, HelpURLProvider { public static final String MESSAGE_BUNDLE = "at/gv/egiz/bku/gui/Messages"; @@ -32,23 +34,22 @@ public abstract class HelpListener implements MouseListener, KeyListener, HelpUR protected String helpTopic; protected ResourceBundle messageBundle; - // localization in helpListener (pass message bundle, getLocale, add language to helpContext) or outside? - public HelpListener(String helpURL, Locale locale) { -// this.codebase = codebase; - this.helpURL = helpURL; + public HelpListener(String baseHelpURL, Locale locale) { + + helpURL = baseHelpURL; if (locale != null) { - log.trace("Check for support of requested help locale {}.", locale.getLanguage().substring(0,2)); - messageBundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, - new Locale(locale.getLanguage().substring(0, 2))); + log.trace("Check for support of requested help locale {}.", locale); + messageBundle = ResourceBundle.getBundle(MESSAGE_BUNDLE, locale); } else { messageBundle = ResourceBundle.getBundle(MESSAGE_BUNDLE); } - if (!"".equals(messageBundle.getLocale().getLanguage())) { - log.trace("Using help locale '{}'.", messageBundle.getLocale().getLanguage().substring(0,2)); - helpURL += messageBundle.getLocale().getLanguage().substring(0,2) + '/'; - } else { + + 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); @@ -66,9 +67,11 @@ public abstract class HelpListener implements MouseListener, KeyListener, HelpUR log.debug("No help topic set, return index."); return helpURL + "index.html"; } - String url = helpURL + helpTopic + ".html"; - log.debug("Return help topic: {}.", url); - return url; + StringBuilder url = new StringBuilder(helpURL); + url.append(helpTopic); + url.append(".html"); + log.debug("Return help url: {}.", url.toString()); + return url.toString(); } /** @@ -79,6 +82,39 @@ public abstract class HelpListener implements MouseListener, KeyListener, HelpUR * (whether a help icon shall be included) * @return true if this HelpListener implements the Mouse/KeyListeners */ - public abstract boolean implementsListener(); - + public boolean implementsListener() { + return false; + } + + @Override + public void mouseClicked(MouseEvent arg0) { + } + + @Override + public void keyPressed(KeyEvent arg0) { + } + + @Override + public void mousePressed(MouseEvent e) { + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + } } diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java index bfd797e8..0322d5a6 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java @@ -27,6 +27,7 @@ import java.awt.event.ActionListener; import java.io.IOException; import java.net.URL; import java.text.MessageFormat; +import java.util.Locale; import java.util.ResourceBundle; import javax.swing.GroupLayout; import javax.swing.JButton; @@ -49,6 +50,8 @@ import org.slf4j.LoggerFactory; public class HelpViewer extends JDialog implements ActionListener { + public static final String MESSAGE_BUNDLE = "at/gv/egiz/bku/gui/Messages"; + private static final long serialVersionUID = 1L; private final Logger log = LoggerFactory.getLogger(HelpViewer.class); @@ -65,29 +68,24 @@ public class HelpViewer extends JDialog * @param messages */ public static void showHelpDialog(AppletContext ctx, - URL helpURL, -// String helpTopic, - ResourceBundle messages) { - showHelpDialog(null, ctx, helpURL, messages); //helpTopic, messages); + URL helpURL, ResourceBundle messages) { + showHelpDialog(null, ctx, helpURL, messages); } - public static void showHelpDialog(URL helpURL, -// String helpTopic, - ResourceBundle messages) { - showHelpDialog(null, null, helpURL, messages); // helpTopic, messages); + public static void showHelpDialog(URL helpURL, ResourceBundle messages) { + showHelpDialog(null, null, helpURL, messages); } public static void showHelpDialog(Component owner, AppletContext ctx, URL helpURL, -// String helpTopic, ResourceBundle messages) { Frame frame = null; if (owner != null) { JOptionPane.getFrameForComponent(owner); } - dialog = new HelpViewer(frame, messages, ctx, helpURL); //, helpTopic); + dialog = new HelpViewer(frame, messages, ctx, helpURL); dialog.setVisible(true); dialog.toFront(); } @@ -95,14 +93,12 @@ public class HelpViewer extends JDialog private HelpViewer(Frame frame, ResourceBundle messages, AppletContext ctx, - URL helpURL) { //, String helpTopic) { + URL helpURL) { super(frame, messages.getString(BKUGUIFacade.WINDOWTITLE_HELP), true); this.messages = messages; this.ctx = ctx; -// String p = messages.getString(BKUGUIFacade.MESSAGE_HELP); -// String helpItem = messages.getString(helpTopic); -// String viewerLabel = MessageFormat.format(p, new Object[]{helpItem}); + log.trace("init help viewer for locale ", messages.getLocale()); JPanel helpPanel = createViewerPanel(helpURL); //viewerLabel, helpURL); JPanel buttonPanel = createButtonPanel(); 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 4860756d..3d01c404 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 @@ -74,28 +74,4 @@ public class ViewerHelpListener extends HelpListener { public void keyPressed(KeyEvent arg0) { displayHelpViewer(getHelpURL()); } - - @Override - public void mousePressed(MouseEvent e) { - } - - @Override - public void mouseReleased(MouseEvent e) { - } - - @Override - public void mouseEntered(MouseEvent e) { - } - - @Override - public void mouseExited(MouseEvent e) { - } - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - } } -- cgit v1.2.3