diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-07-15 10:58:47 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-07-15 10:58:47 +0000 |
commit | bd39623a20d457db1082e942555ec0dfd7110e5f (patch) | |
tree | 9c44b6337e3568074280c1f3d55638ba2321689b | |
parent | 3de42376335c2029b88872062bd7516d7fcf7520 (diff) | |
download | vaadin-framework-bd39623a20d457db1082e942555ec0dfd7110e5f.tar.gz vaadin-framework-bd39623a20d457db1082e942555ec0dfd7110e5f.zip |
fixes #5350
svn changeset:14204/svn branch:6.4
-rw-r--r-- | src/com/vaadin/event/ActionManager.java | 10 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/components/button/ShortCutListenerModification.java | 71 |
2 files changed, 77 insertions, 4 deletions
diff --git a/src/com/vaadin/event/ActionManager.java b/src/com/vaadin/event/ActionManager.java index 84bc0d8277..36e2e21ef5 100644 --- a/src/com/vaadin/event/ActionManager.java +++ b/src/com/vaadin/event/ActionManager.java @@ -129,7 +129,7 @@ public class ActionManager implements Action.Container, Action.Handler, HashSet<Action> actions = new HashSet<Action>(); if (actionHandlers != null) { for (Action.Handler handler : actionHandlers) { - Action[] as = handler.getActions(actionTarget, this.viewer); + Action[] as = handler.getActions(actionTarget, viewer); if (as != null) { for (Action action : as) { actions.add(action); @@ -144,7 +144,7 @@ public class ActionManager implements Action.Container, Action.Handler, if (!actions.isEmpty()) { actionMapper = new KeyMapper(); - paintTarget.addVariable(this.viewer, "action", ""); + paintTarget.addVariable(viewer, "action", ""); paintTarget.startTag("actions"); for (final Action a : actions) { @@ -210,8 +210,10 @@ public class ActionManager implements Action.Container, Action.Handler, public void handleAction(Action action, Object sender, Object target) { if (actionHandlers != null) { - for (Handler h : actionHandlers) { - h.handleAction(action, sender, target); + Handler[] array = actionHandlers.toArray(new Handler[actionHandlers + .size()]); + for (Handler handler : array) { + handler.handleAction(action, sender, target); } } if (ownActions != null && ownActions.contains(action) diff --git a/tests/src/com/vaadin/tests/components/button/ShortCutListenerModification.java b/tests/src/com/vaadin/tests/components/button/ShortCutListenerModification.java new file mode 100644 index 0000000000..eea1d5e943 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/button/ShortCutListenerModification.java @@ -0,0 +1,71 @@ +package com.vaadin.tests.components.button; + +import com.vaadin.event.ShortcutAction.KeyCode; +import com.vaadin.event.ShortcutAction.ModifierKey; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Window; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Window.Notification; + +@SuppressWarnings("serial") +public class ShortCutListenerModification extends TestBase implements + ClickListener { + + @Override + protected String getDescription() { + return "Modifiying listeners in shortcuthandler should succeed. Hitting CTRL-C should close windows one by one."; + } + + @Override + protected Integer getTicketNumber() { + return 5350; + } + + @Override + protected void setup() { + + Button prev = null; + + for (int j = 0; j < 20; j++) { + + Window window = new Window(); + getMainWindow().addWindow(window); + + Button button1 = new Button("b1 (CTRL-C)"); + Button button2 = new Button("b2 (CTRL-V)"); + + button1.addListener(this); + button2.addListener(this); + + button1.setClickShortcut(KeyCode.C, ModifierKey.CTRL); + button2.setClickShortcut(KeyCode.V, ModifierKey.CTRL); + + window.addComponent(button1); + window.addComponent(button2); + button1.focus(); + button1.setData(prev); + prev = button1; + } + + } + + @Override + public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) { + super.terminalError(event); + getMainWindow().showNotification("Failed!", + Notification.TYPE_ERROR_MESSAGE); + + } + + public void buttonClick(ClickEvent event) { + Window window2 = event.getButton().getWindow(); + window2.getParent().removeWindow(window2); + Button prev = (Button) event.getButton().getData(); + if (prev != null) { + prev.focus(); + } + } + +} |