summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main
diff options
context:
space:
mode:
authortkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-04-08 18:41:20 +0000
committertkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2013-04-08 18:41:20 +0000
commit3de114f63e762efc028aea8a935f0a1e1b6b2ed7 (patch)
treef0c4bb814142ba6ae0154524c1a69a5281bf5596 /BKUCommonGUI/src/main
parentce5eab11f8d4f76498f8c80cc646489357394c7d (diff)
downloadmocca-3de114f63e762efc028aea8a935f0a1e1b6b2ed7.tar.gz
mocca-3de114f63e762efc028aea8a935f0a1e1b6b2ed7.tar.bz2
mocca-3de114f63e762efc028aea8a935f0a1e1b6b2ed7.zip
Get rid of switchFocus Label / Listener
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1164 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src/main')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java201
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusFocusListener.java68
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusListener.java78
3 files changed, 26 insertions, 321 deletions
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 a44ceb82..c75bd0eb 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,7 +93,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
protected SecureViewerDialog secureViewer;
protected HelpListener helpListener;
- protected SwitchFocusFocusListener switchFocusKeyListener;
protected FontProvider fontProvider;
protected Container contentPane;
@@ -110,7 +109,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
protected JLabel titleLabel;
protected JLabel msgTitleLabel;
protected JLabel helpLabel;
- protected JLabel switchFocusDummyLabel;
/** remember the pinfield to return to worker */
protected JPasswordField pinField;
protected Document pinpadPIN;
@@ -171,7 +169,7 @@ public class BKUGUIImpl implements BKUGUIFacade {
*/
public BKUGUIImpl(Container contentPane, Locale locale, Style guiStyle,
URL background, FontProvider fontProvider,
- HelpListener helpListener, SwitchFocusListener switchFocusListener) {
+ HelpListener helpListener) {
this.contentPane = contentPane;
Window w = SwingUtilities.getWindowAncestor(contentPane);
if (w != null && w instanceof JFrame) {
@@ -209,8 +207,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
// ensure that buttons can be fired with enter key too
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
- registerSwitchFocusListener(switchFocusListener);
-
this.fontProvider = fontProvider;
this.helpListener = helpListener;
createGUI(background);
@@ -387,14 +383,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
- // This is a hidden label. When it gains focus, it hands over focus to
- // the web browser
- switchFocusDummyLabel = new JLabel();
- switchFocusDummyLabel.setText("");
- switchFocusDummyLabel.setName(SWITCH_FOCUS_DUMMY_LABEL_NAME);
- switchFocusDummyLabel.setFocusable(true);
- switchFocusDummyLabel.addFocusListener(switchFocusKeyListener);
-
buttonSize = initButtonSize();
baseButtonSize = buttonSize;
@@ -429,9 +417,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
verticalHeader.addComponent(helpLabel);
}
- horizontalHeader.addComponent(switchFocusDummyLabel);
- verticalHeader.addComponent(switchFocusDummyLabel);
-
headerPanelLayout.setHorizontalGroup(horizontalHeader);
headerPanelLayout.setVerticalGroup(verticalHeader);
}
@@ -515,9 +500,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
mainPanel.removeAll();
buttonPanel.removeAll();
- // avoid that dummy label gains focus during load
- switchFocusDummyLabel.setFocusable(false);
-
if (renderHeaderPanel) {
if (numRetries < 0) {
String verifyTitle = getMessage(TITLE_VERIFY_PIN);
@@ -561,18 +543,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
}
});
- pinField.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
-
- // focus has been set accordingly - re-enable dummy
- // label
- switchFocusDummyLabel.setFocusable(true);
- }
-
- });
-
infoLabel = new JLabel();
if (numRetries < 0) {
infoLabel.setFont(infoLabel.getFont().deriveFont(
@@ -633,8 +603,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
Short.MAX_VALUE).addComponent(helpLabel);
infoVertical.addComponent(helpLabel);
}
- infoHorizontal.addComponent(switchFocusDummyLabel);
- infoVertical.addComponent(switchFocusDummyLabel);
}
// align pinfield and pinsize to the right
@@ -811,9 +779,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
mainPanel.removeAll();
buttonPanel.removeAll();
- // avoid that dummy label gains focus during load
- switchFocusDummyLabel.setFocusable(false);
-
if (renderHeaderPanel) {
if (retries < 0) {
titleLabel.setText(getMessage(titleKey));
@@ -885,8 +850,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
Short.MAX_VALUE).addComponent(helpLabel);
infoVertical.addComponent(helpLabel);
}
- infoHorizontal.addComponent(switchFocusDummyLabel);
- infoVertical.addComponent(switchFocusDummyLabel);
}
@@ -961,18 +924,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
infoLabel.setFocusable(true);
- infoLabel.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
-
- // focus has been set accordingly - re-enable dummy
- // label
- switchFocusDummyLabel.setFocusable(true);
- }
-
- });
-
String accessibleData = cutOffHTMLTags(infoLabel.getText())
+ cutOffHTMLTags(pinLabel.getText())
+ cutOffHTMLTags(pinsizeLabel.getText());
@@ -1053,9 +1004,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
.setFocusTraversalPolicy(new AdvancedShowSigDataGUIFocusTraversalPolicy());
}
- // avoid that dummy label gains focus during load
- switchFocusDummyLabel.setFocusable(false);
-
if (renderHeaderPanel) {
titleLabel.setText(getMessage(TITLE_SIGNATURE_DATA));
}
@@ -1141,8 +1089,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
Short.MAX_VALUE).addComponent(helpLabel);
infoVertical.addComponent(helpLabel);
}
- infoHorizontal.addComponent(switchFocusDummyLabel);
- infoVertical.addComponent(switchFocusDummyLabel);
}
@@ -1156,18 +1102,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
enterPINButton.setActionCommand(enterPINCommand);
enterPINButton.addActionListener(enterPINListener);
- enterPINButton.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
-
- // focus has been set accordingly - re-enable dummy
- // label
- switchFocusDummyLabel.setFocusable(true);
- }
-
- });
-
if (renderCancelButton) {
cancelButton.setFont(cancelButton.getFont().deriveFont(
cancelButton.getFont().getStyle()
@@ -1292,9 +1226,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
.setFocusTraversalPolicy(new AdvancedSigPinGUIFocusTraversalPolicy());
}
- // avoid that dummy label gains focus during load
- switchFocusDummyLabel.setFocusable(false);
-
if (renderHeaderPanel) {
if (numRetries < 0) {
titleLabel.setText(getMessage(TITLE_SIGN));
@@ -1427,24 +1358,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
}
});
- // FIXME: For some reason, the switchFocusDummyLabel obtains the
- // focus even
- // if the pinField requests the focus. Therefore, the
- // switchFocusDummyLabel is
- // deactivated first and enabled only after the pinField has
- // obtained the focus
- pinField.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
-
- // focus has been set accordingly - re-enable dummy
- // label
- switchFocusDummyLabel.setFocusable(true);
- }
-
- });
-
pinsizeLabel.setFont(pinsizeLabel.getFont()
.deriveFont(
pinsizeLabel.getFont().getStyle()
@@ -1475,8 +1388,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
Short.MAX_VALUE).addComponent(helpLabel);
infoVertical.addComponent(helpLabel);
}
- infoHorizontal.addComponent(switchFocusDummyLabel);
- infoVertical.addComponent(switchFocusDummyLabel);
}
@@ -1690,9 +1601,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
mainPanel.removeAll();
buttonPanel.removeAll();
- // avoid that dummy label gains focus during load
- switchFocusDummyLabel.setFocusable(false);
-
if (renderHeaderPanel) {
titleLabel.setText(getMessage(titleKey));
}
@@ -1749,8 +1657,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
Short.MAX_VALUE).addComponent(helpLabel);
titleVertical.addComponent(helpLabel);
}
- titleHorizontal.addComponent(switchFocusDummyLabel);
- titleVertical.addComponent(switchFocusDummyLabel);
mainHorizontal.addGroup(titleHorizontal);
mainVertical.addGroup(titleVertical);
@@ -1765,18 +1671,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
msgLabel.getAccessibleContext().setAccessibleDescription(
accessibleData + msgLabel.getText());
- msgLabel.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusGained(FocusEvent e) {
-
- // focus has been set accordingly - re-enable dummy
- // label
- switchFocusDummyLabel.setFocusable(true);
- }
-
- });
-
mainPanelLayout.setHorizontalGroup(mainHorizontal
.addComponent(msgLabel));
mainPanelLayout.setVerticalGroup(mainVertical
@@ -2107,8 +2001,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
Short.MAX_VALUE).addComponent(helpLabel);
messageVertical.addComponent(helpLabel);
}
- messageHorizontal.addComponent(switchFocusDummyLabel);
- messageVertical.addComponent(switchFocusDummyLabel);
}
mainPanelLayout.setHorizontalGroup(mainPanelLayout
@@ -2278,28 +2170,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
}
// //////////////////////////////////////////////////////////////////////////
- // UTILITY METHODS
- // //////////////////////////////////////////////////////////////////////////
-
- 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)
// //////////////////////////////////////////////////////////////////////////
@@ -2639,19 +2509,13 @@ public class BKUGUIImpl implements BKUGUIFacade {
return helpLabel;
} else {
- return switchFocusDummyLabel;
+ return null;
}
}
if (component.equals(helpLabel)) {
- return switchFocusDummyLabel;
- }
-
- // should never be the case
- if (component.equals(switchFocusDummyLabel)) {
-
- return pinField;
+ return null;
}
// default
@@ -2664,7 +2528,7 @@ public class BKUGUIImpl implements BKUGUIFacade {
if (component.equals(pinField)) {
- return switchFocusDummyLabel;
+ return null;
}
if (component.equals(signButton)) {
@@ -2695,18 +2559,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
return infoLabel;
}
- // should never be the case
- if (component.equals(switchFocusDummyLabel)) {
-
- if (helpLabel != null && helpLabel.isVisible()) {
-
- return helpLabel;
- } else {
-
- return infoLabel;
- }
- }
-
// default
return pinField;
}
@@ -2726,7 +2578,13 @@ public class BKUGUIImpl implements BKUGUIFacade {
@Override
public Component getLastComponent(Container container) {
- return switchFocusDummyLabel;
+ if (helpLabel != null && helpLabel.isVisible()) {
+
+ return helpLabel;
+ } else {
+
+ return infoLabel;
+ }
}
}
@@ -2753,19 +2611,13 @@ public class BKUGUIImpl implements BKUGUIFacade {
return helpLabel;
} else {
- return switchFocusDummyLabel;
+ return null;
}
}
if (component.equals(helpLabel)) {
- return switchFocusDummyLabel;
- }
-
- // should never be the case
- if (component.equals(switchFocusDummyLabel)) {
-
- return enterPINButton;
+ return null;
}
// default
@@ -2777,8 +2629,13 @@ public class BKUGUIImpl implements BKUGUIFacade {
Component component) {
if (component.equals(enterPINButton)) {
+ if (helpLabel != null && helpLabel.isVisible()) {
- return switchFocusDummyLabel;
+ return helpLabel;
+ } else {
+
+ return infoLabel;
+ }
}
if (component.equals(cancelButton)) {
@@ -2796,18 +2653,6 @@ public class BKUGUIImpl implements BKUGUIFacade {
return infoLabel;
}
- // should never be the case
- if (component.equals(switchFocusDummyLabel)) {
-
- if (helpLabel != null && helpLabel.isVisible()) {
-
- return helpLabel;
- } else {
-
- return infoLabel;
- }
- }
-
// default
return enterPINButton;
}
@@ -2827,7 +2672,13 @@ public class BKUGUIImpl implements BKUGUIFacade {
@Override
public Component getLastComponent(Container container) {
- return switchFocusDummyLabel;
+ if (helpLabel != null && helpLabel.isVisible()) {
+
+ return helpLabel;
+ } else {
+
+ return infoLabel;
+ }
}
}
}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusFocusListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusFocusListener.java
deleted file mode 100644
index 359153dd..00000000
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusFocusListener.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2011 by Graz University of Technology, Austria
- * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint
- * initiative of the Federal Chancellery Austria and Graz University of Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-
-
-package at.gv.egiz.bku.gui;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author Thomas Zefferer <thomas.zefferer@iaik.tugraz.at>
- */
-public class SwitchFocusFocusListener extends FocusAdapter {
-
- private final Logger log = LoggerFactory.getLogger(SwitchFocusFocusListener.class);
-
- protected ActionListener swichFocusListener;
-
- public SwitchFocusFocusListener(ActionListener externalSwitchFocusListener) {
- super();
- this.swichFocusListener = externalSwitchFocusListener;
- }
-
- public ActionListener getActionListener() {
- return swichFocusListener;
- }
-
- @Override
- public void focusGained(FocusEvent arg0) {
-
- log.debug("SwitchFocusFocusListener detected focusGained event!");
- Component comp = arg0.getComponent();
- log.debug("Component that caused event: {}.", comp.getName());
- comp.transferFocus();
-
- ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null);
- swichFocusListener.actionPerformed(e);
- }
-
-
-}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusListener.java
deleted file mode 100644
index d9bafe4d..00000000
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SwitchFocusListener.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2011 by Graz University of Technology, Austria
- * MOCCA has been developed by the E-Government Innovation Center EGIZ, a joint
- * initiative of the Federal Chancellery Austria and Graz University of Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-
-
-package at.gv.egiz.bku.gui;
-
-import java.applet.AppletContext;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author Thomas Zefferer <thomas.zefferer@iaik.tugraz.at>
- */
-public class SwitchFocusListener implements ActionListener {
-
- private final Logger log = LoggerFactory.getLogger(SwitchFocusListener.class);
-
- protected String functionName;
- protected AppletContext ctx;
- protected String javascriptFunction;
-
- public SwitchFocusListener(AppletContext ctx, String javascriptFunctionName) {
-
- this.ctx = ctx;
- this.functionName = javascriptFunctionName;
- buildJSFunction();
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
-
- log.debug("SwitchFocusListener fires!");
-
- try {
- ctx.showDocument
- (new URL("javascript:" + javascriptFunction));
- }
- catch (MalformedURLException me) {
-
- log.warn("Unable to call external javascript function.", me);
- }
-
-
- }
-
- protected void buildJSFunction() {
-
- this.javascriptFunction = functionName + "()";
-
- }
-
-}