summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-07-08 16:52:21 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2015-07-09 13:25:17 +0300
commit4fce93896627b862587533e4bd3b71b0e7a3a6b2 (patch)
treee60c2c8dac5c82ac8a433c824785bc3495a7da1c /server/src
parent7a5b61f19838dec76715026e5232c565082190a7 (diff)
downloadvaadin-framework-4fce93896627b862587533e4bd3b71b0e7a3a6b2.tar.gz
vaadin-framework-4fce93896627b862587533e4bd3b71b0e7a3a6b2.zip
Close Grid editor on container item set change
Also allow user sorting when in unbuffered mode. Change-Id: Ibe1c1770647529b63c6e3c7fc9509562449b54a4
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/ui/Grid.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 80af88e32b..f7d49e6419 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -45,6 +45,9 @@ import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.google.gwt.thirdparty.guava.common.collect.Sets.SetView;
import com.vaadin.data.Container;
import com.vaadin.data.Container.Indexed;
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+import com.vaadin.data.Container.ItemSetChangeNotifier;
import com.vaadin.data.Container.PropertySetChangeEvent;
import com.vaadin.data.Container.PropertySetChangeListener;
import com.vaadin.data.Container.PropertySetChangeNotifier;
@@ -3608,6 +3611,13 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
}
};
+ private final ItemSetChangeListener editorClosingItemSetListener = new ItemSetChangeListener() {
+ @Override
+ public void containerItemSetChange(ItemSetChangeEvent event) {
+ cancelEditor();
+ }
+ };
+
private RpcDataProviderExtension datasourceExtension;
/**
@@ -4111,10 +4121,10 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
removeExtension(datasourceExtension);
}
- datasource = container;
-
resetEditor();
+ datasource = container;
+
//
// Adjust sort order
//
@@ -4161,6 +4171,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
((PropertySetChangeNotifier) datasource)
.addPropertySetChangeListener(propertyListener);
}
+
/*
* activeRowHandler will be updated by the client-side request that
* occurs on container change - no need to actively re-insert any
@@ -5886,6 +5897,10 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
f.markAsDirtyRecursive();
}
+ if (datasource instanceof ItemSetChangeNotifier) {
+ ((ItemSetChangeNotifier) datasource)
+ .addItemSetChangeListener(editorClosingItemSetListener);
+ }
}
private void setEditorField(Object propertyId, Field<?> field) {
@@ -5934,6 +5949,10 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
editorActive = false;
editorFieldGroup.discard();
editorFieldGroup.setItemDataSource(null);
+ if (datasource instanceof ItemSetChangeNotifier) {
+ ((ItemSetChangeNotifier) datasource)
+ .removeItemSetChangeListener(editorClosingItemSetListener);
+ }
}
void resetEditor() {