]> source.dussan.org Git - vaadin-framework.git/commitdiff
Use HasUserOriginated interface where appropriate (#9608)
authorHenri Sara <henri.sara@gmail.com>
Thu, 29 Jun 2017 07:18:33 +0000 (10:18 +0300)
committerGitHub <noreply@github.com>
Thu, 29 Jun 2017 07:18:33 +0000 (10:18 +0300)
server/src/main/java/com/vaadin/data/HasUserOriginated.java [deleted file]
server/src/main/java/com/vaadin/data/HasValue.java
server/src/main/java/com/vaadin/event/CollapseEvent.java
server/src/main/java/com/vaadin/event/ExpandEvent.java
server/src/main/java/com/vaadin/event/HasUserOriginated.java [new file with mode: 0644]
server/src/main/java/com/vaadin/event/SortEvent.java
server/src/main/java/com/vaadin/event/selection/SelectionEvent.java
server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
server/src/main/java/com/vaadin/ui/Grid.java
server/src/main/java/com/vaadin/ui/TabSheet.java

diff --git a/server/src/main/java/com/vaadin/data/HasUserOriginated.java b/server/src/main/java/com/vaadin/data/HasUserOriginated.java
deleted file mode 100644 (file)
index e7d6d12..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2000-2016 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;
-
-import java.io.Serializable;
-
-/**
- * Marker for events which provides information of the event origin.
- *
- * @since
- */
-public interface HasUserOriginated extends Serializable {
-    /**
-     * Returns whether this event was triggered by user interaction, on the
-     * client side, or programmatically, on the server side.
-     *
-     * @return {@code true} if this event originates from the client,
-     *         {@code false} otherwise.
-     */
-    public boolean isUserOriginated();
-
-}
index b2ce098f6f686a4bd834cdef7882e04cb38064e6..935f365e10b6409a4e82cbc953aead7437d1581c 100644 (file)
@@ -21,6 +21,7 @@ import java.util.EventObject;
 import java.util.Objects;
 import java.util.Optional;
 
+import com.vaadin.event.HasUserOriginated;
 import com.vaadin.event.SerializableEventListener;
 import com.vaadin.server.Setter;
 import com.vaadin.shared.Registration;
index 45224496e731f2c36b27ffaf3794ac3b1c4611ce..649fff85aa2c20efa719d5a52a5d2949e3e89fdb 100644 (file)
@@ -30,7 +30,7 @@ import com.vaadin.util.ReflectTools;
  * @param <T>
  *            collapsed item type
  */
-public class CollapseEvent<T> extends Component.Event {
+public class CollapseEvent<T> extends Component.Event implements HasUserOriginated {
 
     private final T collapsedItem;
 
@@ -63,13 +63,7 @@ public class CollapseEvent<T> extends Component.Event {
         return collapsedItem;
     }
 
-    /**
-     * Returns whether this event was triggered by user interaction, on the
-     * client side, or programmatically, on the server side.
-     *
-     * @return {@code true} if this event originates from the client,
-     *         {@code false} otherwise.
-     */
+    @Override
     public boolean isUserOriginated() {
         return userOriginated;
     }
index ea8193dfe0fcf23c46923d346395ceb77ba8fd6f..61642e683fa7c30dec42822f7ac6c30e9b84c0b9 100644 (file)
@@ -29,7 +29,8 @@ import com.vaadin.util.ReflectTools;
  * @param <T>
  *            the expanded item's type
  */
-public class ExpandEvent<T> extends Component.Event {
+public class ExpandEvent<T> extends Component.Event
+        implements HasUserOriginated {
 
     private final T expandedItem;
 
@@ -62,13 +63,7 @@ public class ExpandEvent<T> extends Component.Event {
         return expandedItem;
     }
 
-    /**
-     * Returns whether this event was triggered by user interaction, on the
-     * client side, or programmatically, on the server side.
-     *
-     * @return {@code true} if this event originates from the client,
-     *         {@code false} otherwise.
-     */
+    @Override
     public boolean isUserOriginated() {
         return userOriginated;
     }
diff --git a/server/src/main/java/com/vaadin/event/HasUserOriginated.java b/server/src/main/java/com/vaadin/event/HasUserOriginated.java
new file mode 100644 (file)
index 0000000..cd9d54b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2016 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;
+
+/**
+ * Marker for events which provides information of the event origin.
+ *
+ * @since 8.1
+ */
+public interface HasUserOriginated extends Serializable {
+    /**
+     * Returns whether this event was triggered by user interaction, on the
+     * client side, or programmatically, on the server side.
+     *
+     * @return {@code true} if this event originates from the client,
+     *         {@code false} otherwise.
+     */
+    public boolean isUserOriginated();
+
+}
index cca7bbd3b65e2a75c04b5b56fe11049750a383d6..1b6637b92deb81d31d1a8fb080fd5914a04340a0 100644 (file)
@@ -35,7 +35,8 @@ import com.vaadin.ui.Component;
  * @since 8.0
  * @author Vaadin Ltd
  */
-public class SortEvent<T extends SortOrder<?>> extends Component.Event {
+public class SortEvent<T extends SortOrder<?>> extends Component.Event
+        implements HasUserOriginated {
 
     private final List<T> sortOrder;
     private final boolean userOriginated;
@@ -67,11 +68,7 @@ public class SortEvent<T extends SortOrder<?>> extends Component.Event {
         return sortOrder;
     }
 
-    /**
-     * Returns whether this event originated from actions done by the user.
-     *
-     * @return true if sort event originated from user interaction
-     */
+    @Override
     public boolean isUserOriginated() {
         return userOriginated;
     }
index 525241383000d079ea7c9f0a39e736e473aeac73..46f52eb734fbf2caff20b80275888002650c64d3 100644 (file)
@@ -19,6 +19,8 @@ import java.io.Serializable;
 import java.util.Optional;
 import java.util.Set;
 
+import com.vaadin.event.HasUserOriginated;
+
 /**
  * A selection event that unifies the way to access to selection event for multi
  * selection and single selection components (in case when only one selected
@@ -29,7 +31,7 @@ import java.util.Set;
  * @param <T>
  *            the data type of the selection model
  */
-public interface SelectionEvent<T> extends Serializable {
+public interface SelectionEvent<T> extends HasUserOriginated, Serializable {
 
     /**
      * Get first selected data item.
@@ -51,13 +53,4 @@ public interface SelectionEvent<T> extends Serializable {
      * @return return all the selected items, if any, never {@code null}
      */
     Set<T> getAllSelectedItems();
-
-    /**
-     * Returns whether this selection event was triggered by user interaction,
-     * on the client side, or programmatically, on the server side.
-     *
-     * @return {@code true} if this event originates from the client,
-     *         {@code false} otherwise.
-     */
-    boolean isUserOriginated();
 }
index 898a25674fd78f7c6c26ecd817ccb0bab7579dc7..fea45200b0cd1251a635d0cf35c7980d8a74286b 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Iterator;
 import org.jsoup.nodes.Element;
 
 import com.vaadin.event.ConnectorEventListener;
+import com.vaadin.event.HasUserOriginated;
 import com.vaadin.event.MouseEvents.ClickEvent;
 import com.vaadin.server.SizeWithUnit;
 import com.vaadin.server.Sizeable;
@@ -68,8 +69,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
 
             getSplitterState().position = position;
 
-            fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this, true,
-                    oldPosition, getSplitPositionUnit(), position, getSplitPositionUnit()));
+            fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this,
+                    true, oldPosition, getSplitPositionUnit(), position,
+                    getSplitPositionUnit()));
         }
     };
 
@@ -563,7 +565,8 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
      *
      * @since 7.5.0
      */
-    public static class SplitPositionChangeEvent extends Component.Event {
+    public static class SplitPositionChangeEvent extends Component.Event
+            implements HasUserOriginated {
 
         private final float oldPosition;
         private final Unit oldUnit;
@@ -574,9 +577,8 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
         private final boolean userOriginated;
 
         public SplitPositionChangeEvent(final Component source,
-                                        final boolean userOriginated,
-                                        final float oldPosition, final Unit oldUnit,
-                                        final float position, final Unit unit) {
+                final boolean userOriginated, final float oldPosition,
+                final Unit oldUnit, final float position, final Unit unit) {
             super(source);
             this.userOriginated = userOriginated;
             this.oldUnit = oldUnit;
@@ -588,8 +590,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
         /**
          * Returns the new split position that triggered this change event.
          *
-         * @since 7.5.0
-         *
          * @return the new value of split position
          */
         public float getSplitPosition() {
@@ -599,8 +599,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
         /**
          * Returns the new split position unit that triggered this change event.
          *
-         * @since 7.5.0
-         *
          * @return the new value of split position
          */
         public Unit getSplitPositionUnit() {
@@ -624,22 +622,14 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
          *
          * @since 8.1
          *
-         * @return the split position unit previously set to the source of
-         *         this event
+         * @return the split position unit previously set to the source of this
+         *         event
          */
         public Unit getOldSplitPositionUnit() {
             return oldUnit;
         }
 
-        /**
-         * Returns whether this event was triggered by user interaction, on the
-         * client side, or programmatically, on the server side.
-         *
-         * @since 8.1
-         *
-         * @return {@code true} if this event originates from the client,
-         *         {@code false} otherwise.
-         */
+        @Override
         public boolean isUserOriginated() {
             return userOriginated;
         }
index 6e11989757f1296a6a38c400ce6e94f771751f4a..b67b77b90e4462dec2a39befd1a50143f7bf3246 100644 (file)
@@ -60,6 +60,7 @@ import com.vaadin.data.provider.Query;
 import com.vaadin.data.provider.QuerySortOrder;
 import com.vaadin.event.ConnectorEvent;
 import com.vaadin.event.ContextClickEvent;
+import com.vaadin.event.HasUserOriginated;
 import com.vaadin.event.SortEvent;
 import com.vaadin.event.SortEvent.SortListener;
 import com.vaadin.event.SortEvent.SortNotifier;
@@ -257,7 +258,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
     /**
      * An event that is fired when the columns are reordered.
      */
-    public static class ColumnReorderEvent extends Component.Event {
+    public static class ColumnReorderEvent extends Component.Event
+            implements HasUserOriginated {
 
         private final boolean userOriginated;
 
@@ -280,6 +282,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
          *
          * @return <code>true</code> if event is a result of user interaction
          */
+        @Override
         public boolean isUserOriginated() {
             return userOriginated;
         }
@@ -289,7 +292,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
      * An event that is fired when a column is resized, either programmatically
      * or by the user.
      */
-    public static class ColumnResizeEvent extends Component.Event {
+    public static class ColumnResizeEvent extends Component.Event
+            implements HasUserOriginated {
 
         private final Column<?, ?> column;
         private final boolean userOriginated;
@@ -324,6 +328,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
          *
          * @return <code>true</code> if event is a result of user interaction
          */
+        @Override
         public boolean isUserOriginated() {
             return userOriginated;
         }
@@ -482,7 +487,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
      *
      * @since 7.5.0
      */
-    public static class ColumnVisibilityChangeEvent extends Component.Event {
+    public static class ColumnVisibilityChangeEvent extends Component.Event
+            implements HasUserOriginated {
 
         private final Column<?, ?> column;
         private final boolean userOriginated;
@@ -530,12 +536,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
             return hidden;
         }
 
-        /**
-         * Returns <code>true</code> if the column reorder was done by the user,
-         * <code>false</code> if not and it was triggered by server side code.
-         *
-         * @return <code>true</code> if event is a result of user interaction
-         */
+        @Override
         public boolean isUserOriginated() {
             return userOriginated;
         }
@@ -915,12 +916,13 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
          *            <code>null</code>
          * @param presentationProvider
          *            the function to get presentations from the value of this
-         *            column, not <code>null</code>. For more details, see {@link #setRenderer(ValueProvider, Renderer)}
+         *            column, not <code>null</code>. For more details, see
+         *            {@link #setRenderer(ValueProvider, Renderer)}
          * @param renderer
          *            the presentation renderer, not <code>null</code>
          * @param <P>
          *            the presentation type
-         * 
+         *
          * @since 8.1
          */
         protected <P> Column(ValueProvider<T, V> valueProvider,
@@ -1939,10 +1941,10 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
          *            column, not {@code null}
          * @param renderer
          *            the new renderer, not {@code null}
-         * 
+         *
          * @param <P>
          *            the presentation type
-         * 
+         *
          * @return this column
          *
          * @since 8.1
@@ -2594,7 +2596,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
      *            the value presentation provider
      * @param <V>
      *            the column value type
-     * 
+     *
      * @see #addColumn(ValueProvider, ValueProvider, AbstractRenderer)
      *
      * @return the new column
@@ -2609,7 +2611,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
     /**
      * Adds a new column to this {@link Grid} with value provider, presentation
      * provider and typed renderer.
-     * 
+     *
      * <p>
      * The presentation provider is a method that takes the value from the value
      * provider, and maps that to a value that the renderer accepts. This
@@ -3819,8 +3821,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
      * account.
      *
      * @param row
-     *            zero based index of the item to scroll to in the current
-     *            view.
+     *            zero based index of the item to scroll to in the current view.
      * @throws IllegalArgumentException
      *             if the provided id is not recognized by the data source.
      */
@@ -3835,8 +3836,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
      * account.
      *
      * @param row
-     *            zero based index of the item to scroll to in the current
-     *            view.
+     *            zero based index of the item to scroll to in the current view.
      * @param destination
      *            value specifying desired position of scrolled-to row, not
      *            {@code null}
index 550c5fc8cac0d4f5ac98a81e1528d1051fe352f3..37502e8f484f5229b1554835b80413dbba50f099 100644 (file)
@@ -28,7 +28,6 @@ import java.util.Map;
 import org.jsoup.nodes.Attributes;
 import org.jsoup.nodes.Element;
 
-import com.vaadin.data.HasUserOriginated;
 import com.vaadin.event.FieldEvents.BlurEvent;
 import com.vaadin.event.FieldEvents.BlurListener;
 import com.vaadin.event.FieldEvents.BlurNotifier;
@@ -36,6 +35,7 @@ import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcDecorator;
 import com.vaadin.event.FieldEvents.FocusEvent;
 import com.vaadin.event.FieldEvents.FocusListener;
 import com.vaadin.event.FieldEvents.FocusNotifier;
+import com.vaadin.event.HasUserOriginated;
 import com.vaadin.server.ErrorMessage;
 import com.vaadin.server.KeyMapper;
 import com.vaadin.server.Resource;