* Constructor for {@code ValueContext}. | * Constructor for {@code ValueContext}. | ||||
* | * | ||||
* @param component | * @param component | ||||
* The component related to current value. Can be null. | |||||
* If the component implements {@link HasValue}, it will be returned by {@link #getHasValue()} as well. | |||||
* The component related to current value. Can be null. If the | |||||
* component implements {@link HasValue}, it will be returned by | |||||
* {@link #getHasValue()} as well. | |||||
*/ | */ | ||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public ValueContext(Component component) { | public ValueContext(Component component) { | ||||
Objects.requireNonNull(component, | Objects.requireNonNull(component, | ||||
"Component can't be null in ValueContext construction"); | "Component can't be null in ValueContext construction"); | ||||
this.component = component; | this.component = component; | ||||
if(component instanceof HasValue) { | |||||
if (component instanceof HasValue) { | |||||
hasValue = (HasValue<?>) component; | hasValue = (HasValue<?>) component; | ||||
} else { | } else { | ||||
hasValue = null; | hasValue = null; | ||||
* The component related to current value. Can be null. | * The component related to current value. Can be null. | ||||
* @param hasValue | * @param hasValue | ||||
* The value source related to current value. Can be null. | * The value source related to current value. Can be null. | ||||
* @since 8.1 | |||||
*/ | */ | ||||
public ValueContext(Component component, HasValue<?> hasValue) { | public ValueContext(Component component, HasValue<?> hasValue) { | ||||
Objects.requireNonNull(component, | Objects.requireNonNull(component, | ||||
/** | /** | ||||
* Constructor for {@code ValueContext}. | * Constructor for {@code ValueContext}. | ||||
* | * | ||||
* @param | |||||
* component | |||||
* @param component | |||||
* The component can be {@code null}. | * The component can be {@code null}. | ||||
* @param locale | * @param locale | ||||
* The locale used with conversion. Can be {@code null}. | * The locale used with conversion. Can be {@code null}. | ||||
* @param hasValue | * @param hasValue | ||||
* The value source related to current value. Can be {@code null}. | |||||
* The value source related to current value. Can be | |||||
* {@code null}. | |||||
* @since 8.1 | |||||
*/ | */ | ||||
public ValueContext(Component component, HasValue<?> hasValue, Locale locale) { | |||||
public ValueContext(Component component, HasValue<?> hasValue, | |||||
Locale locale) { | |||||
this.component = component; | this.component = component; | ||||
this.hasValue = hasValue; | this.hasValue = hasValue; | ||||
this.locale = locale; | this.locale = locale; | ||||
/** | /** | ||||
* Returns an {@code Optional} for the {@code HasValue} used in the value | * Returns an {@code Optional} for the {@code HasValue} used in the value | ||||
* conversion. In certain complicated cases, ex. cross-field validation, HasValue might be not available. | |||||
* conversion. In certain complicated cases, ex. cross-field validation, | |||||
* HasValue might be not available. | |||||
* | * | ||||
* @return the optional of {@code HasValue} | * @return the optional of {@code HasValue} | ||||
* @since 8.1 | |||||
*/ | */ | ||||
@SuppressWarnings("unused") | @SuppressWarnings("unused") | ||||
public Optional<HasValue<?>> getHasValue() { | public Optional<HasValue<?>> getHasValue() { |
private final boolean userOriginated; | private final boolean userOriginated; | ||||
/** | |||||
* Creates a split position change event. | |||||
* | |||||
* @param source | |||||
* split panel from which the event originates | |||||
* @param userOriginated | |||||
* true if the event is directly based on user actions | |||||
* @param oldPosition | |||||
* old split position | |||||
* @param oldUnit | |||||
* old unit of split position | |||||
* @param position | |||||
* new split position | |||||
* @param unit | |||||
* new split position unit | |||||
* @since 8.1 | |||||
*/ | |||||
public SplitPositionChangeEvent(final Component source, | public SplitPositionChangeEvent(final Component source, | ||||
final boolean userOriginated, final float oldPosition, | final boolean userOriginated, final float oldPosition, | ||||
final Unit oldUnit, final float position, final Unit unit) { | final Unit oldUnit, final float position, final Unit unit) { | ||||
return oldUnit; | return oldUnit; | ||||
} | } | ||||
/** | |||||
* {@inheritDoc} | |||||
* | |||||
* @since 8.1 | |||||
*/ | |||||
@Override | @Override | ||||
public boolean isUserOriginated() { | public boolean isUserOriginated() { | ||||
return userOriginated; | return userOriginated; |
*/ | */ | ||||
public void addStyleName(String style); | public void addStyleName(String style); | ||||
/** | /** | ||||
* Adds one or more style names to this component by using one or multiple parameters. | |||||
* Adds one or more style names to this component by using one or multiple | |||||
* parameters. | |||||
* | |||||
* @param styles | * @param styles | ||||
* the style name or style names to be added to the component | * the style name or style names to be added to the component | ||||
* @see #addStyleName(String) | * @see #addStyleName(String) | ||||
* @see #setStyleName(String) | * @see #setStyleName(String) | ||||
* @see #removeStyleName(String) | * @see #removeStyleName(String) | ||||
* @since 8.1 | |||||
*/ | */ | ||||
public default void addStyleNames(String ... styles) { | |||||
public default void addStyleNames(String... styles) { | |||||
for (String style : styles) { | for (String style : styles) { | ||||
addStyleName(style); | addStyleName(style); | ||||
} | } | ||||
/** | /** | ||||
* Removes one or more style names from component. Multiple styles can be | * Removes one or more style names from component. Multiple styles can be | ||||
* specified by using multiple parameters. | * specified by using multiple parameters. | ||||
* | |||||
* @param styles | * @param styles | ||||
* the style name or style names to be removed | * the style name or style names to be removed | ||||
* @see #removeStyleName(String) | * @see #removeStyleName(String) | ||||
* @see #setStyleName(String) | * @see #setStyleName(String) | ||||
* @see #addStyleName(String) | * @see #addStyleName(String) | ||||
* @since 8.1 | |||||
*/ | */ | ||||
public default void removeStyleNames(String ... styles) { | |||||
public default void removeStyleNames(String... styles) { | |||||
for (String style : styles) { | for (String style : styles) { | ||||
removeStyleName(style); | removeStyleName(style); | ||||
} | } |
* @param userOriginated | * @param userOriginated | ||||
* <code>true</code> if the event originates from the client | * <code>true</code> if the event originates from the client | ||||
* side, <code>false</code> otherwise | * side, <code>false</code> otherwise | ||||
* @since 8.1 | |||||
*/ | */ | ||||
public void setSelectedTab(Component component, boolean userOriginated) { | public void setSelectedTab(Component component, boolean userOriginated) { | ||||
if (component != null && components.contains(component) | if (component != null && components.contains(component) | ||||
* @param userOriginated | * @param userOriginated | ||||
* <code>true</code> if the event originates from the client | * <code>true</code> if the event originates from the client | ||||
* side, <code>false</code> otherwise | * side, <code>false</code> otherwise | ||||
* @since 8.1 | |||||
*/ | */ | ||||
public SelectedTabChangeEvent(Component source, | public SelectedTabChangeEvent(Component source, | ||||
boolean userOriginated) { | boolean userOriginated) { | ||||
return (TabSheet) getSource(); | return (TabSheet) getSource(); | ||||
} | } | ||||
/** | |||||
* {@inheritDoc} | |||||
* | |||||
* @since 8.1 | |||||
*/ | |||||
@Override | @Override | ||||
public boolean isUserOriginated() { | public boolean isUserOriginated() { | ||||
return userOriginated; | return userOriginated; | ||||
* @param userOriginated | * @param userOriginated | ||||
* <code>true</code> if the event originates from the client | * <code>true</code> if the event originates from the client | ||||
* side, <code>false</code> otherwise | * side, <code>false</code> otherwise | ||||
* @since | |||||
* @since 8.1 | |||||
*/ | */ | ||||
protected void fireSelectedTabChange(boolean userOriginated) { | protected void fireSelectedTabChange(boolean userOriginated) { | ||||
fireEvent(new SelectedTabChangeEvent(this, userOriginated)); | fireEvent(new SelectedTabChangeEvent(this, userOriginated)); |