diff options
author | Automerge <automerge@vaadin.com> | 2012-03-23 18:05:47 +0000 |
---|---|---|
committer | Automerge <automerge@vaadin.com> | 2012-03-23 18:05:47 +0000 |
commit | 44455c31258dd06a42dc6982364b5000d015283f (patch) | |
tree | 9cfbf4cac9d19e81149f0a7c8e51f40b47b3ea21 | |
parent | 7cc4d2c652bf2f65001e96fa8939734c051be99c (diff) | |
download | vaadin-framework-44455c31258dd06a42dc6982364b5000d015283f.tar.gz vaadin-framework-44455c31258dd06a42dc6982364b5000d015283f.zip |
[merge from 6.7] #8526 If a Table row has an open context menu, reopen it after a row update if the same row (equal key) is repainted
svn changeset:23309/svn branch:6.8
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index e4e8663e63..9e3b39f6b5 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -45,6 +45,8 @@ import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.event.dom.client.TouchStartEvent; import com.google.gwt.event.dom.client.TouchStartHandler; +import com.google.gwt.event.logical.shared.CloseEvent; +import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@ -53,6 +55,7 @@ import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.UIObject; import com.google.gwt.user.client.ui.Widget; @@ -442,6 +445,24 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, private int serverCacheFirst = -1; private int serverCacheLast = -1; + /** + * Used to recall the position of an open context menu if we need to close + * and reopen it during a row update. + */ + private class ContextMenuDetails { + String rowKey; + int left; + int top; + + ContextMenuDetails(String rowKey, int left, int top) { + this.rowKey = rowKey; + this.left = left; + this.top = top; + } + } + + ContextMenuDetails contextMenu; + public VScrollTable() { setMultiSelectMode(MULTISELECT_MODE_DEFAULT); @@ -817,6 +838,17 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; + if (this.client == null) { + client.getContextMenu().addCloseHandler( + new CloseHandler<PopupPanel>() { + public void onClose(CloseEvent<PopupPanel> event) { + contextMenu = null; + } + }); + } + + ContextMenuDetails savedContextMenu = contextMenu; + if (uidl.hasAttribute(ATTRIBUTE_PAGEBUFFER_FIRST)) { serverCacheFirst = uidl.getIntAttribute(ATTRIBUTE_PAGEBUFFER_FIRST); serverCacheLast = uidl.getIntAttribute(ATTRIBUTE_PAGEBUFFER_LAST); @@ -1009,6 +1041,16 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, rendering = false; headerChangedDuringUpdate = false; + if (savedContextMenu != null) { + for (Widget w : scrollBody.renderedRows) { + VScrollTableRow row = (VScrollTableRow) w; + if (row.getKey().equals(savedContextMenu.rowKey)) { + contextMenu = savedContextMenu; + client.getContextMenu().showAt(row, savedContextMenu.left, + savedContextMenu.top); + } + } + } } private void initializeRows(UIDL uidl, UIDL rowData) { @@ -5369,6 +5411,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, int top = Util.getTouchOrMouseClientY(event); top += Window.getScrollTop(); left += Window.getScrollLeft(); + contextMenu = new ContextMenuDetails(this.getKey(), + left, top); client.getContextMenu().showAt(this, left, top); } } |