]> source.dussan.org Git - vaadin-framework.git/commitdiff
Move Sort related helpers and events to correct packages (#13334)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Thu, 11 Dec 2014 12:53:04 +0000 (14:53 +0200)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Thu, 11 Dec 2014 22:18:46 +0000 (00:18 +0200)
Change-Id: I3aa86364b61d42f971c4fca2b4c4895ddae870c4

14 files changed:
server/src/com/vaadin/data/sort/Sort.java [new file with mode: 0644]
server/src/com/vaadin/data/sort/SortOrder.java [new file with mode: 0644]
server/src/com/vaadin/data/util/GeneratedPropertyContainer.java
server/src/com/vaadin/data/util/PropertyValueGenerator.java
server/src/com/vaadin/event/SortOrderChangeEvent.java [new file with mode: 0644]
server/src/com/vaadin/ui/Grid.java
server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java [deleted file]
server/src/com/vaadin/ui/components/grid/SortOrderChangeListener.java [deleted file]
server/src/com/vaadin/ui/components/grid/sort/Sort.java [deleted file]
server/src/com/vaadin/ui/components/grid/sort/SortOrder.java [deleted file]
server/tests/src/com/vaadin/data/util/GeneratedPropertyContainerTest.java
server/tests/src/com/vaadin/tests/server/component/grid/sort/SortTest.java
uitest/src/com/vaadin/tests/components/grid/GridGeneratedProperties.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java

diff --git a/server/src/com/vaadin/data/sort/Sort.java b/server/src/com/vaadin/data/sort/Sort.java
new file mode 100644 (file)
index 0000000..914a92f
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * 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.data.sort;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.shared.ui.grid.SortDirection;
+
+/**
+ * Fluid Sort API. Provides a convenient, human-readable way of specifying
+ * multi-column sort order.
+ * 
+ * @since 7.4
+ * @author Vaadin Ltd
+ */
+public class Sort implements Serializable {
+
+    private final Sort previous;
+    private final SortOrder order;
+
+    /**
+     * Initial constructor, called by the static by() methods.
+     * 
+     * @param propertyId
+     *            a property ID, corresponding to a property in the data source
+     * @param direction
+     *            a sort direction value
+     */
+    private Sort(Object propertyId, SortDirection direction) {
+        previous = null;
+        order = new SortOrder(propertyId, direction);
+    }
+
+    /**
+     * Chaining constructor, called by the non-static then() methods. This
+     * constructor links to the previous Sort object.
+     * 
+     * @param previous
+     *            the sort marker that comes before this one
+     * @param propertyId
+     *            a property ID, corresponding to a property in the data source
+     * @param direction
+     *            a sort direction value
+     */
+    private Sort(Sort previous, Object propertyId, SortDirection direction) {
+        this.previous = previous;
+        order = new SortOrder(propertyId, direction);
+
+        Sort s = previous;
+        while (s != null) {
+            if (s.order.getPropertyId() == propertyId) {
+                throw new IllegalStateException(
+                        "Can not sort along the same property (" + propertyId
+                                + ") twice!");
+            }
+            s = s.previous;
+        }
+
+    }
+
+    /**
+     * Start building a Sort order by sorting a provided column in ascending
+     * order.
+     * 
+     * @param propertyId
+     *            a property id, corresponding to a data source property
+     * @return a sort object
+     */
+    public static Sort by(Object propertyId) {
+        return by(propertyId, SortDirection.ASCENDING);
+    }
+
+    /**
+     * Start building a Sort order by sorting a provided column.
+     * 
+     * @param propertyId
+     *            a property id, corresponding to a data source property
+     * @param direction
+     *            a sort direction value
+     * @return a sort object
+     */
+    public static Sort by(Object propertyId, SortDirection direction) {
+        return new Sort(propertyId, direction);
+    }
+
+    /**
+     * Continue building a Sort order. The provided property is sorted in
+     * ascending order if the previously added properties have been evaluated as
+     * equals.
+     * 
+     * @param propertyId
+     *            a property id, corresponding to a data source property
+     * @return a sort object
+     */
+    public Sort then(Object propertyId) {
+        return then(propertyId, SortDirection.ASCENDING);
+    }
+
+    /**
+     * Continue building a Sort order. The provided property is sorted in
+     * specified order if the previously added properties have been evaluated as
+     * equals.
+     * 
+     * @param propertyId
+     *            a property id, corresponding to a data source property
+     * @param direction
+     *            a sort direction value
+     * @return a sort object
+     */
+    public Sort then(Object propertyId, SortDirection direction) {
+        return new Sort(this, propertyId, direction);
+    }
+
+    /**
+     * Build a sort order list, ready to be passed to Grid
+     * 
+     * @return a sort order list.
+     */
+    public List<SortOrder> build() {
+
+        int count = 1;
+        Sort s = this;
+        while (s.previous != null) {
+            s = s.previous;
+            ++count;
+        }
+
+        List<SortOrder> order = new ArrayList<SortOrder>(count);
+
+        s = this;
+        do {
+            order.add(0, s.order);
+            s = s.previous;
+        } while (s != null);
+
+        return order;
+    }
+}
diff --git a/server/src/com/vaadin/data/sort/SortOrder.java b/server/src/com/vaadin/data/sort/SortOrder.java
new file mode 100644 (file)
index 0000000..55cae8c
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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.data.sort;
+
+import java.io.Serializable;
+
+import com.vaadin.shared.ui.grid.SortDirection;
+
+/**
+ * Sort order descriptor. Links together a {@link SortDirection} value and a
+ * Vaadin container property ID.
+ * 
+ * @since 7.4
+ * @author Vaadin Ltd
+ */
+public class SortOrder implements Serializable {
+
+    private final Object propertyId;
+    private final SortDirection direction;
+
+    /**
+     * Create a SortOrder object. Both arguments must be non-null.
+     * 
+     * @param propertyId
+     *            id of the data source property to sort by
+     * @param direction
+     *            value indicating whether the property id should be sorted in
+     *            ascending or descending order
+     */
+    public SortOrder(Object propertyId, SortDirection direction) {
+        if (propertyId == null) {
+            throw new IllegalArgumentException("Property ID can not be null!");
+        }
+        if (direction == null) {
+            throw new IllegalArgumentException(
+                    "Direction value can not be null!");
+        }
+        this.propertyId = propertyId;
+        this.direction = direction;
+    }
+
+    /**
+     * Returns the property ID.
+     * 
+     * @return a property ID
+     */
+    public Object getPropertyId() {
+        return propertyId;
+    }
+
+    /**
+     * Returns the {@link SortDirection} value.
+     * 
+     * @return a sort direction value
+     */
+    public SortDirection getDirection() {
+        return direction;
+    }
+
+    @Override
+    public String toString() {
+        return propertyId + " " + direction;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + direction.hashCode();
+        result = prime * result + propertyId.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        } else if (obj == null) {
+            return false;
+        } else if (getClass() != obj.getClass()) {
+            return false;
+        }
+
+        SortOrder other = (SortOrder) obj;
+        if (direction != other.direction) {
+            return false;
+        } else if (!propertyId.equals(other.propertyId)) {
+            return false;
+        }
+        return true;
+    }
+
+}
index 91498eaeb1864ee0f77a4a9996506f24e7a16e01..17472807b5c5ba1550cb7088a51b7599cfe67314 100644 (file)
@@ -31,9 +31,9 @@ import com.google.gwt.thirdparty.guava.common.collect.Sets;
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
+import com.vaadin.data.sort.SortOrder;
 import com.vaadin.data.util.filter.UnsupportedFilterException;
 import com.vaadin.shared.ui.grid.SortDirection;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 
 /**
  * Container wrapper that adds support for generated properties. This container
index 88169b785b2b966d2dd158113f709681976a7782..c535803ee1abf703cda13f78a4ac0d42563304a6 100644 (file)
@@ -20,8 +20,8 @@ import java.io.Serializable;
 import com.vaadin.data.Container.Filter;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
+import com.vaadin.data.sort.SortOrder;
 import com.vaadin.data.util.filter.UnsupportedFilterException;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 
 /**
  * PropertyValueGenerator for GeneratedPropertyContainer.
diff --git a/server/src/com/vaadin/event/SortOrderChangeEvent.java b/server/src/com/vaadin/event/SortOrderChangeEvent.java
new file mode 100644 (file)
index 0000000..e38097e
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * 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.List;
+
+import com.vaadin.data.sort.SortOrder;
+import com.vaadin.shared.ui.grid.SortEventOriginator;
+import com.vaadin.ui.Component;
+
+/**
+ * Event describing a change in sorting of a {@link Container}. Fired by
+ * {@link SortOrderChangeNotifier SortOrderChangeNotifiers}.
+ * 
+ * @see SortOrderChangeListener
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class SortOrderChangeEvent extends Component.Event {
+
+    private final List<SortOrder> sortOrder;
+    private final SortEventOriginator originator;
+
+    /**
+     * Creates a new sort order change event with a sort order list.
+     * 
+     * @param source
+     *            the component from which the event originates
+     * @param sortOrder
+     *            the new sort order list
+     * @param originator
+     *            an enumeration describing what triggered the sorting
+     */
+    public SortOrderChangeEvent(Component source, List<SortOrder> sortOrder,
+            SortEventOriginator originator) {
+        super(source);
+        this.sortOrder = sortOrder;
+        this.originator = originator;
+    }
+
+    /**
+     * Gets the sort order list.
+     * 
+     * @return the sort order list
+     */
+    public List<SortOrder> getSortOrder() {
+        return sortOrder;
+    }
+
+    /**
+     * Returns whether this event originated from actions done by the user.
+     * 
+     * @return true if sort event originated from user interaction
+     */
+    public boolean isUserOriginated() {
+        return originator == SortEventOriginator.USER;
+    }
+
+    /**
+     * Listener for sort order change events.
+     */
+    public interface SortOrderChangeListener extends Serializable {
+        /**
+         * Called when the sort order has changed.
+         * 
+         * @param event
+         *            the sort order change event
+         */
+        public void sortOrderChange(SortOrderChangeEvent event);
+    }
+
+    /**
+     * The interface for adding and removing listeners for
+     * {@link SortOrderChangeEvent SortOrderChangeEvents}.
+     */
+    public interface SortOrderChangeNotifier extends Serializable {
+        /**
+         * Adds a sort order change listener that gets notified when the sort
+         * order changes.
+         * 
+         * @param listener
+         *            the sort order change listener to add
+         */
+        public void addSortOrderChangeListener(SortOrderChangeListener listener);
+
+        /**
+         * Removes a sort order change listener previously added using
+         * {@link #addSortOrderChangeListener(SortOrderChangeListener)}.
+         * 
+         * @param listener
+         *            the sort order change listener to remove
+         */
+        public void removeSortOrderChangeListener(
+                SortOrderChangeListener listener);
+    }
+}
index ca693873016997a06bc0c657ed0a0aa47c7259f4..49c082b0b22a6a82a020d38818377444477345b5 100644 (file)
@@ -51,12 +51,17 @@ import com.vaadin.data.fieldgroup.FieldGroup;
 import com.vaadin.data.fieldgroup.FieldGroup.BindException;
 import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
 import com.vaadin.data.fieldgroup.FieldGroupFieldFactory;
