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 | |
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
7 files changed, 27 insertions, 82 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 6f6dffee8c..e4bc56f431 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -384,7 +384,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements || !Arrays.equals(directions, getState().sortDirs)) { // Report back to server if changed getRpcProxy(GridServerRpc.class).sort(columnIds, - directions, event.getOriginator()); + directions, event.isUserOriginated()); } } }); diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java index 80ecc9a9e9..3c42ce5eb9 100644 --- a/client/src/com/vaadin/client/ui/grid/Grid.java +++ b/client/src/com/vaadin/client/ui/grid/Grid.java @@ -107,7 +107,6 @@ import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.Range; 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; /** @@ -1965,7 +1964,7 @@ public class Grid<T> extends ResizeComposite implements // sortOrder has been changed; tell the Grid to re-sort itself by // user request. - Grid.this.sort(SortEventOriginator.USER); + Grid.this.sort(true); } /** @@ -4575,18 +4574,17 @@ public class Grid<T> extends ResizeComposite implements * a sort order list. If set to null, the sort order is cleared. */ 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 (order != sortOrder) { sortOrder.clear(); if (order != null) { sortOrder.addAll(order); } } - sort(originator); + sort(userOriginated); } /** @@ -4822,10 +4820,10 @@ public class Grid<T> extends ResizeComposite implements /** * Apply sorting to data source. */ - private void sort(SortEventOriginator originator) { + private void sort(boolean userOriginated) { refreshHeader(); fireEvent(new SortEvent<T>(this, - Collections.unmodifiableList(sortOrder), originator)); + Collections.unmodifiableList(sortOrder), userOriginated)); } private int getLastVisibleRowIndex() { 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 44f1510f6f..02640766b5 100644 --- a/client/src/com/vaadin/client/ui/grid/sort/SortEvent.java +++ b/client/src/com/vaadin/client/ui/grid/sort/SortEvent.java @@ -18,9 +18,7 @@ package com.vaadin.client.ui.grid.sort; import java.util.List; import com.google.gwt.event.shared.GwtEvent; -import com.vaadin.client.data.DataSource; import com.vaadin.client.ui.grid.Grid; -import com.vaadin.shared.ui.grid.SortEventOriginator; /** * A sort event, fired by the Grid when it needs its data source to provide data @@ -35,7 +33,7 @@ public class SortEvent<T> extends GwtEvent<SortHandler<?>> { private final Grid<T> grid; private final List<SortOrder> order; - private final SortEventOriginator originator; + private final boolean userOriginated; /** * Creates a new Sort Event. All provided parameters are final, and passed @@ -48,11 +46,10 @@ public class SortEvent<T> extends GwtEvent<SortHandler<?>> { * @param originator * a value indicating where this event originated from */ - public SortEvent(Grid<T> grid, List<SortOrder> order, - SortEventOriginator originator) { + public SortEvent(Grid<T> grid, List<SortOrder> order, boolean userOriginated) { this.grid = grid; this.order = order; - this.originator = originator; + this.userOriginated = userOriginated; } @Override @@ -104,19 +101,7 @@ public class SortEvent<T> extends GwtEvent<SortHandler<?>> { * @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. - * - * @return a sort event originator value - * - * @see SortEventOriginator - */ - public SortEventOriginator getOriginator() { - return originator; + return userOriginated; } @SuppressWarnings("unchecked") 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; diff --git a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java index c87e2a813f..28149010be 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridServerRpc.java @@ -29,7 +29,7 @@ public interface GridServerRpc extends ServerRpc { void selectionChange(List<String> newSelection); void sort(String[] columnIds, SortDirection[] directions, - SortEventOriginator originator); + boolean userOriginated); void selectAll(); } diff --git a/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java b/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java deleted file mode 100644 index 0160a4fe56..0000000000 --- a/shared/src/com/vaadin/shared/ui/grid/SortEventOriginator.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2014 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.shared.ui.grid; - -/** - * Identifier for the originator of a sort event or sort order change event. - * - * @since - * @author Vaadin Ltd - */ -public enum SortEventOriginator { - - /** - * This event was the result of an API call. - */ - API, - - /** - * This event was the result of a user interacting with the UI. - */ - USER - -} |