Module is.codion.swing.framework.ui
Class EntityComponents
java.lang.Object
is.codion.swing.framework.ui.component.EntityComponents
A factory for
ComponentBuilder
instances
based on attributes from a given entity definition.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal NumberField.Builder<BigDecimal>
bigDecimalField
(Attribute<BigDecimal> attribute) Creates aNumberField
builder based on the given attribute.final ItemComboBoxBuilder<Boolean>
booleanComboBox
(Attribute<Boolean> attribute) Creates a boolean ComboBox builder based on the given attribute.final CheckBoxBuilder
Creates a CheckBox builder based on the given attribute.final <T,
C extends JComboBox<T>, B extends ComboBoxBuilder<T, C, B>>
ComboBoxBuilder<T,C, B> comboBox
(Attribute<T> attribute, ComboBoxModel<T> comboBoxModel) Creates a JComboBox builder based on the given attribute.<T,
C extends JComponent, B extends ComponentBuilder<T, C, B>>
ComponentBuilder<T,C, B> Returns aComponentBuilder
instance for a default input component for the given attribute.final NumberField.Builder<Double>
doubleField
(Attribute<Double> attribute) Creates aNumberField
builder based on the given attribute.final NumberSpinnerBuilder<Double>
doubleSpinner
(Attribute<Double> attribute) Creates aJSpinner
builder based on the given attribute.final EntityDefinition
final <B extends ComboBoxBuilder<Entity,
EntityComboBox, B>>
ComboBoxBuilder<Entity,EntityComboBox, B> foreignKeyComboBox
(ForeignKey foreignKey, EntityComboBoxModel comboBoxModel) Creates a foreign key ComboBox builder based on the given foreign key.foreignKeyComboBoxPanel
(ForeignKey foreignKey, EntityComboBoxModel comboBoxModel, Supplier<EntityEditPanel> editPanelSupplier) Creates a builder for a foreign key combo box panel with optional buttons for adding and editing items.final LabelBuilder<Entity>
foreignKeyLabel
(ForeignKey foreignKey) Creates a foreign key label builder based on the given foreign key.foreignKeySearchField
(ForeignKey foreignKey, EntitySearchModel searchModel) Creates a foreign key search field builder based on the given foreign key.foreignKeySearchFieldPanel
(ForeignKey foreignKey, EntitySearchModel searchModel, Supplier<EntityEditPanel> editPanelSupplier) Creates a builder for a foreign key search field panel with optional buttons for adding and editing items.final <B extends TextFieldBuilder<Entity,
JTextField, B>>
TextFieldBuilder<Entity,JTextField, B> foreignKeyTextField
(ForeignKey foreignKey) Creates foreign key text field builder for the given foreign key, read-only and non-focusable.final NumberField.Builder<Integer>
integerField
(Attribute<Integer> attribute) Creates aNumberField
builder based on the given attribute.final NumberSpinnerBuilder<Integer>
integerSpinner
(Attribute<Integer> attribute) Creates aJSpinner
builder based on the given attribute.final <T> ItemComboBoxBuilder<T>
itemComboBox
(Attribute<T> attribute) Creates a JComboBox builder based on the given attribute.final <T> ItemSpinnerBuilder<T>
itemSpinner
(Attribute<T> attribute) Creates aJSpinner
builder based on the given attribute.final <T> ListSpinnerBuilder<T>
listSpinner
(Attribute<T> attribute, SpinnerListModel listModel) Creates aJSpinner
builder based on the given attribute.final NumberField.Builder<Long>
Creates aNumberField
builder based on the given attribute.final MaskedTextFieldBuilder
maskedTextField
(Attribute<String> attribute) Creates a masked text field builder based on the given attribute.final NumberField.Builder<Short>
shortField
(Attribute<Short> attribute) Creates aNumberField
builder based on the given attribute.final SliderBuilder
Creates aJSlider
builder based on the given attribute, with a bounded range model based on the min/max values of the associated attribute.final SliderBuilder
slider
(Attribute<Integer> attribute, BoundedRangeModel boundedRangeModel) Creates aJSlider
builder based on the given attribute.boolean
final <T extends Temporal>
TemporalField.Builder<T>temporalField
(Attribute<T> attribute) Creates aTemporalField
builder based on the given attribute.final <T extends Temporal>
TemporalField.Builder<T>temporalField
(Attribute<T> attribute, String dateTimePattern) Creates aTemporalField
builder based on the given attribute.final <T extends Temporal>
TemporalFieldPanel.Builder<T>temporalFieldPanel
(Attribute<T> attribute) Creates aTemporalFieldPanel
builder based on the given attribute.final <T extends Temporal>
TemporalFieldPanel.Builder<T>temporalFieldPanel
(Attribute<T> attribute, String dateTimePattern) Creates aTemporalFieldPanel
builder based on the given attribute.final TextAreaBuilder
Creates a TextArea builder based on the given attribute.final <T,
C extends JTextField, B extends TextFieldBuilder<T, C, B>>
TextFieldBuilder<T,C, B> Creates a text field builder based on the given attribute.final TextFieldPanel.Builder
textFieldPanel
(Attribute<String> attribute) Creates aTextFieldPanel
builder based on the given attribute.final <B extends ButtonBuilder<Boolean,
JToggleButton, B>>
ButtonBuilder<Boolean,JToggleButton, B> toggleButton
(Attribute<Boolean> attribute) Creates a ToggleButton builder based on the given attribute.
-
Constructor Details
-
EntityComponents
- Parameters:
entityDefinition
- the entity definition
-
-
Method Details
-
entityDefinition
- Returns:
- the underlying entity definition
-
supports
- Parameters:
attribute
- the attribute- Returns:
- true if
component(Attribute)
supports the given attribute
-
component
public <T,C extends JComponent, ComponentBuilder<T,B extends ComponentBuilder<T, C, B>> C, componentB> (Attribute<T> attribute) Returns aComponentBuilder
instance for a default input component for the given attribute.- Type Parameters:
T
- the attribute typeC
- the component typeB
- the builder type- Parameters:
attribute
- the attribute for which to create the input component- Returns:
- the component builder handling input for
attribute
- Throws:
IllegalArgumentException
- in case the attribute type is not supported- See Also:
-
checkBox
Creates a CheckBox builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a JCheckBox builder
-
toggleButton
public final <B extends ButtonBuilder<Boolean,JToggleButton, ButtonBuilder<Boolean,B>> JToggleButton, toggleButtonB> (Attribute<Boolean> attribute) Creates a ToggleButton builder based on the given attribute.- Type Parameters:
B
- the builder type- Parameters:
attribute
- the attribute- Returns:
- a JToggleButton builder
-
booleanComboBox
Creates a boolean ComboBox builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a boolean JComboBox builder
-
foreignKeyComboBox
public final <B extends ComboBoxBuilder<Entity,EntityComboBox, ComboBoxBuilder<Entity,B>> EntityComboBox, foreignKeyComboBoxB> (ForeignKey foreignKey, EntityComboBoxModel comboBoxModel) Creates a foreign key ComboBox builder based on the given foreign key.- Type Parameters:
B
- the builder type- Parameters:
foreignKey
- the foreign keycomboBoxModel
- the combo box model- Returns:
- a foreign key JComboBox builder
-
foreignKeyComboBoxPanel
public final EntityComboBoxPanel.Builder foreignKeyComboBoxPanel(ForeignKey foreignKey, EntityComboBoxModel comboBoxModel, Supplier<EntityEditPanel> editPanelSupplier) Creates a builder for a foreign key combo box panel with optional buttons for adding and editing items.- Parameters:
foreignKey
- the foreign keycomboBoxModel
- the combo box modeleditPanelSupplier
- the edit panel supplier to use for the add and/or edit buttons- Returns:
- a foreign key combo box panel builder
-
foreignKeySearchField
public final EntitySearchField.Builder foreignKeySearchField(ForeignKey foreignKey, EntitySearchModel searchModel) Creates a foreign key search field builder based on the given foreign key.- Parameters:
foreignKey
- the foreign keysearchModel
- the search model- Returns:
- a foreign key
EntitySearchField
builder
-
foreignKeySearchFieldPanel
public final EntitySearchFieldPanel.Builder foreignKeySearchFieldPanel(ForeignKey foreignKey, EntitySearchModel searchModel, Supplier<EntityEditPanel> editPanelSupplier) Creates a builder for a foreign key search field panel with optional buttons for adding and editing items.- Parameters:
foreignKey
- the foreign keysearchModel
- the search modeleditPanelSupplier
- the edit panel supplier to use for the add and/or edit buttons- Returns:
- a foreign key search field panel builder
-
foreignKeyTextField
public final <B extends TextFieldBuilder<Entity,JTextField, TextFieldBuilder<Entity,B>> JTextField, foreignKeyTextFieldB> (ForeignKey foreignKey) Creates foreign key text field builder for the given foreign key, read-only and non-focusable.- Type Parameters:
B
- the builder type- Parameters:
foreignKey
- the foreign key- Returns:
- a foreign key JTextField builder
-
foreignKeyLabel
Creates a foreign key label builder based on the given foreign key.- Parameters:
foreignKey
- the foreign key- Returns:
- a foreign key JLabel builder
-
itemComboBox
Creates a JComboBox builder based on the given attribute. Note that the attribute must have items associated.- Type Parameters:
T
- the attribute type- Parameters:
attribute
- the attribute- Returns:
- an
Item
based JComboBox builder - Throws:
IllegalArgumentException
- in case the given attribute has no associated items
-
comboBox
public final <T,C extends JComboBox<T>, ComboBoxBuilder<T,B extends ComboBoxBuilder<T, C, B>> C, comboBoxB> (Attribute<T> attribute, ComboBoxModel<T> comboBoxModel) Creates a JComboBox builder based on the given attribute.- Type Parameters:
T
- the attribute typeC
- the component typeB
- the builder type- Parameters:
attribute
- the attributecomboBoxModel
- the combo box model- Returns:
- a JComboBox builder
-
temporalFieldPanel
public final <T extends Temporal> TemporalFieldPanel.Builder<T> temporalFieldPanel(Attribute<T> attribute) Creates aTemporalFieldPanel
builder based on the given attribute.- Type Parameters:
T
- the attribute type- Parameters:
attribute
- the attribute- Returns:
- a
TemporalFieldPanel
builder
-
temporalFieldPanel
public final <T extends Temporal> TemporalFieldPanel.Builder<T> temporalFieldPanel(Attribute<T> attribute, String dateTimePattern) Creates aTemporalFieldPanel
builder based on the given attribute.- Type Parameters:
T
- the attribute type- Parameters:
attribute
- the attributedateTimePattern
- the date time pattern- Returns:
- a
TemporalFieldPanel
builder
-
textFieldPanel
Creates aTextFieldPanel
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
TextFieldPanel
builder
-
textArea
Creates a TextArea builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a JTextArea builder
-
textField
public final <T,C extends JTextField, TextFieldBuilder<T,B extends TextFieldBuilder<T, C, B>> C, textFieldB> (Attribute<T> attribute) Creates a text field builder based on the given attribute.- Type Parameters:
T
- the attribute typeC
- the text field typeB
- the builder type- Parameters:
attribute
- the attribute- Returns:
- a JTextField builder
-
temporalField
Creates aTemporalField
builder based on the given attribute.- Type Parameters:
T
- the temporal type- Parameters:
attribute
- the attribute- Returns:
- a
TemporalField
builder
-
temporalField
public final <T extends Temporal> TemporalField.Builder<T> temporalField(Attribute<T> attribute, String dateTimePattern) Creates aTemporalField
builder based on the given attribute.- Type Parameters:
T
- the temporal type- Parameters:
attribute
- the attributedateTimePattern
- the date time pattern- Returns:
- a
TemporalField
builder
-
shortField
Creates aNumberField
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
NumberField
builder
-
integerField
Creates aNumberField
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
NumberField
builder
-
longField
Creates aNumberField
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
NumberField
builder
-
doubleField
Creates aNumberField
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
NumberField
builder
-
bigDecimalField
Creates aNumberField
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
NumberField
builder
-
slider
Creates aJSlider
builder based on the given attribute, with a bounded range model based on the min/max values of the associated attribute.- Parameters:
attribute
- the attribute- Returns:
- a
JSlider
builder
-
slider
public final SliderBuilder slider(Attribute<Integer> attribute, BoundedRangeModel boundedRangeModel) Creates aJSlider
builder based on the given attribute.- Parameters:
attribute
- the attributeboundedRangeModel
- the bounded range model- Returns:
- a
JSlider
builder
-
integerSpinner
Creates aJSpinner
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
JSpinner
builder
-
doubleSpinner
Creates aJSpinner
builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a
JSpinner
builder
-
listSpinner
public final <T> ListSpinnerBuilder<T> listSpinner(Attribute<T> attribute, SpinnerListModel listModel) Creates aJSpinner
builder based on the given attribute.- Type Parameters:
T
- the value type- Parameters:
attribute
- the attributelistModel
- the spinner model- Returns:
- a
JSpinner
builder
-
itemSpinner
Creates aJSpinner
builder based on the given attribute.- Type Parameters:
T
- the value type- Parameters:
attribute
- the attribute- Returns:
- a
JSpinner
builder
-
maskedTextField
Creates a masked text field builder based on the given attribute.- Parameters:
attribute
- the attribute- Returns:
- a JFormattedTextField builder
-