summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-12-11 14:34:05 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2014-12-11 21:21:09 +0000
commit9fc2409cb33797c536cd2e7e9ef035a5422c5e58 (patch)
treee39fa7ddfcd0a2bb6c043fed6461dafa3b672456
parent341126484e70bdc0f71755acd5277deada3b185c (diff)
downloadvaadin-framework-9fc2409cb33797c536cd2e7e9ef035a5422c5e58.tar.gz
vaadin-framework-9fc2409cb33797c536cd2e7e9ef035a5422c5e58.zip
Make SelectionChangeEvent general and move it to event packacge (#13334)
Change-Id: I232bf1d021dd95dfa3e9697cef4d8e9987da3373
-rw-r--r--server/src/com/vaadin/event/SelectionChangeEvent.java (renamed from server/src/com/vaadin/ui/components/grid/selection/SelectionChangeEvent.java)49
-rw-r--r--server/src/com/vaadin/ui/Grid.java6
-rw-r--r--server/src/com/vaadin/ui/components/grid/selection/SelectionChangeListener.java35
-rw-r--r--server/src/com/vaadin/ui/components/grid/selection/SelectionChangeNotifier.java43
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java4
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java4
6 files changed, 50 insertions, 91 deletions
diff --git a/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeEvent.java b/server/src/com/vaadin/event/SelectionChangeEvent.java
index 4d45a32615..adc7b13d49 100644
--- a/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeEvent.java
+++ b/server/src/com/vaadin/event/SelectionChangeEvent.java
@@ -13,15 +13,15 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.ui.components.grid.selection;
+package com.vaadin.event;
+import java.io.Serializable;
import java.util.Collection;
import java.util.EventObject;
import java.util.LinkedHashSet;
import java.util.Set;
import com.google.gwt.thirdparty.guava.common.collect.Sets;
-import com.vaadin.ui.Grid;
/**
* An event that specifies what in a selection has changed, and where the
@@ -35,7 +35,7 @@ public class SelectionChangeEvent extends EventObject {
private LinkedHashSet<Object> oldSelection;
private LinkedHashSet<Object> newSelection;
- public SelectionChangeEvent(Grid source, Collection<Object> oldSelection,
+ public SelectionChangeEvent(Object source, Collection<Object> oldSelection,
Collection<Object> newSelection) {
super(source);
this.oldSelection = new LinkedHashSet<Object>(oldSelection);
@@ -66,8 +66,45 @@ public class SelectionChangeEvent extends EventObject {
return Sets.difference(oldSelection, newSelection);
}
- @Override
- public Grid getSource() {
- return (Grid) super.getSource();
+ /**
+ * The listener interface for receiving {@link SelectionChangeEvent
+ * SelectionChangeEvents}.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+ public interface SelectionChangeListener extends Serializable {
+ /**
+ * Notifies the listener that the selection state has changed.
+ *
+ * @param event
+ * the selection change event
+ */
+ void selectionChange(SelectionChangeEvent event);
+ }
+
+ /**
+ * The interface for adding and removing listeners for
+ * {@link SelectionChangeEvent SelectionChangeEvents}.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+ public interface SelectionChangeNotifier extends Serializable {
+ /**
+ * Registers a new selection change listener
+ *
+ * @param listener
+ * the listener to register
+ */
+ void addSelectionChangeListener(SelectionChangeListener listener);
+
+ /**
+ * Removes a previously registered selection change listener
+ *
+ * @param listener
+ * the listener to remove
+ */
+ void removeSelectionChangeListener(SelectionChangeListener listener);
}
}
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 2ead3bf514..ca69387301 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -54,6 +54,9 @@ import com.vaadin.data.fieldgroup.FieldGroupFieldFactory;
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.server.AbstractClientConnector;
import com.vaadin.server.AbstractExtension;
import com.vaadin.server.ClientConnector;
@@ -80,9 +83,6 @@ import com.vaadin.shared.ui.grid.SortEventOriginator;
import com.vaadin.shared.util.SharedUtil;
import com.vaadin.ui.components.grid.SortOrderChangeEvent;
import com.vaadin.ui.components.grid.SortOrderChangeListener;
-import com.vaadin.ui.components.grid.selection.SelectionChangeEvent;
-import com.vaadin.ui.components.grid.selection.SelectionChangeListener;
-import com.vaadin.ui.components.grid.selection.SelectionChangeNotifier;
import com.vaadin.ui.components.grid.sort.Sort;
import com.vaadin.ui.components.grid.sort.SortOrder;
import com.vaadin.ui.renderer.Renderer;
diff --git a/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeListener.java b/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeListener.java
deleted file mode 100644
index 0d10e8c74d..0000000000
--- a/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeListener.java
+++ /dev/null
@@ -1,35 +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.ui.components.grid.selection;
-
-import java.io.Serializable;
-
-/**
- * The listener interface for receiving {@link SelectionChangeEvent
- * SelectionChangeEvents}.
- *
- * @since
- * @author Vaadin Ltd
- */
-public interface SelectionChangeListener extends Serializable {
- /**
- * Notifies the listener that the selection state has changed.
- *
- * @param event
- * the selection change event
- */
- void selectionChange(SelectionChangeEvent event);
-}
diff --git a/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeNotifier.java b/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeNotifier.java
deleted file mode 100644
index 40cef965dd..0000000000
--- a/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeNotifier.java
+++ /dev/null
@@ -1,43 +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.ui.components.grid.selection;
-
-import java.io.Serializable;
-
-/**
- * The interface for adding and removing listeners for
- * {@link SelectionChangeEvent SelectionChangeEvents}.
- *
- * @since
- * @author Vaadin Ltd
- */
-public interface SelectionChangeNotifier extends Serializable {
- /**
- * Registers a new selection change listener
- *
- * @param listener
- * the listener to register
- */
- void addSelectionChangeListener(SelectionChangeListener listener);
-
- /**
- * Removes a previously registered selection change listener
- *
- * @param listener
- * the listener to remove
- */
- void removeSelectionChangeListener(SelectionChangeListener listener);
-}
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 5378828ae7..a941a92117 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,11 +25,11 @@ 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.ui.Grid;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.Grid.SelectionModel;
-import com.vaadin.ui.components.grid.selection.SelectionChangeEvent;
-import com.vaadin.ui.components.grid.selection.SelectionChangeListener;
public class GridSelection {
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 a183c555a6..9f54930ac8 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,11 +22,11 @@ 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.ui.Grid;
import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.Grid.SingleSelectionModel;
-import com.vaadin.ui.components.grid.selection.SelectionChangeEvent;
-import com.vaadin.ui.components.grid.selection.SelectionChangeListener;
public class SingleSelectionModelTest {