aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/ui/Button.java
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2007-08-29 12:37:25 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2007-08-29 12:37:25 +0000
commit6fe8bfa9b78797b483ac811840630b5dcc6785e9 (patch)
treee72067a2ca6d56affa98f09935eb0db12314d4b5 /src/com/itmill/toolkit/ui/Button.java
parent7dee7b1d38fdeb116d2c63790489a08bf5e6e4e3 (diff)
downloadvaadin-framework-6fe8bfa9b78797b483ac811840630b5dcc6785e9.tar.gz
vaadin-framework-6fe8bfa9b78797b483ac811840630b5dcc6785e9.zip
added initial support for keyboard shortcuts. Now only Panel supports them on server side, IView (main windows) on client side.
svn changeset:2150/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/Button.java')
-rw-r--r--src/com/itmill/toolkit/ui/Button.java100
1 files changed, 1 insertions, 99 deletions
diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java
index b15d3b2da3..8968c229f2 100644
--- a/src/com/itmill/toolkit/ui/Button.java
+++ b/src/com/itmill/toolkit/ui/Button.java
@@ -52,17 +52,12 @@ import com.itmill.toolkit.terminal.PaintTarget;
* @VERSION@
* @since 3.0
*/
-public class Button extends AbstractField implements Action.Container {
+public class Button extends AbstractField {
/* Private members ************************************************* */
boolean switchMode = false;
- /** List of action handlers */
- private LinkedList actionHandlers = null;
-
- /** Action mapper */
- private KeyMapper actionMapper = null;
/**
* Creates a new push button. The value of the push button is allways false
@@ -176,44 +171,6 @@ public class Button extends AbstractField implements Action.Container {
}
target.addVariable(this, "state", state);
- // Actions
- if (actionHandlers != null) {
- Set actionSet = new LinkedHashSet();
- for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
- Action[] aa = ((Action.Handler) ahi.next()).getActions(this,
- this);
- if (aa != null)
- for (int ai = 0; ai < aa.length; ai++) {
- actionSet.add(aa[ai]);
- }
- }
-
- target.startTag("actions");
- target.addVariable(this, "action", "");
- for (Iterator i = actionSet.iterator(); i.hasNext();) {
- try {
- ShortcutAction a = (ShortcutAction) i.next();
- target.startTag("action");
- if (a.getCaption() != null)
- target.addAttribute("caption", a.getCaption());
- if (a.getIcon() != null)
- target.addAttribute("icon", a.getIcon());
- target.addAttribute("key", actionMapper.key(a));
- target.addAttribute("keycode", a.getKeyCode());
- if (a.getModifiers() != null) {
- int[] modifiers = a.getModifiers();
- target.addAttribute("modifiers", modifiers.length);
- for (int j = 0; j < modifiers.length; j++) {
- target.addAttribute("modifier" + j, modifiers[j]);
- }
- }
- target.endTag("action");
- } catch (Exception e) {
- // ignore non-shorcut actions for button
- }
- }
- target.endTag("actions");
- }
}
/**
@@ -249,21 +206,6 @@ public class Button extends AbstractField implements Action.Container {
setValue(new Boolean(false));
}
}
- // Actions
- // TODO this is pretty much copy-pasted from tree, may be simplified
- if (variables.containsKey("action")) {
-
- StringTokenizer st = new StringTokenizer((String) variables
- .get("action"), ",");
- if (st.countTokens() == 2) {
- Action action = (Action) actionMapper.get(st.nextToken());
- if (action != null && actionHandlers != null)
- for (Iterator i = actionHandlers.iterator(); i.hasNext();)
- ((Action.Handler) i.next()).handleAction(action, this,
- this);
- }
- }
-
}
/**
@@ -403,44 +345,4 @@ public class Button extends AbstractField implements Action.Container {
fireEvent(new Button.ClickEvent(this));
}
- /**
- * Adds an action handler.
- *
- * @see com.itmill.toolkit.event.Action.Container#addActionHandler(Action.Handler)
- */
- public void addActionHandler(Action.Handler actionHandler) {
-
- if (actionHandler != null) {
-
- if (actionHandlers == null) {
- actionHandlers = new LinkedList();
- actionMapper = new KeyMapper();
- }
-
- if (!actionHandlers.contains(actionHandler)) {
- actionHandlers.add(actionHandler);
- requestRepaint();
- }
- }
- }
-
- /**
- * Removes an action handler.
- *
- * @see com.itmill.toolkit.event.Action.Container#removeActionHandler(Action.Handler)
- */
- public void removeActionHandler(Action.Handler actionHandler) {
-
- if (actionHandlers != null && actionHandlers.contains(actionHandler)) {
-
- actionHandlers.remove(actionHandler);
-
- if (actionHandlers.isEmpty()) {
- actionHandlers = null;
- actionMapper = null;
- }
-
- requestRepaint();
- }
- }
}