diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-11 23:12:55 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-12 08:56:06 +0000 |
commit | 2ed3d92ef894656ead3f17e1816cdc1517c3d4e6 (patch) | |
tree | 632a491dba511daebff74cb8bc9a6e6190f7bdcf /server | |
parent | 6fdc3320fec5801a73f51d3e3a3584d23d942c6c (diff) | |
download | vaadin-framework-2ed3d92ef894656ead3f17e1816cdc1517c3d4e6.tar.gz vaadin-framework-2ed3d92ef894656ead3f17e1816cdc1517c3d4e6.zip |
Remove SortEventOriginator and replace it with a boolean (#13334)
Change-Id: I8a203c5e2f4bc9074ccf3cb4e7f347f17d89fe52
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/event/SortOrderChangeEvent.java | 14 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 18 |
2 files changed, 15 insertions, 17 deletions
diff --git a/server/src/com/vaadin/event/SortOrderChangeEvent.java b/server/src/com/vaadin/event/SortOrderChangeEvent.java index e38097e3ba..fdf604a034 100644 --- a/server/src/com/vaadin/event/SortOrderChangeEvent.java +++ b/server/src/com/vaadin/event/SortOrderChangeEvent.java @@ -19,7 +19,6 @@ import java.io.Serializable; import java.util.List; import com.vaadin.data.sort.SortOrder; -import com.vaadin.shared.ui.grid.SortEventOriginator; import com.vaadin.ui.Component; /** @@ -34,7 +33,7 @@ import com.vaadin.ui.Component; public class SortOrderChangeEvent extends Component.Event { private final List<SortOrder> sortOrder; - private final SortEventOriginator originator; + private final boolean userOriginated; /** * Creates a new sort order change event with a sort order list. @@ -43,14 +42,15 @@ public class SortOrderChangeEvent extends Component.Event { * the component from which the event originates * @param sortOrder * the new sort order list - * @param originator - * an enumeration describing what triggered the sorting + * @param userOriginated + * <code>true</code> if event is a result of user interaction, + * <code>false</code> if from API call */ public SortOrderChangeEvent(Component source, List<SortOrder> sortOrder, - SortEventOriginator originator) { + boolean userOriginated) { super(source); this.sortOrder = sortOrder; - this.originator = originator; + this.userOriginated = userOriginated; } /** @@ -68,7 +68,7 @@ public class SortOrderChangeEvent extends Component.Event { * @return true if sort event originated from user interaction */ public boolean isUserOriginated() { - return originator == SortEventOriginator.USER; + return userOriginated; } /** diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index d0485c3d68..24f9b31faa 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -83,7 +83,6 @@ import com.vaadin.shared.ui.grid.GridStaticSectionState.RowState; import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.ScrollDestination; import com.vaadin.shared.ui.grid.SortDirection; -import com.vaadin.shared.ui.grid.SortEventOriginator; import com.vaadin.shared.util.SharedUtil; import com.vaadin.ui.renderer.Renderer; import com.vaadin.ui.renderer.TextRenderer; @@ -2284,7 +2283,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, @Override public void sort(String[] columnIds, SortDirection[] directions, - SortEventOriginator originator) { + boolean userOriginated) { assert columnIds.length == directions.length; List<SortOrder> order = new ArrayList<SortOrder>( @@ -2294,7 +2293,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, order.add(new SortOrder(propertyId, directions[i])); } - setSortOrder(order, originator); + setSortOrder(order, userOriginated); } @Override @@ -2432,7 +2431,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, } } - sort(SortEventOriginator.API); + sort(false); } else { // If the new container is not sortable, we'll just re-set the sort @@ -3253,11 +3252,10 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, * a sort order list. */ public void setSortOrder(List<SortOrder> order) { - setSortOrder(order, SortEventOriginator.API); + setSortOrder(order, false); } - private void setSortOrder(List<SortOrder> order, - SortEventOriginator originator) { + private void setSortOrder(List<SortOrder> order, boolean userOriginated) { if (!(getContainerDataSource() instanceof Container.Sortable)) { throw new IllegalStateException( "Attached container is not sortable (does not implement Container.Sortable)"); @@ -3282,7 +3280,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, } sortOrder.addAll(order); - sort(originator); + sort(false); } /** @@ -3297,7 +3295,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, /** * Apply sorting to data source. */ - private void sort(SortEventOriginator originator) { + private void sort(boolean userOriginated) { Container c = getContainerDataSource(); if (c instanceof Container.Sortable) { @@ -3333,7 +3331,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, cs.sort(propertyIds, directions); fireEvent(new SortOrderChangeEvent(this, new ArrayList<SortOrder>( - sortOrder), originator)); + sortOrder), userOriginated)); getState().sortColumns = columnKeys; getState(false).sortDirs = stateDirs; |