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.
Note that the component created by component(Attribute) for a ForeignKey is a non-editable and
non-focusable JTextField displaying a String representation of the referenced Entity.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbigDecimalField(Attribute<BigDecimal> attribute) Creates aNumberFieldbuilder based on the given attribute.booleanComboBox(Attribute<Boolean> attribute) Creates a boolean ComboBox builder based on the given attribute.ComponentValueBuilder<FileInputPanel, byte[], FileInputPanel.Builder<byte[]>> byteArrayInputPanel(Attribute<byte[]> attribute) Creates a byte array basedFileInputPanelbuilder based on the given attribute.Creates a CheckBox builder based on the given attribute.<T,C extends JComboBox<T>, B extends ComboBoxBuilder<C, T, B>>
ComboBoxBuilder<C, T, B> comboBox(Attribute<T> attribute, ComboBoxModel<T> comboBoxModel) Creates a JComboBox builder based on the given attribute.comboBox(ForeignKey foreignKey, EntityComboBoxModel comboBoxModel) Creates aEntityComboBox.Builderbased on the given foreign key.comboBoxPanel(ForeignKey foreignKey, EntityComboBoxModel comboBoxModel, Supplier<EntityEditPanel> editPanel) Creates aEntityComboBoxPanel.Builderwith optional buttons for adding and editing items.<C extends JComponent,T, B extends ComponentValueBuilder<C, T, B>>
ComponentValueBuilder<C, T, B> Returns aComponentBuilderinstance for a default input component for the given attribute.doubleField(Attribute<Double> attribute) Creates aNumberFieldbuilder based on the given attribute.doubleSpinner(Attribute<Double> attribute) Creates aJSpinnerbuilder based on the given attribute.static EntityComponentsentityComponents(EntityDefinition entityDefinition) integerField(Attribute<Integer> attribute) Creates aNumberFieldbuilder based on the given attribute.integerSpinner(Attribute<Integer> attribute) Creates aJSpinnerbuilder based on the given attribute.<T> ItemComboBoxBuilder<T> itemComboBox(Attribute<T> attribute) Creates a JComboBox builder based on the given attribute.<T> ItemSpinnerBuilder<T> itemSpinner(Attribute<T> attribute) Creates aJSpinnerbuilder based on the given attribute.<T> ListSpinnerBuilder<T> listSpinner(Attribute<T> attribute, SpinnerListModel listModel) Creates aJSpinnerbuilder based on the given attribute.Creates aNumberFieldbuilder based on the given attribute.maskedTextField(Attribute<String> attribute) Creates a masked text field builder based on the given attribute.nullableCheckBox(Attribute<Boolean> attribute) Creates a NullableCheckBox builder based on the given attribute.searchField(ForeignKey foreignKey, EntitySearchModel searchModel) Creates aEntitySearchField.Builder.Factory.searchFieldPanel(ForeignKey foreignKey, EntitySearchModel searchModel, Supplier<EntityEditPanel> editPanel) Creates aEntitySearchFieldPanel.Builder.Factory.shortField(Attribute<Short> attribute) Creates aNumberFieldbuilder based on the given attribute.Creates aJSliderbuilder based on the given attribute, with a bounded range model based on the min/max values of the associated attribute.slider(Attribute<Integer> attribute, BoundedRangeModel boundedRangeModel) Creates aJSliderbuilder based on the given attribute.<T extends Temporal>
TemporalField.Builder<T> temporalField(Attribute<T> attribute) Creates aTemporalFieldbuilder based on the given attribute.<T extends Temporal>
TemporalFieldPanel.Builder<T> temporalFieldPanel(Attribute<T> attribute) Creates aTemporalFieldPanelbuilder based on the given attribute.Creates a TextArea builder based on the given attribute.<T,C extends JTextField, B extends TextFieldBuilder<C, T, B>>
TextFieldBuilder<C, T, B> Creates a text field builder based on the given attribute.<B extends TextFieldBuilder<JTextField,Entity, B>>
TextFieldBuilder<JTextField, Entity, B> textField(ForeignKey foreignKey) textFieldPanel(Attribute<String> attribute) Creates aTextFieldPanelbuilder based on the given attribute.<B extends ButtonBuilder<JToggleButton,Boolean, B>>
ButtonBuilder<JToggleButton, Boolean, B> toggleButton(Attribute<Boolean> attribute) Creates a ToggleButton builder based on the given attribute.
-
Method Details
-
entityDefinition
- Returns:
- the underlying entity definition
-
component
public <C extends JComponent,T, ComponentValueBuilder<C,B extends ComponentValueBuilder<C, T, B>> T, componentB> (Attribute<T> attribute) Returns a
ComponentBuilderinstance for a default input component for the given attribute.Note that this method does not create an input component for
ForeignKeys, it simply returns a non-focusable and non-editableJTextFieldfromtextField(ForeignKey).Input components for
ForeignKeys (EntityComboBoxorEntitySearchField) require a data model, usecomboBox(Attribute, ComboBoxModel)orsearchField(ForeignKey, EntitySearchModel).- Type Parameters:
C- the component typeT- the attribute 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 given attribute is not supported
-
checkBox
Creates a CheckBox builder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a JCheckBox builder
- Throws:
IllegalArgumentException- in case the attribute is nullable
-
nullableCheckBox
Creates a NullableCheckBox builder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a NullableCheckBox builder
-
toggleButton
public <B extends ButtonBuilder<JToggleButton,Boolean, ButtonBuilder<JToggleButton,B>> Boolean, 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
-
comboBox
Creates aEntityComboBox.Builderbased on the given foreign key.- Parameters:
foreignKey- the foreign keycomboBoxModel- the combo box model- Returns:
- a foreign key JComboBox builder
-
comboBoxPanel
public EntityComboBoxPanel.Builder comboBoxPanel(ForeignKey foreignKey, EntityComboBoxModel comboBoxModel, Supplier<EntityEditPanel> editPanel) Creates aEntityComboBoxPanel.Builderwith optional buttons for adding and editing items.- Parameters:
foreignKey- the foreign keycomboBoxModel- the combo box modeleditPanel- supplies the edit panel to use for the add and/or edit buttons- Returns:
- a foreign key combo box panel builder
-
searchField
public EntitySearchField.Builder.Factory searchField(ForeignKey foreignKey, EntitySearchModel searchModel) Creates aEntitySearchField.Builder.Factory.- Parameters:
foreignKey- the foreign keysearchModel- the search model- Returns:
- a foreign key
EntitySearchFieldbuilder
-
searchFieldPanel
public EntitySearchFieldPanel.Builder.Factory searchFieldPanel(ForeignKey foreignKey, EntitySearchModel searchModel, Supplier<EntityEditPanel> editPanel) Creates aEntitySearchFieldPanel.Builder.Factory.- Parameters:
foreignKey- the foreign keysearchModel- the search modeleditPanel- supplies the edit panel to use for the add and/or edit buttons- Returns:
- a foreign key search field panel builder
-
textField
public <B extends TextFieldBuilder<JTextField,Entity, TextFieldBuilder<JTextField,B>> Entity, textFieldB> (ForeignKey foreignKey) CreatesEntitytext field builder for the given foreign key, read-only and non-focusable, displaying the String representation theEntity- Type Parameters:
B- the builder type- Parameters:
foreignKey- the foreign key- Returns:
- a
EntityJTextField 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
Itembased JComboBox builder - Throws:
IllegalArgumentException- in case the given attribute has no associated items
-
comboBox
public <T,C extends JComboBox<T>, ComboBoxBuilder<C,B extends ComboBoxBuilder<C, T, B>> T, 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 <T extends Temporal> TemporalFieldPanel.Builder<T> temporalFieldPanel(Attribute<T> attribute) Creates aTemporalFieldPanelbuilder based on the given attribute.- Type Parameters:
T- the attribute type- Parameters:
attribute- the attribute- Returns:
- a
TemporalFieldPanelbuilder
-
textFieldPanel
Creates aTextFieldPanelbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
TextFieldPanelbuilder
-
textArea
Creates a TextArea builder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a JTextArea builder
-
textField
public <T,C extends JTextField, TextFieldBuilder<C,B extends TextFieldBuilder<C, T, B>> T, 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 aTemporalFieldbuilder based on the given attribute.- Type Parameters:
T- the temporal type- Parameters:
attribute- the attribute- Returns:
- a
TemporalFieldbuilder
-
shortField
Creates aNumberFieldbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
NumberFieldbuilder
-
integerField
Creates aNumberFieldbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
NumberFieldbuilder
-
longField
Creates aNumberFieldbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
NumberFieldbuilder
-
doubleField
Creates aNumberFieldbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
NumberFieldbuilder
-
bigDecimalField
Creates aNumberFieldbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
NumberFieldbuilder
-
slider
Creates aJSliderbuilder 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
JSliderbuilder
-
slider
Creates aJSliderbuilder based on the given attribute.- Parameters:
attribute- the attributeboundedRangeModel- the bounded range model- Returns:
- a
JSliderbuilder
-
integerSpinner
Creates aJSpinnerbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
JSpinnerbuilder
-
doubleSpinner
Creates aJSpinnerbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
JSpinnerbuilder
-
listSpinner
Creates aJSpinnerbuilder based on the given attribute.- Type Parameters:
T- the value type- Parameters:
attribute- the attributelistModel- the spinner model- Returns:
- a
JSpinnerbuilder
-
itemSpinner
Creates aJSpinnerbuilder based on the given attribute.- Type Parameters:
T- the value type- Parameters:
attribute- the attribute- Returns:
- a
JSpinnerbuilder
-
maskedTextField
Creates a masked text field builder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a JFormattedTextField builder
-
byteArrayInputPanel
public ComponentValueBuilder<FileInputPanel,byte[], byteArrayInputPanelFileInputPanel.Builder<byte[]>> (Attribute<byte[]> attribute) Creates a byte array basedFileInputPanelbuilder based on the given attribute.- Parameters:
attribute- the attribute- Returns:
- a
FileInputPanel.Builder
-
entityComponents
- Parameters:
entityDefinition- the entity definition- Returns:
- a new
EntityComponentsinstance
-