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;
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;
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);
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);
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) {
int top = Util.getTouchOrMouseClientY(event);
top += Window.getScrollTop();
left += Window.getScrollLeft();
+ contextMenu = new ContextMenuDetails(this.getKey(),
+ left, top);
client.getContextMenu().showAt(this, left, top);
}
}