diff options
author | Anna Miroshnik <anna.miroshnik@arcadia.spb.ru> | 2014-09-08 11:32:01 +0400 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-09-12 11:32:02 +0300 |
commit | 84038225ac71d56d21887a338e5daa8994a76eed (patch) | |
tree | faa8904b81ec2d43e3055151b149c60ac9a77265 /client | |
parent | 74460ffcd165f921cae03a86eaf3117501af03eb (diff) | |
download | vaadin-framework-84038225ac71d56d21887a338e5daa8994a76eed.tar.gz vaadin-framework-84038225ac71d56d21887a338e5daa8994a76eed.zip |
Tree item fails with ItemClickListener (#14388)
Patch for #14388: added modifications to remove the regression on #6845
(RIGHT, MIDDLE mouse buttons listeners)
Change-Id: I3ef95df68efa0a70bbe0d566ceea187505e2999a
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VTree.java | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java index b12053ea04..02ad7cfb3e 100644 --- a/client/src/com/vaadin/client/ui/VTree.java +++ b/client/src/com/vaadin/client/ui/VTree.java @@ -160,6 +160,13 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, private boolean selectionHasChanged = false; + /* + * to fix #14388. The cause of defect #14388: event 'clickEvent' is sent to + * server before updating of "selected" variable, but should be send after + * it + */ + private boolean sendClickEventNow = false; + /** For internal use only. May be removed or replaced in the future. */ public String[] bodyActionKeys; @@ -471,9 +478,15 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, Command command = new Command() { @Override public void execute() { + /* + * we should send selection to server immediately in 2 cases: 1) + * 'immediate' property of Tree is true 2) sendClickEventNow is + * true + */ client.updateVariable(paintableId, "selected", selectedIds.toArray(new String[selectedIds.size()]), - immediate); + sendClickEventNow || immediate); + sendClickEventNow = false; selectionHasChanged = false; } }; @@ -831,26 +844,41 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, // server. We do not want to send the event if there is a // selection event happening after this. In all other cases // we want to send it immediately. - boolean sendClickEventNow = true; - - if (details.getButton() == MouseButton.LEFT && immediate - && selectable) { - // Probably a selection that will cause a value change - // event to be sent - sendClickEventNow = false; - - // The exception is that user clicked on the - // currently selected row and null selection is not - // allowed == no selection event - if (isSelected() && selectedIds.size() == 1 - && !isNullSelectionAllowed) { - sendClickEventNow = true; + sendClickEventNow = true; + + if (details.getButton() == MouseButton.LEFT && selectable) { + if (immediate) { + // event to be sent + sendClickEventNow = false; + + // The exception is that user clicked on the + // currently selected row and null selection is not + // allowed == no selection event + if (isSelected() && selectedIds.size() == 1 + && !isNullSelectionAllowed) { + sendClickEventNow = true; + } } - } - client.updateVariable(paintableId, "clickedKey", key, false); - client.updateVariable(paintableId, "clickEvent", - details.toString(), sendClickEventNow); + client.updateVariable(paintableId, "clickedKey", key, + false); + + /* + * in any case event should not be send immediately here + * - send after updating of "selected" variable + */ + client.updateVariable(paintableId, "clickEvent", + details.toString(), false); + + } else { // for all another mouse buttons (RIGHT, MIDDLE) or + // if not selectable + client.updateVariable(paintableId, "clickedKey", key, + false); + + client.updateVariable(paintableId, "clickEvent", + details.toString(), sendClickEventNow); + sendClickEventNow = false; // reset it + } } }); } |