diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-06-29 10:18:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-29 10:18:33 +0300 |
commit | b2c0ac2bac558a4bc497fa3a6d29b8f030511e1a (patch) | |
tree | 54661aff762131fe847da8e20f5e70f2c5f2bfe0 /server/src/main/java/com/vaadin/event | |
parent | b0d109fe1d1ad856bc04d2a358065fb2935e75ad (diff) | |
download | vaadin-framework-b2c0ac2bac558a4bc497fa3a6d29b8f030511e1a.tar.gz vaadin-framework-b2c0ac2bac558a4bc497fa3a6d29b8f030511e1a.zip |
Use HasUserOriginated interface where appropriate (#9608)
Diffstat (limited to 'server/src/main/java/com/vaadin/event')
5 files changed, 46 insertions, 32 deletions
diff --git a/server/src/main/java/com/vaadin/event/CollapseEvent.java b/server/src/main/java/com/vaadin/event/CollapseEvent.java index 45224496e7..649fff85aa 100644 --- a/server/src/main/java/com/vaadin/event/CollapseEvent.java +++ b/server/src/main/java/com/vaadin/event/CollapseEvent.java @@ -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; } diff --git a/server/src/main/java/com/vaadin/event/ExpandEvent.java b/server/src/main/java/com/vaadin/event/ExpandEvent.java index ea8193dfe0..61642e683f 100644 --- a/server/src/main/java/com/vaadin/event/ExpandEvent.java +++ b/server/src/main/java/com/vaadin/event/ExpandEvent.java @@ -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 index 0000000000..cd9d54bc26 --- /dev/null +++ b/server/src/main/java/com/vaadin/event/HasUserOriginated.java @@ -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(); + +} diff --git a/server/src/main/java/com/vaadin/event/SortEvent.java b/server/src/main/java/com/vaadin/event/SortEvent.java index cca7bbd3b6..1b6637b92d 100644 --- a/server/src/main/java/com/vaadin/event/SortEvent.java +++ b/server/src/main/java/com/vaadin/event/SortEvent.java @@ -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; } diff --git a/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java b/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java index 5252413830..46f52eb734 100644 --- a/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java +++ b/server/src/main/java/com/vaadin/event/selection/SelectionEvent.java @@ -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(); } |