summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-10-16 14:34:53 +0300
committerVaadin Code Review <review@vaadin.com>2014-10-16 12:27:26 +0000
commitb69d2dd7f87633d3acd1d2243388f6f22d4f841d (patch)
treeb7428fb59a238c04ae1bc94b647af44ae7f41145
parent9e769462bd09483c1ccfde452bc679ea54a5d85e (diff)
downloadvaadin-framework-b69d2dd7f87633d3acd1d2243388f6f22d4f841d.tar.gz
vaadin-framework-b69d2dd7f87633d3acd1d2243388f6f22d4f841d.zip
Add isUserOriginated to SortOrderChangeEvents (#13334)
Change-Id: Idb387e3b27ea757f27510f7ad97aaaa39b8f71ef
-rw-r--r--client/src/com/vaadin/client/ui/grid/sort/SortEvent.java23
-rw-r--r--server/src/com/vaadin/ui/components/grid/Grid.java2
-rw-r--r--server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java11
-rw-r--r--shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java7
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java19
5 files changed, 24 insertions, 38 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/sort/SortEvent.java b/client/src/com/vaadin/client/ui/grid/sort/SortEvent.java
index edbd84c4a5..97566d944b 100644
--- a/client/src/com/vaadin/client/ui/grid/sort/SortEvent.java
+++ b/client/src/com/vaadin/client/ui/grid/sort/SortEvent.java
@@ -25,7 +25,7 @@ import com.vaadin.shared.ui.grid.SortEventOriginator;
/**
* A sort event, fired by the Grid when it needs its data source to provide data
* sorted in a specific manner.
- *
+ *
* @since
* @author Vaadin Ltd
*/
@@ -40,7 +40,7 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
/**
* Creates a new Sort Event. All provided parameters are final, and passed
* on as-is.
- *
+ *
* @param grid
* a grid reference
* @param order
@@ -63,7 +63,7 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
/**
* Static access to the GWT event type identifier associated with this Event
* class
- *
+ *
* @return a type object, uniquely describing this event type.
*/
public static Type<SortEventHandler<?>> getType() {
@@ -72,7 +72,7 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
/**
* Get access to the Grid that fired this event
- *
+ *
* @return the grid instance
*/
@Override
@@ -82,7 +82,7 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
/**
* Get access to the Grid that fired this event
- *
+ *
* @return the grid instance
*/
public Grid<T> getGrid() {
@@ -91,7 +91,7 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
/**
* Access the data source of the Grid that fired this event
- *
+ *
* @return a data source instance
*/
public DataSource<T> getDataSource() {
@@ -100,7 +100,7 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
/**
* Get the sort ordering that is to be applied to the Grid
- *
+ *
* @return a list of sort order objects
*/
public List<SortOrder> getOrder() {
@@ -108,6 +108,15 @@ public class SortEvent<T> extends GwtEvent<SortEventHandler<?>> {
}
/**
+ * Returns whether this event originated from actions done by the user.
+ *
+ * @return true if sort event originated from user interaction
+ */
+ public boolean isUserOriginated() {
+ return originator == SortEventOriginator.USER;
+ }
+
+ /**
* Gets a value describing the originator of this event, i.e. what actions
* resulted in this event being fired.
*
diff --git a/server/src/com/vaadin/ui/components/grid/Grid.java b/server/src/com/vaadin/ui/components/grid/Grid.java
index bb1c5b6fbc..fe03d589c0 100644
--- a/server/src/com/vaadin/ui/components/grid/Grid.java
+++ b/server/src/com/vaadin/ui/components/grid/Grid.java
@@ -528,7 +528,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier,
}
}
- sort(SortEventOriginator.INTERNAL);
+ sort(SortEventOriginator.API);
} else {
// If the new container is not sortable, we'll just re-set the sort
diff --git a/server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java b/server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java
index 690fcdf1c4..69d5de0245 100644
--- a/server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java
+++ b/server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java
@@ -62,15 +62,12 @@ public class SortOrderChangeEvent extends Component.Event {
}
/**
- * Gets a value describing the originator of this event, i.e. what actions
- * resulted in this event being fired.
+ * Returns whether this event originated from actions done by the user.
*
- * @return a sort event originator value
- *
- * @see SortEventOriginator
+ * @return true if sort event originated from user interaction
*/
- public SortEventOriginator getOriginator() {
- return originator;
+ public boolean isUserOriginated() {
+ return originator == SortEventOriginator.USER;
}
}
diff --git a/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java b/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java
index acdd46ea5b..0160a4fe56 100644
--- a/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java
+++ b/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java
@@ -31,11 +31,6 @@ public enum SortEventOriginator {
/**
* This event was the result of a user interacting with the UI.
*/
- USER,
-
- /**
- * This event resulted as a side-effect of an internal event.
- */
- INTERNAL
+ USER
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index afa51644eb..2abe073edd 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -173,23 +173,8 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
@Override
public void sortOrderChange(SortOrderChangeEvent event) {
- String origin;
- switch (event.getOriginator()) {
- case API:
- origin = "API";
- break;
- case INTERNAL:
- origin = "INTERNAL";
- break;
- case USER:
- origin = "USER";
- break;
- default:
- origin = "!!! ERROR !!!";
- break;
- }
-
- log("Sort order: " + event.getSortOrder() + " by " + origin);
+ log("SortOrderChangeEvent: isUserOriginated? "
+ + event.isUserOriginated());
}
});