From d214efa39a011002eb88e683676508e438842fe4 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Mon, 29 Apr 2013 13:36:32 +0300 Subject: Ensure actions are handled in a deterministic order (#11735) (merged from #11432 in 6.8 branch) svn changeset:25867/svn branch:6.8 Change-Id: Ie34cc4c4fe6524a23b2e7692b9e73a421443ac4f --- server/src/com/vaadin/event/ActionManager.java | 60 +++++++++++--------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 7a4b39444e..ce3e27d539 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -15,7 +15,7 @@ */ package com.vaadin.event; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import com.vaadin.event.Action.Container; @@ -44,10 +44,10 @@ public class ActionManager implements Action.Container, Action.Handler, private static final long serialVersionUID = 1641868163608066491L; /** List of action handlers */ - protected HashSet ownActions = null; + protected LinkedHashSet ownActions = null; /** List of action handlers */ - protected HashSet actionHandlers = null; + protected LinkedHashSet actionHandlers = null; /** Action mapper */ protected KeyMapper actionMapper = null; @@ -90,7 +90,7 @@ public class ActionManager implements Action.Container, Action.Handler, @Override public void addAction(T action) { if (ownActions == null) { - ownActions = new HashSet(); + ownActions = new LinkedHashSet(); } if (ownActions.add(action)) { requestRepaint(); @@ -115,7 +115,7 @@ public class ActionManager implements Action.Container, Action.Handler, if (actionHandler != null) { if (actionHandlers == null) { - actionHandlers = new HashSet(); + actionHandlers = new LinkedHashSet(); } if (actionHandlers.add(actionHandler)) { @@ -150,20 +150,7 @@ public class ActionManager implements Action.Container, Action.Handler, actionMapper = null; - HashSet actions = new HashSet(); - if (actionHandlers != null) { - for (Action.Handler handler : actionHandlers) { - Action[] as = handler.getActions(actionTarget, viewer); - if (as != null) { - for (Action action : as) { - actions.add(action); - } - } - } - } - if (ownActions != null) { - actions.addAll(ownActions); - } + LinkedHashSet actions = getActionSet(actionTarget, viewer); /* * Must repaint whenever there are actions OR if all actions have been @@ -225,22 +212,7 @@ public class ActionManager implements Action.Container, Action.Handler, @Override public Action[] getActions(Object target, Object sender) { - HashSet actions = new HashSet(); - if (ownActions != null) { - for (Action a : ownActions) { - actions.add(a); - } - } - if (actionHandlers != null) { - for (Action.Handler h : actionHandlers) { - Action[] as = h.getActions(target, sender); - if (as != null) { - for (Action a : as) { - actions.add(a); - } - } - } - } + LinkedHashSet actions = getActionSet(target, sender); return actions.toArray(new Action[actions.size()]); } @@ -259,4 +231,22 @@ public class ActionManager implements Action.Container, Action.Handler, } } + private LinkedHashSet getActionSet(Object target, Object sender) { + LinkedHashSet actions = new LinkedHashSet(); + if (ownActions != null) { + actions.addAll(ownActions); + + } + if (actionHandlers != null) { + for (Action.Handler h : actionHandlers) { + Action[] as = h.getActions(target, sender); + if (as != null) { + for (Action a : as) { + actions.add(a); + } + } + } + } + return actions; + } } -- cgit v1.2.3