Module is.codion.swing.common.ui
Class AbstractComponentValueBuilder<T,C extends JComponent,B extends ComponentValueBuilder<T,C,B>>
java.lang.Object
is.codion.swing.common.ui.component.builder.AbstractComponentBuilder<C,B>
is.codion.swing.common.ui.component.builder.AbstractComponentValueBuilder<T,C,B>
- All Implemented Interfaces:
ComponentBuilder<C,
,B> ComponentValueBuilder<T,
,C, B> Supplier<C>
- Direct Known Subclasses:
DefaultComboBoxBuilder
public abstract class AbstractComponentValueBuilder<T,C extends JComponent,B extends ComponentValueBuilder<T,C,B>>
extends AbstractComponentBuilder<C,B>
implements ComponentValueBuilder<T,C,B>
-
Field Summary
Fields inherited from interface is.codion.swing.common.ui.component.builder.ComponentValueBuilder
COMPONENT_VALUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ComponentValue
<T, C> Builds and returns the component value.final ComponentValue
<T, C> buildValue
(@Nullable Consumer<ComponentValue<T, C>> onBuild) Builds and returns the component value.protected final C
configureComponent
(C component) final B
protected abstract ComponentValue
<T, C> createComponentValue
(C component) Creates the component valuefinal B
link
(Observable<T> linkedObservable) Creates a read-only link to the givenObservable
.final B
Creates a bidirectional link to the given value.final B
final B
modifiedIndicator
(@Nullable ObservableState modified) Enables a modified indicator based on the given modified state.final B
modifiedIndicatorFactory
(@Nullable ModifiedIndicatorFactory modifiedIndicatorFactory) By defaultUnderlineModifiedIndicatorFactory
.final B
onBuildValue
(Consumer<ComponentValue<T, C>> onBuildValue) final B
validator
(Value.Validator<T> validator) final B
Enables a valid indicator based on the given valid state.final B
validIndicator
(@Nullable Predicate<T> validator) Enables a valid indicator based on the given validator.final B
validIndicatorFactory
(@Nullable ValidIndicatorFactory validIndicatorFactory) final B
Sets the initial value for the component, unless value(s) have been linked viaComponentValueBuilder.link(Value)
orComponentValueBuilder.link(Observable)
, which then control the inital value.Methods inherited from class is.codion.swing.common.ui.component.builder.AbstractComponentBuilder
background, border, build, build, clientProperty, componentListener, componentOrientation, createComponent, enabled, enabled, enableTransferFocusOnEnter, enableValidIndicator, focusable, focusable, focusCycleRoot, focusListener, font, foreground, keyEvent, keyListener, label, label, maximumHeight, maximumSize, maximumWidth, minimumHeight, minimumSize, minimumWidth, mouseListener, mouseMotionListener, mouseWheelListener, name, onBuild, onSetVisible, opaque, popupMenu, popupMenuControl, popupMenuControls, preferredHeight, preferredSize, preferredWidth, propertyChangeListener, propertyChangeListener, scrollPane, self, supportsNull, toolTipText, toolTipText, transferFocusOnEnter, transferFocusOnEnter, transferHandler, visible, visible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface is.codion.swing.common.ui.component.builder.ComponentBuilder
background, border, build, build, clientProperty, componentListener, componentOrientation, enabled, enabled, focusable, focusable, focusCycleRoot, focusListener, font, foreground, get, keyEvent, keyListener, label, label, maximumHeight, maximumSize, maximumWidth, minimumHeight, minimumSize, minimumWidth, mouseListener, mouseMotionListener, mouseWheelListener, name, onBuild, onSetVisible, opaque, popupMenu, popupMenuControl, popupMenuControls, preferredHeight, preferredSize, preferredWidth, propertyChangeListener, propertyChangeListener, scrollPane, toolTipText, toolTipText, transferFocusOnEnter, transferFocusOnEnter, transferHandler, visible, visible
-
Constructor Details
-
AbstractComponentValueBuilder
protected AbstractComponentValueBuilder()
-
-
Method Details
-
validIndicatorFactory
- Specified by:
validIndicatorFactory
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
validIndicatorFactory
- theValidIndicatorFactory
to use, null for none- Returns:
- this builder instance
- See Also:
-
validIndicator
Description copied from interface:ComponentValueBuilder
Enables a valid indicator based on the given valid state.- Specified by:
validIndicator
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
valid
- the valid state- Returns:
- this builder instance
- See Also:
-
validIndicator
Description copied from interface:ComponentValueBuilder
Enables a valid indicator based on the given validator. Note that this is overridden by
ComponentValueBuilder.validIndicator(ObservableState)
.The validator gets called each time the value changes and should return true as long as the value is valid.
- Specified by:
validIndicator
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
validator
- called each time the component value changes- Returns:
- this builder instance
- See Also:
-
modifiedIndicatorFactory
public final B modifiedIndicatorFactory(@Nullable ModifiedIndicatorFactory modifiedIndicatorFactory) Description copied from interface:ComponentValueBuilder
By defaultUnderlineModifiedIndicatorFactory
.- Specified by:
modifiedIndicatorFactory
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
modifiedIndicatorFactory
- theModifiedIndicatorFactory
to use, null for none- Returns:
- this builder instance
-
modifiedIndicator
Description copied from interface:ComponentValueBuilder
Enables a modified indicator based on the given modified state.- Specified by:
modifiedIndicator
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
modified
- the modified state- Returns:
- this builder instance
- See Also:
-
validator
- Specified by:
validator
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
validator
- the validator to use- Returns:
- this builder instance
-
link
Description copied from interface:ComponentValueBuilder
Creates a bidirectional link to the given value. Overrides any initial value set.- Specified by:
link
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
linkedValue
- a value to link to the component value- Returns:
- this builder instance
-
link
Description copied from interface:ComponentValueBuilder
Creates a read-only link to the givenObservable
.- Specified by:
link
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
linkedObservable
- a value to link to the component value- Returns:
- this builder instance
-
listener
- Specified by:
listener
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
listener
- a listener to add to the resulting component value- Returns:
- this builder instance
-
consumer
- Specified by:
consumer
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
consumer
- a consumer to add to the resulting component value- Returns:
- this builder instance
-
value
Description copied from interface:ComponentValueBuilder
Sets the initial value for the component, unless value(s) have been linked viaComponentValueBuilder.link(Value)
orComponentValueBuilder.link(Observable)
, which then control the inital value. The initial value is set before any listeners are added, so no events are triggered.- Specified by:
value
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
value
- the initial value- Returns:
- this builder instance
-
onBuildValue
- Specified by:
onBuildValue
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
onBuildValue
- called when the component value has been built.- Returns:
- this builder instance
-
buildValue
Description copied from interface:ComponentValueBuilder
Builds and returns the component value.- Specified by:
buildValue
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Returns:
- the component value
-
buildValue
Description copied from interface:ComponentValueBuilder
Builds and returns the component value.- Specified by:
buildValue
in interfaceComponentValueBuilder<T,
C extends JComponent, B extends ComponentValueBuilder<T, C, B>> - Parameters:
onBuild
- called after the component value is built.- Returns:
- the component value
-
configureComponent
- Overrides:
configureComponent
in classAbstractComponentBuilder<C extends JComponent,
B extends ComponentValueBuilder<T, C, B>>
-
createComponentValue
Creates the component value- Parameters:
component
- the component- Returns:
- a component value based on the component
-