summaryrefslogtreecommitdiff
path: root/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui
diff options
context:
space:
mode:
Diffstat (limited to 'BKUAppletExt/src/main/java/at/gv/egiz/bku/gui')
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java519
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java47
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java (renamed from BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java)15
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java63
-rw-r--r--BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java60
5 files changed, 653 insertions, 51 deletions
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
index 8acf051e..8eef8aea 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUI.java
@@ -17,15 +17,28 @@
package at.gv.egiz.bku.gui;
+import at.gv.egiz.smcc.PINSpec;
import java.awt.Container;
+import java.awt.Cursor;
+import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
import java.net.URL;
+import java.text.MessageFormat;
import java.util.Locale;
+import java.util.Map;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
+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;
/**
* TODO pull out ResourceBundle to common superclass for activationGUI and pinMgmtGUI
@@ -33,9 +46,10 @@ import javax.swing.SwingUtilities;
*/
public class PINManagementGUI extends ActivationGUI implements PINManagementGUIFacade {
- public static final String BUTTON_ACTIVATE = "button.activate";
- public static final String BUTTON_UNBLOCK = "button.unblock";
- public static final String BUTTON_CHANGE = "button.change";
+ /** remember the pinfield to return to worker */
+ protected JPasswordField oldPinField;
+ /** remember the pinSpec to return to worker */
+ protected PINSpec pinSpec;
public PINManagementGUI(Container contentPane,
Locale locale,
@@ -46,12 +60,31 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF
}
@Override
- public void showPINManagementDialog(final PINStatusProvider pinStatusProvider,
- final ActionListener activateListener, final String activateCmd,
- final ActionListener changeListener, final String changeCmd,
- final ActionListener unblockListener, final String unblockCmd,
- final ActionListener cancelListener, final String cancelCmd) {
-// try {
+ public char[] getOldPin() {
+ if (oldPinField != null) {
+ char[] pin = oldPinField.getPassword();
+ oldPinField = null;
+ return pin;
+ }
+ return null;
+ }
+
+ @Override
+ public PINSpec getSelectedPIN() {
+ return pinSpec;
+ }
+
+ @Override
+ public void showPINManagementDialog(final Map<PINSpec, STATUS> pins,
+ final ActionListener activateListener,
+ final String activateCmd,
+ final String changeCmd,
+ final String unblockCmd,
+ final ActionListener cancelListener,
+ final String cancelCmd) {
+
+ log.debug("scheduling PIN managment dialog");
+
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -68,13 +101,76 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF
if (renderHeaderPanel) {
titleLabel.setText(cardmgmtMessages.getString(TITLE_PINMGMT));
- mgmtLabel.setText(cardmgmtMessages.getString(MESSAGE_PINMGMT));
+ String infoPattern = cardmgmtMessages.getString(MESSAGE_PINMGMT);
+ mgmtLabel.setText(MessageFormat.format(infoPattern, pins.size()));
} else {
mgmtLabel.setText(cardmgmtMessages.getString(TITLE_PINMGMT));
}
+ final PINStatusTableModel tableModel = new PINStatusTableModel(pins);
+ final JTable pinStatusTable = new JTable(tableModel);
+ pinStatusTable.setDefaultRenderer(PINSpec.class, new PINSpecRenderer());
+ pinStatusTable.setDefaultRenderer(STATUS.class, new PINStatusRenderer(cardmgmtMessages));
+ pinStatusTable.setTableHeader(null);
-
+ pinStatusTable.addMouseMotionListener(new MouseMotionAdapter() {
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ if (pinStatusTable.columnAtPoint(e.getPoint()) == 0) {
+ pinStatusTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ } else {
+ pinStatusTable.setCursor(Cursor.getDefaultCursor());
+ }
+ }
+ });
+
+ final JButton activateButton = new JButton();
+ activateButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
+ activateButton.addActionListener(activateListener);
+
+ pinStatusTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ pinStatusTable.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) {
+ pinSpec = (PINSpec) tableModel.getValueAt(selectionIdx, 0);
+ STATUS status = (STATUS) tableModel.getValueAt(selectionIdx, 1);
+
+ if (status == STATUS.NOT_ACTIV) {
+ activateButton.setText(cardmgmtMessages.getString(BUTTON_ACTIVATE));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(activateCmd);
+ } else if (status == STATUS.BLOCKED) {
+ activateButton.setText(cardmgmtMessages.getString(BUTTON_UNBLOCK));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(unblockCmd);
+ } else if (status == STATUS.ACTIV) {
+ activateButton.setText(cardmgmtMessages.getString(BUTTON_CHANGE));
+ activateButton.setEnabled(true);
+ activateButton.setActionCommand(changeCmd);
+ } else {
+ activateButton.setText(cardmgmtMessages.getString(BUTTON_ACTIVATE));
+ activateButton.setEnabled(false);
+ }
+ }
+ }
+ });
+ }
+ });
+
+ //select first entry
+ pinStatusTable.getSelectionModel().setSelectionInterval(0, 0);
+
+ JScrollPane pinStatusScrollPane = new JScrollPane(pinStatusTable);
GroupLayout mainPanelLayout = new GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
@@ -91,30 +187,16 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF
.addComponent(helpLabel);
}
- mainPanelLayout.setHorizontalGroup(messageHorizontal);
- mainPanelLayout.setVerticalGroup(messageVertical);
+ mainPanelLayout.setHorizontalGroup(
+ mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addGroup(messageHorizontal)
+ .addComponent(pinStatusScrollPane, 0, 0, Short.MAX_VALUE));
-
- JButton activateButton = new JButton();
- activateButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
- activateButton.setText(cardmgmtMessages.getString(BUTTON_ACTIVATE));
- activateButton.setEnabled(true);//false);
- activateButton.setActionCommand(activateCmd);
- activateButton.addActionListener(activateListener);
-
- JButton changeButton = new JButton();
- changeButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
- changeButton.setText(cardmgmtMessages.getString(BUTTON_CHANGE));
- changeButton.setEnabled(false);
- changeButton.setActionCommand(changeCmd);
- changeButton.addActionListener(changeListener);
-
- JButton unblockButton = new JButton();
- unblockButton.setFont(activateButton.getFont().deriveFont(activateButton.getFont().getStyle() & ~java.awt.Font.BOLD));
- unblockButton.setText(cardmgmtMessages.getString(BUTTON_UNBLOCK));
- unblockButton.setEnabled(false);
- unblockButton.setActionCommand(unblockCmd);
- unblockButton.addActionListener(unblockListener);
+ mainPanelLayout.setVerticalGroup(
+ mainPanelLayout.createSequentialGroup()
+ .addGroup(messageVertical)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinStatusScrollPane, 0, 0, pinStatusTable.getPreferredSize().height+3));
JButton cancelButton = new JButton();
cancelButton.setFont(cancelButton.getFont().deriveFont(cancelButton.getFont().getStyle() & ~java.awt.Font.BOLD));
@@ -129,30 +211,377 @@ public class PINManagementGUI extends ActivationGUI implements PINManagementGUIF
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(activateButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(changeButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(unblockButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, buttonSize, GroupLayout.PREFERRED_SIZE);
GroupLayout.Group buttonVertical = buttonPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(activateButton)
- .addComponent(changeButton)
- .addComponent(unblockButton)
.addComponent(cancelButton);
buttonPanelLayout.setHorizontalGroup(buttonHorizontal);
buttonPanelLayout.setVerticalGroup(buttonVertical);
contentPanel.validate();
-
}
});
+ }
+
+ @Override
+ public void showActivatePINDialog(final PINSpec pin,
+ final ActionListener okListener, final String okCommand,
+ final ActionListener cancelListener, final String cancelCommand) {
+ log.debug("scheduling activate pin dialog");
+ showPINDialog(false, pin, okListener, okCommand, cancelListener, cancelCommand);
+ }
+
+
+ private void showPINDialog(final boolean changePin, final PINSpec pinSpec,
+ final ActionListener okListener, final String okCommand,
+ final ActionListener cancelListener, final String cancelCommand) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ String HELP_TOPIC, TITLE, MESSAGE_MGMT;
+ if (changePin) {
+ log.debug("show change pin dialog");
+ HELP_TOPIC = HELP_PINMGMT;
+ TITLE = TITLE_CHANGE_PIN;
+ MESSAGE_MGMT = MESSAGE_CHANGE_PIN;
+ } else {
+ log.debug("show activate pin dialog");
+ HELP_TOPIC = HELP_PINMGMT;
+ TITLE = TITLE_ACTIVATE_PIN;
+ MESSAGE_MGMT = MESSAGE_ACTIVATE_PIN;
+ oldPinField = null;
+ }
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ helpListener.setHelpTopic(HELP_TOPIC);
+
+ JLabel mgmtLabel = new JLabel();
+ mgmtLabel.setFont(mgmtLabel.getFont().deriveFont(mgmtLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(cardmgmtMessages.getString(TITLE));
+ String mgmtPattern = cardmgmtMessages.getString(MESSAGE_MGMT);
+ if (shortText) {
+ mgmtLabel.setText(MessageFormat.format(mgmtPattern, "PIN"));
+ } else {
+ mgmtLabel.setText(MessageFormat.format(mgmtPattern, pinSpec.getLocalizedName()));
+ }
+ } else {
+ mgmtLabel.setText(cardmgmtMessages.getString(TITLE));
+ }
+
+ 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 pinLabel = new JLabel();
+ pinLabel.setFont(pinLabel.getFont().deriveFont(pinLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+ String pinLabelPattern = (changePin) ? cardmgmtMessages.getString(LABEL_NEW_PIN) : messages.getString(LABEL_PIN);
+ pinLabel.setText(MessageFormat.format(pinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
+
+ final JPasswordField repeatPinField = new JPasswordField();
+ pinField = new JPasswordField();
+ pinField.setText("");
+ pinField.setDocument(new PINDocument(pinSpec, null));
+ pinField.setActionCommand(okCommand);
+ pinField.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (pinField.getPassword().length >= pinSpec.getMinLength()) {
+ repeatPinField.requestFocusInWindow();
+ }
+ }
+ });
+ JLabel repeatPinLabel = new JLabel();
+ repeatPinLabel.setFont(pinLabel.getFont());
+ String repeatPinLabelPattern = cardmgmtMessages.getString(LABEL_REPEAT_PIN);
+ repeatPinLabel.setText(MessageFormat.format(repeatPinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
+
+ repeatPinField.setText("");
+ repeatPinField.setDocument(new PINDocument(pinSpec, okButton, pinField.getDocument()));
+ repeatPinField.setActionCommand(okCommand);
+ repeatPinField.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (pinField.getPassword().length >= pinSpec.getMinLength()) {
+ okListener.actionPerformed(e);
+ }
+ }
+ });
+
+ JLabel oldPinLabel = null;
+ if (changePin) {
+ oldPinLabel = new JLabel();
+ oldPinLabel.setFont(oldPinLabel.getFont().deriveFont(oldPinLabel.getFont().getStyle() & ~java.awt.Font.BOLD));
+ String oldPinLabelPattern = cardmgmtMessages.getString(LABEL_OLD_PIN);
+ oldPinLabel.setText(MessageFormat.format(oldPinLabelPattern, new Object[]{pinSpec.getLocalizedName()}));
+
+ oldPinField = new JPasswordField();
+ oldPinField.setText("");
+ oldPinField.setDocument(new PINDocument(pinSpec, null));
+ oldPinField.setActionCommand(okCommand);
+ oldPinField.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (oldPinField.getPassword().length >= pinSpec.getMinLength()) {
+ pinField.requestFocusInWindow();
+ }
+ }
+ });
+ }
+
+ 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.SequentialGroup infoHorizontal = mainPanelLayout.createSequentialGroup()
+ .addComponent(mgmtLabel);
+ GroupLayout.ParallelGroup infoVertical = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(mgmtLabel);
+
+ if (!renderHeaderPanel) {
+ infoHorizontal
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+ .addComponent(helpLabel);
+ infoVertical
+ .addComponent(helpLabel);
+ }
-// } catch (Exception ex) {
-// log.error(ex.getMessage(), ex);
-// showErrorDialog(ERR_UNKNOWN_WITH_PARAM, new Object[] {ex.getMessage()});
-// }
+ GroupLayout.ParallelGroup pinHorizontal = mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
+ GroupLayout.SequentialGroup pinVertical = mainPanelLayout.createSequentialGroup();
+
+ if (pinLabelPos == PinLabelPosition.ABOVE) {
+ if (changePin) {
+ pinHorizontal
+ .addComponent(oldPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(oldPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
+ pinVertical
+ .addComponent(oldPinLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(oldPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
+ }
+ pinHorizontal
+ .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(repeatPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(repeatPinField, 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
+ .addComponent(pinLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(repeatPinLabel)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(pinsizeLabel);
+ } else {
+ if (changePin) {
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(oldPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(repeatPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(oldPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ pinVertical
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(oldPinLabel)
+ .addComponent(oldPinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
+ } else {
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(pinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(repeatPinLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(pinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(repeatPinField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
+
+ }
+ pinHorizontal
+ .addGroup(mainPanelLayout.createSequentialGroup()
+ .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE)
+ .addComponent(pinsizeLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
+ pinVertical
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(pinLabel)
+ .addComponent(pinField))
+ .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(mainPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(repeatPinLabel)
+ .addComponent(repeatPinField))
+ .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));
+
+ 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;
+
+ 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);
+
+ buttonPanelLayout.setHorizontalGroup(buttonHorizontal);
+ buttonPanelLayout.setVerticalGroup(buttonVertical);
+
+ if (oldPinField != null) {
+ oldPinField.requestFocusInWindow();
+ } else {
+ pinField.requestFocusInWindow();
+ }
+ contentPanel.validate();
+
+ }
+ });
+ }
+
+ @Override
+ public void showChangePINDialog(final PINSpec pin,
+ final ActionListener okListener, final String okCommand,
+ final ActionListener cancelListener, final String cancelCommand) {
+
+ log.debug("scheduling change pin dialog");
+ showPINDialog(true, pin, okListener, okCommand, cancelListener, cancelCommand);
+ }
+
+ @Override
+ public void showUnblockPINDialog(final PINSpec pin,
+ final ActionListener okListener, final String okCommand,
+ final ActionListener cancelListener, final String cancelCommand) {
+
+ log.debug("scheduling unblock PIN dialog");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("show unblock PIN dialog");
+
+ log.error("unblock pin not supported");
+
+ mainPanel.removeAll();
+ buttonPanel.removeAll();
+
+ if (renderHeaderPanel) {
+ titleLabel.setText(messages.getString(TITLE_ERROR));
+ }
+
+ helpListener.setHelpTopic(HELP_PINMGMT);
+
+ String errorMsgPattern = cardmgmtMessages.getString(ERR_UNBLOCK);
+ String errorMsg = MessageFormat.format(errorMsgPattern, pin.getLocalizedName());
+
+ 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(cancelCommand);
+ okButton.addActionListener(cancelListener);
+
+ 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();
+ }
+ });
}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
index 3d653fab..2a8f28d2 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINManagementGUIFacade.java
@@ -17,7 +17,9 @@
package at.gv.egiz.bku.gui;
+import at.gv.egiz.smcc.PINSpec;
import java.awt.event.ActionListener;
+import java.util.Map;
/**
*
@@ -27,8 +29,49 @@ public interface PINManagementGUIFacade extends BKUGUIFacade {
public static final String HELP_PINMGMT = "help.pin.mgmt";
public static final String TITLE_PINMGMT = "title.pin.mgmt";
+ public static final String TITLE_ACTIVATE_PIN = "title.activate.pin";
+ public static final String TITLE_CHANGE_PIN = "title.change.pin";
+ public static final String TITLE_UNBLOCK_PIN = "title.unblock.pin";
public static final String MESSAGE_PINMGMT = "message.pin.mgmt";
-
- public void showPINManagementDialog(PINStatusProvider pinStatusProvider, ActionListener activateListener, String activateCmd, ActionListener changeListener, String changeCmd, ActionListener unblockListener, String unblockCmd, ActionListener cancelListener, String cancelCmd);
+ public static final String MESSAGE_ACTIVATE_PIN = "message.activate.pin";
+ public static final String MESSAGE_CHANGE_PIN = "message.change.pin";
+ public static final String MESSAGE_UNBLOCK_PIN = "message.unblock.pin";
+ public static final String LABEL_OLD_PIN = "label.old.pin";
+ public static final String LABEL_NEW_PIN = "label.new.pin";
+ public static final String LABEL_REPEAT_PIN = "label.repeat.pin";
+ public static final String ERR_ACTIVATE = "err.activate";
+ public static final String ERR_CHANGE = "err.change";
+ public static final String ERR_UNBLOCK = "err.unblock";
+
+ public static final String BUTTON_ACTIVATE = "button.activate";
+ public static final String BUTTON_UNBLOCK = "button.unblock";
+ public static final String BUTTON_CHANGE = "button.change";
+
+ public static final String STATUS_ACTIVE = "status.active";
+ public static final String STATUS_BLOCKED = "status.blocked";
+ public static final String STATUS_NOT_ACTIVE = "status.not.active";
+ public static final String STATUS_UNKNOWN = "status.unknown";
+
+ public enum STATUS { ACTIV, NOT_ACTIV, BLOCKED, UNKNOWN };
+
+ public void showPINManagementDialog(Map<PINSpec, STATUS> pins,
+ ActionListener activateListener, String activateCmd, String changeCmd, String unblockCmd,
+ ActionListener cancelListener, String cancelCmd);
+
+ public void showActivatePINDialog(PINSpec pin,
+ ActionListener okListener, String okCmd,
+ ActionListener cancelListener, String cancelCmd);
+
+ public void showChangePINDialog(PINSpec pin,
+ ActionListener okListener, String okCmd,
+ ActionListener cancelListener, String cancelCmd);
+
+ public void showUnblockPINDialog(PINSpec pin,
+ ActionListener okListener, String okCmd,
+ ActionListener cancelListener, String cancelCmd);
+
+ public char[] getOldPin();
+
+ public PINSpec getSelectedPIN();
}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java
index 73fa0920..e3d73e1f 100644
--- a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusProvider.java
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINSpecRenderer.java
@@ -17,16 +17,23 @@
package at.gv.egiz.bku.gui;
-import at.gv.egiz.smcc.SignatureCardException;
+import at.gv.egiz.smcc.PINSpec;
+import javax.swing.table.DefaultTableCellRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
*
* @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
*/
-public interface PINStatusProvider {
+public class PINSpecRenderer extends DefaultTableCellRenderer {
- public enum STATUS { ACTIV, NOT_ACTIV, BLOCKED };
+ private static final Log log = LogFactory.getLog(PINSpecRenderer.class);
- public STATUS getPINStatus(int pin) throws SignatureCardException;
+ @Override
+ protected void setValue(Object value) {
+ PINSpec pinSpec = (PINSpec) value;
+ super.setText(pinSpec.getLocalizedName());
+ }
}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java
new file mode 100644
index 00000000..2f8852ff
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusRenderer.java
@@ -0,0 +1,63 @@
+/*
+ * 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.bku.gui.PINManagementGUIFacade.STATUS;
+import java.awt.Color;
+import java.awt.Font;
+import java.util.ResourceBundle;
+import javax.swing.table.DefaultTableCellRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINStatusRenderer extends DefaultTableCellRenderer {
+
+ private static final Log log = LogFactory.getLog(PINStatusRenderer.class);
+
+ public static final Color RED = new Color(0.9f, 0.0f, 0.0f);
+ public static final Color GREEN = new Color(0.0f, 0.8f, 0.0f);
+ protected ResourceBundle messages;
+
+ public PINStatusRenderer(ResourceBundle messages) {
+ this.messages = messages;
+ }
+
+ @Override
+ protected void setValue(Object value) {
+ STATUS pinStatus = (STATUS) value;
+ super.setFont(super.getFont().deriveFont(super.getFont().getStyle() | Font.BOLD));
+
+ if (pinStatus == STATUS.NOT_ACTIV) {
+ super.setForeground(RED);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_NOT_ACTIVE) + "</html>");
+ } else if (pinStatus == STATUS.ACTIV) {
+ super.setForeground(GREEN);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_ACTIVE) + "</html>");
+ } else if (pinStatus == STATUS.BLOCKED) {
+ super.setForeground(RED);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_BLOCKED) + "</html>");
+ } else {
+ super.setForeground(Color.BLACK);
+ super.setText("<html>" + messages.getString(PINManagementGUIFacade.STATUS_UNKNOWN) + "</html>");
+ }
+ }
+}
diff --git a/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java
new file mode 100644
index 00000000..feaa5072
--- /dev/null
+++ b/BKUAppletExt/src/main/java/at/gv/egiz/bku/gui/PINStatusTableModel.java
@@ -0,0 +1,60 @@
+/*
+ * 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.bku.gui.PINManagementGUIFacade.STATUS;
+import at.gv.egiz.smcc.PINSpec;
+import java.util.Map;
+import javax.swing.table.DefaultTableModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PINStatusTableModel extends DefaultTableModel {
+
+ protected static final Log log = LogFactory.getLog(PINStatusTableModel.class);
+ protected Class[] types;
+
+ public PINStatusTableModel(Map<PINSpec, STATUS> pinStatuses) {
+ super(0, 2);
+ if (pinStatuses == null) {
+ throw new RuntimeException("pinStatuses must not be null");
+ }
+ log.trace(pinStatuses.size() + " PINs");
+ types = new Class[] { PINSpec.class, STATUS.class };
+ for (PINSpec pinSpec : pinStatuses.keySet()) {
+ addRow(new Object[] { pinSpec, pinStatuses.get(pinSpec) });
+ }
+// PINSpec activePIN = new PINSpec(0, 1, null, "active-PIN", (byte) 0x01);
+// PINSpec blockedPIN = new PINSpec(0, 1, null, "blocked-PIN", (byte) 0x01);
+// addRow(new Object[] { activePIN, PINStatusProvider.STATUS.ACTIV });
+// addRow(new Object[] { blockedPIN, PINStatusProvider.STATUS.BLOCKED });
+ }
+
+ @Override
+ public Class getColumnClass(int columnIndex) {
+ return types[columnIndex];
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+}