+import com.vaadin.data.sort.Sort;
+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.server.AbstractClientConnector;
 import com.vaadin.server.AbstractExtension;
 import com.vaadin.server.ClientConnector;
@@ -81,10 +86,6 @@ 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.components.grid.SortOrderChangeEvent;
-import com.vaadin.ui.components.grid.SortOrderChangeListener;
-import com.vaadin.ui.components.grid.sort.Sort;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 import com.vaadin.ui.renderer.Renderer;
 import com.vaadin.ui.renderer.TextRenderer;
 import com.vaadin.util.ReflectTools;
@@ -157,7 +158,7 @@ import elemental.json.JsonValue;
  * @author Vaadin Ltd
  */
 public class Grid extends AbstractComponent implements SelectionChangeNotifier,
-        SelectiveRenderer {
+        SortOrderChangeNotifier, SelectiveRenderer {
 
     /**
      * Selection modes representing built-in {@link SelectionModel
@@ -3354,6 +3355,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier,
      * @param listener
      *            the sort order change listener to add
      */
+    @Override
     public void addSortOrderChangeListener(SortOrderChangeListener listener) {
         addListener(SortOrderChangeEvent.class, listener,
                 SORT_ORDER_CHANGE_METHOD);
@@ -3366,6 +3368,7 @@ public class Grid extends AbstractComponent implements SelectionChangeNotifier,
      * @param listener
      *            the sort order change listener to remove
      */
+    @Override
     public void removeSortOrderChangeListener(SortOrderChangeListener listener) {
         removeListener(SortOrderChangeEvent.class, listener,
                 SORT_ORDER_CHANGE_METHOD);
diff --git a/server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java b/server/src/com/vaadin/ui/components/grid/SortOrderChangeEvent.java
deleted file mode 100644 (file)
index 09e3902..0000000
+++ /dev/null
@@ -1,74 +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;
-
-import java.util.List;
-
-import com.vaadin.shared.ui.grid.SortEventOriginator;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.Grid;
-import com.vaadin.ui.components.grid.sort.SortOrder;
-
-/**
- * Event fired by {@link Grid} when the sort order has changed.
- * 
- * @see SortOrderChangeListener
- * 
- * @since
- * @author Vaadin Ltd
- */
-public class SortOrderChangeEvent extends Component.Event {
-
-    private final List<SortOrder> sortOrder;
-    private final SortEventOriginator originator;
-
-    /**
-     * Creates a new sort order change event for a grid and a sort order list.
-     * 
-     * @param grid
-     *            the grid from which the event originates
-     * @param sortOrder
-     *            the new sort order list
-     * @param wasInitiatedByUser
-     *            should be set to true if this event results from end-user
-     *            interaction instead of an API call or side effect
-     */
-    public SortOrderChangeEvent(Grid grid, List<SortOrder> sortOrder,
-            SortEventOriginator originator) {
-        super(grid);
-        this.sortOrder = sortOrder;
-        this.originator = originator;
-    }
-
-    /**
-     * Gets the sort order list.
-     * 
-     * @return the sort order list
-     */
-    public List<SortOrder> getSortOrder() {
-        return sortOrder;
-    }
-
-    /**
-     * Returns whether this event originated from actions done by the user.
-     * 
-     * @return true if sort event originated from user interaction
-     */
-    public boolean isUserOriginated() {
-        return originator == SortEventOriginator.USER;
-    }
-
-}
diff --git a/server/src/com/vaadin/ui/components/grid/SortOrderChangeListener.java b/server/src/com/vaadin/ui/components/grid/SortOrderChangeListener.java
deleted file mode 100644 (file)
index 82d7ba3..0000000
+++ /dev/null
@@ -1,34 +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;
-
-import java.io.Serializable;
-
-/**
- * Listener for sort order change events from {@link Grid}.
- * 
- * @since
- * @author Vaadin Ltd
- */
-public interface SortOrderChangeListener extends Serializable {
-    /**
-     * Called when the sort order has changed.
-     * 
-     * @param event
-     *            the sort order change event
-     */
-    public void sortOrderChange(SortOrderChangeEvent event);
-}
diff --git a/server/src/com/vaadin/ui/components/grid/sort/Sort.java b/server/src/com/vaadin/ui/components/grid/sort/Sort.java
deleted file mode 100644 (file)
index 5483137..0000000
+++ /dev/null
@@ -1,153 +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.sort;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.vaadin.shared.ui.grid.SortDirection;
-
-/**
- * Fluid Sort API. Provides a convenient, human-readable way of specifying
- * multi-column sort order.
- * 
- * @since 7.4
- * @author Vaadin Ltd
- */
-public class Sort implements Serializable {
-
-    private final Sort previous;
-    private final SortOrder order;
-
-    /**
-     * Initial constructor, called by the static by() methods.
-     * 
-     * @param propertyId
-     *            a property ID, corresponding to a property in the data source
-     * @param direction
-     *            a sort direction value
-     */
-    private Sort(Object propertyId, SortDirection direction) {
-        previous = null;
-        order = new SortOrder(propertyId, direction);
-    }
-
-    /**
-     * Chaining constructor, called by the non-static then() methods. This
-     * constructor links to the previous Sort object.
-     * 
-     * @param previous
-     *            the sort marker that comes before this one
-     * @param propertyId
-     *            a property ID, corresponding to a property in the data source
-     * @param direction
-     *            a sort direction value
-     */
-    private Sort(Sort previous, Object propertyId, SortDirection direction) {
-        this.previous = previous;
-        order = new SortOrder(propertyId, direction);
-
-        Sort s = previous;
-        while (s != null) {
-            if (s.order.getPropertyId() == propertyId) {
-                throw new IllegalStateException(
-                        "Can not sort along the same property (" + propertyId
-                                + ") twice!");
-            }
-            s = s.previous;
-        }
-
-    }
-
-    /**
-     * Start building a Sort order by sorting a provided column in ascending
-     * order.
-     * 
-     * @param propertyId
-     *            a property id, corresponding to a data source property
-     * @return a sort object
-     */
-    public static Sort by(Object propertyId) {
-        return by(propertyId, SortDirection.ASCENDING);
-    }
-
-    /**
-     * Start building a Sort order by sorting a provided column.
-     * 
-     * @param propertyId
-     *            a property id, corresponding to a data source property
-     * @param direction
-     *            a sort direction value
-     * @return a sort object
-     */
-    public static Sort by(Object propertyId, SortDirection direction) {
-        return new Sort(propertyId, direction);
-    }
-
-    /**
-     * Continue building a Sort order. The provided property is sorted in
-     * ascending order if the previously added properties have been evaluated as
-     * equals.
-     * 
-     * @param propertyId
-     *            a property id, corresponding to a data source property
-     * @return a sort object
-     */
-    public Sort then(Object propertyId) {
-        return then(propertyId, SortDirection.ASCENDING);
-    }
-
-    /**
-     * Continue building a Sort order. The provided property is sorted in
-     * specified order if the previously added properties have been evaluated as
-     * equals.
-     * 
-     * @param propertyId
-     *            a property id, corresponding to a data source property
-     * @param direction
-     *            a sort direction value
-     * @return a sort object
-     */
-    public Sort then(Object propertyId, SortDirection direction) {
-        return new Sort(this, propertyId, direction);
-    }
-
-    /**
-     * Build a sort order list, ready to be passed to Grid
-     * 
-     * @return a sort order list.
-     */
-    public List<SortOrder> build() {
-
-        int count = 1;
-        Sort s = this;
-        while (s.previous != null) {
-            s = s.previous;
-            ++count;
-        }
-
-        List<SortOrder> order = new ArrayList<SortOrder>(count);
-
-        s = this;
-        do {
-            order.add(0, s.order);
-            s = s.previous;
-        } while (s != null);
-
-        return order;
-    }
-}
diff --git a/server/src/com/vaadin/ui/components/grid/sort/SortOrder.java b/server/src/com/vaadin/ui/components/grid/sort/SortOrder.java
deleted file mode 100644 (file)
index a76148f..0000000
+++ /dev/null
@@ -1,106 +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.sort;
-
-import java.io.Serializable;
-
-import com.vaadin.shared.ui.grid.SortDirection;
-
-/**
- * Sort order descriptor. Links together a {@link SortDirection} value and a
- * Vaadin container property ID.
- * 
- * @since 7.4
- * @author Vaadin Ltd
- */
-public class SortOrder implements Serializable {
-
-    private final Object propertyId;
-    private final SortDirection direction;
-
-    /**
-     * Create a SortOrder object. Both arguments must be non-null.
-     * 
-     * @param propertyId
-     *            id of the data source property to sort by
-     * @param direction
-     *            value indicating whether the property id should be sorted in
-     *            ascending or descending order
-     */
-    public SortOrder(Object propertyId, SortDirection direction) {
-        if (propertyId == null) {
-            throw new IllegalArgumentException("Property ID can not be null!");
-        }
-        if (direction == null) {
-            throw new IllegalArgumentException(
-                    "Direction value can not be null!");
-        }
-        this.propertyId = propertyId;
-        this.direction = direction;
-    }
-
-    /**
-     * Returns the property ID.
-     * 
-     * @return a property ID
-     */
-    public Object getPropertyId() {
-        return propertyId;
-    }
-
-    /**
-     * Returns the {@link SortDirection} value.
-     * 
-     * @return a sort direction value
-     */
-    public SortDirection getDirection() {
-        return direction;
-    }
-
-    @Override
-    public String toString() {
-        return propertyId + " " + direction;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + direction.hashCode();
-        result = prime * result + propertyId.hashCode();
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        } else if (obj == null) {
-            return false;
-        } else if (getClass() != obj.getClass()) {
-            return false;
-        }
-
-        SortOrder other = (SortOrder) obj;
-        if (direction != other.direction) {
-            return false;
-        } else if (!propertyId.equals(other.propertyId)) {
-            return false;
-        }
-        return true;
-    }
-
-}
index 589976af2f79122c176f79f54b5128d9dab01426..bfa77eab526668bb8898686a1de96fb74aebd70c 100644 (file)
@@ -30,9 +30,9 @@ import com.vaadin.data.Container.ItemSetChangeListener;
 import com.vaadin.data.Container.PropertySetChangeEvent;
 import com.vaadin.data.Container.PropertySetChangeListener;
 import com.vaadin.data.Item;
+import com.vaadin.data.sort.SortOrder;
 import com.vaadin.data.util.filter.Compare;
 import com.vaadin.data.util.filter.UnsupportedFilterException;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 
 public class GeneratedPropertyContainerTest {
 
index 5c74728437f7e85f3f0713cad95920e7f548b3da..b339cb9aff5d30a382b54661adc1e3242e26997b 100644 (file)
@@ -23,13 +23,13 @@ import org.junit.Assert;
 import org.junit.Before;
 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.shared.ui.grid.SortDirection;
 import com.vaadin.ui.Grid;
-import com.vaadin.ui.components.grid.SortOrderChangeEvent;
-import com.vaadin.ui.components.grid.SortOrderChangeListener;
-import com.vaadin.ui.components.grid.sort.Sort;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 
 public class SortTest {
 
index f3b7d1366f9cad1b936b9b13629488de3edcd398..294c23ffe5974752e5c4e0f8fec8993474015644 100644 (file)
@@ -19,6 +19,8 @@ import com.vaadin.data.Container.Filter;
 import com.vaadin.data.Container.Filterable;
 import com.vaadin.data.Container.Indexed;
 import com.vaadin.data.Item;
+import com.vaadin.data.sort.Sort;
+import com.vaadin.data.sort.SortOrder;
 import com.vaadin.data.util.GeneratedPropertyContainer;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.data.util.PropertyValueGenerator;
@@ -30,8 +32,6 @@ import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Button.ClickListener;
 import com.vaadin.ui.Grid;
-import com.vaadin.ui.components.grid.sort.Sort;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 
 public class GridGeneratedProperties extends AbstractTestUI {
 
index 23af14d86b69758093abd5038045b95358321251..043ff2e2e0a94627645f7fb129f0040e444fc8cb 100644 (file)
@@ -29,7 +29,11 @@ import com.vaadin.data.Container.Filter;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
 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.shared.ui.grid.GridStaticCellType;
 import com.vaadin.shared.ui.grid.HeightMode;
 import com.vaadin.shared.ui.grid.SortDirection;
@@ -45,10 +49,6 @@ import com.vaadin.ui.Grid.HeaderCell;
 import com.vaadin.ui.Grid.HeaderRow;
 import com.vaadin.ui.Grid.MultiSelectionModel;
 import com.vaadin.ui.Grid.SelectionMode;
-import com.vaadin.ui.components.grid.SortOrderChangeEvent;
-import com.vaadin.ui.components.grid.SortOrderChangeListener;
-import com.vaadin.ui.components.grid.sort.Sort;
-import com.vaadin.ui.components.grid.sort.SortOrder;
 import com.vaadin.ui.renderer.DateRenderer;
 import com.vaadin.ui.renderer.HtmlRenderer;
 import com.vaadin.ui.renderer.NumberRenderer;