]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make SelectionChangeEvent general and move it to event packacge (#13334)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Thu, 11 Dec 2014 12:34:05 +0000 (14:34 +0200)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Thu, 11 Dec 2014 21:21:09 +0000 (21:21 +0000)
Change-Id: I232bf1d021dd95dfa3e9697cef4d8e9987da3373

server/src/com/vaadin/event/SelectionChangeEvent.java [new file with mode: 0644]
server/src/com/vaadin/ui/Grid.java
server/src/com/vaadin/ui/components/grid/selection/SelectionChangeEvent.java [deleted file]
server/src/com/vaadin/ui/components/grid/selection/SelectionChangeListener.java [deleted file]
server/src/com/vaadin/ui/components/grid/selection/SelectionChangeNotifier.java [deleted file]
server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java
server/tests/src/com/vaadin/tests/server/component/grid/SingleSelectionModelTest.java

diff --git a/server/src/com/vaadin/event/SelectionChangeEvent.java b/server/src/com/vaadin/event/SelectionChangeEvent.java
new file mode 100644 (file)
index 0000000..adc7b13
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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.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;
+
+/**
+ * An event that specifies what in a selection has changed, and where the
+ * selection took place.
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class SelectionChangeEvent extends EventObject {
+
+    private LinkedHashSet<Object> oldSelection;
+    private LinkedHashSet<Object> newSelection;
+
+    public SelectionChangeEvent(Object source, Collection<Object> oldSelection,
+            Collection<Object> newSelection) {
+        super(source);
+        this.oldSelection = new LinkedHashSet<Object>(oldSelection);
+        this.newSelection = new LinkedHashSet<Object>(newSelection);
+    }
+
+    /**
+     * A {@link Collection} of all the itemIds that became selected.
+     * <p>
+     * <em>Note:</em> this excludes all itemIds that might have been previously
+     * selected.
+     * 
+     * @return a Collection of the itemIds that became selected
+     */
+    public Set<Object> getAdded() {
+        return Sets.difference(newSelection, oldSelection);
+    }
+
+    /**
+     * A {@link Collection} of all the itemIds that became deselected.
+     * <p>
+     * <em>Note:</em> this excludes all itemIds that might have been previously
+     * deselected.
+     * 
+     * @return a Collection of the itemIds that became deselected
+     */
+    public Set<Object> getRemoved() {
+        return Sets.difference(oldSelection, newSelection);
+    }
+
+    /**
+     * 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);
+    }
+}
index 2ead3bf514cd0fcb2994c5a078006bb41d0f52f9..ca693873016997a06bc0c657ed0a0aa47c7259f4 100644 (file)
@@ -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/SelectionChangeEvent.java b/server/src/com/vaadin/ui/components/grid/selection/SelectionChangeEvent.java
deleted file mode 100644 (file)
index 4d45a32..0000000
+++ /dev/null
@@ -1,73 +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.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
- * selection took place.
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class SelectionChangeEvent extends EventObject {
-
-    private LinkedHashSet<Object> oldSelection;
-    private LinkedHashSet<Object> newSelection;
-
-    public SelectionChangeEvent(Grid source, Collection<Object> oldSelection,
-            Collection<Object> newSelection) {
-        super(source);
-        this.oldSelection = new LinkedHashSet<Object>(oldSelection);
-        this.newSelection = new LinkedHashSet<Object>(newSelection);
-    }
-
-    /**
-     * A {@link Collection} of all the itemIds that became selected.
-     * <p>
-     * <em>Note:</em> this excludes all itemIds that might have been previously
-     * selected.
-     * 
-     * @return a Collection of the itemIds that became selected
-     */
-    public Set<Object> getAdded() {
-        return Sets.difference(newSelection, oldSelection);
-    }
-
-    /**
-     * A {@link Collection} of all the itemIds that became deselected.
-     * <p>
-     * <em>Note:</em> this excludes all itemIds that might have been previously
-     * deselected.
-     * 
-     * @return a Collection of the itemIds that became deselected
-     */
-    public Set<Object> getRemoved() {
-        return Sets.difference(oldSelection, newSelection);
-    }
-
-    @Override
-    public Grid getSource() {
-        return (Grid) super.getSource();
-    }
-}
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 (file)
index 0d10e8c..0000000
+++ /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 (file)
index 40cef96..0000000
+++ /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);
-}
index 5378828ae7450aa2916929ea2b1a6eef28ec44de..a941a921177ec7e40f3940de5f97be5d9437e424 100644 (file)
@@ -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 {
 
index a183c555a646921d7ae81168e5b4334cacc7fa94..9f54930ac88bae45a48e2c82b004c1ec7dfd7377 100644 (file)
@@ -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 {