diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-12 15:30:24 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-12 16:59:15 +0200 |
commit | a539b4cd7becbd1aa370f9502e4f85912d7c2844 (patch) | |
tree | b1a5a28bd747db47ce68732689082052ba1c6ae9 | |
parent | c9fe985fc34788d197417715d8d439c2ce0bc26b (diff) | |
download | vaadin-framework-a539b4cd7becbd1aa370f9502e4f85912d7c2844.tar.gz vaadin-framework-a539b4cd7becbd1aa370f9502e4f85912d7c2844.zip |
Rename SelectionChangeEvent and SortOrderChangeEvent (#13334)
Also renames related listeners and notifiers.
Change-Id: I96bfdae8173a1c691623938cc7dbcddee7198e46
-rw-r--r-- | server/src/com/vaadin/event/SelectionEvent.java (renamed from server/src/com/vaadin/event/SelectionChangeEvent.java) | 28 | ||||
-rw-r--r-- | server/src/com/vaadin/event/SortEvent.java (renamed from server/src/com/vaadin/event/SortOrderChangeEvent.java) | 25 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 76 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java | 12 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java | 10 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/sort/SortTest.java | 10 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java | 8 |
7 files changed, 78 insertions, 91 deletions
diff --git a/server/src/com/vaadin/event/SelectionChangeEvent.java b/server/src/com/vaadin/event/SelectionEvent.java index adc7b13d49..f852ea0949 100644 --- a/server/src/com/vaadin/event/SelectionChangeEvent.java +++ b/server/src/com/vaadin/event/SelectionEvent.java @@ -30,12 +30,12 @@ import com.google.gwt.thirdparty.guava.common.collect.Sets; * @since * @author Vaadin Ltd */ -public class SelectionChangeEvent extends EventObject { +public class SelectionEvent extends EventObject { private LinkedHashSet<Object> oldSelection; private LinkedHashSet<Object> newSelection; - public SelectionChangeEvent(Object source, Collection<Object> oldSelection, + public SelectionEvent(Object source, Collection<Object> oldSelection, Collection<Object> newSelection) { super(source); this.oldSelection = new LinkedHashSet<Object>(oldSelection); @@ -67,37 +67,31 @@ public class SelectionChangeEvent extends EventObject { } /** - * The listener interface for receiving {@link SelectionChangeEvent - * SelectionChangeEvents}. - * - * @since - * @author Vaadin Ltd + * The listener interface for receiving {@link SelectionEvent + * SelectionEvents}. */ - public interface SelectionChangeListener extends Serializable { + public interface SelectionListener extends Serializable { /** * Notifies the listener that the selection state has changed. * * @param event * the selection change event */ - void selectionChange(SelectionChangeEvent event); + void select(SelectionEvent event); } /** * The interface for adding and removing listeners for - * {@link SelectionChangeEvent SelectionChangeEvents}. - * - * @since - * @author Vaadin Ltd + * {@link SelectionEvent SelectionEvents}. */ - public interface SelectionChangeNotifier extends Serializable { + public interface SelectionNotifier extends Serializable { /** - * Registers a new selection change listener + * Registers a new selection listener * * @param listener * the listener to register */ - void addSelectionChangeListener(SelectionChangeListener listener); + void addSelectionListener(SelectionListener listener); /** * Removes a previously registered selection change listener @@ -105,6 +99,6 @@ public class SelectionChangeEvent extends EventObject { * @param listener * the listener to remove */ - void removeSelectionChangeListener(SelectionChangeListener listener); + void removeSelectionListener(SelectionListener listener); } } diff --git a/server/src/com/vaadin/event/SortOrderChangeEvent.java b/server/src/com/vaadin/event/SortEvent.java index fdf604a034..968d2f6d83 100644 --- a/server/src/com/vaadin/event/SortOrderChangeEvent.java +++ b/server/src/com/vaadin/event/SortEvent.java @@ -23,14 +23,14 @@ import com.vaadin.ui.Component; /** * Event describing a change in sorting of a {@link Container}. Fired by - * {@link SortOrderChangeNotifier SortOrderChangeNotifiers}. + * {@link SortNotifier SortNotifiers}. * - * @see SortOrderChangeListener + * @see SortListener * * @since * @author Vaadin Ltd */ -public class SortOrderChangeEvent extends Component.Event { +public class SortEvent extends Component.Event { private final List<SortOrder> sortOrder; private final boolean userOriginated; @@ -46,7 +46,7 @@ public class SortOrderChangeEvent extends Component.Event { * <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, + public SortEvent(Component source, List<SortOrder> sortOrder, boolean userOriginated) { super(source); this.sortOrder = sortOrder; @@ -74,21 +74,21 @@ public class SortOrderChangeEvent extends Component.Event { /** * Listener for sort order change events. */ - public interface SortOrderChangeListener extends Serializable { + public interface SortListener extends Serializable { /** * Called when the sort order has changed. * * @param event * the sort order change event */ - public void sortOrderChange(SortOrderChangeEvent event); + public void sort(SortEvent event); } /** - * The interface for adding and removing listeners for - * {@link SortOrderChangeEvent SortOrderChangeEvents}. + * The interface for adding and removing listeners for {@link SortEvent + * SortEvents}. */ - public interface SortOrderChangeNotifier extends Serializable { + public interface SortNotifier extends Serializable { /** * Adds a sort order change listener that gets notified when the sort * order changes. @@ -96,16 +96,15 @@ public class SortOrderChangeEvent extends Component.Event { * @param listener * the sort order change listener to add */ - public void addSortOrderChangeListener(SortOrderChangeListener listener); + public void addSortListener(SortListener listener); /** * Removes a sort order change listener previously added using - * {@link #addSortOrderChangeListener(SortOrderChangeListener)}. + * {@link #addSortListener(SortListener)}. * * @param listener * the sort order change listener to remove */ - public void removeSortOrderChangeListener( - SortOrderChangeListener listener); + public void removeSortistener(SortListener listener); } } diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index 1842e3e757..6957a5bd3d 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -56,12 +56,12 @@ import com.vaadin.data.sort.SortOrder; import com.vaadin.data.util.IndexedContainer; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ConverterUtil; -import com.vaadin.event.SelectionChangeEvent; -import com.vaadin.event.SelectionChangeEvent.SelectionChangeListener; -import com.vaadin.event.SelectionChangeEvent.SelectionChangeNotifier; -import com.vaadin.event.SortOrderChangeEvent; -import com.vaadin.event.SortOrderChangeEvent.SortOrderChangeListener; -import com.vaadin.event.SortOrderChangeEvent.SortOrderChangeNotifier; +import com.vaadin.event.SelectionEvent; +import com.vaadin.event.SelectionEvent.SelectionListener; +import com.vaadin.event.SelectionEvent.SelectionNotifier; +import com.vaadin.event.SortEvent; +import com.vaadin.event.SortEvent.SortListener; +import com.vaadin.event.SortEvent.SortNotifier; import com.vaadin.server.AbstractClientConnector; import com.vaadin.server.AbstractExtension; import com.vaadin.server.ErrorMessage; @@ -154,8 +154,8 @@ import elemental.json.JsonValue; * @since * @author Vaadin Ltd */ -public class Grid extends AbstractComponent implements SelectionChangeNotifier, - SortOrderChangeNotifier, SelectiveRenderer { +public class Grid extends AbstractComponent implements SelectionNotifier, + SortNotifier, SelectiveRenderer { /** * Custom field group that allows finding property types before an item has @@ -479,13 +479,13 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, } /** - * Fires a {@link SelectionChangeEvent} to all the - * {@link SelectionChangeListener SelectionChangeListeners} currently - * added to the Grid in which this SelectionModel is. + * Fires a {@link SelectionEvent} to all the {@link SelectionListener + * SelectionListeners} currently added to the Grid in which this + * SelectionModel is. * <p> * Note that this is only a helper method, and routes the call all the * way to Grid. A {@link SelectionModel} is not a - * {@link SelectionChangeNotifier} + * {@link SelectionNotifier} * * @param oldSelection * the complete {@link Collection} of the itemIds that were @@ -494,10 +494,10 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, * the complete {@link Collection} of the itemIds that are * selected <em>after</em> this event happened */ - protected void fireSelectionChangeEvent( + protected void fireSelectionEvent( final Collection<Object> oldSelection, final Collection<Object> newSelection) { - grid.fireSelectionChangeEvent(oldSelection, newSelection); + grid.fireSelectionEvent(oldSelection, newSelection); } } @@ -525,7 +525,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, deselected = Collections.emptySet(); } - fireSelectionChangeEvent(deselected, selection); + fireSelectionEvent(deselected, selection); } return modified; @@ -539,7 +539,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, boolean fireEventIfNeeded) { final boolean modified = selection.remove(itemId); if (fireEventIfNeeded && modified) { - fireSelectionChangeEvent(Collections.singleton(itemId), + fireSelectionEvent(Collections.singleton(itemId), Collections.emptySet()); } return modified; @@ -653,7 +653,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, } else { selection.addAll(itemIds); } - fireSelectionChangeEvent(oldSelection, selection); + fireSelectionEvent(oldSelection, selection); } return selectionWillChange; } @@ -718,7 +718,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, final HashSet<Object> oldSelection = new HashSet<Object>( selection); selection.removeAll(itemIds); - fireSelectionChangeEvent(oldSelection, selection); + fireSelectionEvent(oldSelection, selection); } return hasCommonElements; } @@ -2411,12 +2411,10 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, private boolean defaultContainer = true; private static final Method SELECTION_CHANGE_METHOD = ReflectTools - .findMethod(SelectionChangeListener.class, "selectionChange", - SelectionChangeEvent.class); + .findMethod(SelectionListener.class, "select", SelectionEvent.class); private static final Method SORT_ORDER_CHANGE_METHOD = ReflectTools - .findMethod(SortOrderChangeListener.class, "sortOrderChange", - SortOrderChangeEvent.class); + .findMethod(SortListener.class, "sort", SortEvent.class); /** * Creates a new Grid with a new {@link IndexedContainer} as the datasource. @@ -2442,9 +2440,9 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, */ private void initGrid() { setSelectionMode(SelectionMode.MULTI); - addSelectionChangeListener(new SelectionChangeListener() { + addSelectionListener(new SelectionListener() { @Override - public void selectionChange(SelectionChangeEvent event) { + public void select(SelectionEvent event) { if (applyingSelectionFromClient) { /* * Avoid sending changes back to the client if they @@ -3443,21 +3441,19 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, * @param removedSelections * the selections that were removed by this event */ - public void fireSelectionChangeEvent(Collection<Object> oldSelection, + public void fireSelectionEvent(Collection<Object> oldSelection, Collection<Object> newSelection) { - fireEvent(new SelectionChangeEvent(this, oldSelection, newSelection)); + fireEvent(new SelectionEvent(this, oldSelection, newSelection)); } @Override - public void addSelectionChangeListener(SelectionChangeListener listener) { - addListener(SelectionChangeEvent.class, listener, - SELECTION_CHANGE_METHOD); + public void addSelectionListener(SelectionListener listener) { + addListener(SelectionEvent.class, listener, SELECTION_CHANGE_METHOD); } @Override - public void removeSelectionChangeListener(SelectionChangeListener listener) { - removeListener(SelectionChangeEvent.class, listener, - SELECTION_CHANGE_METHOD); + public void removeSelectionListener(SelectionListener listener) { + removeListener(SelectionEvent.class, listener, SELECTION_CHANGE_METHOD); } /** @@ -3611,8 +3607,8 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, cs.sort(propertyIds, directions); - fireEvent(new SortOrderChangeEvent(this, new ArrayList<SortOrder>( - sortOrder), userOriginated)); + fireEvent(new SortEvent(this, new ArrayList<SortOrder>(sortOrder), + userOriginated)); getState().sortColumns = columnKeys; getState(false).sortDirs = stateDirs; @@ -3630,22 +3626,20 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier, * the sort order change listener to add */ @Override - public void addSortOrderChangeListener(SortOrderChangeListener listener) { - addListener(SortOrderChangeEvent.class, listener, - SORT_ORDER_CHANGE_METHOD); + public void addSortListener(SortListener listener) { + addListener(SortEvent.class, listener, SORT_ORDER_CHANGE_METHOD); } /** * Removes a sort order change listener previously added using - * {@link #addSortOrderChangeListener(SortOrderChangeListener)}. + * {@link #addSortListener(SortListener)}. * * @param listener * the sort order change listener to remove */ @Override - public void removeSortOrderChangeListener(SortOrderChangeListener listener) { - removeListener(SortOrderChangeEvent.class, listener, - SORT_ORDER_CHANGE_METHOD); + public void removeSortistener(SortListener listener) { + removeListener(SortEvent.class, listener, SORT_ORDER_CHANGE_METHOD); } /* Grid Headers */ diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java index a941a92117..07a138c6ca 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java @@ -25,8 +25,8 @@ import org.junit.Before; import org.junit.Test; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.event.SelectionChangeEvent; -import com.vaadin.event.SelectionChangeEvent.SelectionChangeListener; +import com.vaadin.event.SelectionEvent; +import com.vaadin.event.SelectionEvent.SelectionListener; import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Grid.SelectionModel; @@ -34,11 +34,11 @@ import com.vaadin.ui.Grid.SelectionModel; public class GridSelection { private static class MockSelectionChangeListener implements - SelectionChangeListener { - private SelectionChangeEvent event; + SelectionListener { + private SelectionEvent event; @Override - public void selectionChange(final SelectionChangeEvent event) { + public void select(final SelectionEvent event) { this.event = event; } @@ -93,7 +93,7 @@ public class GridSelection { grid = new Grid(container); mockListener = new MockSelectionChangeListener(); - grid.addSelectionChangeListener(mockListener); + grid.addSelectionListener(mockListener); assertFalse("eventHasHappened", mockListener.eventHasHappened()); } diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java b/server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java index 9f54930ac8..c217efb935 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java @@ -22,8 +22,8 @@ import org.junit.Test; import com.vaadin.data.Container; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.event.SelectionChangeEvent; -import com.vaadin.event.SelectionChangeEvent.SelectionChangeListener; +import com.vaadin.event.SelectionEvent; +import com.vaadin.event.SelectionEvent.SelectionListener; import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.Grid.SingleSelectionModel; @@ -124,10 +124,10 @@ public class SingleSelectionModelTest { private void expectEvent(final Object selected, final Object deselected) { expectingEvent = true; - grid.addSelectionChangeListener(new SelectionChangeListener() { + grid.addSelectionListener(new SelectionListener() { @Override - public void selectionChange(SelectionChangeEvent event) { + public void select(SelectionEvent event) { if (selected != null) { Assert.assertTrue( "Selection did not contain expected item", event @@ -146,7 +146,7 @@ public class SingleSelectionModelTest { .getRemoved().isEmpty()); } - grid.removeSelectionChangeListener(this); + grid.removeSelectionListener(this); expectingEvent = false; } }); diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/sort/SortTest.java b/server/tests/src/com/vaadin/tests/server/component/grid/sort/SortTest.java index b339cb9aff..22640b8b8f 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/sort/SortTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/sort/SortTest.java @@ -26,8 +26,8 @@ import org.junit.Test; import com.vaadin.data.sort.Sort; import com.vaadin.data.sort.SortOrder; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.event.SortOrderChangeEvent; -import com.vaadin.event.SortOrderChangeEvent.SortOrderChangeListener; +import com.vaadin.event.SortEvent; +import com.vaadin.event.SortEvent.SortListener; import com.vaadin.shared.ui.grid.SortDirection; import com.vaadin.ui.Grid; @@ -71,11 +71,11 @@ public class SortTest { } } - class RegisteringSortChangeListener implements SortOrderChangeListener { + class RegisteringSortChangeListener implements SortListener { private List<SortOrder> order; @Override - public void sortOrderChange(SortOrderChangeEvent event) { + public void sort(SortEvent event) { assert order == null : "The same listener was notified multipe times without checking"; order = event.getSortOrder(); @@ -102,7 +102,7 @@ public class SortTest { listener = new RegisteringSortChangeListener(); grid = new Grid(container); - grid.addSortOrderChangeListener(listener); + grid.addSortListener(listener); } @After 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 30a0d0bbf5..5339fcf472 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -32,8 +32,8 @@ import com.vaadin.data.fieldgroup.FieldGroup.CommitException; import com.vaadin.data.sort.Sort; import com.vaadin.data.sort.SortOrder; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.event.SortOrderChangeEvent; -import com.vaadin.event.SortOrderChangeEvent.SortOrderChangeListener; +import com.vaadin.event.SortEvent; +import com.vaadin.event.SortEvent.SortListener; import com.vaadin.shared.ui.grid.GridStaticCellType; import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.SortDirection; @@ -178,9 +178,9 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { grid.getColumn(getColumnProperty(col)).setWidth(100 + col * 50); } - grid.addSortOrderChangeListener(new SortOrderChangeListener() { + grid.addSortListener(new SortListener() { @Override - public void sortOrderChange(SortOrderChangeEvent event) { + public void sort(SortEvent event) { log("SortOrderChangeEvent: isUserOriginated? " + event.isUserOriginated()); |