Browse Source

Use HasUserOriginated interface where appropriate (#9608)

tags/8.1.0.rc1
Henri Sara 7 years ago
parent
commit
b2c0ac2bac

+ 1
- 0
server/src/main/java/com/vaadin/data/HasValue.java View File

import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;


import com.vaadin.event.HasUserOriginated;
import com.vaadin.event.SerializableEventListener; import com.vaadin.event.SerializableEventListener;
import com.vaadin.server.Setter; import com.vaadin.server.Setter;
import com.vaadin.shared.Registration; import com.vaadin.shared.Registration;

+ 2
- 8
server/src/main/java/com/vaadin/event/CollapseEvent.java View File

* @param <T> * @param <T>
* collapsed item type * collapsed item type
*/ */
public class CollapseEvent<T> extends Component.Event {
public class CollapseEvent<T> extends Component.Event implements HasUserOriginated {


private final T collapsedItem; private final T collapsedItem;


return collapsedItem; 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() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }

+ 3
- 8
server/src/main/java/com/vaadin/event/ExpandEvent.java View File

* @param <T> * @param <T>
* the expanded item's type * 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; private final T expandedItem;


return expandedItem; 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() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }

server/src/main/java/com/vaadin/data/HasUserOriginated.java → server/src/main/java/com/vaadin/event/HasUserOriginated.java View File

* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.vaadin.data;
package com.vaadin.event;


import java.io.Serializable; import java.io.Serializable;


/** /**
* Marker for events which provides information of the event origin. * Marker for events which provides information of the event origin.
* *
* @since
* @since 8.1
*/ */
public interface HasUserOriginated extends Serializable { public interface HasUserOriginated extends Serializable {
/** /**

+ 3
- 6
server/src/main/java/com/vaadin/event/SortEvent.java View File

* @since 8.0 * @since 8.0
* @author Vaadin Ltd * @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 List<T> sortOrder;
private final boolean userOriginated; private final boolean userOriginated;
return sortOrder; 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() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }

+ 3
- 10
server/src/main/java/com/vaadin/event/selection/SelectionEvent.java View File

import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;


import com.vaadin.event.HasUserOriginated;

/** /**
* A selection event that unifies the way to access to selection event for multi * 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 * selection and single selection components (in case when only one selected
* @param <T> * @param <T>
* the data type of the selection model * 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. * Get first selected data item.
* @return return all the selected items, if any, never {@code null} * @return return all the selected items, if any, never {@code null}
*/ */
Set<T> getAllSelectedItems(); 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();
} }

+ 11
- 21
server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java View File

import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;


import com.vaadin.event.ConnectorEventListener; import com.vaadin.event.ConnectorEventListener;
import com.vaadin.event.HasUserOriginated;
import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.server.SizeWithUnit; import com.vaadin.server.SizeWithUnit;
import com.vaadin.server.Sizeable; import com.vaadin.server.Sizeable;


getSplitterState().position = position; getSplitterState().position = position;


fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this, true,
oldPosition, getSplitPositionUnit(), position, getSplitPositionUnit()));
fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this,
true, oldPosition, getSplitPositionUnit(), position,
getSplitPositionUnit()));
} }
}; };


* *
* @since 7.5.0 * @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 float oldPosition;
private final Unit oldUnit; private final Unit oldUnit;
private final boolean userOriginated; private final boolean userOriginated;


