From 6d2cd68c8adff8c27a6a3a18711ea44a2e7bfe30 Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 18 Nov 2008 18:00:44 +0000 Subject: GUI refactoring 2 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@178 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 1306 ++++++++++++++++++++ 1 file changed, 1306 insertions(+) create mode 100644 BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 new file mode 100644 index 00000000..9d23315c --- /dev/null +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java @@ -0,0 +1,1306 @@ +/* + * 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 at.gv.egiz.smcc.PINSpec; +import at.gv.egiz.stal.HashDataInput; +import at.gv.egiz.stal.impl.ByteArrayHashDataInput; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.text.MessageFormat; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import javax.swing.CellRendererPane; +import javax.swing.GroupLayout; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.LayoutStyle; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author clemens + */ +public class BKUGUIImpl implements BKUGUIFacade { + + private static final Log log = LogFactory.getLog(BKUGUIImpl.class); + + protected HelpMouseListener helpListener; + + protected Container contentPane; + protected ResourceBundle messages; + /** left and right side main panels */ + protected JPanel iconPanel; + protected JPanel contentPanel; + /** right side content panels and layouts */ + protected JPanel headerPanel; + protected JPanel mainPanel; + protected JPanel buttonPanel; + /** right side fixed labels */ + protected JLabel titleLabel; + protected JLabel helpLabel; + /** remember the pinfield to return to worker */ + protected JPasswordField pinField; + + protected int buttonSize; + + /** gui style config (default 'simple') */ + protected boolean renderHeaderPanel = false; + protected boolean renderIconPanel = false; + protected boolean renderCancelButton = false; + + /** + * set contentPane + * init message bundle + * configure the style + * register the help listener + * create GUI (on event-dispatching thread) + * + * @param contentPane + * @param locale + * @param guiStyle + * @param background + * @param helpListener + */ + public BKUGUIImpl(Container contentPane, + Locale locale, + Style guiStyle, + URL background, + ActionListener helpListener) { + this.contentPane = contentPane; + + if (locale != null) { + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, locale); + } else { + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); + } + + if (guiStyle == Style.advanced) { + renderHeaderPanel = true; + renderIconPanel = false; + renderCancelButton = true; + } + + registerHelpListener(helpListener); + + createGUI(background); + } + + private void createGUI(final URL background) { + + try { + + log.debug("scheduling gui initialization"); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + + log.debug("initializing gui"); + + if (renderIconPanel) { + initIconPanel(background); + initContentPanel(null); + } else { + initContentPanel(background); + } + + GroupLayout layout = new GroupLayout(contentPane); + contentPane.setLayout(layout); + + if (renderIconPanel) { + layout.setHorizontalGroup(layout.createSequentialGroup() + .addComponent(iconPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(contentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(iconPanel, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(contentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + } else { + layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(contentPanel)); + layout.setVerticalGroup(layout.createSequentialGroup().addComponent(contentPanel)); + } + } + }); + } catch (Exception ex) { + throw new RuntimeException("Failed to init GUI: " + ex.getMessage()); + } + } + + protected void initIconPanel(URL background) { + if (background == null) { + background = getClass().getResource(DEFAULT_BACKGROUND); + } + if ("file".equals(background.getProtocol())) { + log.warn("file:// background images not permitted: " + background); + background = getClass().getResource(DEFAULT_BACKGROUND); + } + log.debug("loading icon panel background " + background); + + iconPanel = new JPanel(); + JLabel iconLabel = new JLabel(); + iconLabel.setIcon(new ImageIcon(background)); + + GroupLayout iconPanelLayout = new GroupLayout(iconPanel); + iconPanel.setLayout(iconPanelLayout); + iconPanelLayout.setHorizontalGroup( + iconPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + // no gap here (contentPanel has containerGap) + iconPanelLayout.setVerticalGroup( + iconPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + } + + protected void initContentPanel(URL background) { + + if (background == null) { + background = getClass().getResource(DEFAULT_BACKGROUND); + } + if ("file".equals(background.getProtocol())) { + log.warn("file:// background images not permitted: " + background); + background = getClass().getResource(DEFAULT_BACKGROUND); + } + log.debug("loading background " + background); + contentPanel = new ImagePanel(background); + + mainPanel = new JPanel(); + mainPanel.setOpaque(false); + buttonPanel = new JPanel(); + buttonPanel.setOpaque(false); + + helpLabel = new JLabel(); + helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG))); + helpLabel.getAccessibleContext().setAccessibleName(messages.getString(ALT_HELP)); + helpLabel.addMouseListener(helpListener); + helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + + buttonSize = initButtonSize(messages, renderCancelButton); + + if (renderHeaderPanel) { + headerPanel = new JPanel(); + headerPanel.setOpaque(false); + + titleLabel = new JLabel(); + titleLabel.setFont(titleLabel.getFont().deriveFont(titleLabel.getFont().getStyle() | + java.awt.Font.BOLD, titleLabel.getFont().getSize() + 2)); + + GroupLayout headerPanelLayout = new GroupLayout(headerPanel); + headerPanel.setLayout(headerPanelLayout); + + headerPanelLayout.setHorizontalGroup( + headerPanelLayout.createSequentialGroup() + .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel)); + headerPanelLayout.setVerticalGroup( + headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) + .addComponent(helpLabel)); + } + + GroupLayout contentPanelLayout = new GroupLayout(contentPanel); + contentPanel.setLayout(contentPanelLayout); + + GroupLayout.ParallelGroup horizontalContentInner = contentPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + if (renderHeaderPanel) { + horizontalContentInner + .addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + } + horizontalContentInner + .addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + GroupLayout.SequentialGroup horizontalContentOuter = contentPanelLayout.createSequentialGroup(); + if (!renderIconPanel) { + horizontalContentOuter + .addContainerGap(); + } + horizontalContentOuter + .addGroup(horizontalContentInner) + .addContainerGap(); + contentPanelLayout.setHorizontalGroup(horizontalContentOuter); + + GroupLayout.SequentialGroup verticalContent = contentPanelLayout.createSequentialGroup(); + verticalContent.addContainerGap(); + if (renderHeaderPanel) { + verticalContent.addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); + } + verticalContent.addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap(); + contentPanelLayout.setVerticalGroup(verticalContent); + } + + @Override + public Locale getLocale() { + return messages.getLocale(); + } + + @Override + public void showWelcomeDialog() { + + log.debug("scheduling welcome dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show welcome dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + helpListener.setHelpTopic(HELP_WELCOME); + + JLabel welcomeMsgLabel = new JLabel(); + welcomeMsgLabel.setFont(welcomeMsgLabel.getFont().deriveFont(welcomeMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_WELCOME)); + welcomeMsgLabel.setText(messages.getString(MESSAGE_WAIT)); + } else { + welcomeMsgLabel.setText(messages.getString(TITLE_WELCOME)); + } + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(welcomeMsgLabel); + GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(welcomeMsgLabel); + if (!renderHeaderPanel) { + messageHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + messageVertical + .addComponent(helpLabel); + } + + mainPanelLayout.setHorizontalGroup(messageHorizontal); + mainPanelLayout.setVerticalGroup(messageVertical); + + contentPanel.validate(); + + } + }); + } + + @Override + public void showInsertCardDialog(final ActionListener cancelListener, final String cancelCommand) { + + log.debug("scheduling insert card dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show insert card dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_INSERTCARD)); + } + + helpListener.setHelpTopic(HELP_INSERTCARD); + + JLabel insertCardMsgLabel = new JLabel(); + insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + insertCardMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(insertCardMsgLabel); + GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup() + .addComponent(insertCardMsgLabel); + + if (!renderHeaderPanel) { + messageHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + messageVertical + .addComponent(helpLabel); + } + + mainPanelLayout.setHorizontalGroup(messageHorizontal); + mainPanelLayout.setVerticalGroup(messageVertical); + + if (renderCancelButton) { + JButton cancelButton = new JButton(); + cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.addActionListener(cancelListener); + cancelButton.setActionCommand(cancelCommand); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + buttonPanelLayout.setHorizontalGroup( + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createSequentialGroup() + .addComponent(cancelButton)); + } + + contentPanel.validate(); + } + }); + } + + /** + * only difference to showInsertCard: title text: card not supported + * @param cancelListener + * @param cancelCommand + */ + @Override + public void showCardNotSupportedDialog(final ActionListener cancelListener, final String cancelCommand) { + + log.debug("scheduling card not supported dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show card not supported dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + JLabel insertCardMsgLabel = new JLabel(); + insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); + insertCardMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); + } else { + insertCardMsgLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); + } + + helpListener.setHelpTopic(HELP_CARDNOTSUPPORTED); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(insertCardMsgLabel); + GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(insertCardMsgLabel); + if (!renderHeaderPanel) { + messageHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + messageVertical + .addComponent(helpLabel); + } + + mainPanelLayout.setHorizontalGroup(messageHorizontal); + mainPanelLayout.setVerticalGroup(messageVertical); + + if (renderCancelButton) { + JButton cancelButton = new JButton(); + cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.addActionListener(cancelListener); + cancelButton.setActionCommand(cancelCommand); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + buttonPanelLayout.setHorizontalGroup( + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createSequentialGroup() + .addComponent(cancelButton)); + } + + contentPanel.validate(); + } + }); + } + + private void showCardPINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener okListener, final String okCommand, final ActionListener cancelListener, final String cancelCommand) { + + log.debug("scheduling card-pin dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show card-pin dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + if (numRetries < 0) { + String cardpinTitle = messages.getString(TITLE_CARDPIN); + titleLabel.setText(MessageFormat.format(cardpinTitle, new Object[]{pinSpec.getLocalizedName()})); + } else { + titleLabel.setText(messages.getString(TITLE_RETRY)); + } + } + + JButton okButton = new JButton(); + okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + okButton.setText(messages.getString(BUTTON_OK)); + okButton.setEnabled(false); + okButton.setActionCommand(okCommand); + okButton.addActionListener(okListener); + + JLabel cardPinLabel = new JLabel(); + cardPinLabel.setFont(cardPinLabel.getFont().deriveFont(cardPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + String pinLabel = messages.getString(LABEL_PIN); + cardPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); + + pinField = new JPasswordField(); + pinField.setText(""); + pinField.setDocument(new PINDocument(pinSpec, okButton)); + pinField.setActionCommand(okCommand); + pinField.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + if (pinField.getPassword().length >= pinSpec.getMinLength()) { + okListener.actionPerformed(e); + } + } + }); + + JLabel infoLabel = new JLabel(); + if (numRetries < 0) { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + String infoPattern = messages.getString(MESSAGE_ENTERPIN); + infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()})); + helpListener.setHelpTopic(HELP_CARDPIN); + } else { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); + infoLabel.setText(MessageFormat.format(messages.getString(MESSAGE_RETRIES), new Object[]{String.valueOf(numRetries)})); + infoLabel.setForeground(ERROR_COLOR); + helpListener.setHelpTopic(HELP_RETRY); + } + + JLabel pinsizeLabel = new JLabel(); + pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); + String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinSize = String.valueOf(pinSpec.getMinLength()); + if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { + pinSize += "-" + pinSpec.getMaxLength(); + } + pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + GroupLayout.SequentialGroup pinHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) //)) + .addComponent(pinsizeLabel)); + + GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); + + if (!renderHeaderPanel) { + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(infoLabel) //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + mainHorizontal + .addGroup(infoHorizontal) + .addGroup(pinHorizontal); + GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(infoLabel) + .addComponent(helpLabel); + mainVertical + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); + } else { + mainHorizontal + .addGroup(pinHorizontal); + } + + mainVertical + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(cardPinLabel) + .addComponent(pinField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel); + + mainPanelLayout.setHorizontalGroup(mainHorizontal); + mainPanelLayout.setVerticalGroup(mainVertical); + + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + GroupLayout.Group buttonVertical; + + if (renderCancelButton) { + JButton cancelButton = new JButton(); + cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setActionCommand(cancelCommand); + cancelButton.addActionListener(cancelListener); + + buttonHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(okButton) + .addComponent(cancelButton); + } else { + buttonVertical = buttonPanelLayout.createSequentialGroup() + .addComponent(okButton); + } + + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); + buttonPanelLayout.setVerticalGroup(buttonVertical); + + pinField.requestFocusInWindow(); + contentPanel.validate(); + + } + }); + } + + @Override + public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { + showCardPINDialog(pinSpec, -1, okListener, okCommand, cancelListener, cancelCommand); + } + + @Override + public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { + showCardPINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand); + } + + @Override + public void showSignaturePINDialog(PINSpec pinSpec, ActionListener signListener, String signCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand) { + showSignaturePINDialog(pinSpec, -1, signListener, signCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); + } + + @Override + public void showSignaturePINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand) { + showSignaturePINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); + } + + private void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener signListener, final String signCommand, final ActionListener cancelListener, final String cancelCommand, final ActionListener hashdataListener, final String hashdataCommand) { + + log.debug("scheduling signature-pin dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show signature-pin dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + if (numRetries < 0) { + titleLabel.setText(messages.getString(TITLE_SIGN)); + } else { + titleLabel.setText(messages.getString(TITLE_RETRY)); + } + } + + JButton signButton = new JButton(); + signButton.setFont(signButton.getFont().deriveFont(signButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + signButton.setText(messages.getString(BUTTON_SIGN)); + signButton.setEnabled(false); + signButton.setActionCommand(signCommand); + signButton.addActionListener(signListener); + + JLabel signPinLabel = new JLabel(); + signPinLabel.setFont(signPinLabel.getFont().deriveFont(signPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + String pinLabel = messages.getString(LABEL_PIN); + signPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); + + pinField = new JPasswordField(); + pinField.setText(""); + pinField.setDocument(new PINDocument(pinSpec, signButton)); + pinField.setActionCommand(signCommand); + pinField.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + if (pinField.getPassword().length >= pinSpec.getMinLength()) { + signListener.actionPerformed(e); + } + } + }); + + JLabel pinsizeLabel = new JLabel(); + pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); + String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinSize = String.valueOf(pinSpec.getMinLength()); + if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { + pinSize += "-" + pinSpec.getMaxLength(); + } + pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); + + JLabel infoLabel = new JLabel(); + if (numRetries < 0) { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK)); + infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + infoLabel.setForeground(HYPERLINK_COLOR); + infoLabel.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent me) { + ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e); + } + }); + helpListener.setHelpTopic(HELP_SIGNPIN); + } else { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); + infoLabel.setText(MessageFormat.format(messages.getString(MESSAGE_RETRIES), new Object[]{String.valueOf(numRetries)})); + infoLabel.setForeground(ERROR_COLOR); + helpListener.setHelpTopic(HELP_RETRY); + } + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(infoLabel); + GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(infoLabel); + + if (!renderHeaderPanel) { + infoHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + infoVertical + .addComponent(helpLabel); + } + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(infoHorizontal) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(pinsizeLabel)))); + + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(signPinLabel) + .addComponent(pinField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel)); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + GroupLayout.Group buttonVertical; + + if (renderCancelButton) { + JButton cancelButton = new JButton(); + cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setActionCommand(cancelCommand); + cancelButton.addActionListener(cancelListener); + + buttonHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + + buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(signButton) + .addComponent(cancelButton); + } else { + buttonVertical = buttonPanelLayout.createSequentialGroup() + .addComponent(signButton); + } + + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); + buttonPanelLayout.setVerticalGroup(buttonVertical); + + pinField.requestFocusInWindow(); + contentPanel.validate(); + + } + }); + } + + @Override + public void showErrorDialog(final String errorMsgKey, final Object[] errorMsgParams, final ActionListener okListener, final String okCommand) { + + log.debug("scheduling error dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show error dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_ERROR)); + } + + helpListener.setHelpTopic(errorMsgKey); + + String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); + + JLabel errorMsgLabel = new JLabel(); + errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + errorMsgLabel.setText(errorMsg); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); + + if (!renderHeaderPanel) { + JLabel errorTitleLabel = new JLabel(); + errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); + errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setForeground(ERROR_COLOR); + + mainHorizontal + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(errorTitleLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel)); + mainVertical + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorTitleLabel) + .addComponent(helpLabel)); + } + + mainPanelLayout.setHorizontalGroup(mainHorizontal + .addComponent(errorMsgLabel)); + mainPanelLayout.setVerticalGroup(mainVertical + .addComponent(errorMsgLabel)); + + JButton okButton = new JButton(); + okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + okButton.setText(messages.getString(BUTTON_OK)); + okButton.setActionCommand(okCommand); + okButton.addActionListener(okListener); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + buttonPanelLayout.setHorizontalGroup( + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createSequentialGroup() + .addComponent(okButton)); + + contentPanel.validate(); + } + }); + } + + @Override + public void showErrorDialog(final String errorMsgKey, final Object[] errorMsgParams) { + + log.debug("scheduling error dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show error dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_ERROR)); + } + + helpListener.setHelpTopic(errorMsgKey); + + String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); + + JLabel errorMsgLabel = new JLabel(); + errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + errorMsgLabel.setText(errorMsg); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + + GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); + + if (!renderHeaderPanel) { + JLabel errorTitleLabel = new JLabel(); + errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); + errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setForeground(ERROR_COLOR); + + mainHorizontal + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(errorTitleLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel)); + mainVertical + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(errorTitleLabel) + .addComponent(helpLabel)); + } + + mainPanelLayout.setHorizontalGroup(mainHorizontal + .addComponent(errorMsgLabel)); + mainPanelLayout.setVerticalGroup(mainVertical + .addComponent(errorMsgLabel)); + + contentPanel.validate(); + } + }); + } + + @Override + public void showWaitDialog(final String waitMessage) { + + log.debug("scheduling wait dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show wait dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_WAIT)); + } + + helpListener.setHelpTopic(HELP_WAIT); + + JLabel waitMsgLabel = new JLabel(); + waitMsgLabel.setFont(waitMsgLabel.getFont().deriveFont(waitMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + if (waitMessage != null) { + waitMsgLabel.setText("" + waitMessage + ""); + } else { + waitMsgLabel.setText(messages.getString(MESSAGE_WAIT)); + } + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(waitMsgLabel); + GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(waitMsgLabel); + + if (!renderHeaderPanel) { + messageHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + messageVertical + .addComponent(helpLabel); + } + mainPanelLayout.setHorizontalGroup(messageHorizontal); + mainPanelLayout.setVerticalGroup(messageVertical); + + contentPanel.validate(); + } + }); + } + + @Override + public char[] getPin() { + if (pinField != null) { + return pinField.getPassword(); + } + return null; + } + + /** + * TODO handle multiple references in HashDataViewer + * @param signedReferences + * @param okListener + * @param okCommand + */ + @Override + public void showHashDataInputDialog(final List signedReferences, + final ActionListener okListener, + final String okCommand) { + + if (signedReferences == null) { + showErrorDialog(messages.getString(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); + return; + } + + if (signedReferences.size() == 1) { + ActionListener saveHashDataListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + HashDataInput hdi = signedReferences.get(0); + showSaveHashDataInputDialog(Collections.singletonList(hdi), okListener, okCommand); + } + }; + showHashDataViewer(signedReferences.get(0), saveHashDataListener, "save"); + } else { + HashDataTableModel tableModel = new HashDataTableModel(signedReferences); + showSignedReferencesListDialog(tableModel, okListener, okCommand); + } + } + + /** + * Opens HashDataViewer on mouse clicked event + */ + public class HashDataMouseListener extends MouseAdapter { + + private HashDataInput hashData; + + public void setHashData(HashDataInput hashData) { + this.hashData = hashData; + } + + @Override + public void mouseClicked(MouseEvent e) { + ActionListener saveListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + showSaveHashDataInputDialog(Collections.singletonList(hashData), null, null); + } + }; + showHashDataViewer(hashData, saveListener, "save"); + super.mouseClicked(e); + } + + + + } + + /** + * blocks until dialog returns (is closed) + * @param hashDataText + * @param saveListener + * @param saveCommand + */ + private void showHashDataViewer(final HashDataInput hashDataInput, final ActionListener saveListener, final String saveCommand) { + + try { + log.debug("scheduling plaintext hashdatainput dialog"); + + // avoid double-clicks on hashdata link + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + + log.debug("show plaintext hashdatainput dialog"); + + ActionListener l = helpListener.getActionListener(); + HashDataViewer.showHashDataInput(contentPane, hashDataInput, messages, saveListener, saveCommand, l); + } + }); + + } catch (InterruptedException ex) { + log.error("Failed to display HashDataViewer: " + ex.getMessage()); + } catch (InvocationTargetException ex) { + log.error("Failed to display HashDataViewer: " + ex.getMessage()); + } + } + + private void showSignedReferencesListDialog(final HashDataTableModel signedReferences, final ActionListener backListener, final String backCommand) { + + log.debug("scheduling signed references list dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show signed references list dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + titleLabel.setText(messages.getString(TITLE_HASHDATA)); + } + + helpListener.setHelpTopic(HELP_HASHDATALIST); + + JLabel refIdLabel = new JLabel(); + refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST); + refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.getRowCount()})); + + JTable hashDataTable = new JTable(signedReferences); + hashDataTable.setDefaultRenderer(HashDataInput.class, signedReferences.getRenderer()); + + hashDataTable.setTableHeader(null); + // hashDataTable.setShowVerticalLines(false); + hashDataTable.setRowSelectionAllowed(true); +// TableColumn selectCol = hashDataTable.getColumnModel().getColumn(1); +// selectCol.setMinWidth(CHECKBOX_WIDTH); +// selectCol.setMaxWidth(CHECKBOX_WIDTH); + + +// hashDataTable.setPreferredScrollableViewportSize(mainPanel.getPreferredSize()); + + JScrollPane hashDataScrollPane = new JScrollPane(hashDataTable); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(refIdLabel); + + GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(refIdLabel); + + if (!renderHeaderPanel) { + messageHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + messageVertical + .addComponent(helpLabel); + } + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(messageHorizontal) + .addComponent(hashDataScrollPane, 0, 0, Short.MAX_VALUE)); + + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(messageVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(hashDataScrollPane, 0, 0, hashDataTable.getPreferredSize().height+3)); + + JButton backButton = new JButton(); + backButton.setFont(backButton.getFont().deriveFont(backButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + backButton.setText(messages.getString(BUTTON_BACK)); + backButton.setActionCommand(backCommand); + backButton.addActionListener(backListener); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + buttonPanelLayout.setHorizontalGroup(buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); + buttonPanelLayout.setVerticalGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(backButton)); + + contentPanel.validate(); + } + }); + } + + private void showSaveHashDataInputDialog(final List signedRefs, final ActionListener okListener, final String okCommand) { + + log.debug("scheduling save hashdatainput dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show save hashdatainput dialog"); + + String userHome = System.getProperty("user.home"); + + JFileChooser fileDialog = new JFileChooser(userHome); + fileDialog.setMultiSelectionEnabled(false); + fileDialog.setDialogType(JFileChooser.SAVE_DIALOG); + fileDialog.setFileHidingEnabled(true); + if (signedRefs.size() == 1) { + fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVE)); + fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY); + String mimeType = signedRefs.get(0).getMimeType(); + MimeFilter mimeFilter = new MimeFilter(mimeType, messages); + fileDialog.setFileFilter(mimeFilter); + String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); + fileDialog.setSelectedFile(new File(userHome, filename)); + } else { + fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVEDIR)); + fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + } + + //parent contentPane -> placed over applet + switch (fileDialog.showSaveDialog(fileDialog)) { + case JFileChooser.APPROVE_OPTION: + File f = fileDialog.getSelectedFile(); + for (HashDataInput hashDataInput : signedRefs) { + String mimeType = hashDataInput.getMimeType(); + String id = hashDataInput.getReferenceId(); + File file; + if (f.isDirectory()) { + String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); + file = new File(f, filename); + } else { + file = f; + } + if (file.exists()) { + String ovrwrt = messages.getString(MESSAGE_OVERWRITE); + int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), messages.getString(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); + if (overwrite != JOptionPane.OK_OPTION) { + continue; + } + } + if (log.isDebugEnabled()) { + log.debug("Writing HashDataInput " + id + " (" + mimeType + ") to file " + file); + } + FileOutputStream fos = null; + try { + fos = new FileOutputStream(file); + BufferedOutputStream bos = new BufferedOutputStream(fos); + InputStream hdi = hashDataInput.getHashDataInput(); + int b; + while ((b = hdi.read()) != -1) { + bos.write(b); + } + bos.flush(); + bos.close(); + } catch (IOException ex) { + log.error("Failed to write HashDataInput to file " + file + ": " + ex.getMessage()); + showErrorDialog(ERR_WRITE_HASHDATA, new Object[] {ex.getMessage()}, null, null); + ex.printStackTrace(); + } finally { + try { + fos.close(); + } catch (IOException ex) { + } + } + } + } + log.debug("done saving hashdatainput"); + if (okListener != null) { + okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand)); + } + } + }); + } + + private void registerHelpListener(ActionListener helpListener) { + if (helpListener != null) { + this.helpListener = new HelpMouseListener(helpListener); + } else { + log.error("no help listener provided, will not be able to display help"); + this.helpListener = new HelpMouseListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + log.error("no help listener registered (requested help topic: " + e.getActionCommand() + ")"); + } + }); + } + } + + private static int initButtonSize(ResourceBundle messages, boolean renderCancelButton) { + + int buttonSize = 0; + + JButton b = new JButton(); + b.setText(messages.getString(BUTTON_OK)); + if (b.getPreferredSize().width > buttonSize) { + buttonSize = b.getPreferredSize().width; + } + b.setText(messages.getString(BUTTON_SIGN)); + if (b.getPreferredSize().width > buttonSize) { + buttonSize = b.getPreferredSize().width; + } + b.setText(messages.getString(BUTTON_BACK)); + if (b.getPreferredSize().width > buttonSize) { + buttonSize = b.getPreferredSize().width; + } + b.setText(messages.getString(BUTTON_SAVE)); + if (b.getPreferredSize().width > buttonSize) { + buttonSize = b.getPreferredSize().width; + } + if (renderCancelButton) { + b.setText(messages.getString(BUTTON_CANCEL)); + if (b.getPreferredSize().width > buttonSize) { + buttonSize = b.getPreferredSize().width; + } + } + return buttonSize; + } +} -- cgit v1.2.3 From bc81c317e254fa617fc24c8129b743ac74aad470 Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 19 Nov 2008 11:49:55 +0000 Subject: GUI feature complete git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@180 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 158 ++++++++++++--------- 1 file changed, 92 insertions(+), 66 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 9d23315c..38247174 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 @@ -38,6 +38,8 @@ import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.CellRendererPane; import javax.swing.GroupLayout; import javax.swing.ImageIcon; @@ -50,8 +52,12 @@ import javax.swing.JPasswordField; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.LayoutStyle; +import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -1013,80 +1019,75 @@ public class BKUGUIImpl implements BKUGUIFacade { } if (signedReferences.size() == 1) { - ActionListener saveHashDataListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - HashDataInput hdi = signedReferences.get(0); - showSaveHashDataInputDialog(Collections.singletonList(hdi), okListener, okCommand); - } - }; - showHashDataViewer(signedReferences.get(0), saveHashDataListener, "save"); + try { + log.debug("scheduling hashdata viewer"); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + ActionListener saveHashDataListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + HashDataInput hdi = signedReferences.get(0); + showSaveHashDataInputDialog(Collections.singletonList(hdi), okListener, okCommand); + } + }; + showHashDataViewer(signedReferences.get(0), saveHashDataListener, "save"); + } + }); + + } catch (InterruptedException ex) { + log.error("Failed to display HashDataViewer: " + ex.getMessage()); + } catch (InvocationTargetException ex) { + log.error("Failed to display HashDataViewer: " + ex.getMessage()); + } } else { - HashDataTableModel tableModel = new HashDataTableModel(signedReferences); - showSignedReferencesListDialog(tableModel, okListener, okCommand); + showSignedReferencesListDialog(signedReferences, okListener, okCommand); } } /** * Opens HashDataViewer on mouse clicked event */ - public class HashDataMouseListener extends MouseAdapter { - - private HashDataInput hashData; - - public void setHashData(HashDataInput hashData) { - this.hashData = hashData; - } - - @Override - public void mouseClicked(MouseEvent e) { - ActionListener saveListener = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - showSaveHashDataInputDialog(Collections.singletonList(hashData), null, null); - } - }; - showHashDataViewer(hashData, saveListener, "save"); - super.mouseClicked(e); - } - - - - } +// public class HashDataMouseListener extends MouseAdapter { +// +// private HashDataInput hashData; +// +// public void setHashData(HashDataInput hashData) { +// this.hashData = hashData; +// } +// +// @Override +// public void mouseClicked(MouseEvent e) { +// ActionListener saveListener = new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// showSaveHashDataInputDialog(Collections.singletonList(hashData), null, null); +// } +// }; +// showHashDataViewer(hashData, saveListener, "save"); +// super.mouseClicked(e); +// } +// } /** - * blocks until dialog returns (is closed) + * has to be called from event dispatcher thread * @param hashDataText * @param saveListener * @param saveCommand */ private void showHashDataViewer(final HashDataInput hashDataInput, final ActionListener saveListener, final String saveCommand) { - try { - log.debug("scheduling plaintext hashdatainput dialog"); - - // avoid double-clicks on hashdata link - SwingUtilities.invokeAndWait(new Runnable() { - - @Override - public void run() { - - log.debug("show plaintext hashdatainput dialog"); + log.debug("show hashdata viewer"); - ActionListener l = helpListener.getActionListener(); - HashDataViewer.showHashDataInput(contentPane, hashDataInput, messages, saveListener, saveCommand, l); - } - }); - - } catch (InterruptedException ex) { - log.error("Failed to display HashDataViewer: " + ex.getMessage()); - } catch (InvocationTargetException ex) { - log.error("Failed to display HashDataViewer: " + ex.getMessage()); - } + ActionListener l = helpListener.getActionListener(); + HashDataViewer.showHashDataInput(contentPane, hashDataInput, messages, saveListener, saveCommand, l); } - private void showSignedReferencesListDialog(final HashDataTableModel signedReferences, final ActionListener backListener, final String backCommand) { + private void showSignedReferencesListDialog(final List signedReferences, final ActionListener backListener, final String backCommand) { log.debug("scheduling signed references list dialog"); @@ -1109,21 +1110,40 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel refIdLabel = new JLabel(); refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST); - refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.getRowCount()})); + refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()})); - JTable hashDataTable = new JTable(signedReferences); - hashDataTable.setDefaultRenderer(HashDataInput.class, signedReferences.getRenderer()); - + HashDataTableModel tableModel = new HashDataTableModel(signedReferences); + JTable hashDataTable = new JTable(tableModel); +// hashDataTable.setDefaultRenderer(HashDataInput.class, signedReferences.getRenderer()); hashDataTable.setTableHeader(null); - // hashDataTable.setShowVerticalLines(false); - hashDataTable.setRowSelectionAllowed(true); -// TableColumn selectCol = hashDataTable.getColumnModel().getColumn(1); -// selectCol.setMinWidth(CHECKBOX_WIDTH); -// selectCol.setMaxWidth(CHECKBOX_WIDTH); + + hashDataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + hashDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(final ListSelectionEvent e) { + //invoke later to allow thread to paint selection background + SwingUtilities.invokeLater(new Runnable() { -// hashDataTable.setPreferredScrollableViewportSize(mainPanel.getPreferredSize()); + @Override + public void run() { + ListSelectionModel lsm = (ListSelectionModel) e.getSource(); + int selectionIdx = lsm.getMinSelectionIndex(); + if (selectionIdx >= 0) { + final HashDataInput selection = signedReferences.get(selectionIdx); + showHashDataViewer(selection, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showSaveHashDataInputDialog(Collections.singletonList(selection), null, null); + } + }, "save"); + } + } + }); + } + }); + JScrollPane hashDataScrollPane = new JScrollPane(hashDataTable); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); @@ -1174,6 +1194,12 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } + /** + * + * @param signedRefs + * @param okListener may be null + * @param okCommand + */ private void showSaveHashDataInputDialog(final List signedRefs, final ActionListener okListener, final String okCommand) { log.debug("scheduling save hashdatainput dialog"); -- cgit v1.2.3 From d8901c075f9deb663e0edd640672ed620ffb4610 Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 19 Nov 2008 16:14:57 +0000 Subject: GUI bugfixes and cleanup git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@181 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 103 +++++++++------------ 1 file changed, 43 insertions(+), 60 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 38247174..a190b9c0 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 @@ -26,6 +26,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -554,44 +556,37 @@ public class BKUGUIImpl implements BKUGUIFacade { GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); - GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); - GroupLayout.SequentialGroup pinHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) //)) - .addComponent(pinsizeLabel)); - - GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(infoLabel); + GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(infoLabel); if (!renderHeaderPanel) { - GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(infoLabel) //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + infoHorizontal .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - mainHorizontal - .addGroup(infoHorizontal) - .addGroup(pinHorizontal); - GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(infoLabel) .addComponent(helpLabel); - mainVertical - .addGroup(infoVertical) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); - } else { - mainHorizontal - .addGroup(pinHorizontal); - } - - mainVertical - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(cardPinLabel) - .addComponent(pinField)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(pinsizeLabel); + infoVertical + .addComponent(helpLabel); + } - mainPanelLayout.setHorizontalGroup(mainHorizontal); - mainPanelLayout.setVerticalGroup(mainVertical); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(infoHorizontal) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) //)) + .addComponent(pinsizeLabel)))); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(cardPinLabel) + .addComponent(pinField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel)); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); @@ -1048,31 +1043,6 @@ public class BKUGUIImpl implements BKUGUIFacade { } } - /** - * Opens HashDataViewer on mouse clicked event - */ -// public class HashDataMouseListener extends MouseAdapter { -// -// private HashDataInput hashData; -// -// public void setHashData(HashDataInput hashData) { -// this.hashData = hashData; -// } -// -// @Override -// public void mouseClicked(MouseEvent e) { -// ActionListener saveListener = new ActionListener() { -// -// @Override -// public void actionPerformed(ActionEvent e) { -// showSaveHashDataInputDialog(Collections.singletonList(hashData), null, null); -// } -// }; -// showHashDataViewer(hashData, saveListener, "save"); -// super.mouseClicked(e); -// } -// } - /** * has to be called from event dispatcher thread * @param hashDataText @@ -1113,10 +1083,23 @@ public class BKUGUIImpl implements BKUGUIFacade { refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()})); HashDataTableModel tableModel = new HashDataTableModel(signedReferences); - JTable hashDataTable = new JTable(tableModel); -// hashDataTable.setDefaultRenderer(HashDataInput.class, signedReferences.getRenderer()); + final JTable hashDataTable = new JTable(tableModel); + hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer()); hashDataTable.setTableHeader(null); + // not possible to add mouse listener to TableCellRenderer + hashDataTable.addMouseMotionListener(new MouseMotionAdapter() { + + @Override + public void mouseMoved(MouseEvent e) { + if (hashDataTable.columnAtPoint(e.getPoint()) == 0) { + hashDataTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } else { + hashDataTable.setCursor(Cursor.getDefaultCursor()); + } + } + }); + hashDataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); hashDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { -- cgit v1.2.3 From b93f035e2c9df0ad430300c4f755b775a4aa1ed3 Mon Sep 17 00:00:00 2001 From: clemenso Date: Mon, 24 Nov 2008 13:37:11 +0000 Subject: xhtml warning git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@192 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 a190b9c0..c786a291 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 @@ -208,13 +208,16 @@ public class BKUGUIImpl implements BKUGUIFacade { if (background == null) { background = getClass().getResource(DEFAULT_BACKGROUND); } - if ("file".equals(background.getProtocol())) { - log.warn("file:// background images not permitted: " + background); - background = getClass().getResource(DEFAULT_BACKGROUND); + if (background == null) { + contentPanel = new JPanel(); + } else { + if ("file".equals(background.getProtocol())) { + log.warn("file:// background images not permitted: " + background); + background = getClass().getResource(DEFAULT_BACKGROUND); + } + log.debug("loading background " + background); + contentPanel = new ImagePanel(background); } - log.debug("loading background " + background); - contentPanel = new ImagePanel(background); - mainPanel = new JPanel(); mainPanel.setOpaque(false); buttonPanel = new JPanel(); -- cgit v1.2.3 From 959130f29903568c6b7fe3d6538b33887b3b1aaf Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 27 Nov 2008 15:22:32 +0000 Subject: help viewer label removed git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@221 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 c786a291..d61c9a03 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 @@ -58,9 +58,6 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -117,7 +114,9 @@ public class BKUGUIImpl implements BKUGUIFacade { this.contentPane = contentPane; if (locale != null) { - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, locale); + Locale lang = new Locale(locale.getLanguage().substring(0,2)); + log.debug("loading applet resources for language: " + lang.toString()); + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); } else { messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); } -- cgit v1.2.3 From 9ef5d25ffec1c26ccf76ad46131e33a861335da1 Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 23 Jan 2009 13:45:39 +0000 Subject: tiny applet git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@286 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 140 ++++++++++++++++----- 1 file changed, 106 insertions(+), 34 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 d61c9a03..1e63c8d7 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 @@ -53,6 +53,7 @@ import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.JTextField; import javax.swing.LayoutStyle; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; @@ -69,6 +70,10 @@ public class BKUGUIImpl implements BKUGUIFacade { private static final Log log = LogFactory.getLog(BKUGUIImpl.class); + protected enum PinLabelPosition { + LEFT, ABOVE + } + protected HelpMouseListener helpListener; protected Container contentPane; @@ -92,6 +97,9 @@ public class BKUGUIImpl implements BKUGUIFacade { protected boolean renderHeaderPanel = false; protected boolean renderIconPanel = false; protected boolean renderCancelButton = false; + protected boolean shortText = false; + protected PinLabelPosition pinLabelPos = PinLabelPosition.LEFT; + protected boolean renderRefId = false; /** * set contentPane @@ -125,6 +133,10 @@ public class BKUGUIImpl implements BKUGUIFacade { renderHeaderPanel = true; renderIconPanel = false; renderCancelButton = true; + renderRefId = true; + } else if (guiStyle == Style.tiny) { + shortText = true; + pinLabelPos = PinLabelPosition.ABOVE; } registerHelpListener(helpListener); @@ -537,11 +549,21 @@ public class BKUGUIImpl implements BKUGUIFacade { if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); String infoPattern = messages.getString(MESSAGE_ENTERPIN); - infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()})); + if (shortText) { + infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {"PIN"})); + } else { + infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()})); + } helpListener.setHelpTopic(HELP_CARDPIN); } else { + String retryPattern; + if (numRetries < 2) { + retryPattern = messages.getString(MESSAGE_LAST_RETRY); + } else { + retryPattern = messages.getString(MESSAGE_RETRIES); + } infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); - infoLabel.setText(MessageFormat.format(messages.getString(MESSAGE_RETRIES), new Object[]{String.valueOf(numRetries)})); + infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setForeground(ERROR_COLOR); helpListener.setHelpTopic(HELP_RETRY); } @@ -570,27 +592,47 @@ public class BKUGUIImpl implements BKUGUIFacade { infoVertical .addComponent(helpLabel); } - - mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(infoHorizontal) + + GroupLayout.Group pinHorizontal; + GroupLayout.Group pinVertical; + + if (pinLabelPos == PinLabelPosition.ABOVE) { + pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(mainPanelLayout.createSequentialGroup() - .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) //)) - .addComponent(pinsizeLabel)))); - mainPanelLayout.setVerticalGroup( - mainPanelLayout.createSequentialGroup() - .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + pinVertical = mainPanelLayout.createSequentialGroup() + .addComponent(cardPinLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(cardPinLabel) - .addComponent(pinField)) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + } else { + pinHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(pinsizeLabel)); - - + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(pinsizeLabel)); + pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(cardPinLabel) + .addComponent(pinField); + } + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(infoHorizontal) + .addGroup(pinHorizontal)); + + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pinVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel)); + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); @@ -707,7 +749,11 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel infoLabel = new JLabel(); if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK)); + if (shortText) { + infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK)); + } infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(HYPERLINK_COLOR); infoLabel.addMouseListener(new MouseAdapter() { @@ -720,8 +766,14 @@ public class BKUGUIImpl implements BKUGUIFacade { }); helpListener.setHelpTopic(HELP_SIGNPIN); } else { + String retryPattern; + if (numRetries < 2) { + retryPattern = messages.getString(MESSAGE_LAST_RETRY); + } else { + retryPattern = messages.getString(MESSAGE_RETRIES); + } + infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); - infoLabel.setText(MessageFormat.format(messages.getString(MESSAGE_RETRIES), new Object[]{String.valueOf(numRetries)})); infoLabel.setForeground(ERROR_COLOR); helpListener.setHelpTopic(HELP_RETRY); } @@ -737,28 +789,48 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { infoHorizontal .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); //, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + .addComponent(helpLabel); infoVertical .addComponent(helpLabel); } + GroupLayout.Group pinHorizontal; + GroupLayout.Group pinVertical; + + if (pinLabelPos == PinLabelPosition.ABOVE) { + pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(mainPanelLayout.createSequentialGroup() + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + + pinVertical = mainPanelLayout.createSequentialGroup() + .addComponent(signPinLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + } else { + pinHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(pinsizeLabel)); + pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(signPinLabel) + .addComponent(pinField); + } + mainPanelLayout.setHorizontalGroup( mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(infoHorizontal) - .addGroup(mainPanelLayout.createSequentialGroup() - .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(pinsizeLabel)))); + .addGroup(pinHorizontal)); mainPanelLayout.setVerticalGroup( mainPanelLayout.createSequentialGroup() .addGroup(infoVertical) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(signPinLabel) - .addComponent(pinField)) + .addGroup(pinVertical) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(pinsizeLabel)); @@ -1084,9 +1156,9 @@ public class BKUGUIImpl implements BKUGUIFacade { String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST); refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()})); - HashDataTableModel tableModel = new HashDataTableModel(signedReferences); + HashDataTableModel tableModel = new HashDataTableModel(signedReferences, renderRefId); final JTable hashDataTable = new JTable(tableModel); - hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer()); + hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer(renderRefId)); hashDataTable.setTableHeader(null); // not possible to add mouse listener to TableCellRenderer -- cgit v1.2.3 From ff9a71fe2a2beb94ad7aa52ba2c77a24dd39509e Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 11 Feb 2009 20:04:58 +0000 Subject: removed BKUGUIFactory git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@297 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 1e63c8d7..f564c07a 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 @@ -19,14 +19,12 @@ package at.gv.egiz.bku.gui; import at.gv.egiz.smcc.PINSpec; import at.gv.egiz.stal.HashDataInput; -import at.gv.egiz.stal.impl.ByteArrayHashDataInput; import java.awt.Container; import java.awt.Cursor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.awt.event.MouseMotionAdapter; import java.io.BufferedOutputStream; import java.io.File; @@ -68,7 +66,7 @@ import org.apache.commons.logging.LogFactory; */ public class BKUGUIImpl implements BKUGUIFacade { - private static final Log log = LogFactory.getLog(BKUGUIImpl.class); + protected static final Log log = LogFactory.getLog(BKUGUIImpl.class); protected enum PinLabelPosition { LEFT, ABOVE -- cgit v1.2.3 From 6576428966f1e3d688269a407b072fb01f9f7647 Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 26 Feb 2009 19:39:00 +0000 Subject: 1.1 candidate (activation) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@309 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 f564c07a..1d5a2cf4 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 @@ -38,9 +38,6 @@ import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.CellRendererPane; import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -51,7 +48,6 @@ import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; import javax.swing.JTable; -import javax.swing.JTextField; import javax.swing.LayoutStyle; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; @@ -1064,7 +1060,9 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public char[] getPin() { if (pinField != null) { - return pinField.getPassword(); + char[] pin = pinField.getPassword(); + pinField = null; + return pin; } return null; } -- cgit v1.2.3 From 4387153c6f65b55d576e1890c5b582237227369e Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 27 Feb 2009 18:10:57 +0000 Subject: 1.1-rc2 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@310 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 198 ++++++++++++--------- 1 file changed, 115 insertions(+), 83 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 1d5a2cf4..ca597701 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 @@ -115,13 +115,7 @@ public class BKUGUIImpl implements BKUGUIFacade { ActionListener helpListener) { this.contentPane = contentPane; - if (locale != null) { - Locale lang = new Locale(locale.getLanguage().substring(0,2)); - log.debug("loading applet resources for language: " + lang.toString()); - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); - } else { - messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); - } + loadMessageBundle(locale); if (guiStyle == Style.advanced) { renderHeaderPanel = true; @@ -230,11 +224,11 @@ public class BKUGUIImpl implements BKUGUIFacade { helpLabel = new JLabel(); helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG))); - helpLabel.getAccessibleContext().setAccessibleName(messages.getString(ALT_HELP)); + helpLabel.getAccessibleContext().setAccessibleName(getMessage(ALT_HELP)); helpLabel.addMouseListener(helpListener); helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - buttonSize = initButtonSize(messages, renderCancelButton); + buttonSize = initButtonSize(); if (renderHeaderPanel) { headerPanel = new JPanel(); @@ -292,11 +286,33 @@ public class BKUGUIImpl implements BKUGUIFacade { contentPanelLayout.setVerticalGroup(verticalContent); } + /** + * BKUWorker inits signaturecard with locale + * @return + */ @Override public Locale getLocale() { return messages.getLocale(); } + /** + * to be overridden by subclasses providing additional resource messages + * @param key + * @return + */ + protected String getMessage(String key) { + return messages.getString(key); + } + + /** + * to be overridden by subclasses providing additional resource messages + * @param key + * @return + */ + protected boolean hasMessage(String key) { + return messages.containsKey(key); + } + @Override public void showWelcomeDialog() { @@ -318,10 +334,10 @@ public class BKUGUIImpl implements BKUGUIFacade { welcomeMsgLabel.setFont(welcomeMsgLabel.getFont().deriveFont(welcomeMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_WELCOME)); - welcomeMsgLabel.setText(messages.getString(MESSAGE_WAIT)); + titleLabel.setText(getMessage(TITLE_WELCOME)); + welcomeMsgLabel.setText(getMessage(MESSAGE_WAIT)); } else { - welcomeMsgLabel.setText(messages.getString(TITLE_WELCOME)); + welcomeMsgLabel.setText(getMessage(TITLE_WELCOME)); } GroupLayout mainPanelLayout = new GroupLayout(mainPanel); @@ -364,14 +380,14 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_INSERTCARD)); + titleLabel.setText(getMessage(TITLE_INSERTCARD)); } helpListener.setHelpTopic(HELP_INSERTCARD); JLabel insertCardMsgLabel = new JLabel(); insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - insertCardMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); + insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); @@ -395,7 +411,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.addActionListener(cancelListener); cancelButton.setActionCommand(cancelCommand); @@ -440,10 +456,10 @@ public class BKUGUIImpl implements BKUGUIFacade { insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); - insertCardMsgLabel.setText(messages.getString(MESSAGE_INSERTCARD)); + titleLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); + insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); } else { - insertCardMsgLabel.setText(messages.getString(TITLE_CARD_NOT_SUPPORTED)); + insertCardMsgLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); } helpListener.setHelpTopic(HELP_CARDNOTSUPPORTED); @@ -469,7 +485,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.addActionListener(cancelListener); cancelButton.setActionCommand(cancelCommand); @@ -506,23 +522,23 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderHeaderPanel) { if (numRetries < 0) { - String cardpinTitle = messages.getString(TITLE_CARDPIN); + String cardpinTitle = getMessage(TITLE_CARDPIN); titleLabel.setText(MessageFormat.format(cardpinTitle, new Object[]{pinSpec.getLocalizedName()})); } else { - titleLabel.setText(messages.getString(TITLE_RETRY)); + titleLabel.setText(getMessage(TITLE_RETRY)); } } JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(messages.getString(BUTTON_OK)); + okButton.setText(getMessage(BUTTON_OK)); okButton.setEnabled(false); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); JLabel cardPinLabel = new JLabel(); cardPinLabel.setFont(cardPinLabel.getFont().deriveFont(cardPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String pinLabel = messages.getString(LABEL_PIN); + String pinLabel = getMessage(LABEL_PIN); cardPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); pinField = new JPasswordField(); @@ -542,7 +558,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel infoLabel = new JLabel(); if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String infoPattern = messages.getString(MESSAGE_ENTERPIN); + String infoPattern = getMessage(MESSAGE_ENTERPIN); if (shortText) { infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {"PIN"})); } else { @@ -552,9 +568,9 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { String retryPattern; if (numRetries < 2) { - retryPattern = messages.getString(MESSAGE_LAST_RETRY); + retryPattern = getMessage(MESSAGE_LAST_RETRY); } else { - retryPattern = messages.getString(MESSAGE_RETRIES); + retryPattern = getMessage(MESSAGE_RETRIES); } infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); @@ -564,7 +580,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinsizePattern = getMessage(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { pinSize += "-" + pinSpec.getMaxLength(); @@ -638,7 +654,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); @@ -699,22 +715,22 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderHeaderPanel) { if (numRetries < 0) { - titleLabel.setText(messages.getString(TITLE_SIGN)); + titleLabel.setText(getMessage(TITLE_SIGN)); } else { - titleLabel.setText(messages.getString(TITLE_RETRY)); + titleLabel.setText(getMessage(TITLE_RETRY)); } } JButton signButton = new JButton(); signButton.setFont(signButton.getFont().deriveFont(signButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - signButton.setText(messages.getString(BUTTON_SIGN)); + signButton.setText(getMessage(BUTTON_SIGN)); signButton.setEnabled(false); signButton.setActionCommand(signCommand); signButton.addActionListener(signListener); JLabel signPinLabel = new JLabel(); signPinLabel.setFont(signPinLabel.getFont().deriveFont(signPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String pinLabel = messages.getString(LABEL_PIN); + String pinLabel = getMessage(LABEL_PIN); signPinLabel.setText(MessageFormat.format(pinLabel, new Object[]{pinSpec.getLocalizedName()})); pinField = new JPasswordField(); @@ -733,7 +749,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = messages.getString(LABEL_PINSIZE); + String pinsizePattern = getMessage(LABEL_PINSIZE); String pinSize = String.valueOf(pinSpec.getMinLength()); if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { pinSize += "-" + pinSpec.getMaxLength(); @@ -744,9 +760,9 @@ public class BKUGUIImpl implements BKUGUIFacade { if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (shortText) { - infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK_TINY)); + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); } else { - infoLabel.setText(messages.getString(MESSAGE_HASHDATALINK)); + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); } infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(HYPERLINK_COLOR); @@ -762,9 +778,9 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { String retryPattern; if (numRetries < 2) { - retryPattern = messages.getString(MESSAGE_LAST_RETRY); + retryPattern = getMessage(MESSAGE_LAST_RETRY); } else { - retryPattern = messages.getString(MESSAGE_RETRIES); + retryPattern = getMessage(MESSAGE_RETRIES); } infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); @@ -839,7 +855,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(messages.getString(BUTTON_CANCEL)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); cancelButton.setActionCommand(cancelCommand); cancelButton.addActionListener(cancelListener); @@ -881,12 +897,12 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_ERROR)); + titleLabel.setText(getMessage(TITLE_ERROR)); } helpListener.setHelpTopic(errorMsgKey); - String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsgPattern = getMessage(errorMsgKey); String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); JLabel errorMsgLabel = new JLabel(); @@ -902,7 +918,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { JLabel errorTitleLabel = new JLabel(); errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setText(getMessage(TITLE_ERROR)); errorTitleLabel.setForeground(ERROR_COLOR); mainHorizontal @@ -923,7 +939,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(messages.getString(BUTTON_OK)); + okButton.setText(getMessage(BUTTON_OK)); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); @@ -959,12 +975,12 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_ERROR)); + titleLabel.setText(getMessage(TITLE_ERROR)); } helpListener.setHelpTopic(errorMsgKey); - String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsgPattern = getMessage(errorMsgKey); String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); JLabel errorMsgLabel = new JLabel(); @@ -981,7 +997,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { JLabel errorTitleLabel = new JLabel(); errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(messages.getString(TITLE_ERROR)); + errorTitleLabel.setText(getMessage(TITLE_ERROR)); errorTitleLabel.setForeground(ERROR_COLOR); mainHorizontal @@ -1021,7 +1037,7 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_WAIT)); + titleLabel.setText(getMessage(TITLE_WAIT)); } helpListener.setHelpTopic(HELP_WAIT); @@ -1031,7 +1047,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (waitMessage != null) { waitMsgLabel.setText("" + waitMessage + ""); } else { - waitMsgLabel.setText(messages.getString(MESSAGE_WAIT)); + waitMsgLabel.setText(getMessage(MESSAGE_WAIT)); } GroupLayout mainPanelLayout = new GroupLayout(mainPanel); @@ -1079,7 +1095,7 @@ public class BKUGUIImpl implements BKUGUIFacade { final String okCommand) { if (signedReferences == null) { - showErrorDialog(messages.getString(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); + showErrorDialog(getMessage(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); return; } @@ -1142,14 +1158,14 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(messages.getString(TITLE_HASHDATA)); + titleLabel.setText(getMessage(TITLE_HASHDATA)); } helpListener.setHelpTopic(HELP_HASHDATALIST); JLabel refIdLabel = new JLabel(); refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - String refIdLabelPattern = messages.getString(MESSAGE_HASHDATALIST); + String refIdLabelPattern = getMessage(MESSAGE_HASHDATALIST); refIdLabel.setText(MessageFormat.format(refIdLabelPattern, new Object[]{signedReferences.size()})); HashDataTableModel tableModel = new HashDataTableModel(signedReferences, renderRefId); @@ -1229,7 +1245,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JButton backButton = new JButton(); backButton.setFont(backButton.getFont().deriveFont(backButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - backButton.setText(messages.getString(BUTTON_BACK)); + backButton.setText(getMessage(BUTTON_BACK)); backButton.setActionCommand(backCommand); backButton.addActionListener(backListener); @@ -1271,15 +1287,15 @@ public class BKUGUIImpl implements BKUGUIFacade { fileDialog.setDialogType(JFileChooser.SAVE_DIALOG); fileDialog.setFileHidingEnabled(true); if (signedRefs.size() == 1) { - fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVE)); + fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVE)); fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY); String mimeType = signedRefs.get(0).getMimeType(); MimeFilter mimeFilter = new MimeFilter(mimeType, messages); fileDialog.setFileFilter(mimeFilter); - String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); + String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); fileDialog.setSelectedFile(new File(userHome, filename)); } else { - fileDialog.setDialogTitle(messages.getString(WINDOWTITLE_SAVEDIR)); + fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVEDIR)); fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } @@ -1292,14 +1308,14 @@ public class BKUGUIImpl implements BKUGUIFacade { String id = hashDataInput.getReferenceId(); File file; if (f.isDirectory()) { - String filename = messages.getString(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); + String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); file = new File(f, filename); } else { file = f; } if (file.exists()) { - String ovrwrt = messages.getString(MESSAGE_OVERWRITE); - int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), messages.getString(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); + String ovrwrt = getMessage(MESSAGE_OVERWRITE); + int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), getMessage(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); if (overwrite != JOptionPane.OK_OPTION) { continue; } @@ -1352,34 +1368,50 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } } - - private static int initButtonSize(ResourceBundle messages, boolean renderCancelButton) { - int buttonSize = 0; - - JButton b = new JButton(); - b.setText(messages.getString(BUTTON_OK)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; - } - b.setText(messages.getString(BUTTON_SIGN)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; - } - b.setText(messages.getString(BUTTON_BACK)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; - } - b.setText(messages.getString(BUTTON_SAVE)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; + /** + * Called from constructor. + * Subclasses may override this method to ensure the message bundle is loaded + * once initButtonSize (called from constructor as well) is called. + * (Only relevant if initButtonSize is overridden as well) + * @param locale + */ + protected void loadMessageBundle(Locale locale) { + if (locale != null) { + Locale lang = new Locale(locale.getLanguage().substring(0, 2)); + log.debug("loading applet resources for language: " + lang.toString()); + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); + } else { + messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); + } } - if (renderCancelButton) { - b.setText(messages.getString(BUTTON_CANCEL)); - if (b.getPreferredSize().width > buttonSize) { - buttonSize = b.getPreferredSize().width; + + protected int initButtonSize() { + int bs = 0; + + JButton b = new JButton(); + b.setText(getMessage(BUTTON_OK)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_SIGN)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_BACK)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + b.setText(getMessage(BUTTON_SAVE)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } + if (renderCancelButton) { + b.setText(getMessage(BUTTON_CANCEL)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } } + return bs; } - return buttonSize; - } } -- cgit v1.2.3 From a8690cc956924e1d83b0c45d21995ee2e10fbba2 Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 4 Mar 2009 16:44:34 +0000 Subject: 1.1-rc3 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@311 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 177 +++++++++------------ 1 file changed, 75 insertions(+), 102 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 ca597701..d6c96627 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 @@ -19,8 +19,10 @@ package at.gv.egiz.bku.gui; import at.gv.egiz.smcc.PINSpec; import at.gv.egiz.stal.HashDataInput; +import java.awt.Color; import java.awt.Container; import java.awt.Cursor; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -882,145 +884,116 @@ public class BKUGUIImpl implements BKUGUIFacade { } @Override - public void showErrorDialog(final String errorMsgKey, final Object[] errorMsgParams, final ActionListener okListener, final String okCommand) { + public void showErrorDialog( + final String errorMsgKey, final Object[] errorMsgParams, + final ActionListener okListener, final String okCommand) { - log.debug("scheduling error dialog"); - + showMessageDialog(TITLE_ERROR, ERROR_COLOR, + errorMsgKey, errorMsgParams, okListener, okCommand); + } + + @Override + public void showErrorDialog( + final String errorMsgKey, final Object[] errorMsgParams) { + + showMessageDialog(TITLE_ERROR, ERROR_COLOR, + errorMsgKey, errorMsgParams, null, null); + } + + @Override + public void showMessageDialog( + final String titleKey, + final String msgKey, final Object[] msgParams, + final ActionListener okListener, final String okCommand) { + + showMessageDialog(titleKey, null, + msgKey, msgParams, okListener, okCommand); + } + + private void showMessageDialog( + final String titleKey, final Color titleColor, + final String msgKey, final Object[] msgParams, + final ActionListener okListener, final String okCommand) { + + log.debug("scheduling message dialog"); + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - log.debug("show error dialog"); - + log.debug("show message dialog"); + mainPanel.removeAll(); buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_ERROR)); + titleLabel.setText(getMessage(titleKey)); } - helpListener.setHelpTopic(errorMsgKey); - - String errorMsgPattern = getMessage(errorMsgKey); - String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); - - JLabel errorMsgLabel = new JLabel(); - errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - errorMsgLabel.setText(errorMsg); + helpListener.setHelpTopic(msgKey); + + String msgPattern = getMessage(msgKey); + String msg = MessageFormat.format(msgPattern, msgParams); + + JLabel msgLabel = new JLabel(); + msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); + msgLabel.setText(msg); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); - + if (!renderHeaderPanel) { - JLabel errorTitleLabel = new JLabel(); - errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(getMessage(TITLE_ERROR)); - errorTitleLabel.setForeground(ERROR_COLOR); - + JLabel titleLabel = new JLabel(); + titleLabel.setFont(titleLabel.getFont().deriveFont(titleLabel.getFont().getStyle() | Font.BOLD)); + titleLabel.setText(getMessage(titleKey)); + if (titleColor != null) { + titleLabel.setForeground(titleColor); + } + mainHorizontal .addGroup(mainPanelLayout.createSequentialGroup() - .addComponent(errorTitleLabel) + .addComponent(titleLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) .addComponent(helpLabel)); mainVertical .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(errorTitleLabel) + .addComponent(titleLabel) .addComponent(helpLabel)); } - + mainPanelLayout.setHorizontalGroup(mainHorizontal - .addComponent(errorMsgLabel)); + .addComponent(msgLabel)); mainPanelLayout.setVerticalGroup(mainVertical - .addComponent(errorMsgLabel)); - - JButton okButton = new JButton(); - okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(getMessage(BUTTON_OK)); - okButton.setActionCommand(okCommand); - okButton.addActionListener(okListener); + .addComponent(msgLabel)); - GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); - buttonPanel.setLayout(buttonPanelLayout); + if (okListener != null && okCommand != null) { + JButton okButton = new JButton(); + okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + okButton.setText(getMessage(BUTTON_OK)); + okButton.setActionCommand(okCommand); + okButton.addActionListener(okListener); - buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); - buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createSequentialGroup() - .addComponent(okButton)); + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + buttonPanelLayout.setHorizontalGroup( + buttonPanelLayout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); + buttonPanelLayout.setVerticalGroup( + buttonPanelLayout.createSequentialGroup() + .addComponent(okButton)); + } contentPanel.validate(); } }); } - @Override - public void showErrorDialog(final String errorMsgKey, final Object[] errorMsgParams) { - - log.debug("scheduling error dialog"); - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - - log.debug("show error dialog"); - - mainPanel.removeAll(); - buttonPanel.removeAll(); - - if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_ERROR)); - } - - helpListener.setHelpTopic(errorMsgKey); - - String errorMsgPattern = getMessage(errorMsgKey); - String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); - - JLabel errorMsgLabel = new JLabel(); - errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - errorMsgLabel.setText(errorMsg); - - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); - - - GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); - GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); - - if (!renderHeaderPanel) { - JLabel errorTitleLabel = new JLabel(); - errorTitleLabel.setFont(errorTitleLabel.getFont().deriveFont(errorTitleLabel.getFont().getStyle() | java.awt.Font.BOLD)); - errorTitleLabel.setText(getMessage(TITLE_ERROR)); - errorTitleLabel.setForeground(ERROR_COLOR); - - mainHorizontal - .addGroup(mainPanelLayout.createSequentialGroup() - .addComponent(errorTitleLabel) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel)); - mainVertical - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(errorTitleLabel) - .addComponent(helpLabel)); - } - - mainPanelLayout.setHorizontalGroup(mainHorizontal - .addComponent(errorMsgLabel)); - mainPanelLayout.setVerticalGroup(mainVertical - .addComponent(errorMsgLabel)); - - contentPanel.validate(); - } - }); - } - @Override public void showWaitDialog(final String waitMessage) { -- cgit v1.2.3 From d20bfd8b45e0a83773a12a649aa7ba0aaf58e649 Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 10 Mar 2009 10:37:45 +0000 Subject: bug: showMessageDialog(key, param, listener, null) does not display OK button git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@315 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 d6c96627..6a1f2aad 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 @@ -970,7 +970,7 @@ public class BKUGUIImpl implements BKUGUIFacade { mainPanelLayout.setVerticalGroup(mainVertical .addComponent(msgLabel)); - if (okListener != null && okCommand != null) { + if (okListener != null) { JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); okButton.setText(getMessage(BUTTON_OK)); -- cgit v1.2.3 From b1c0b243cc7f24f4a2ede6d02bdead4032451f41 Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 10 Mar 2009 11:10:27 +0000 Subject: pinfield and pinsize label aligned trailing git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@316 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 53 +++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 6a1f2aad..76b1d795 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 @@ -605,27 +605,27 @@ public class BKUGUIImpl implements BKUGUIFacade { .addComponent(helpLabel); } - GroupLayout.Group pinHorizontal; + // align pinfield and pinsize to the right + GroupLayout.ParallelGroup pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING); GroupLayout.Group pinVertical; if (pinLabelPos == PinLabelPosition.ABOVE) { - pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(mainPanelLayout.createSequentialGroup() - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + pinHorizontal + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); pinVertical = mainPanelLayout.createSequentialGroup() .addComponent(cardPinLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); } else { - pinHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(pinsizeLabel)); + pinHorizontal + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(cardPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(cardPinLabel) .addComponent(pinField); @@ -806,28 +806,27 @@ public class BKUGUIImpl implements BKUGUIFacade { .addComponent(helpLabel); } - GroupLayout.Group pinHorizontal; + // align pinfield and pinsize to the right + GroupLayout.ParallelGroup pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING); GroupLayout.Group pinVertical; if (pinLabelPos == PinLabelPosition.ABOVE) { - pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(mainPanelLayout.createSequentialGroup() - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); - + pinHorizontal + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); pinVertical = mainPanelLayout.createSequentialGroup() .addComponent(signPinLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); } else { - pinHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(pinsizeLabel)); + pinHorizontal + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(signPinLabel) .addComponent(pinField); -- cgit v1.2.3 From 2a1df5e58e44f8d77f34eb80df74e8c0d27caceb Mon Sep 17 00:00:00 2001 From: clemenso Date: Wed, 18 Mar 2009 22:27:28 +0000 Subject: 1.1-rc5 (pinProviderFactories, gui refactoring, signatureCard, secureViewer) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@322 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 560 +++++++++++---------- 1 file changed, 295 insertions(+), 265 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 76b1d795..928be249 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 @@ -315,200 +315,204 @@ public class BKUGUIImpl implements BKUGUIFacade { return messages.containsKey(key); } - @Override - public void showWelcomeDialog() { - - log.debug("scheduling welcome dialog"); - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - - log.debug("show welcome dialog"); - - mainPanel.removeAll(); - buttonPanel.removeAll(); - - helpListener.setHelpTopic(HELP_WELCOME); - - JLabel welcomeMsgLabel = new JLabel(); - welcomeMsgLabel.setFont(welcomeMsgLabel.getFont().deriveFont(welcomeMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - - if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_WELCOME)); - welcomeMsgLabel.setText(getMessage(MESSAGE_WAIT)); - } else { - welcomeMsgLabel.setText(getMessage(TITLE_WELCOME)); - } - - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); - - GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(welcomeMsgLabel); - GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(welcomeMsgLabel); - if (!renderHeaderPanel) { - messageHorizontal - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); - messageVertical - .addComponent(helpLabel); - } - - mainPanelLayout.setHorizontalGroup(messageHorizontal); - mainPanelLayout.setVerticalGroup(messageVertical); - - contentPanel.validate(); - - } - }); - } - - @Override - public void showInsertCardDialog(final ActionListener cancelListener, final String cancelCommand) { - - log.debug("scheduling insert card dialog"); - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - - log.debug("show insert card dialog"); - - mainPanel.removeAll(); - buttonPanel.removeAll(); - - if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_INSERTCARD)); - } - - helpListener.setHelpTopic(HELP_INSERTCARD); - - JLabel insertCardMsgLabel = new JLabel(); - insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); - - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); - - GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(insertCardMsgLabel); - GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup() - .addComponent(insertCardMsgLabel); - - if (!renderHeaderPanel) { - messageHorizontal - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); - messageVertical - .addComponent(helpLabel); - } - - mainPanelLayout.setHorizontalGroup(messageHorizontal); - mainPanelLayout.setVerticalGroup(messageVertical); - - if (renderCancelButton) { - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(getMessage(BUTTON_CANCEL)); - cancelButton.addActionListener(cancelListener); - cancelButton.setActionCommand(cancelCommand); - - GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); - buttonPanel.setLayout(buttonPanelLayout); - - buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); - buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createSequentialGroup() - .addComponent(cancelButton)); - } - - contentPanel.validate(); - } - }); - } +// @Override +// public void showWelcomeDialog() { +// +// log.debug("scheduling welcome dialog"); +// +// SwingUtilities.invokeLater(new Runnable() { +// +// @Override +// public void run() { +// +// log.debug("show welcome dialog"); +// +// mainPanel.removeAll(); +// buttonPanel.removeAll(); +// +// helpListener.setHelpTopic(HELP_WELCOME); +// +// JLabel welcomeMsgLabel = new JLabel(); +// welcomeMsgLabel.setFont(welcomeMsgLabel.getFont().deriveFont(welcomeMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); +// +// if (renderHeaderPanel) { +// titleLabel.setText(getMessage(TITLE_WELCOME)); +// welcomeMsgLabel.setText(getMessage(MESSAGE_WAIT)); +// } else { +// welcomeMsgLabel.setText(getMessage(TITLE_WELCOME)); +// } +// +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() +// .addComponent(welcomeMsgLabel); +// GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addComponent(welcomeMsgLabel); +// if (!renderHeaderPanel) { +// messageHorizontal +// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) +// .addComponent(helpLabel); +// messageVertical +// .addComponent(helpLabel); +// } +// +// mainPanelLayout.setHorizontalGroup(messageHorizontal); +// mainPanelLayout.setVerticalGroup(messageVertical); +// +// contentPanel.validate(); +// +// } +// }); +// } + +// @Override +// public void showInsertCardDialog( +// final ActionListener cancelListener, final String cancelCommand) { +// +// log.debug("scheduling insert card dialog"); +// +// SwingUtilities.invokeLater(new Runnable() { +// +// @Override +// public void run() { +// +// log.debug("show insert card dialog"); +// +// mainPanel.removeAll(); +// buttonPanel.removeAll(); +// +// if (renderHeaderPanel) { +// titleLabel.setText(getMessage(TITLE_INSERTCARD)); +// } +// +// helpListener.setHelpTopic(HELP_INSERTCARD); +// +// JLabel insertCardMsgLabel = new JLabel(); +// insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); +// insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); +// +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() +// .addComponent(insertCardMsgLabel); +// GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup() +// .addComponent(insertCardMsgLabel); +// +// if (!renderHeaderPanel) { +// messageHorizontal +// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) +// .addComponent(helpLabel); +// messageVertical +// .addComponent(helpLabel); +// } +// +// mainPanelLayout.setHorizontalGroup(messageHorizontal); +// mainPanelLayout.setVerticalGroup(messageVertical); +// +// if (renderCancelButton) { +// JButton cancelButton = new JButton(); +// cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); +// cancelButton.setText(getMessage(BUTTON_CANCEL)); +// cancelButton.addActionListener(cancelListener); +// cancelButton.setActionCommand(cancelCommand); +// +// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); +// buttonPanel.setLayout(buttonPanelLayout); +// +// buttonPanelLayout.setHorizontalGroup( +// buttonPanelLayout.createSequentialGroup() +// .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) +// .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); +// buttonPanelLayout.setVerticalGroup( +// buttonPanelLayout.createSequentialGroup() +// .addComponent(cancelButton)); +// } +// +// contentPanel.validate(); +// } +// }); +// } /** * only difference to showInsertCard: title text: card not supported * @param cancelListener * @param cancelCommand */ - @Override - public void showCardNotSupportedDialog(final ActionListener cancelListener, final String cancelCommand) { - - log.debug("scheduling card not supported dialog"); - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - - log.debug("show card not supported dialog"); - - mainPanel.removeAll(); - buttonPanel.removeAll(); - - JLabel insertCardMsgLabel = new JLabel(); - insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - - if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); - insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); - } else { - insertCardMsgLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); - } - - helpListener.setHelpTopic(HELP_CARDNOTSUPPORTED); - - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); - - GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(insertCardMsgLabel); - GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(insertCardMsgLabel); - if (!renderHeaderPanel) { - messageHorizontal - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); - messageVertical - .addComponent(helpLabel); - } - - mainPanelLayout.setHorizontalGroup(messageHorizontal); - mainPanelLayout.setVerticalGroup(messageVertical); - - if (renderCancelButton) { - JButton cancelButton = new JButton(); - cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - cancelButton.setText(getMessage(BUTTON_CANCEL)); - cancelButton.addActionListener(cancelListener); - cancelButton.setActionCommand(cancelCommand); - - GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); - buttonPanel.setLayout(buttonPanelLayout); - - buttonPanelLayout.setHorizontalGroup( - buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); - buttonPanelLayout.setVerticalGroup( - buttonPanelLayout.createSequentialGroup() - .addComponent(cancelButton)); - } - - contentPanel.validate(); - } - }); - } - - private void showCardPINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener okListener, final String okCommand, final ActionListener cancelListener, final String cancelCommand) { +// @Override +// public void showCardNotSupportedDialog(final ActionListener cancelListener, final String cancelCommand) { +// +// log.debug("scheduling card not supported dialog"); +// +// SwingUtilities.invokeLater(new Runnable() { +// +// @Override +// public void run() { +// +// log.debug("show card not supported dialog"); +// +// mainPanel.removeAll(); +// buttonPanel.removeAll(); +// +// JLabel insertCardMsgLabel = new JLabel(); +// insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); +// +// if (renderHeaderPanel) { +// titleLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); +// insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); +// } else { +// insertCardMsgLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); +// } +// +// helpListener.setHelpTopic(HELP_CARDNOTSUPPORTED); +// +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() +// .addComponent(insertCardMsgLabel); +// GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addComponent(insertCardMsgLabel); +// if (!renderHeaderPanel) { +// messageHorizontal +// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) +// .addComponent(helpLabel); +// messageVertical +// .addComponent(helpLabel); +// } +// +// mainPanelLayout.setHorizontalGroup(messageHorizontal); +// mainPanelLayout.setVerticalGroup(messageVertical); +// +// if (renderCancelButton) { +// JButton cancelButton = new JButton(); +// cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); +// cancelButton.setText(getMessage(BUTTON_CANCEL)); +// cancelButton.addActionListener(cancelListener); +// cancelButton.setActionCommand(cancelCommand); +// +// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); +// buttonPanel.setLayout(buttonPanelLayout); +// +// buttonPanelLayout.setHorizontalGroup( +// buttonPanelLayout.createSequentialGroup() +// .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) +// .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); +// buttonPanelLayout.setVerticalGroup( +// buttonPanelLayout.createSequentialGroup() +// .addComponent(cancelButton)); +// } +// +// contentPanel.validate(); +// } +// }); +// } + + @Override + public void showCardPINDialog(final PINSpec pinSpec, final int numRetries, + final ActionListener okListener, final String okCommand, + final ActionListener cancelListener, final String cancelCommand) { log.debug("scheduling card-pin dialog"); @@ -534,7 +538,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); okButton.setText(getMessage(BUTTON_OK)); - okButton.setEnabled(false); + okButton.setEnabled(pinSpec.getMinLength() <= 0); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); @@ -681,27 +685,30 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } - @Override - public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { - showCardPINDialog(pinSpec, -1, okListener, okCommand, cancelListener, cancelCommand); - } - - @Override - public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { - showCardPINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand); - } - - @Override - public void showSignaturePINDialog(PINSpec pinSpec, ActionListener signListener, String signCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand) { - showSignaturePINDialog(pinSpec, -1, signListener, signCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); - } +// @Override +// public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { +// showCardPINDialog(pinSpec, -1, okListener, okCommand, cancelListener, cancelCommand); +// } +// +// @Override +// public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { +// showCardPINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand); +// } + +// @Override +// public void showSignaturePINDialog(PINSpec pinSpec, ActionListener signListener, String signCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand) { +// showSignaturePINDialog(pinSpec, -1, signListener, signCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); +// } @Override - public void showSignaturePINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand) { - showSignaturePINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); - } - - private void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener signListener, final String signCommand, final ActionListener cancelListener, final String cancelCommand, final ActionListener hashdataListener, final String hashdataCommand) { + public void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, + final ActionListener signListener, final String signCommand, + final ActionListener cancelListener, final String cancelCommand, + final ActionListener hashdataListener, final String hashdataCommand) { +// showSignaturePINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); +// } +// +// private void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener signListener, final String signCommand, final ActionListener cancelListener, final String cancelCommand, final ActionListener hashdataListener, final String hashdataCommand) { log.debug("scheduling signature-pin dialog"); @@ -726,7 +733,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JButton signButton = new JButton(); signButton.setFont(signButton.getFont().deriveFont(signButton.getFont().getStyle() & ~java.awt.Font.BOLD)); signButton.setText(getMessage(BUTTON_SIGN)); - signButton.setEnabled(false); + signButton.setEnabled(pinSpec.getMinLength() <= 0); signButton.setActionCommand(signCommand); signButton.addActionListener(signListener); @@ -888,7 +895,7 @@ public class BKUGUIImpl implements BKUGUIFacade { final ActionListener okListener, final String okCommand) { showMessageDialog(TITLE_ERROR, ERROR_COLOR, - errorMsgKey, errorMsgParams, okListener, okCommand); + errorMsgKey, errorMsgParams, BUTTON_OK, okListener, okCommand); } @Override @@ -896,22 +903,45 @@ public class BKUGUIImpl implements BKUGUIFacade { final String errorMsgKey, final Object[] errorMsgParams) { showMessageDialog(TITLE_ERROR, ERROR_COLOR, - errorMsgKey, errorMsgParams, null, null); + errorMsgKey, errorMsgParams, null, null, null); } @Override public void showMessageDialog( final String titleKey, final String msgKey, final Object[] msgParams, + final String buttonKey, final ActionListener okListener, final String okCommand) { showMessageDialog(titleKey, null, - msgKey, msgParams, okListener, okCommand); + msgKey, msgParams, buttonKey, okListener, okCommand); + } + + @Override + public void showMessageDialog( + final String titleKey, + final String msgKey, final Object[] msgParams) { + + showMessageDialog(titleKey, null, + msgKey, msgParams, null, null, null); + } + + @Override + public void showMessageDialog( + final String titleKey, final String msgKey) { + + showMessageDialog(titleKey, null, + msgKey, null, null, null, null); } + /** + * + * @param buttonKey if null defaults to BUTTON_OK + */ private void showMessageDialog( final String titleKey, final Color titleColor, final String msgKey, final Object[] msgParams, + final String buttonKey, final ActionListener okListener, final String okCommand) { log.debug("scheduling message dialog"); @@ -972,7 +1002,7 @@ public class BKUGUIImpl implements BKUGUIFacade { if (okListener != null) { JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); - okButton.setText(getMessage(BUTTON_OK)); + okButton.setText(getMessage((buttonKey != null) ? buttonKey : BUTTON_OK)); okButton.setActionCommand(okCommand); okButton.addActionListener(okListener); @@ -993,57 +1023,57 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } - @Override - public void showWaitDialog(final String waitMessage) { - - log.debug("scheduling wait dialog"); - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - - log.debug("show wait dialog"); - - mainPanel.removeAll(); - buttonPanel.removeAll(); - - if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_WAIT)); - } - - helpListener.setHelpTopic(HELP_WAIT); - - JLabel waitMsgLabel = new JLabel(); - waitMsgLabel.setFont(waitMsgLabel.getFont().deriveFont(waitMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - if (waitMessage != null) { - waitMsgLabel.setText("" + waitMessage + ""); - } else { - waitMsgLabel.setText(getMessage(MESSAGE_WAIT)); - } - - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); - - GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(waitMsgLabel); - GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(waitMsgLabel); - - if (!renderHeaderPanel) { - messageHorizontal - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); - messageVertical - .addComponent(helpLabel); - } - mainPanelLayout.setHorizontalGroup(messageHorizontal); - mainPanelLayout.setVerticalGroup(messageVertical); - - contentPanel.validate(); - } - }); - } +// @Override +// public void showWaitDialog(final String waitMessage) { +// +// log.debug("scheduling wait dialog"); +// +// SwingUtilities.invokeLater(new Runnable() { +// +// @Override +// public void run() { +// +// log.debug("show wait dialog"); +// +// mainPanel.removeAll(); +// buttonPanel.removeAll(); +// +// if (renderHeaderPanel) { +// titleLabel.setText(getMessage(TITLE_WAIT)); +// } +// +// helpListener.setHelpTopic(HELP_WAIT); +// +// JLabel waitMsgLabel = new JLabel(); +// waitMsgLabel.setFont(waitMsgLabel.getFont().deriveFont(waitMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); +// if (waitMessage != null) { +// waitMsgLabel.setText("" + waitMessage + ""); +// } else { +// waitMsgLabel.setText(getMessage(MESSAGE_WAIT)); +// } +// +// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); +// mainPanel.setLayout(mainPanelLayout); +// +// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() +// .addComponent(waitMsgLabel); +// GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addComponent(waitMsgLabel); +// +// if (!renderHeaderPanel) { +// messageHorizontal +// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) +// .addComponent(helpLabel); +// messageVertical +// .addComponent(helpLabel); +// } +// mainPanelLayout.setHorizontalGroup(messageHorizontal); +// mainPanelLayout.setVerticalGroup(messageVertical); +// +// contentPanel.validate(); +// } +// }); +// } @Override public char[] getPin() { @@ -1062,7 +1092,7 @@ public class BKUGUIImpl implements BKUGUIFacade { * @param okCommand */ @Override - public void showHashDataInputDialog(final List signedReferences, + public void showSecureViewer(final List signedReferences, final ActionListener okListener, final String okCommand) { -- cgit v1.2.3 From 616e06910051528674165319a1d6d161dff5859c Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 27 Mar 2009 17:33:11 +0000 Subject: 1.1-RC6 (pinpad, pinmgmt, secureviewer) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@323 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 603 +++++++++++++-------- 1 file changed, 370 insertions(+), 233 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 928be249..a7eebbfd 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 @@ -71,6 +71,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } protected HelpMouseListener helpListener; + protected SecureViewerDialog secureViewer; protected Container contentPane; protected ResourceBundle messages; @@ -145,13 +146,16 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("initializing gui"); + log.debug("initializing gui [" + Thread.currentThread().getName() + "]"); if (renderIconPanel) { initIconPanel(background); initContentPanel(null); } else { - initContentPanel(background); + initContentPanel((background == null) ? + getClass().getResource(DEFAULT_BACKGROUND) : + background + ); } GroupLayout layout = new GroupLayout(contentPane); @@ -159,15 +163,27 @@ public class BKUGUIImpl implements BKUGUIFacade { if (renderIconPanel) { layout.setHorizontalGroup(layout.createSequentialGroup() - .addComponent(iconPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(contentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(iconPanel, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(contentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + .addContainerGap() + .addComponent(iconPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(contentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()); + layout.setVerticalGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(iconPanel, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(contentPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()); } else { - layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(contentPanel)); - layout.setVerticalGroup(layout.createSequentialGroup().addComponent(contentPanel)); + layout.setHorizontalGroup(layout.createSequentialGroup() + // left border + .addContainerGap() + .addComponent(contentPanel) + .addContainerGap()); + layout.setVerticalGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(contentPanel) + .addContainerGap()); } } }); @@ -178,11 +194,12 @@ public class BKUGUIImpl implements BKUGUIFacade { protected void initIconPanel(URL background) { if (background == null) { - background = getClass().getResource(DEFAULT_BACKGROUND); + background = getClass().getResource(DEFAULT_ICON); } if ("file".equals(background.getProtocol())) { - log.warn("file:// background images not permitted: " + background); - background = getClass().getResource(DEFAULT_BACKGROUND); + log.warn("file:// background images not permitted: " + background + + ", loading default background"); + background = getClass().getResource(DEFAULT_ICON); } log.debug("loading icon panel background " + background); @@ -194,26 +211,24 @@ public class BKUGUIImpl implements BKUGUIFacade { iconPanel.setLayout(iconPanelLayout); iconPanelLayout.setHorizontalGroup( iconPanelLayout.createSequentialGroup() - .addContainerGap() .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); - // no gap here (contentPanel has containerGap) iconPanelLayout.setVerticalGroup( iconPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + .addComponent(iconLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); } protected void initContentPanel(URL background) { +// if (background == null) { +// background = getClass().getResource(DEFAULT_BACKGROUND); +// } if (background == null) { - background = getClass().getResource(DEFAULT_BACKGROUND); - } - if (background == null) { + log.debug("no background image set"); contentPanel = new JPanel(); } else { if ("file".equals(background.getProtocol())) { - log.warn("file:// background images not permitted: " + background); + log.warn("file:// background images not permitted: " + background + + ", loading default background"); background = getClass().getResource(DEFAULT_BACKGROUND); } log.debug("loading background " + background); @@ -257,34 +272,29 @@ public class BKUGUIImpl implements BKUGUIFacade { GroupLayout contentPanelLayout = new GroupLayout(contentPanel); contentPanel.setLayout(contentPanelLayout); - GroupLayout.ParallelGroup horizontalContentInner = contentPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + // align header, main and button to the right + GroupLayout.ParallelGroup horizontalContent = + contentPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING); //LEADING); + GroupLayout.SequentialGroup verticalContent = + contentPanelLayout.createSequentialGroup(); + if (renderHeaderPanel) { - horizontalContentInner + horizontalContent .addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); + verticalContent + .addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); + } - horizontalContentInner + horizontalContent .addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); - GroupLayout.SequentialGroup horizontalContentOuter = contentPanelLayout.createSequentialGroup(); - if (!renderIconPanel) { - horizontalContentOuter - .addContainerGap(); - } - horizontalContentOuter - .addGroup(horizontalContentInner) - .addContainerGap(); - contentPanelLayout.setHorizontalGroup(horizontalContentOuter); - - GroupLayout.SequentialGroup verticalContent = contentPanelLayout.createSequentialGroup(); - verticalContent.addContainerGap(); - if (renderHeaderPanel) { - verticalContent.addComponent(headerPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED); - } - verticalContent.addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap(); + .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); //Short.MAX_VALUE); + verticalContent + .addComponent(mainPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(buttonPanel, 0, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + + contentPanelLayout.setHorizontalGroup(horizontalContent); //Outer); contentPanelLayout.setVerticalGroup(verticalContent); } @@ -521,7 +531,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show card-pin dialog"); + log.debug("show card-pin dialog [" + Thread.currentThread().getName() + "]"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -653,7 +663,6 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.setLayout(buttonPanelLayout); GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); GroupLayout.Group buttonVertical; @@ -700,6 +709,128 @@ public class BKUGUIImpl implements BKUGUIFacade { // showSignaturePINDialog(pinSpec, -1, signListener, signCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); // } + @Override + public void showPinpadSignaturePINDialog(final PINSpec pinSpec, final int numRetries, +// final ActionListener cancelListener, final String cancelCommand, + final ActionListener hashdataListener, final String hashdataCommand) { + + log.debug("scheduling pinpad signature-pin dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("show pinpad signature-pin dialog [" + Thread.currentThread().getName() + "]"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + if (numRetries < 0) { + titleLabel.setText(getMessage(TITLE_SIGN)); + } else { + titleLabel.setText(getMessage(TITLE_RETRY)); + } + } + + JLabel infoLabel = new JLabel(); + if (numRetries < 0) { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); + } + infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + infoLabel.setForeground(HYPERLINK_COLOR); + infoLabel.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent me) { + ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e); + } + }); + helpListener.setHelpTopic(HELP_SIGNPIN); + } else { + String retryPattern; + if (numRetries < 2) { + retryPattern = getMessage(MESSAGE_LAST_RETRY); + } else { + retryPattern = getMessage(MESSAGE_RETRIES); + } + infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); + infoLabel.setForeground(ERROR_COLOR); + helpListener.setHelpTopic(HELP_RETRY); + } + + String pinSize = String.valueOf(pinSpec.getMinLength()); + if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { + pinSize += "-" + pinSpec.getMaxLength(); + } + + String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); + String msg = MessageFormat.format(msgPattern, new Object[] { + pinSpec.getLocalizedName(), pinSize }); + + JLabel msgLabel = new JLabel(); + msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); + msgLabel.setText(msg); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(infoLabel); + GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(infoLabel); + + if (!renderHeaderPanel) { + infoHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + infoVertical + .addComponent(helpLabel); + } + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(infoHorizontal) + .addComponent(msgLabel)); + + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(msgLabel)); + + //no cancel button (cancel via pinpad) +// if (renderCancelButton) { +// JButton cancelButton = new JButton(); +// cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); +// cancelButton.setText(getMessage(BUTTON_CANCEL)); +// cancelButton.setActionCommand(cancelCommand); +// cancelButton.addActionListener(cancelListener); +// +// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); +// buttonPanel.setLayout(buttonPanelLayout); +// +// GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup() +// .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); +// GroupLayout.SequentialGroup buttonVertical = buttonPanelLayout.createSequentialGroup() +// .addComponent(cancelButton); +// +// buttonPanelLayout.setHorizontalGroup(buttonHorizontal); +// buttonPanelLayout.setVerticalGroup(buttonVertical); +// } + + contentPanel.validate(); + } + }); + } + @Override public void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener signListener, final String signCommand, @@ -717,7 +848,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show signature-pin dialog"); + log.debug("show signature-pin dialog [" + Thread.currentThread().getName() + "]"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -730,6 +861,38 @@ public class BKUGUIImpl implements BKUGUIFacade { } } + JLabel infoLabel = new JLabel(); + if (numRetries < 0) { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); + } + infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + infoLabel.setForeground(HYPERLINK_COLOR); + infoLabel.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent me) { + ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e); + } + }); + helpListener.setHelpTopic(HELP_SIGNPIN); + } else { + String retryPattern; + if (numRetries < 2) { + retryPattern = getMessage(MESSAGE_LAST_RETRY); + } else { + retryPattern = getMessage(MESSAGE_RETRIES); + } + infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); + infoLabel.setForeground(ERROR_COLOR); + helpListener.setHelpTopic(HELP_RETRY); + } + JButton signButton = new JButton(); signButton.setFont(signButton.getFont().deriveFont(signButton.getFont().getStyle() & ~java.awt.Font.BOLD)); signButton.setText(getMessage(BUTTON_SIGN)); @@ -765,46 +928,14 @@ public class BKUGUIImpl implements BKUGUIFacade { } pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); - JLabel infoLabel = new JLabel(); - if (numRetries < 0) { - infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - if (shortText) { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); - } else { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); - } - infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - infoLabel.setForeground(HYPERLINK_COLOR); - infoLabel.addMouseListener(new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent me) { - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); - hashdataListener.actionPerformed(e); - } - }); - helpListener.setHelpTopic(HELP_SIGNPIN); - } else { - String retryPattern; - if (numRetries < 2) { - retryPattern = getMessage(MESSAGE_LAST_RETRY); - } else { - retryPattern = getMessage(MESSAGE_RETRIES); - } - infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); - infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); - infoLabel.setForeground(ERROR_COLOR); - helpListener.setHelpTopic(HELP_RETRY); - } - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); - + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() .addComponent(infoLabel); GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(infoLabel); - + if (!renderHeaderPanel) { infoHorizontal .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) @@ -814,8 +945,8 @@ public class BKUGUIImpl implements BKUGUIFacade { } // align pinfield and pinsize to the right - GroupLayout.ParallelGroup pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING); - GroupLayout.Group pinVertical; + GroupLayout.Group pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING); + GroupLayout.SequentialGroup pinVertical = mainPanelLayout.createSequentialGroup(); if (pinLabelPos == PinLabelPosition.ABOVE) { pinHorizontal @@ -823,20 +954,25 @@ public class BKUGUIImpl implements BKUGUIFacade { .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); - pinVertical = mainPanelLayout.createSequentialGroup() + pinVertical .addComponent(signPinLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); - } else { + .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel); + } else { // PinLabelPosition.LEFT pinHorizontal .addGroup(mainPanelLayout.createSequentialGroup() .addComponent(signPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); - pinVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(signPinLabel) - .addComponent(pinField); + pinVertical + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(signPinLabel) + .addComponent(pinField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel); } mainPanelLayout.setHorizontalGroup( @@ -848,18 +984,14 @@ public class BKUGUIImpl implements BKUGUIFacade { mainPanelLayout.createSequentialGroup() .addGroup(infoVertical) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(pinVertical) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(pinsizeLabel)); + .addGroup(pinVertical)); GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); buttonPanel.setLayout(buttonPanelLayout); - GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup(); GroupLayout.Group buttonVertical; - + if (renderCancelButton) { JButton cancelButton = new JButton(); cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); @@ -868,17 +1000,19 @@ public class BKUGUIImpl implements BKUGUIFacade { cancelButton.addActionListener(cancelListener); buttonHorizontal + .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); - buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(signButton) - .addComponent(cancelButton); + .addComponent(cancelButton); } else { + buttonHorizontal + .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); buttonVertical = buttonPanelLayout.createSequentialGroup() .addComponent(signButton); } - + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); buttonPanelLayout.setVerticalGroup(buttonVertical); @@ -951,7 +1085,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show message dialog"); + log.debug("show message dialog [" + Thread.currentThread().getName() + "]"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -1011,7 +1145,6 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanelLayout.setHorizontalGroup( buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(okButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); buttonPanelLayout.setVerticalGroup( buttonPanelLayout.createSequentialGroup() @@ -1084,68 +1217,69 @@ public class BKUGUIImpl implements BKUGUIFacade { } return null; } + + + //////////////////////////////////////////////////////////////////////////// + // SECURE VIEWER + //////////////////////////////////////////////////////////////////////////// + /** - * TODO handle multiple references in HashDataViewer * @param signedReferences - * @param okListener + * @param backListener gets notified if pin-dialog has to be redrawn + * (signedRefencesList returns via BACK button) * @param okCommand */ @Override - public void showSecureViewer(final List signedReferences, - final ActionListener okListener, - final String okCommand) { - - if (signedReferences == null) { - showErrorDialog(getMessage(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); - return; - } + public void showSecureViewer(final List dataToBeSigned, + final ActionListener backListener, final String backCommand) { - if (signedReferences.size() == 1) { + if (dataToBeSigned == null) { + showErrorDialog(getMessage(ERR_NO_HASHDATA), + new Object[] {"no signature data provided"}, + backListener, backCommand); + } else if (dataToBeSigned.size() == 1) { try { - log.debug("scheduling hashdata viewer"); + log.debug("scheduling secure viewer"); - SwingUtilities.invokeAndWait(new Runnable() { + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - ActionListener saveHashDataListener = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - HashDataInput hdi = signedReferences.get(0); - showSaveHashDataInputDialog(Collections.singletonList(hdi), okListener, okCommand); - } - }; - showHashDataViewer(signedReferences.get(0), saveHashDataListener, "save"); + showSecureViewer(dataToBeSigned.get(0)); } }); - } catch (InterruptedException ex) { - log.error("Failed to display HashDataViewer: " + ex.getMessage()); - } catch (InvocationTargetException ex) { - log.error("Failed to display HashDataViewer: " + ex.getMessage()); + } catch (Exception ex) { //InterruptedException InvocationTargetException + log.error("Failed to display secure viewer: " + ex.getMessage()); + log.trace(ex); + showErrorDialog(ERR_UNKNOWN, null, backListener, backCommand); } } else { - showSignedReferencesListDialog(signedReferences, okListener, okCommand); + showSignedReferencesListDialog(dataToBeSigned, backListener, backCommand); } } /** * has to be called from event dispatcher thread + * This method blocks until the dialog's close button is pressed. * @param hashDataText * @param saveListener * @param saveCommand */ - private void showHashDataViewer(final HashDataInput hashDataInput, final ActionListener saveListener, final String saveCommand) { + private void showSecureViewer(HashDataInput dataToBeSigned) { - log.debug("show hashdata viewer"); - - ActionListener l = helpListener.getActionListener(); - HashDataViewer.showHashDataInput(contentPane, hashDataInput, messages, saveListener, saveCommand, l); + log.debug("show secure viewer [" + Thread.currentThread().getName() + "]"); + if (secureViewer == null) { + secureViewer = new SecureViewerDialog(null, messages, + helpListener.getActionListener()); + } + secureViewer.setContent(dataToBeSigned); + log.trace("show secure viewer returned"); } - private void showSignedReferencesListDialog(final List signedReferences, final ActionListener backListener, final String backCommand) { + private void showSignedReferencesListDialog(final List signedReferences, + final ActionListener backListener, final String backCommand) { log.debug("scheduling signed references list dialog"); @@ -1154,7 +1288,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show signed references list dialog"); + log.debug("show signed references list dialog [" + Thread.currentThread().getName() + "]"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -1202,13 +1336,7 @@ public class BKUGUIImpl implements BKUGUIFacade { int selectionIdx = lsm.getMinSelectionIndex(); if (selectionIdx >= 0) { final HashDataInput selection = signedReferences.get(selectionIdx); - showHashDataViewer(selection, new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - showSaveHashDataInputDialog(Collections.singletonList(selection), null, null); - } - }, "save"); + showSecureViewer(selection); } } }); @@ -1255,9 +1383,8 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.setLayout(buttonPanelLayout); buttonPanelLayout.setHorizontalGroup(buttonPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(backButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); - buttonPanelLayout.setVerticalGroup(buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + buttonPanelLayout.setVerticalGroup(buttonPanelLayout.createSequentialGroup() .addComponent(backButton)); contentPanel.validate(); @@ -1266,96 +1393,101 @@ public class BKUGUIImpl implements BKUGUIFacade { } /** - * - * @param signedRefs * @param okListener may be null - * @param okCommand */ - private void showSaveHashDataInputDialog(final List signedRefs, final ActionListener okListener, final String okCommand) { - - log.debug("scheduling save hashdatainput dialog"); - - SwingUtilities.invokeLater(new Runnable() { +// private void showSaveDialog(final List signedRefs, +// final ActionListener okListener, final String okCommand) { +// +// log.debug("scheduling save dialog"); +// +// SwingUtilities.invokeLater(new Runnable() { +// +// @Override +// public void run() { +// +// log.debug("show save dialog"); +// +// String userHome = System.getProperty("user.home"); +// +// JFileChooser fileDialog = new JFileChooser(userHome); +// fileDialog.setMultiSelectionEnabled(false); +// fileDialog.setDialogType(JFileChooser.SAVE_DIALOG); +// fileDialog.setFileHidingEnabled(true); +// if (signedRefs.size() == 1) { +// fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVE)); +// fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY); +// String mimeType = signedRefs.get(0).getMimeType(); +// MimeFilter mimeFilter = new MimeFilter(mimeType, messages); +// fileDialog.setFileFilter(mimeFilter); +// String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); +// fileDialog.setSelectedFile(new File(userHome, filename)); +// } else { +// fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVEDIR)); +// fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); +// } +// +// //parent contentPane -> placed over applet +// switch (fileDialog.showSaveDialog(fileDialog)) { +// case JFileChooser.APPROVE_OPTION: +// File f = fileDialog.getSelectedFile(); +// for (HashDataInput hashDataInput : signedRefs) { +// String mimeType = hashDataInput.getMimeType(); +// String id = hashDataInput.getReferenceId(); +// File file; +// if (f.isDirectory()) { +// String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); +// file = new File(f, filename); +// } else { +// file = f; +// } +// if (file.exists()) { +// String ovrwrt = getMessage(MESSAGE_OVERWRITE); +// int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), getMessage(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); +// if (overwrite != JOptionPane.OK_OPTION) { +// continue; +// } +// } +// if (log.isDebugEnabled()) { +// log.debug("writing hashdata input " + id + " (" + mimeType + ") to file " + file); +// } +// FileOutputStream fos = null; +// try { +// fos = new FileOutputStream(file); +// BufferedOutputStream bos = new BufferedOutputStream(fos); +// InputStream hdi = hashDataInput.getHashDataInput(); +// int b; +// while ((b = hdi.read()) != -1) { +// bos.write(b); +// } +// bos.flush(); +// bos.close(); +// } catch (IOException ex) { +// log.error("Failed to write " + file + ": " + ex.getMessage()); +// showErrorDialog(ERR_WRITE_HASHDATA, new Object[] {ex.getMessage()}, null, null); +// ex.printStackTrace(); +// } finally { +// try { +// fos.close(); +// } catch (IOException ex) { +// } +// } +// } +// break; +// case JFileChooser.CANCEL_OPTION : +// log.debug("cancelled save dialog"); +// break; +// } +// if (okListener != null) { +// okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand)); +// } +// } +// }); +// } + + //////////////////////////////////////////////////////////////////////////// + // UTILITY METHODS + //////////////////////////////////////////////////////////////////////////// - @Override - public void run() { - - log.debug("show save hashdatainput dialog"); - - String userHome = System.getProperty("user.home"); - - JFileChooser fileDialog = new JFileChooser(userHome); - fileDialog.setMultiSelectionEnabled(false); - fileDialog.setDialogType(JFileChooser.SAVE_DIALOG); - fileDialog.setFileHidingEnabled(true); - if (signedRefs.size() == 1) { - fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVE)); - fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY); - String mimeType = signedRefs.get(0).getMimeType(); - MimeFilter mimeFilter = new MimeFilter(mimeType, messages); - fileDialog.setFileFilter(mimeFilter); - String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); - fileDialog.setSelectedFile(new File(userHome, filename)); - } else { - fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVEDIR)); - fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - } - - //parent contentPane -> placed over applet - switch (fileDialog.showSaveDialog(fileDialog)) { - case JFileChooser.APPROVE_OPTION: - File f = fileDialog.getSelectedFile(); - for (HashDataInput hashDataInput : signedRefs) { - String mimeType = hashDataInput.getMimeType(); - String id = hashDataInput.getReferenceId(); - File file; - if (f.isDirectory()) { - String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); - file = new File(f, filename); - } else { - file = f; - } - if (file.exists()) { - String ovrwrt = getMessage(MESSAGE_OVERWRITE); - int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), getMessage(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); - if (overwrite != JOptionPane.OK_OPTION) { - continue; - } - } - if (log.isDebugEnabled()) { - log.debug("Writing HashDataInput " + id + " (" + mimeType + ") to file " + file); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(file); - BufferedOutputStream bos = new BufferedOutputStream(fos); - InputStream hdi = hashDataInput.getHashDataInput(); - int b; - while ((b = hdi.read()) != -1) { - bos.write(b); - } - bos.flush(); - bos.close(); - } catch (IOException ex) { - log.error("Failed to write HashDataInput to file " + file + ": " + ex.getMessage()); - showErrorDialog(ERR_WRITE_HASHDATA, new Object[] {ex.getMessage()}, null, null); - ex.printStackTrace(); - } finally { - try { - fos.close(); - } catch (IOException ex) { - } - } - } - } - log.debug("done saving hashdatainput"); - if (okListener != null) { - okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand)); - } - } - }); - } - private void registerHelpListener(ActionListener helpListener) { if (helpListener != null) { this.helpListener = new HelpMouseListener(helpListener); @@ -1371,6 +1503,11 @@ public class BKUGUIImpl implements BKUGUIFacade { } } + + //////////////////////////////////////////////////////////////////////////// + // INITIALIZERS (MAY BE OVERRIDDEN BY SUBCLASSES) + //////////////////////////////////////////////////////////////////////////// + /** * Called from constructor. * Subclasses may override this method to ensure the message bundle is loaded -- cgit v1.2.3 From 8a336c8343f86f69680817153334d0d37da56010 Mon Sep 17 00:00:00 2001 From: clemenso Date: Mon, 20 Apr 2009 14:56:16 +0000 Subject: en localization of pinMgmt (verifyPin, cancelbutton) no java message (todo: localize) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@339 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 a7eebbfd..e5cac7b7 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 @@ -1533,6 +1533,12 @@ public class BKUGUIImpl implements BKUGUIFacade { if (b.getPreferredSize().width > bs) { bs = b.getPreferredSize().width; } + // need cancel button for message dialog, + // even if renderCancelButton == false + b.setText(getMessage(BUTTON_CANCEL)); + if (b.getPreferredSize().width > bs) { + bs = b.getPreferredSize().width; + } b.setText(getMessage(BUTTON_SIGN)); if (b.getPreferredSize().width > bs) { bs = b.getPreferredSize().width; @@ -1545,12 +1551,6 @@ public class BKUGUIImpl implements BKUGUIFacade { if (b.getPreferredSize().width > bs) { bs = b.getPreferredSize().width; } - if (renderCancelButton) { - b.setText(getMessage(BUTTON_CANCEL)); - if (b.getPreferredSize().width > bs) { - bs = b.getPreferredSize().width; - } - } return bs; } } -- cgit v1.2.3 From cb4496d82e8271102cda305e5490d6bc55e63fb6 Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 9 Jul 2009 12:07:40 +0000 Subject: log locale git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@403 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 e5cac7b7..4cab29e0 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 @@ -39,6 +39,7 @@ import java.text.MessageFormat; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.swing.GroupLayout; import javax.swing.ImageIcon; @@ -1509,6 +1510,9 @@ public class BKUGUIImpl implements BKUGUIFacade { //////////////////////////////////////////////////////////////////////////// /** + * Load applet messages bundle. Note that getBundle looks for classes based + * on the default Locale before it selects the base class! + * * Called from constructor. * Subclasses may override this method to ensure the message bundle is loaded * once initButtonSize (called from constructor as well) is called. @@ -1517,12 +1521,16 @@ public class BKUGUIImpl implements BKUGUIFacade { */ protected void loadMessageBundle(Locale locale) { 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 applet resources for language: " + lang.toString()); messages = ResourceBundle.getBundle(MESSAGES_BUNDLE, lang); } else { + log.debug("loading default language applet resources"); messages = ResourceBundle.getBundle(MESSAGES_BUNDLE); } + // how the f*** you know the default Messages.properties is de?! + log.debug("applet messages loaded: " + messages.getLocale()); } protected int initButtonSize() { -- cgit v1.2.3 From 5bff0a3288bd2b5e1f1030c6e47430735cd09463 Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 9 Jul 2009 16:34:07 +0000 Subject: [#393] loading of default background fails git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@407 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 31 +++++----------------- 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 4cab29e0..16297218 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 @@ -28,25 +28,15 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.text.MessageFormat; -import java.util.Collections; import java.util.List; import java.util.Locale; -import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; -import javax.swing.JFileChooser; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; @@ -153,10 +143,7 @@ public class BKUGUIImpl implements BKUGUIFacade { initIconPanel(background); initContentPanel(null); } else { - initContentPanel((background == null) ? - getClass().getResource(DEFAULT_BACKGROUND) : - background - ); + initContentPanel(background); } GroupLayout layout = new GroupLayout(contentPane); @@ -220,20 +207,16 @@ public class BKUGUIImpl implements BKUGUIFacade { protected void initContentPanel(URL background) { -// if (background == null) { -// background = getClass().getResource(DEFAULT_BACKGROUND); -// } if (background == null) { log.debug("no background image set"); +// contentPanel = new ImagePanel(getClass().getResource(DEFAULT_BACKGROUND)); + contentPanel = new JPanel(); + } else if ("file".equals(background.getProtocol())) { + log.warn("file:// background images not permitted: " + background); contentPanel = new JPanel(); } else { - if ("file".equals(background.getProtocol())) { - log.warn("file:// background images not permitted: " + background + - ", loading default background"); - background = getClass().getResource(DEFAULT_BACKGROUND); - } - log.debug("loading background " + background); - contentPanel = new ImagePanel(background); + log.debug("loading background " + background); + contentPanel = new ImagePanel(background); } mainPanel = new JPanel(); mainPanel.setOpaque(false); -- cgit v1.2.3 From 2429c7e98cb9e47e36dc5ff07fd10bd18cc999bc Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 13 Aug 2009 09:11:09 +0000 Subject: [#436] resolve "#PIN digits" message via message resource bundle git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@419 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 16297218..4f3a8f1e 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 @@ -581,11 +581,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); String pinsizePattern = getMessage(LABEL_PINSIZE); - String pinSize = String.valueOf(pinSpec.getMinLength()); - if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { - pinSize += "-" + pinSpec.getMaxLength(); - } - pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); + pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSpec.getLocalizedLength()})); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); @@ -750,14 +746,9 @@ public class BKUGUIImpl implements BKUGUIFacade { helpListener.setHelpTopic(HELP_RETRY); } - String pinSize = String.valueOf(pinSpec.getMinLength()); - if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { - pinSize += "-" + pinSpec.getMaxLength(); - } - String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); String msg = MessageFormat.format(msgPattern, new Object[] { - pinSpec.getLocalizedName(), pinSize }); + pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }); JLabel msgLabel = new JLabel(); msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); @@ -906,11 +897,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); String pinsizePattern = getMessage(LABEL_PINSIZE); - String pinSize = String.valueOf(pinSpec.getMinLength()); - if (pinSpec.getMinLength() != pinSpec.getMaxLength()) { - pinSize += "-" + pinSpec.getMaxLength(); - } - pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); + pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSpec.getLocalizedLength()})); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); -- cgit v1.2.3 From d791931ac69b0a2a1201ef7cd2f7ca247e92ba8c Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 14 Aug 2009 10:46:26 +0000 Subject: [#436] resolve "#PIN digits" message via message resource bundle only for activation git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@431 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 4f3a8f1e..de9a91b9 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 @@ -581,7 +581,10 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); String pinsizePattern = getMessage(LABEL_PINSIZE); - pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSpec.getLocalizedLength()})); + String pinSize = (pinSpec.getMaxLength() > pinSpec.getMinLength()) ? + pinSpec.getMinLength() + "-" + pinSpec.getMaxLength() : + String.valueOf(pinSpec.getMinLength()); + pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); @@ -747,8 +750,11 @@ public class BKUGUIImpl implements BKUGUIFacade { } String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); + String pinSize = (pinSpec.getMaxLength() > pinSpec.getMinLength()) ? + pinSpec.getMinLength() + "-" + pinSpec.getMaxLength() : + String.valueOf(pinSpec.getMinLength()); String msg = MessageFormat.format(msgPattern, new Object[] { - pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }); + pinSpec.getLocalizedName(), pinSize }); JLabel msgLabel = new JLabel(); msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); @@ -897,7 +903,10 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); String pinsizePattern = getMessage(LABEL_PINSIZE); - pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSpec.getLocalizedLength()})); + String pinSize = (pinSpec.getMaxLength() > pinSpec.getMinLength()) ? + pinSpec.getMinLength() + "-" + pinSpec.getMaxLength() : + String.valueOf(pinSpec.getMinLength()); + pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); -- cgit v1.2.3 From 22001c93bca360d1b15c252cb22d2a4147ff350d Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 20 Aug 2009 16:24:55 +0000 Subject: [#430] Activation/PIN-management in MOCCA Web Start - new Modules: smccSTALExt, BKUGuiExt in order not to depend on BKUAppletExt in BKULocal - provide stal-request handler de-registration in abstractSMCCSTAL git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@448 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 de9a91b9..2663e8bf 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 @@ -132,7 +132,7 @@ public class BKUGUIImpl implements BKUGUIFacade { log.debug("scheduling gui initialization"); - SwingUtilities.invokeAndWait(new Runnable() { + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { -- cgit v1.2.3 From 598f62c5b30d6e40f6983fc3eec17613d19cdc0e Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 25 Aug 2009 12:49:43 +0000 Subject: [#436] resolve "#pin digits" message via resource bundle (now, all dialogs - not only pinactivation - get pinLength from resource bundle) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@472 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 2663e8bf..5ea2499a 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 @@ -580,11 +580,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = getMessage(LABEL_PINSIZE); - String pinSize = (pinSpec.getMaxLength() > pinSpec.getMinLength()) ? - pinSpec.getMinLength() + "-" + pinSpec.getMaxLength() : - String.valueOf(pinSpec.getMinLength()); - pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); + pinsizeLabel.setText(MessageFormat.format(getMessage(LABEL_PINSIZE), pinSpec.getLocalizedLength())); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); @@ -750,11 +746,8 @@ public class BKUGUIImpl implements BKUGUIFacade { } String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); - String pinSize = (pinSpec.getMaxLength() > pinSpec.getMinLength()) ? - pinSpec.getMinLength() + "-" + pinSpec.getMaxLength() : - String.valueOf(pinSpec.getMinLength()); String msg = MessageFormat.format(msgPattern, new Object[] { - pinSpec.getLocalizedName(), pinSize }); + pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }); JLabel msgLabel = new JLabel(); msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); @@ -902,11 +895,7 @@ public class BKUGUIImpl implements BKUGUIFacade { JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); - String pinsizePattern = getMessage(LABEL_PINSIZE); - String pinSize = (pinSpec.getMaxLength() > pinSpec.getMinLength()) ? - pinSpec.getMinLength() + "-" + pinSpec.getMaxLength() : - String.valueOf(pinSpec.getMinLength()); - pinsizeLabel.setText(MessageFormat.format(pinsizePattern, new Object[]{pinSize})); + pinsizeLabel.setText(MessageFormat.format(getMessage(LABEL_PINSIZE), pinSpec.getLocalizedLength())); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); -- cgit v1.2.3 From 3ca1928f20603069058bf89dce1a47599d064091 Mon Sep 17 00:00:00 2001 From: mcentner Date: Tue, 8 Sep 2009 15:55:46 +0000 Subject: Fixed Bug [#467] Border between Background image and border. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@505 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 1 + 1 file changed, 1 insertion(+) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 5ea2499a..35a53ff7 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 @@ -218,6 +218,7 @@ public class BKUGUIImpl implements BKUGUIFacade { log.debug("loading background " + background); contentPanel = new ImagePanel(background); } + contentPanel.setOpaque(false); mainPanel = new JPanel(); mainPanel.setOpaque(false); buttonPanel = new JPanel(); -- cgit v1.2.3 From 3b59e8f40dbddf0a752d39bb7d5c8bab86546205 Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 2 Oct 2009 17:48:37 +0000 Subject: [#439], [#478] MOCCA Dialog is AlwaysOnTop (follow up for [#439]) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@518 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 35a53ff7..b84a2164 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 @@ -23,6 +23,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.Cursor; import java.awt.Font; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -1243,6 +1244,14 @@ public class BKUGUIImpl implements BKUGUIFacade { if (secureViewer == null) { secureViewer = new SecureViewerDialog(null, messages, helpListener.getActionListener()); + + // workaround for [#439] + // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. + Window window = SwingUtilities.getWindowAncestor(contentPane); + if (window != null && window.isAlwaysOnTop()) { + log.debug("make secureViewer alwaysOnTop"); + secureViewer.setAlwaysOnTop(true); + } } secureViewer.setContent(dataToBeSigned); log.trace("show secure viewer returned"); -- cgit v1.2.3 From 4b8b858ddcab0bfbde80304a0f631233388a13d1 Mon Sep 17 00:00:00 2001 From: tzefferer Date: Fri, 16 Oct 2009 09:54:37 +0000 Subject: Keyboard accessibility for Online-BKU git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@528 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 280 ++++++++++++++++++--- 1 file changed, 243 insertions(+), 37 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 b84a2164..e83502a8 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 @@ -26,6 +26,10 @@ import java.awt.Font; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; @@ -45,11 +49,14 @@ import javax.swing.JTable; import javax.swing.LayoutStyle; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + + /** * * @author clemens @@ -62,7 +69,9 @@ public class BKUGUIImpl implements BKUGUIFacade { LEFT, ABOVE } - protected HelpMouseListener helpListener; + protected HelpMouseListener helpMouseListener; + protected HelpKeyListener helpKeyListener; + protected SwitchFocusFocusListener switchFocusKeyListener; protected SecureViewerDialog secureViewer; protected Container contentPane; @@ -77,6 +86,7 @@ public class BKUGUIImpl implements BKUGUIFacade { /** right side fixed labels */ protected JLabel titleLabel; protected JLabel helpLabel; + protected JLabel switchFocusDummyLabel; /** remember the pinfield to return to worker */ protected JPasswordField pinField; @@ -107,7 +117,8 @@ public class BKUGUIImpl implements BKUGUIFacade { Locale locale, Style guiStyle, URL background, - ActionListener helpListener) { + ActionListener helpListener, + SwitchFocusListener switchFocusListener) { this.contentPane = contentPane; loadMessageBundle(locale); @@ -122,8 +133,13 @@ public class BKUGUIImpl implements BKUGUIFacade { pinLabelPos = PinLabelPosition.ABOVE; } + // ensure that buttons can be fired with enter key too + UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE); + registerHelpListener(helpListener); + registerSwitchFocusListener(switchFocusListener); + createGUI(background); } @@ -224,12 +240,35 @@ public class BKUGUIImpl implements BKUGUIFacade { mainPanel.setOpaque(false); buttonPanel = new JPanel(); buttonPanel.setOpaque(false); - + helpLabel = new JLabel(); helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG))); helpLabel.getAccessibleContext().setAccessibleName(getMessage(ALT_HELP)); - helpLabel.addMouseListener(helpListener); + helpLabel.setFocusable(true); + helpLabel.addMouseListener(helpMouseListener); + helpLabel.addKeyListener(helpKeyListener); + helpLabel.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + + helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG_FOCUS))); + } + + @Override + public void focusLost(FocusEvent e) { + + helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG))); + } + + + }); helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + + switchFocusDummyLabel = new JLabel(); + switchFocusDummyLabel.setText(""); + switchFocusDummyLabel.setFocusable(true); + switchFocusDummyLabel.addFocusListener(switchFocusKeyListener); buttonSize = initButtonSize(); @@ -248,11 +287,15 @@ public class BKUGUIImpl implements BKUGUIFacade { headerPanelLayout.createSequentialGroup() .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel)); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ); headerPanelLayout.setVerticalGroup( headerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(titleLabel, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) - .addComponent(helpLabel)); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ); } GroupLayout contentPanelLayout = new GroupLayout(contentPanel); @@ -566,7 +609,8 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()})); } - helpListener.setHelpTopic(HELP_CARDPIN); + helpMouseListener.setHelpTopic(HELP_CARDPIN); + helpKeyListener.setHelpTopic(HELP_CARDPIN); } else { String retryPattern; if (numRetries < 2) { @@ -577,7 +621,8 @@ public class BKUGUIImpl implements BKUGUIFacade { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setForeground(ERROR_COLOR); - helpListener.setHelpTopic(HELP_RETRY); + helpMouseListener.setHelpTopic(HELP_RETRY); + helpKeyListener.setHelpTopic(HELP_RETRY); } JLabel pinsizeLabel = new JLabel(); @@ -595,9 +640,13 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { infoHorizontal .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; infoVertical - .addComponent(helpLabel); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; } // align pinfield and pinsize to the right @@ -668,7 +717,9 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanelLayout.setHorizontalGroup(buttonHorizontal); buttonPanelLayout.setVerticalGroup(buttonVertical); - pinField.requestFocusInWindow(); +// pinField.requestFocusInWindow(); +// helpLabel.requestFocus(); + pinField.requestFocus(); contentPanel.validate(); } @@ -715,7 +766,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } } - JLabel infoLabel = new JLabel(); + final JLabel infoLabel = new JLabel(); if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (shortText) { @@ -723,6 +774,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); } + infoLabel.setFocusable(true); infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(HYPERLINK_COLOR); infoLabel.addMouseListener(new MouseAdapter() { @@ -733,7 +785,47 @@ public class BKUGUIImpl implements BKUGUIFacade { hashdataListener.actionPerformed(e); } }); - helpListener.setHelpTopic(HELP_SIGNPIN); + + infoLabel.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + + if(e.getKeyCode() == KeyEvent.VK_ENTER) { + ActionEvent e1 = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e1); + } + } + + }); + + infoLabel.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY_FOCUS)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_FOCUS)); + } + } + + @Override + public void focusLost(FocusEvent e) { + + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); + } + + } + + }); + + helpMouseListener.setHelpTopic(HELP_SIGNPIN); + helpKeyListener.setHelpTopic(HELP_SIGNPIN); } else { String retryPattern; if (numRetries < 2) { @@ -741,10 +833,12 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { retryPattern = getMessage(MESSAGE_RETRIES); } + infoLabel.setFocusable(true); infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); infoLabel.setForeground(ERROR_COLOR); - helpListener.setHelpTopic(HELP_RETRY); + helpMouseListener.setHelpTopic(HELP_RETRY); + helpKeyListener.setHelpTopic(HELP_RETRY); } String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); @@ -766,9 +860,13 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { infoHorizontal .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; infoVertical - .addComponent(helpLabel); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; } mainPanelLayout.setHorizontalGroup( @@ -837,7 +935,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } } - JLabel infoLabel = new JLabel(); + final JLabel infoLabel = new JLabel(); if (numRetries < 0) { infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (shortText) { @@ -845,6 +943,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); } + infoLabel.setFocusable(true); infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(HYPERLINK_COLOR); infoLabel.addMouseListener(new MouseAdapter() { @@ -855,7 +954,49 @@ public class BKUGUIImpl implements BKUGUIFacade { hashdataListener.actionPerformed(e); } }); - helpListener.setHelpTopic(HELP_SIGNPIN); + + infoLabel.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + + if(e.getKeyCode() == KeyEvent.VK_ENTER) { + ActionEvent e1 = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e1); + } + } + + }); + + infoLabel.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { + + + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY_FOCUS)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_FOCUS)); + } + } + + @Override + public void focusLost(FocusEvent e) { + + + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); + } + + } + + }); + + helpMouseListener.setHelpTopic(HELP_SIGNPIN); + helpKeyListener.setHelpTopic(HELP_SIGNPIN); } else { String retryPattern; if (numRetries < 2) { @@ -863,10 +1004,12 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { retryPattern = getMessage(MESSAGE_RETRIES); } + infoLabel.setFocusable(true); infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); infoLabel.setForeground(ERROR_COLOR); - helpListener.setHelpTopic(HELP_RETRY); + helpMouseListener.setHelpTopic(HELP_RETRY); + helpKeyListener.setHelpTopic(HELP_RETRY); } JButton signButton = new JButton(); @@ -895,6 +1038,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } }); + JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); pinsizeLabel.setText(MessageFormat.format(getMessage(LABEL_PINSIZE), pinSpec.getLocalizedLength())); @@ -910,9 +1054,13 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { infoHorizontal .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; infoVertical - .addComponent(helpLabel); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; } // align pinfield and pinsize to the right @@ -973,21 +1121,27 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonHorizontal .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + ; buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(signButton) - .addComponent(cancelButton); + .addComponent(cancelButton) + ; } else { buttonHorizontal - .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); + .addComponent(signButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + ; buttonVertical = buttonPanelLayout.createSequentialGroup() - .addComponent(signButton); + .addComponent(signButton) + ; } buttonPanelLayout.setHorizontalGroup(buttonHorizontal); buttonPanelLayout.setVerticalGroup(buttonVertical); - pinField.requestFocusInWindow(); +// pinField.requestFocusInWindow(); +// helpLabel.requestFocus(); + pinField.requestFocus(); contentPanel.validate(); } @@ -1065,7 +1219,8 @@ public class BKUGUIImpl implements BKUGUIFacade { titleLabel.setText(getMessage(titleKey)); } - helpListener.setHelpTopic(msgKey); + helpMouseListener.setHelpTopic(msgKey); + helpKeyListener.setHelpTopic(msgKey); String msgPattern = getMessage(msgKey); String msg = MessageFormat.format(msgPattern, msgParams); @@ -1080,6 +1235,9 @@ public class BKUGUIImpl implements BKUGUIFacade { GroupLayout.ParallelGroup mainHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); GroupLayout.SequentialGroup mainVertical = mainPanelLayout.createSequentialGroup(); + log.debug("focus to contentPanel"); + contentPanel.requestFocus(); + if (!renderHeaderPanel) { JLabel titleLabel = new JLabel(); titleLabel.setFont(titleLabel.getFont().deriveFont(titleLabel.getFont().getStyle() | Font.BOLD)); @@ -1092,11 +1250,18 @@ public class BKUGUIImpl implements BKUGUIFacade { .addGroup(mainPanelLayout.createSequentialGroup() .addComponent(titleLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel)); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ); mainVertical .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(titleLabel) - .addComponent(helpLabel)); + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ); + + log.debug("focus to helpLabel"); + helpLabel.requestFocus(); } mainPanelLayout.setHorizontalGroup(mainHorizontal @@ -1105,6 +1270,7 @@ public class BKUGUIImpl implements BKUGUIFacade { .addComponent(msgLabel)); if (okListener != null) { + JButton okButton = new JButton(); okButton.setFont(okButton.getFont().deriveFont(okButton.getFont().getStyle() & ~java.awt.Font.BOLD)); okButton.setText(getMessage((buttonKey != null) ? buttonKey : BUTTON_OK)); @@ -1120,6 +1286,9 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanelLayout.setVerticalGroup( buttonPanelLayout.createSequentialGroup() .addComponent(okButton)); + + log.debug("focus to ok-button"); + okButton.requestFocus(); } contentPanel.validate(); @@ -1243,7 +1412,7 @@ public class BKUGUIImpl implements BKUGUIFacade { log.debug("show secure viewer [" + Thread.currentThread().getName() + "]"); if (secureViewer == null) { secureViewer = new SecureViewerDialog(null, messages, - helpListener.getActionListener()); + helpMouseListener.getActionListener()); // workaround for [#439] // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. @@ -1276,7 +1445,8 @@ public class BKUGUIImpl implements BKUGUIFacade { titleLabel.setText(getMessage(TITLE_HASHDATA)); } - helpListener.setHelpTopic(HELP_HASHDATALIST); + helpMouseListener.setHelpTopic(HELP_HASHDATALIST); + helpKeyListener.setHelpTopic(HELP_HASHDATALIST); JLabel refIdLabel = new JLabel(); refIdLabel.setFont(refIdLabel.getFont().deriveFont(refIdLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); @@ -1335,10 +1505,14 @@ public class BKUGUIImpl implements BKUGUIFacade { if (!renderHeaderPanel) { messageHorizontal - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(helpLabel); - messageVertical - .addComponent(helpLabel); + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; + messageVertical + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; } mainPanelLayout.setHorizontalGroup( @@ -1469,19 +1643,42 @@ public class BKUGUIImpl implements BKUGUIFacade { private void registerHelpListener(ActionListener helpListener) { if (helpListener != null) { - this.helpListener = new HelpMouseListener(helpListener); + this.helpMouseListener = new HelpMouseListener(helpListener); + this.helpKeyListener = new HelpKeyListener(helpListener); } else { log.error("no help listener provided, will not be able to display help"); - this.helpListener = new HelpMouseListener(new ActionListener() { + this.helpMouseListener = new HelpMouseListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { log.error("no help listener registered (requested help topic: " + e.getActionCommand() + ")"); } }); + this.helpKeyListener = new HelpKeyListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + log.error("no help listener registered (requested help topic: " + e.getActionCommand() + ")"); + } + }); } } + private void registerSwitchFocusListener(ActionListener switchFocusListener) { + if (switchFocusListener != null) { + this.switchFocusKeyListener = new SwitchFocusFocusListener(switchFocusListener); + + } else { + + this.switchFocusKeyListener = new SwitchFocusFocusListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + log.warn("no switch focus listener registered"); + } + }); + } + } //////////////////////////////////////////////////////////////////////////// // INITIALIZERS (MAY BE OVERRIDDEN BY SUBCLASSES) @@ -1539,4 +1736,13 @@ public class BKUGUIImpl implements BKUGUIFacade { } return bs; } + + @Override + public void getFocusFromBrowser() { + + // This method puts the focus to the helpLabel as this + // element is supposed to appear in each dialogue. + helpLabel.requestFocus(); + + } } -- cgit v1.2.3 From 83e8c95ea7d257166d350a59bfd81e9833ec14fd Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 5 Nov 2009 19:05:14 +0000 Subject: [#484] European Language support git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@535 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 e83502a8..8df4bd72 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 @@ -17,6 +17,8 @@ package at.gv.egiz.bku.gui; +import at.gv.egiz.bku.gui.viewer.FontProviderException; +import at.gv.egiz.bku.gui.viewer.FontProvider; import at.gv.egiz.smcc.PINSpec; import at.gv.egiz.stal.HashDataInput; import java.awt.Color; @@ -73,6 +75,7 @@ public class BKUGUIImpl implements BKUGUIFacade { protected HelpKeyListener helpKeyListener; protected SwitchFocusFocusListener switchFocusKeyListener; protected SecureViewerDialog secureViewer; + protected FontProvider fontProvider; protected Container contentPane; protected ResourceBundle messages; @@ -115,8 +118,9 @@ public class BKUGUIImpl implements BKUGUIFacade { */ public BKUGUIImpl(Container contentPane, Locale locale, - Style guiStyle, + Style guiStyle, URL background, + FontProvider fontProvider, ActionListener helpListener, SwitchFocusListener switchFocusListener) { this.contentPane = contentPane; @@ -139,7 +143,8 @@ public class BKUGUIImpl implements BKUGUIFacade { registerHelpListener(helpListener); registerSwitchFocusListener(switchFocusListener); - + + this.fontProvider = fontProvider; createGUI(background); } @@ -1386,7 +1391,12 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - showSecureViewer(dataToBeSigned.get(0)); + try { + showSecureViewer(dataToBeSigned.get(0)); + } catch (FontProviderException ex) { + log.error("failed to display secure viewer", ex); + showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand); + } } }); @@ -1407,12 +1417,12 @@ public class BKUGUIImpl implements BKUGUIFacade { * @param saveListener * @param saveCommand */ - private void showSecureViewer(HashDataInput dataToBeSigned) { + private void showSecureViewer(HashDataInput dataToBeSigned) throws FontProviderException { log.debug("show secure viewer [" + Thread.currentThread().getName() + "]"); if (secureViewer == null) { secureViewer = new SecureViewerDialog(null, messages, - helpMouseListener.getActionListener()); + fontProvider, helpMouseListener.getActionListener()); // workaround for [#439] // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. @@ -1485,7 +1495,12 @@ public class BKUGUIImpl implements BKUGUIFacade { int selectionIdx = lsm.getMinSelectionIndex(); if (selectionIdx >= 0) { final HashDataInput selection = signedReferences.get(selectionIdx); - showSecureViewer(selection); + try { + showSecureViewer(selection); + } catch (FontProviderException ex) { + log.error("failed to display secure viewer", ex); + showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand); + } } } }); -- cgit v1.2.3 From caca721368d8c24559b1cd5ea2018884b4874f6b Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 10 Nov 2009 15:30:16 +0000 Subject: Removed switchFocusListener due to problem with viewer/help dialogs on Firefox/Mac git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@539 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 8df4bd72..34f278fb 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 @@ -159,7 +159,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("initializing gui [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] initializing gui"); if (renderIconPanel) { initIconPanel(background); @@ -565,7 +565,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show card-pin dialog [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] show card-pin dialog"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -758,7 +758,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show pinpad signature-pin dialog [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] show pinpad signature-pin dialog"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -927,7 +927,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show signature-pin dialog [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] show signature-pin dialog"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -1215,7 +1215,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { - log.debug("show message dialog [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] show message dialog"); mainPanel.removeAll(); buttonPanel.removeAll(); @@ -1385,7 +1385,7 @@ public class BKUGUIImpl implements BKUGUIFacade { backListener, backCommand); } else if (dataToBeSigned.size() == 1) { try { - log.debug("scheduling secure viewer"); + log.debug("[" + Thread.currentThread().getName() + "] scheduling secure viewer"); SwingUtilities.invokeLater(new Runnable() { @@ -1419,7 +1419,7 @@ public class BKUGUIImpl implements BKUGUIFacade { */ private void showSecureViewer(HashDataInput dataToBeSigned) throws FontProviderException { - log.debug("show secure viewer [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] show secure viewer"); if (secureViewer == null) { secureViewer = new SecureViewerDialog(null, messages, fontProvider, helpMouseListener.getActionListener()); @@ -1439,14 +1439,14 @@ public class BKUGUIImpl implements BKUGUIFacade { private void showSignedReferencesListDialog(final List signedReferences, final ActionListener backListener, final String backCommand) { - log.debug("scheduling signed references list dialog"); + log.debug("[" + Thread.currentThread().getName() + "] scheduling signed references list dialog"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - log.debug("show signed references list dialog [" + Thread.currentThread().getName() + "]"); + log.debug("[" + Thread.currentThread().getName() + "] show signed references list dialog"); mainPanel.removeAll(); buttonPanel.removeAll(); -- cgit v1.2.3 From 68651bf67987905980734f5c2199f337a232f427 Mon Sep 17 00:00:00 2001 From: mcentner Date: Thu, 12 Nov 2009 20:48:57 +0000 Subject: Added support for enforcing a PIN length in a CHANGE REFERENCE DATA to match the recommended PIN length via Applet parameter. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@541 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 34f278fb..20fe4f56 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 @@ -593,7 +593,7 @@ public class BKUGUIImpl implements BKUGUIFacade { pinField = new JPasswordField(); pinField.setText(""); - pinField.setDocument(new PINDocument(pinSpec, okButton)); + pinField.setDocument(new PINDocument(pinSpec.getMinLength(), pinSpec.getMaxLength(), pinSpec.getRexepPattern(), okButton)); pinField.setActionCommand(okCommand); pinField.addActionListener(new ActionListener() { @@ -1031,7 +1031,7 @@ public class BKUGUIImpl implements BKUGUIFacade { pinField = new JPasswordField(); pinField.setText(""); - pinField.setDocument(new PINDocument(pinSpec, signButton)); + pinField.setDocument(new PINDocument(pinSpec.getMinLength(), pinSpec.getMaxLength(), pinSpec.getRexepPattern(), signButton)); pinField.setActionCommand(signCommand); pinField.addActionListener(new ActionListener() { -- cgit v1.2.3 From b7dd29046e232e4d42623655efc28965cce942b8 Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 13 Nov 2009 15:13:21 +0000 Subject: git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@546 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 318 +++++++++++---------- 1 file changed, 160 insertions(+), 158 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 20fe4f56..baffb3fd 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 @@ -19,6 +19,7 @@ package at.gv.egiz.bku.gui; import at.gv.egiz.bku.gui.viewer.FontProviderException; import at.gv.egiz.bku.gui.viewer.FontProvider; +import at.gv.egiz.bku.gui.viewer.SecureViewerSaveDialog; import at.gv.egiz.smcc.PINSpec; import at.gv.egiz.stal.HashDataInput; import java.awt.Color; @@ -1384,26 +1385,34 @@ public class BKUGUIImpl implements BKUGUIFacade { new Object[] {"no signature data provided"}, backListener, backCommand); } else if (dataToBeSigned.size() == 1) { - try { - log.debug("[" + Thread.currentThread().getName() + "] scheduling secure viewer"); - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - try { - showSecureViewer(dataToBeSigned.get(0)); - } catch (FontProviderException ex) { - log.error("failed to display secure viewer", ex); - showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand); + //TODO pull out (see also SignedReferencesSelectionListener) + if (SecureViewerDialog.SUPPORTED_MIME_TYPES.contains(dataToBeSigned.get(0).getMimeType())) { + try { + log.debug("[" + Thread.currentThread().getName() + "] scheduling secure viewer"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + try { + showMessageDialog(TITLE_HASHDATA, MESSAGE_HASHDATA_VIEWER); + showSecureViewer(dataToBeSigned.get(0), backListener, backCommand); + } catch (FontProviderException ex) { + log.error("failed to display secure viewer", ex); + showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand); + } } - } - }); - - } catch (Exception ex) { //InterruptedException InvocationTargetException - log.error("Failed to display secure viewer: " + ex.getMessage()); - log.trace(ex); - showErrorDialog(ERR_UNKNOWN, null, backListener, backCommand); + }); + + } catch (Exception ex) { //InterruptedException InvocationTargetException + log.error("Failed to display secure viewer: " + ex.getMessage()); + log.trace(ex); + showErrorDialog(ERR_UNKNOWN, null, backListener, backCommand); + } + } else { + log.debug("[" + Thread.currentThread().getName() + "] mime-type not supported by secure viewer, scheduling save dialog"); + showMessageDialog(TITLE_HASHDATA, MESSAGE_UNSUPPORTED_MIMETYPE); + SecureViewerSaveDialog.showSaveDialog(dataToBeSigned.get(0), messages, backListener, backCommand); } } else { showSignedReferencesListDialog(dataToBeSigned, backListener, backCommand); @@ -1412,30 +1421,48 @@ public class BKUGUIImpl implements BKUGUIFacade { /** * has to be called from event dispatcher thread - * This method blocks until the dialog's close button is pressed. * @param hashDataText * @param saveListener * @param saveCommand */ - private void showSecureViewer(HashDataInput dataToBeSigned) throws FontProviderException { +// private void showSecureViewer(HashDataInput dataToBeSigned) throws FontProviderException { +// +// log.debug("[" + Thread.currentThread().getName() + "] show secure viewer"); +// if (secureViewer == null) { +// secureViewer = new SecureViewerDialog(null, messages, +// fontProvider, helpMouseListener.getActionListener()); +// +// // workaround for [#439] +// // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. +// Window window = SwingUtilities.getWindowAncestor(contentPane); +// if (window != null && window.isAlwaysOnTop()) { +// log.debug("make secureViewer alwaysOnTop"); +// secureViewer.setAlwaysOnTop(true); +// } +// } +// secureViewer.setContent(dataToBeSigned); +// log.trace("show secure viewer returned"); +// } + private void showSecureViewer(HashDataInput dataToBeSigned, ActionListener closeListener, String closeCommand) throws FontProviderException { log.debug("[" + Thread.currentThread().getName() + "] show secure viewer"); - if (secureViewer == null) { - secureViewer = new SecureViewerDialog(null, messages, - fontProvider, helpMouseListener.getActionListener()); - - // workaround for [#439] - // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. - Window window = SwingUtilities.getWindowAncestor(contentPane); - if (window != null && window.isAlwaysOnTop()) { - log.debug("make secureViewer alwaysOnTop"); - secureViewer.setAlwaysOnTop(true); - } + SecureViewerDialog secureViewer = new SecureViewerDialog(null, messages, + closeListener, closeCommand, + fontProvider, helpMouseListener.getActionListener()); + + // workaround for [#439] + // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. + Window window = SwingUtilities.getWindowAncestor(contentPane); + if (window != null && window.isAlwaysOnTop()) { + log.debug("make secureViewer alwaysOnTop"); + secureViewer.setAlwaysOnTop(true); } secureViewer.setContent(dataToBeSigned); - log.trace("show secure viewer returned"); + log.trace("viewer setContent returned"); } + + private void showSignedReferencesListDialog(final List signedReferences, final ActionListener backListener, final String backCommand) { @@ -1468,44 +1495,10 @@ public class BKUGUIImpl implements BKUGUIFacade { hashDataTable.setDefaultRenderer(HashDataInput.class, new HyperlinkRenderer(renderRefId)); hashDataTable.setTableHeader(null); - // not possible to add mouse listener to TableCellRenderer - hashDataTable.addMouseMotionListener(new MouseMotionAdapter() { - - @Override - public void mouseMoved(MouseEvent e) { - if (hashDataTable.columnAtPoint(e.getPoint()) == 0) { - hashDataTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } else { - hashDataTable.setCursor(Cursor.getDefaultCursor()); - } - } - }); + hashDataTable.addMouseMotionListener(new SignedReferencesMouseMotionListener(hashDataTable)); hashDataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - hashDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - - @Override - public void valueChanged(final ListSelectionEvent e) { - //invoke later to allow thread to paint selection background - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - ListSelectionModel lsm = (ListSelectionModel) e.getSource(); - int selectionIdx = lsm.getMinSelectionIndex(); - if (selectionIdx >= 0) { - final HashDataInput selection = signedReferences.get(selectionIdx); - try { - showSecureViewer(selection); - } catch (FontProviderException ex) { - log.error("failed to display secure viewer", ex); - showErrorDialog(ERR_VIEWER, new Object[] {ex.getMessage()}, backListener, backCommand); - } - } - } - }); - } - }); + hashDataTable.getSelectionModel().addListSelectionListener(new SignedReferencesSelectionListener(signedReferences, backListener, backCommand)); JScrollPane hashDataScrollPane = new JScrollPane(hashDataTable); @@ -1560,97 +1553,106 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } + + /** - * @param okListener may be null + * not possible to add mouse listener to TableCellRenderer + * to change cursor on specific columns only, use table.columnAtPoint(e.getPoint()) + * */ -// private void showSaveDialog(final List signedRefs, -// final ActionListener okListener, final String okCommand) { -// -// log.debug("scheduling save dialog"); -// -// SwingUtilities.invokeLater(new Runnable() { -// -// @Override -// public void run() { -// -// log.debug("show save dialog"); -// -// String userHome = System.getProperty("user.home"); -// -// JFileChooser fileDialog = new JFileChooser(userHome); -// fileDialog.setMultiSelectionEnabled(false); -// fileDialog.setDialogType(JFileChooser.SAVE_DIALOG); -// fileDialog.setFileHidingEnabled(true); -// if (signedRefs.size() == 1) { -// fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVE)); -// fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY); -// String mimeType = signedRefs.get(0).getMimeType(); -// MimeFilter mimeFilter = new MimeFilter(mimeType, messages); -// fileDialog.setFileFilter(mimeFilter); -// String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + MimeFilter.getExtension(mimeType); -// fileDialog.setSelectedFile(new File(userHome, filename)); -// } else { -// fileDialog.setDialogTitle(getMessage(WINDOWTITLE_SAVEDIR)); -// fileDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); -// } -// -// //parent contentPane -> placed over applet -// switch (fileDialog.showSaveDialog(fileDialog)) { -// case JFileChooser.APPROVE_OPTION: -// File f = fileDialog.getSelectedFile(); -// for (HashDataInput hashDataInput : signedRefs) { -// String mimeType = hashDataInput.getMimeType(); -// String id = hashDataInput.getReferenceId(); -// File file; -// if (f.isDirectory()) { -// String filename = getMessage(SAVE_HASHDATAINPUT_PREFIX) + '_' + id + MimeFilter.getExtension(mimeType); -// file = new File(f, filename); -// } else { -// file = f; -// } -// if (file.exists()) { -// String ovrwrt = getMessage(MESSAGE_OVERWRITE); -// int overwrite = JOptionPane.showConfirmDialog(fileDialog, MessageFormat.format(ovrwrt, file), getMessage(WINDOWTITLE_OVERWRITE), JOptionPane.OK_CANCEL_OPTION); -// if (overwrite != JOptionPane.OK_OPTION) { -// continue; -// } -// } -// if (log.isDebugEnabled()) { -// log.debug("writing hashdata input " + id + " (" + mimeType + ") to file " + file); -// } -// FileOutputStream fos = null; -// try { -// fos = new FileOutputStream(file); -// BufferedOutputStream bos = new BufferedOutputStream(fos); -// InputStream hdi = hashDataInput.getHashDataInput(); -// int b; -// while ((b = hdi.read()) != -1) { -// bos.write(b); -// } -// bos.flush(); -// bos.close(); -// } catch (IOException ex) { -// log.error("Failed to write " + file + ": " + ex.getMessage()); -// showErrorDialog(ERR_WRITE_HASHDATA, new Object[] {ex.getMessage()}, null, null); -// ex.printStackTrace(); -// } finally { -// try { -// fos.close(); -// } catch (IOException ex) { -// } -// } -// } -// break; -// case JFileChooser.CANCEL_OPTION : -// log.debug("cancelled save dialog"); -// break; -// } -// if (okListener != null) { -// okListener.actionPerformed(new ActionEvent(fileDialog, ActionEvent.ACTION_PERFORMED, okCommand)); -// } -// } -// }); -// } + private class SignedReferencesMouseMotionListener extends MouseMotionAdapter { + + JTable hashDataTable; + + public SignedReferencesMouseMotionListener(JTable table) { + this.hashDataTable = table; + } + + @Override + public void mouseMoved(MouseEvent e) { +// if (hashDataTable.columnAtPoint(e.getPoint()) == 0) { + hashDataTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + } + + /////////// + // SignedReferencesList (TODO pull out) + + public class SignedReferencesSelectionListener implements ListSelectionListener { + + List signedReferences; + ActionListener backListener; + String backCommand; + + public SignedReferencesSelectionListener(List signedReferences, ActionListener backListener, String backCommand) { + this.signedReferences = signedReferences; + this.backListener = backListener; + this.backCommand = backCommand; + } + + @Override + public void valueChanged(ListSelectionEvent event) { + + if (event.getValueIsAdjusting()) { + return; + } + + ListSelectionModel lsm = (ListSelectionModel) event.getSource(); + int selectionIdx = lsm.getMinSelectionIndex(); + + log.debug("[" + Thread.currentThread().getName() + "] reference " + selectionIdx + " selected"); + + if (selectionIdx >= 0) { + final HashDataInput selection = signedReferences.get(selectionIdx); + final SignedReferencesListDisplayer backToListListener = new SignedReferencesListDisplayer(signedReferences, backListener, backCommand); + + if (SecureViewerDialog.SUPPORTED_MIME_TYPES.contains(selection.getMimeType())) { + log.debug("[" + Thread.currentThread().getName() + "] scheduling secure viewer dialog"); + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + try { + showMessageDialog(TITLE_HASHDATA, MESSAGE_HASHDATA_VIEWER); + showSecureViewer(selection, backToListListener, null); +// SecureViewerDialog.showSecureViewer(selection, messages, fontProvider, helpMouseListener.getActionListener(), false); + } catch (FontProviderException ex) { + log.error("failed to display secure viewer", ex); + showErrorDialog(BKUGUIFacade.ERR_VIEWER, new Object[] {ex.getMessage()}, backToListListener, null); + } + + } + }); + } else { + log.debug("[" + Thread.currentThread().getName() + "] mime-type not supported by secure viewer, scheduling save dialog"); + showMessageDialog(BKUGUIFacade.TITLE_HASHDATA, BKUGUIFacade.MESSAGE_UNSUPPORTED_MIMETYPE); + SecureViewerSaveDialog.showSaveDialog(selection, messages, backToListListener, null); + } + } + } + + /** + * ActionListener that returns to signed references list + */ + private class SignedReferencesListDisplayer implements ActionListener { + List sr; + ActionListener bl; + String bc; + + public SignedReferencesListDisplayer(List signedReferences, ActionListener backListener, String backCommand) { + sr = signedReferences; + bl = backListener; + bc = backCommand; + } + + @Override + public void actionPerformed(ActionEvent e) { +// log.debug("[" + Thread.currentThread().getName() + "] displaying signed references list"); + showSignedReferencesListDialog(sr, bl, bc); + } + } + } + //////////////////////////////////////////////////////////////////////////// // UTILITY METHODS -- cgit v1.2.3 From 3da4655d011dfc2f04f9e4ac28b38aee42d01bc0 Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 5 Jan 2010 10:06:47 +0000 Subject: Features [#437] Handle pinpad [64:03] response apdu correctly [#445] pin entry feedback for VERIFY_PIN_START/FINISH [#471] Provide SecureViewer Link before Pinpad PinEntry timeout starts Bugs [#479] PIN Managment Applet allows unmatching new pin and pin confirmation [#480] PIN Management displays blocked PINs as ACTIVE [#486] Not possible to select 3 times in series the same item from signedReferencesList for display in secureViewer [#506] change pin dialog (gui) issues [#508] e-card G3 PIN activation (with TransportPIN) not supported [#509] closing secure viewer window (WINDOW_CLOSING) leaves "signature data is displayed in viewer" dialog in applet git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@565 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 765 +++++++++------------ 1 file changed, 326 insertions(+), 439 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 baffb3fd..3fc631c3 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 @@ -93,6 +93,7 @@ public class BKUGUIImpl implements BKUGUIFacade { protected JLabel switchFocusDummyLabel; /** remember the pinfield to return to worker */ protected JPasswordField pinField; + protected JPasswordField pinpadPINField; protected int buttonSize; @@ -360,221 +361,27 @@ public class BKUGUIImpl implements BKUGUIFacade { return messages.containsKey(key); } -// @Override -// public void showWelcomeDialog() { -// -// log.debug("scheduling welcome dialog"); -// -// SwingUtilities.invokeLater(new Runnable() { -// -// @Override -// public void run() { -// -// log.debug("show welcome dialog"); -// -// mainPanel.removeAll(); -// buttonPanel.removeAll(); -// -// helpListener.setHelpTopic(HELP_WELCOME); -// -// JLabel welcomeMsgLabel = new JLabel(); -// welcomeMsgLabel.setFont(welcomeMsgLabel.getFont().deriveFont(welcomeMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); -// -// if (renderHeaderPanel) { -// titleLabel.setText(getMessage(TITLE_WELCOME)); -// welcomeMsgLabel.setText(getMessage(MESSAGE_WAIT)); -// } else { -// welcomeMsgLabel.setText(getMessage(TITLE_WELCOME)); -// } -// -// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); -// mainPanel.setLayout(mainPanelLayout); -// -// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() -// .addComponent(welcomeMsgLabel); -// GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) -// .addComponent(welcomeMsgLabel); -// if (!renderHeaderPanel) { -// messageHorizontal -// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) -// .addComponent(helpLabel); -// messageVertical -// .addComponent(helpLabel); -// } -// -// mainPanelLayout.setHorizontalGroup(messageHorizontal); -// mainPanelLayout.setVerticalGroup(messageVertical); -// -// contentPanel.validate(); -// -// } -// }); -// } - -// @Override -// public void showInsertCardDialog( -// final ActionListener cancelListener, final String cancelCommand) { -// -// log.debug("scheduling insert card dialog"); -// -// SwingUtilities.invokeLater(new Runnable() { -// -// @Override -// public void run() { -// -// log.debug("show insert card dialog"); -// -// mainPanel.removeAll(); -// buttonPanel.removeAll(); -// -// if (renderHeaderPanel) { -// titleLabel.setText(getMessage(TITLE_INSERTCARD)); -// } -// -// helpListener.setHelpTopic(HELP_INSERTCARD); -// -// JLabel insertCardMsgLabel = new JLabel(); -// insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); -// insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); -// -// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); -// mainPanel.setLayout(mainPanelLayout); -// -// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() -// .addComponent(insertCardMsgLabel); -// GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup() -// .addComponent(insertCardMsgLabel); -// -// if (!renderHeaderPanel) { -// messageHorizontal -// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) -// .addComponent(helpLabel); -// messageVertical -// .addComponent(helpLabel); -// } -// -// mainPanelLayout.setHorizontalGroup(messageHorizontal); -// mainPanelLayout.setVerticalGroup(messageVertical); -// -// if (renderCancelButton) { -// JButton cancelButton = new JButton(); -// cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); -// cancelButton.setText(getMessage(BUTTON_CANCEL)); -// cancelButton.addActionListener(cancelListener); -// cancelButton.setActionCommand(cancelCommand); -// -// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); -// buttonPanel.setLayout(buttonPanelLayout); -// -// buttonPanelLayout.setHorizontalGroup( -// buttonPanelLayout.createSequentialGroup() -// .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) -// .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); -// buttonPanelLayout.setVerticalGroup( -// buttonPanelLayout.createSequentialGroup() -// .addComponent(cancelButton)); -// } -// -// contentPanel.validate(); -// } -// }); -// } - - /** - * only difference to showInsertCard: title text: card not supported - * @param cancelListener - * @param cancelCommand - */ -// @Override -// public void showCardNotSupportedDialog(final ActionListener cancelListener, final String cancelCommand) { -// -// log.debug("scheduling card not supported dialog"); -// -// SwingUtilities.invokeLater(new Runnable() { -// -// @Override -// public void run() { -// -// log.debug("show card not supported dialog"); -// -// mainPanel.removeAll(); -// buttonPanel.removeAll(); -// -// JLabel insertCardMsgLabel = new JLabel(); -// insertCardMsgLabel.setFont(insertCardMsgLabel.getFont().deriveFont(insertCardMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); -// -// if (renderHeaderPanel) { -// titleLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); -// insertCardMsgLabel.setText(getMessage(MESSAGE_INSERTCARD)); -// } else { -// insertCardMsgLabel.setText(getMessage(TITLE_CARD_NOT_SUPPORTED)); -// } -// -// helpListener.setHelpTopic(HELP_CARDNOTSUPPORTED); -// -// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); -// mainPanel.setLayout(mainPanelLayout); -// -// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() -// .addComponent(insertCardMsgLabel); -// GroupLayout.Group messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) -// .addComponent(insertCardMsgLabel); -// if (!renderHeaderPanel) { -// messageHorizontal -// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) -// .addComponent(helpLabel); -// messageVertical -// .addComponent(helpLabel); -// } -// -// mainPanelLayout.setHorizontalGroup(messageHorizontal); -// mainPanelLayout.setVerticalGroup(messageVertical); -// -// if (renderCancelButton) { -// JButton cancelButton = new JButton(); -// cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); -// cancelButton.setText(getMessage(BUTTON_CANCEL)); -// cancelButton.addActionListener(cancelListener); -// cancelButton.setActionCommand(cancelCommand); -// -// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); -// buttonPanel.setLayout(buttonPanelLayout); -// -// buttonPanelLayout.setHorizontalGroup( -// buttonPanelLayout.createSequentialGroup() -// .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) -// .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)); -// buttonPanelLayout.setVerticalGroup( -// buttonPanelLayout.createSequentialGroup() -// .addComponent(cancelButton)); -// } -// -// contentPanel.validate(); -// } -// }); -// } - @Override - public void showCardPINDialog(final PINSpec pinSpec, final int numRetries, + public void showVerifyPINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener okListener, final String okCommand, final ActionListener cancelListener, final String cancelCommand) { - log.debug("scheduling card-pin dialog"); + log.debug("scheduling verify pin dialog"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - log.debug("[" + Thread.currentThread().getName() + "] show card-pin dialog"); + log.debug("[" + Thread.currentThread().getName() + "] show verify pin dialog"); mainPanel.removeAll(); buttonPanel.removeAll(); if (renderHeaderPanel) { if (numRetries < 0) { - String cardpinTitle = getMessage(TITLE_CARDPIN); - titleLabel.setText(MessageFormat.format(cardpinTitle, new Object[]{pinSpec.getLocalizedName()})); + String verifyTitle = getMessage(TITLE_VERIFY_PIN); + titleLabel.setText(MessageFormat.format(verifyTitle, new Object[]{pinSpec.getLocalizedName()})); } else { titleLabel.setText(getMessage(TITLE_RETRY)); } @@ -615,8 +422,8 @@ public class BKUGUIImpl implements BKUGUIFacade { } else { infoLabel.setText(MessageFormat.format(infoPattern, new Object[] {pinSpec.getLocalizedName()})); } - helpMouseListener.setHelpTopic(HELP_CARDPIN); - helpKeyListener.setHelpTopic(HELP_CARDPIN); + helpMouseListener.setHelpTopic(HELP_VERIFY_PIN); + helpKeyListener.setHelpTopic(HELP_VERIFY_PIN); } else { String retryPattern; if (numRetries < 2) { @@ -732,194 +539,346 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } -// @Override -// public void showCardPINDialog(PINSpec pinSpec, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { -// showCardPINDialog(pinSpec, -1, okListener, okCommand, cancelListener, cancelCommand); -// } -// -// @Override -// public void showCardPINRetryDialog(PINSpec pinSpec, int numRetries, ActionListener okListener, String okCommand, ActionListener cancelListener, String cancelCommand) { -// showCardPINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand); -// } + @Override + public void showEnterPINDirect(PINSpec pinSpec, int retries) { + if (retries < 0) { + showMessageDialog(TITLE_VERIFY_PINPAD, MESSAGE_ENTERPIN_PINPAD_DIRECT, new Object[] { + pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }); + } else { + showMessageDialog(TITLE_RETRY, MESSAGE_RETRIES, new Object[]{String.valueOf(retries) }); + } + } -// @Override -// public void showSignaturePINDialog(PINSpec pinSpec, ActionListener signListener, String signCommand, ActionListener cancelListener, String cancelCommand, ActionListener hashdataListener, String hashdataCommand) { -// showSignaturePINDialog(pinSpec, -1, signListener, signCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); -// } + @Override + public void showEnterPIN(final PINSpec pinSpec, final int retries) { + showEnterPIN(pinSpec, retries, TITLE_VERIFY_PINPAD, MESSAGE_ENTERPIN_PINPAD, null); + } - @Override - public void showPinpadSignaturePINDialog(final PINSpec pinSpec, final int numRetries, -// final ActionListener cancelListener, final String cancelCommand, - final ActionListener hashdataListener, final String hashdataCommand) { + protected void showEnterPIN(final PINSpec pinSpec, final int retries, final String titleKey, final String messageKey, final Object[] messageParams) { + log.debug("scheduling pinpad dialog"); - log.debug("scheduling pinpad signature-pin dialog"); + SwingUtilities.invokeLater(new Runnable() { - SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { - @Override - public void run() { + log.debug("[" + Thread.currentThread().getName() + "] show pinpad dialog"); - log.debug("[" + Thread.currentThread().getName() + "] show pinpad signature-pin dialog"); + mainPanel.removeAll(); + buttonPanel.removeAll(); - mainPanel.removeAll(); - buttonPanel.removeAll(); + if (renderHeaderPanel) { + if (retries < 0) { + titleLabel.setText(getMessage(titleKey)); + } else { + titleLabel.setText(getMessage(TITLE_RETRY)); + } + } - if (renderHeaderPanel) { - if (numRetries < 0) { - titleLabel.setText(getMessage(TITLE_SIGN)); - } else { - titleLabel.setText(getMessage(TITLE_RETRY)); - } - } + final JLabel infoLabel = new JLabel(); + if (retries < 0) { + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + infoLabel.setText(MessageFormat.format(getMessage(messageKey), messageParams)); + helpMouseListener.setHelpTopic(HELP_PINPAD); + helpKeyListener.setHelpTopic(HELP_PINPAD); + } else { + String retryPattern; + if (retries == 1) { + retryPattern = getMessage(MESSAGE_LAST_RETRY); + } else { + retryPattern = getMessage(MESSAGE_RETRIES); + } + infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(retries)})); + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); + infoLabel.setForeground(ERROR_COLOR); + helpMouseListener.setHelpTopic(HELP_RETRY); + helpKeyListener.setHelpTopic(HELP_RETRY); + } + + JLabel pinLabel = new JLabel(); + pinLabel.setFont(pinLabel.getFont().deriveFont(pinLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + String pinName = getMessage(LABEL_PIN); + pinLabel.setText(MessageFormat.format(pinName, new Object[]{pinSpec.getLocalizedName()})); + + pinpadPINField = new JPasswordField(); + pinpadPINField.setText(""); + pinpadPINField.setEnabled(false); + + JLabel pinsizeLabel = new JLabel(); + pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); + pinsizeLabel.setText(MessageFormat.format(getMessage(LABEL_PINSIZE), pinSpec.getLocalizedLength())); + + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(infoLabel); + GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(infoLabel); + + if (!renderHeaderPanel) { + infoHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; + infoVertical + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; + } + + // align pinfield and pinsize to the right + GroupLayout.Group pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING); + GroupLayout.SequentialGroup pinVertical = mainPanelLayout.createSequentialGroup(); + + if (pinLabelPos == PinLabelPosition.ABOVE) { + pinHorizontal + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(pinpadPINField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + pinVertical + .addComponent(pinLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinpadPINField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel); + } else { // PinLabelPosition.LEFT + pinHorizontal + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinpadPINField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE); + pinVertical + .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(pinLabel) + .addComponent(pinpadPINField)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pinsizeLabel); + } + + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(infoHorizontal) + .addGroup(pinHorizontal)); + + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createSequentialGroup() + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pinVertical)); + + contentPanel.validate(); + } + }); + } + + @Override + public void showSignatureDataDialog(PINSpec spec, + final ActionListener enterPINListener, final String enterPINCommand, + final ActionListener cancelListener, final String cancelCommand, + final ActionListener hashdataListener, final String hashdataCommand) { + + log.debug("scheduling signature-data dialog"); + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + log.debug("[" + Thread.currentThread().getName() + "] show signature-data dialog"); + + mainPanel.removeAll(); + buttonPanel.removeAll(); + + if (renderHeaderPanel) { + titleLabel.setText(getMessage(TITLE_SIGNATURE_DATA)); + } + + final JLabel infoLabel = new JLabel(); + infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); + } + infoLabel.setFocusable(true); + infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + infoLabel.setForeground(HYPERLINK_COLOR); + infoLabel.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent me) { + ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e); + } + }); + + infoLabel.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + + if(e.getKeyCode() == KeyEvent.VK_ENTER) { + ActionEvent e1 = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); + hashdataListener.actionPerformed(e1); + } + } + + }); + + infoLabel.addFocusListener(new FocusAdapter() { + + @Override + public void focusGained(FocusEvent e) { - final JLabel infoLabel = new JLabel(); - if (numRetries < 0) { - infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); if (shortText) { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); - } else { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); - } - infoLabel.setFocusable(true); - infoLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - infoLabel.setForeground(HYPERLINK_COLOR); - infoLabel.addMouseListener(new MouseAdapter() { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY_FOCUS)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_FOCUS)); + } + } - @Override - public void mouseClicked(MouseEvent me) { - ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); - hashdataListener.actionPerformed(e); - } - }); - - infoLabel.addKeyListener(new KeyAdapter() { - - @Override - public void keyPressed(KeyEvent e) { - - if(e.getKeyCode() == KeyEvent.VK_ENTER) { - ActionEvent e1 = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, hashdataCommand); - hashdataListener.actionPerformed(e1); - } - } - - }); - - infoLabel.addFocusListener(new FocusAdapter() { - - @Override - public void focusGained(FocusEvent e) { - - if (shortText) { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY_FOCUS)); - } else { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_FOCUS)); - } - } - - @Override - public void focusLost(FocusEvent e) { - - if (shortText) { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); - } else { - infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); - } - - } - - }); - - helpMouseListener.setHelpTopic(HELP_SIGNPIN); - helpKeyListener.setHelpTopic(HELP_SIGNPIN); - } else { - String retryPattern; - if (numRetries < 2) { - retryPattern = getMessage(MESSAGE_LAST_RETRY); - } else { - retryPattern = getMessage(MESSAGE_RETRIES); - } - infoLabel.setFocusable(true); - infoLabel.setText(MessageFormat.format(retryPattern, new Object[]{String.valueOf(numRetries)})); - infoLabel.setFont(infoLabel.getFont().deriveFont(infoLabel.getFont().getStyle() | java.awt.Font.BOLD)); - infoLabel.setForeground(ERROR_COLOR); - helpMouseListener.setHelpTopic(HELP_RETRY); - helpKeyListener.setHelpTopic(HELP_RETRY); - } + @Override + public void focusLost(FocusEvent e) { - String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); - String msg = MessageFormat.format(msgPattern, new Object[] { - pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }); + if (shortText) { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK_TINY)); + } else { + infoLabel.setText(getMessage(MESSAGE_HASHDATALINK)); + } - JLabel msgLabel = new JLabel(); - msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); - msgLabel.setText(msg); + } - GroupLayout mainPanelLayout = new GroupLayout(mainPanel); - mainPanel.setLayout(mainPanelLayout); + }); - GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() - .addComponent(infoLabel); - GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(infoLabel); + helpMouseListener.setHelpTopic(HELP_SIGNPIN); + helpKeyListener.setHelpTopic(HELP_SIGNPIN); - if (!renderHeaderPanel) { - infoHorizontal - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) - .addComponent(switchFocusDummyLabel) - .addComponent(helpLabel) - ; - infoVertical - .addComponent(switchFocusDummyLabel) - .addComponent(helpLabel) - ; - } + //TODO message panel - mainPanelLayout.setHorizontalGroup( - mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(infoHorizontal) - .addComponent(msgLabel)); +// String msgPattern = getMessage(MESSAGE_ENTERPIN_PINPAD); +// String msg = MessageFormat.format(msgPattern, new Object[] { +// pinSpec.getLocalizedName(), pinSpec.getLocalizedLength() }); +// +// JLabel msgLabel = new JLabel(); +// msgLabel.setFont(msgLabel.getFont().deriveFont(msgLabel.getFont().getStyle() & ~Font.BOLD)); +// msgLabel.setText(msg); - mainPanelLayout.setVerticalGroup( - mainPanelLayout.createSequentialGroup() - .addGroup(infoVertical) + GroupLayout mainPanelLayout = new GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + + GroupLayout.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup() + .addComponent(infoLabel); + GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(infoLabel); + + if (!renderHeaderPanel) { + infoHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; + infoVertical + .addComponent(switchFocusDummyLabel) + .addComponent(helpLabel) + ; + } + + mainPanelLayout.setHorizontalGroup( + infoHorizontal); +// mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) +// .addGroup(infoHorizontal) +// .addComponent(msgLabel)); + + mainPanelLayout.setVerticalGroup( + infoVertical); +// mainPanelLayout.createSequentialGroup() +// .addGroup(infoVertical) +// .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) +// .addComponent(msgLabel)); + + + GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); + buttonPanel.setLayout(buttonPanelLayout); + + GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup(); + GroupLayout.Group buttonVertical; + + JButton enterPINButton = new JButton(); + enterPINButton.setFont(enterPINButton.getFont().deriveFont(enterPINButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + enterPINButton.setText(getMessage(BUTTON_SIGN)); + enterPINButton.setActionCommand(enterPINCommand); + enterPINButton.addActionListener(enterPINListener); + + if (renderCancelButton) { + JButton cancelButton = new JButton(); + cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); + cancelButton.setText(getMessage(BUTTON_CANCEL)); + cancelButton.setActionCommand(cancelCommand); + cancelButton.addActionListener(cancelListener); + + buttonHorizontal + .addComponent(enterPINButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(msgLabel)); - - //no cancel button (cancel via pinpad) -// if (renderCancelButton) { -// JButton cancelButton = new JButton(); -// cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD)); -// cancelButton.setText(getMessage(BUTTON_CANCEL)); -// cancelButton.setActionCommand(cancelCommand); -// cancelButton.addActionListener(cancelListener); -// -// GroupLayout buttonPanelLayout = new GroupLayout(buttonPanel); -// buttonPanel.setLayout(buttonPanelLayout); -// -// GroupLayout.SequentialGroup buttonHorizontal = buttonPanelLayout.createSequentialGroup() -// .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE); -// GroupLayout.SequentialGroup buttonVertical = buttonPanelLayout.createSequentialGroup() -// .addComponent(cancelButton); -// -// buttonPanelLayout.setHorizontalGroup(buttonHorizontal); -// buttonPanelLayout.setVerticalGroup(buttonVertical); -// } + .addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + ; + buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(enterPINButton) + .addComponent(cancelButton) + ; + } else { + buttonHorizontal + .addComponent(enterPINButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE) + ; + buttonVertical = buttonPanelLayout.createSequentialGroup() + .addComponent(enterPINButton) + ; + } - contentPanel.validate(); - } - }); + buttonPanelLayout.setHorizontalGroup(buttonHorizontal); + buttonPanelLayout.setVerticalGroup(buttonVertical); + + contentPanel.validate(); + } + }); + } + + @Override + public void correctionButtonPressed() { + log.debug("[" + Thread.currentThread().getName() + "] correction button pressed"); + + if (pinpadPINField != null) { + String maskedPIN = pinpadPINField.getText(); + pinpadPINField.setText(maskedPIN.substring(0, maskedPIN.length() - 1)); + } + } + + @Override + public void allKeysCleared() { + log.debug("[" + Thread.currentThread().getName() + "] all keys cleared"); + + if (pinpadPINField != null) { + pinpadPINField.setText(""); + } + } + + @Override + public void validKeyPressed() { + log.debug("[" + Thread.currentThread().getName() + "] valid key pressed"); + + if (pinpadPINField != null) { + pinpadPINField.setText(pinpadPINField.getText() + '*'); } + } @Override public void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener signListener, final String signCommand, final ActionListener cancelListener, final String cancelCommand, final ActionListener hashdataListener, final String hashdataCommand) { -// showSignaturePINDialog(pinSpec, numRetries, okListener, okCommand, cancelListener, cancelCommand, hashdataListener, hashdataCommand); -// } -// -// private void showSignaturePINDialog(final PINSpec pinSpec, final int numRetries, final ActionListener signListener, final String signCommand, final ActionListener cancelListener, final String cancelCommand, final ActionListener hashdataListener, final String hashdataCommand) { log.debug("scheduling signature-pin dialog"); @@ -1302,57 +1261,6 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } -// @Override -// public void showWaitDialog(final String waitMessage) { -// -// log.debug("scheduling wait dialog"); -// -// SwingUtilities.invokeLater(new Runnable() { -// -// @Override -// public void run() { -// -// log.debug("show wait dialog"); -// -// mainPanel.removeAll(); -// buttonPanel.removeAll(); -// -// if (renderHeaderPanel) { -// titleLabel.setText(getMessage(TITLE_WAIT)); -// } -// -// helpListener.setHelpTopic(HELP_WAIT); -// -// JLabel waitMsgLabel = new JLabel(); -// waitMsgLabel.setFont(waitMsgLabel.getFont().deriveFont(waitMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); -// if (waitMessage != null) { -// waitMsgLabel.setText("" + waitMessage + ""); -// } else { -// waitMsgLabel.setText(getMessage(MESSAGE_WAIT)); -// } -// -// GroupLayout mainPanelLayout = new GroupLayout(mainPanel); -// mainPanel.setLayout(mainPanelLayout); -// -// GroupLayout.SequentialGroup messageHorizontal = mainPanelLayout.createSequentialGroup() -// .addComponent(waitMsgLabel); -// GroupLayout.ParallelGroup messageVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) -// .addComponent(waitMsgLabel); -// -// if (!renderHeaderPanel) { -// messageHorizontal -// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) -// .addComponent(helpLabel); -// messageVertical -// .addComponent(helpLabel); -// } -// mainPanelLayout.setHorizontalGroup(messageHorizontal); -// mainPanelLayout.setVerticalGroup(messageVertical); -// -// contentPanel.validate(); -// } -// }); -// } @Override public char[] getPin() { @@ -1395,7 +1303,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { try { - showMessageDialog(TITLE_HASHDATA, MESSAGE_HASHDATA_VIEWER); + showMessageDialog(TITLE_SIGNATURE_DATA, MESSAGE_HASHDATA_VIEWER); showSecureViewer(dataToBeSigned.get(0), backListener, backCommand); } catch (FontProviderException ex) { log.error("failed to display secure viewer", ex); @@ -1411,7 +1319,7 @@ public class BKUGUIImpl implements BKUGUIFacade { } } else { log.debug("[" + Thread.currentThread().getName() + "] mime-type not supported by secure viewer, scheduling save dialog"); - showMessageDialog(TITLE_HASHDATA, MESSAGE_UNSUPPORTED_MIMETYPE); + showMessageDialog(TITLE_SIGNATURE_DATA, MESSAGE_UNSUPPORTED_MIMETYPE); SecureViewerSaveDialog.showSaveDialog(dataToBeSigned.get(0), messages, backListener, backCommand); } } else { @@ -1421,28 +1329,7 @@ public class BKUGUIImpl implements BKUGUIFacade { /** * has to be called from event dispatcher thread - * @param hashDataText - * @param saveListener - * @param saveCommand */ -// private void showSecureViewer(HashDataInput dataToBeSigned) throws FontProviderException { -// -// log.debug("[" + Thread.currentThread().getName() + "] show secure viewer"); -// if (secureViewer == null) { -// secureViewer = new SecureViewerDialog(null, messages, -// fontProvider, helpMouseListener.getActionListener()); -// -// // workaround for [#439] -// // avoid AlwaysOnTop at least in applet, otherwise make secureViewer AlwaysOnTop since MOCCA Dialog (JFrame created in LocalSTALFactory) is always on top. -// Window window = SwingUtilities.getWindowAncestor(contentPane); -// if (window != null && window.isAlwaysOnTop()) { -// log.debug("make secureViewer alwaysOnTop"); -// secureViewer.setAlwaysOnTop(true); -// } -// } -// secureViewer.setContent(dataToBeSigned); -// log.trace("show secure viewer returned"); -// } private void showSecureViewer(HashDataInput dataToBeSigned, ActionListener closeListener, String closeCommand) throws FontProviderException { log.debug("[" + Thread.currentThread().getName() + "] show secure viewer"); @@ -1479,7 +1366,7 @@ public class BKUGUIImpl implements BKUGUIFacade { buttonPanel.removeAll(); if (renderHeaderPanel) { - titleLabel.setText(getMessage(TITLE_HASHDATA)); + titleLabel.setText(getMessage(TITLE_SIGNATURE_DATA)); } helpMouseListener.setHelpTopic(HELP_HASHDATALIST); @@ -1613,7 +1500,7 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public void run() { try { - showMessageDialog(TITLE_HASHDATA, MESSAGE_HASHDATA_VIEWER); + showMessageDialog(TITLE_SIGNATURE_DATA, MESSAGE_HASHDATA_VIEWER); showSecureViewer(selection, backToListListener, null); // SecureViewerDialog.showSecureViewer(selection, messages, fontProvider, helpMouseListener.getActionListener(), false); } catch (FontProviderException ex) { @@ -1625,7 +1512,7 @@ public class BKUGUIImpl implements BKUGUIFacade { }); } else { log.debug("[" + Thread.currentThread().getName() + "] mime-type not supported by secure viewer, scheduling save dialog"); - showMessageDialog(BKUGUIFacade.TITLE_HASHDATA, BKUGUIFacade.MESSAGE_UNSUPPORTED_MIMETYPE); + showMessageDialog(BKUGUIFacade.TITLE_SIGNATURE_DATA, BKUGUIFacade.MESSAGE_UNSUPPORTED_MIMETYPE); SecureViewerSaveDialog.showSaveDialog(selection, messages, backToListListener, null); } } -- cgit v1.2.3 From d592f2a95096d4f234a24564b794c712359756fb Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 19 Jan 2010 12:10:37 +0000 Subject: clear pin after use bugfix correction/backspace button pinpadPinGUI git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@581 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java') 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 3fc631c3..e005836c 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 @@ -41,6 +41,8 @@ import java.text.MessageFormat; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -55,6 +57,8 @@ import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -93,7 +97,7 @@ public class BKUGUIImpl implements BKUGUIFacade { protected JLabel switchFocusDummyLabel; /** remember the pinfield to return to worker */ protected JPasswordField pinField; - protected JPasswordField pinpadPINField; + protected Document pinpadPIN; protected int buttonSize; @@ -600,9 +604,10 @@ public class BKUGUIImpl implements BKUGUIFacade { String pinName = getMessage(LABEL_PIN); pinLabel.setText(MessageFormat.format(pinName, new Object[]{pinSpec.getLocalizedName()})); - pinpadPINField = new JPasswordField(); + JPasswordField pinpadPINField = new JPasswordField(); pinpadPINField.setText(""); pinpadPINField.setEnabled(false); + pinpadPIN = pinpadPINField.getDocument(); JLabel pinsizeLabel = new JLabel(); pinsizeLabel.setFont(pinsizeLabel.getFont().deriveFont(pinsizeLabel.getFont().getStyle() & ~java.awt.Font.BOLD, pinsizeLabel.getFont().getSize()-2)); @@ -850,9 +855,11 @@ public class BKUGUIImpl implements BKUGUIFacade { public void correctionButtonPressed() { log.debug("[" + Thread.currentThread().getName() + "] correction button pressed"); - if (pinpadPINField != null) { - String maskedPIN = pinpadPINField.getText(); - pinpadPINField.setText(maskedPIN.substring(0, maskedPIN.length() - 1)); + if (pinpadPIN != null) { + try { + pinpadPIN.remove(0, 1); + } catch (BadLocationException ex) { + } } } @@ -860,8 +867,11 @@ public class BKUGUIImpl implements BKUGUIFacade { public void allKeysCleared() { log.debug("[" + Thread.currentThread().getName() + "] all keys cleared"); - if (pinpadPINField != null) { - pinpadPINField.setText(""); + if (pinpadPIN != null) { + try { + pinpadPIN.remove(0, pinpadPIN.getLength()); + } catch (BadLocationException ex) { + } } } @@ -869,8 +879,11 @@ public class BKUGUIImpl implements BKUGUIFacade { public void validKeyPressed() { log.debug("[" + Thread.currentThread().getName() + "] valid key pressed"); - if (pinpadPINField != null) { - pinpadPINField.setText(pinpadPINField.getText() + '*'); + if (pinpadPIN != null) { + try { + pinpadPIN.insertString(0, "*", null); + } catch (BadLocationException ex) { + } } } @@ -1265,8 +1278,8 @@ public class BKUGUIImpl implements BKUGUIFacade { @Override public char[] getPin() { if (pinField != null) { - char[] pin = pinField.getPassword(); - pinField = null; + char[] pin = pinField.getPassword(); //returns a copy + pinField = null; //garbage collect original pin (make sure to clear char[] after use) return pin; } return null; -- cgit v1.2.3