public SplitPositionChangeEvent(final Component source, 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); super(source);
this.userOriginated = userOriginated; this.userOriginated = userOriginated;
this.oldUnit = oldUnit; this.oldUnit = oldUnit;
/** /**
* Returns the new split position that triggered this change event. * Returns the new split position that triggered this change event.
* *
* @since 7.5.0
*
* @return the new value of split position * @return the new value of split position
*/ */
public float getSplitPosition() { public float getSplitPosition() {
/** /**
* Returns the new split position unit that triggered this change event. * Returns the new split position unit that triggered this change event.
* *
* @since 7.5.0
*
* @return the new value of split position * @return the new value of split position
*/ */
public Unit getSplitPositionUnit() { public Unit getSplitPositionUnit() {
* *
* @since 8.1 * @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() { public Unit getOldSplitPositionUnit() {
return oldUnit; 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() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }

+ 19
- 19
server/src/main/java/com/vaadin/ui/Grid.java View File

import com.vaadin.data.provider.QuerySortOrder; import com.vaadin.data.provider.QuerySortOrder;
import com.vaadin.event.ConnectorEvent; import com.vaadin.event.ConnectorEvent;
import com.vaadin.event.ContextClickEvent; import com.vaadin.event.ContextClickEvent;
import com.vaadin.event.HasUserOriginated;
import com.vaadin.event.SortEvent; import com.vaadin.event.SortEvent;
import com.vaadin.event.SortEvent.SortListener; import com.vaadin.event.SortEvent.SortListener;
import com.vaadin.event.SortEvent.SortNotifier; import com.vaadin.event.SortEvent.SortNotifier;
/** /**
* An event that is fired when the columns are reordered. * 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; private final boolean userOriginated;


* *
* @return <code>true</code> if event is a result of user interaction * @return <code>true</code> if event is a result of user interaction
*/ */
@Override
public boolean isUserOriginated() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }
* An event that is fired when a column is resized, either programmatically * An event that is fired when a column is resized, either programmatically
* or by the user. * 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 Column<?, ?> column;
private final boolean userOriginated; private final boolean userOriginated;
* *
* @return <code>true</code> if event is a result of user interaction * @return <code>true</code> if event is a result of user interaction
*/ */
@Override
public boolean isUserOriginated() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }
* *
* @since 7.5.0 * @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 Column<?, ?> column;
private final boolean userOriginated; private final boolean userOriginated;
return hidden; 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() { public boolean isUserOriginated() {
return userOriginated; return userOriginated;
} }
* <code>null</code> * <code>null</code>
* @param presentationProvider * @param presentationProvider
* the function to get presentations from the value of this * 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 * @param renderer
* the presentation renderer, not <code>null</code> * the presentation renderer, not <code>null</code>
* @param <P> * @param <P>
* the presentation type * the presentation type
*
*
* @since 8.1 * @since 8.1
*/ */
protected <P> Column(ValueProvider<T, V> valueProvider, protected <P> Column(ValueProvider<T, V> valueProvider,
* column, not {@code null} * column, not {@code null}
* @param renderer * @param renderer
* the new renderer, not {@code null} * the new renderer, not {@code null}
*
*
* @param <P> * @param <P>
* the presentation type * the presentation type
*
*
* @return this column * @return this column
* *
* @since 8.1 * @since 8.1
* the value presentation provider * the value presentation provider
* @param <V> * @param <V>
* the column value type * the column value type
*
*
* @see #addColumn(ValueProvider, ValueProvider, AbstractRenderer) * @see #addColumn(ValueProvider, ValueProvider, AbstractRenderer)
* *
* @return the new column * @return the new column
/** /**
* Adds a new column to this {@link Grid} with value provider, presentation * Adds a new column to this {@link Grid} with value provider, presentation
* provider and typed renderer. * provider and typed renderer.
*
*
* <p> * <p>
* The presentation provider is a method that takes the value from the value * 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 * provider, and maps that to a value that the renderer accepts. This
* account. * account.
* *
* @param row * @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 * @throws IllegalArgumentException
* if the provided id is not recognized by the data source. * if the provided id is not recognized by the data source.
*/ */
* account. * account.
* *
* @param row * @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 * @param destination
* value specifying desired position of scrolled-to row, not * value specifying desired position of scrolled-to row, not
* {@code null} * {@code null}

+ 1
- 1
server/src/main/java/com/vaadin/ui/TabSheet.java View File

import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;


import com.vaadin.data.HasUserOriginated;
import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.BlurNotifier; import com.vaadin.event.FieldEvents.BlurNotifier;
import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.event.HasUserOriginated;
import com.vaadin.server.ErrorMessage; import com.vaadin.server.ErrorMessage;
import com.vaadin.server.KeyMapper; import com.vaadin.server.KeyMapper;
import com.vaadin.server.Resource; import com.vaadin.server.Resource;

Loading…
Cancel
Save