java.lang.Object
is.codion.swing.framework.ui.component.EntityComponents

public class EntityComponents extends Object
A factory for ComponentBuilder instances based on attributes from a given entity definition.
  • Constructor Details

    • EntityComponents

      public EntityComponents(EntityDefinition entityDefinition)
      Parameters:
      entityDefinition - the entity definition
  • Method Details

    • entityDefinition

      public final EntityDefinition entityDefinition()
      Returns:
      the underlying entity definition
    • supports

      public boolean supports(Attribute<?> attribute)
      Parameters:
      attribute - the attribute
      Returns:
      true if component(Attribute) supports the given attribute
    • component

      public <T, C extends JComponent, B extends ComponentBuilder<T, C, B>> ComponentBuilder<T,C,B> component(Attribute<T> attribute)
      Returns a ComponentBuilder instance for a default input component for the given attribute.
      Type Parameters:
      T - the attribute type
      C - the component type
      B - 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

      public final CheckBoxBuilder checkBox(Attribute<Boolean> attribute)
      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, B>> ButtonBuilder<Boolean,JToggleButton,B> toggleButton(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

      public final ItemComboBoxBuilder<Boolean> booleanComboBox(Attribute<Boolean> attribute)
      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, B>> ComboBoxBuilder<Entity,EntityComboBox,B> foreignKeyComboBox(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 key
      comboBoxModel - 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 key
      comboBoxModel - the combo box model
      editPanelSupplier - 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 key
      searchModel - 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 key
      searchModel - the search model
      editPanelSupplier - 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, B>> TextFieldBuilder<Entity,JTextField,B> foreignKeyTextField(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

      public final LabelBuilder<Entity> foreignKeyLabel(ForeignKey foreignKey)
      Creates a foreign key label builder based on the given foreign key.
      Parameters:
      foreignKey - the foreign key
      Returns:
      a foreign key JLabel builder
    • itemComboBox

      public final <T> ItemComboBoxBuilder<T> itemComboBox(Attribute<T> attribute)
      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>, 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.
      Type Parameters:
      T - the attribute type
      C - the component type
      B - the builder type
      Parameters:
      attribute - the attribute
      comboBoxModel - the combo box model
      Returns:
      a JComboBox builder
    • temporalFieldPanel

      public final <T extends Temporal> TemporalFieldPanel.Builder<T> temporalFieldPanel(Attribute<T> attribute)
      Creates a TemporalFieldPanel 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 a TemporalFieldPanel builder based on the given attribute.
      Type Parameters:
      T - the attribute type
      Parameters:
      attribute - the attribute
      dateTimePattern - the date time pattern
      Returns:
      a TemporalFieldPanel builder
    • textFieldPanel

      public final TextFieldPanel.Builder textFieldPanel(Attribute<String> attribute)
      Creates a TextFieldPanel builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a TextFieldPanel builder
    • textArea

      public final TextAreaBuilder textArea(Attribute<String> attribute)
      Creates a TextArea builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a JTextArea builder
    • textField

      public final <T, C extends JTextField, B extends TextFieldBuilder<T, C, B>> TextFieldBuilder<T,C,B> textField(Attribute<T> attribute)
      Creates a text field builder based on the given attribute.
      Type Parameters:
      T - the attribute type
      C - the text field type
      B - the builder type
      Parameters:
      attribute - the attribute
      Returns:
      a JTextField builder
    • temporalField

      public final <T extends Temporal> TemporalField.Builder<T> temporalField(Attribute<T> attribute)
      Creates a TemporalField 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 a TemporalField builder based on the given attribute.
      Type Parameters:
      T - the temporal type
      Parameters:
      attribute - the attribute
      dateTimePattern - the date time pattern
      Returns:
      a TemporalField builder
    • shortField

      public final NumberField.Builder<Short> shortField(Attribute<Short> attribute)
      Creates a NumberField builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a NumberField builder
    • integerField

      public final NumberField.Builder<Integer> integerField(Attribute<Integer> attribute)
      Creates a NumberField builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a NumberField builder
    • longField

      public final NumberField.Builder<Long> longField(Attribute<Long> attribute)
      Creates a NumberField builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a NumberField builder
    • doubleField

      public final NumberField.Builder<Double> doubleField(Attribute<Double> attribute)
      Creates a NumberField builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a NumberField builder
    • bigDecimalField

      public final NumberField.Builder<BigDecimal> bigDecimalField(Attribute<BigDecimal> attribute)
      Creates a NumberField builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a NumberField builder
    • slider

      public final SliderBuilder slider(Attribute<Integer> attribute)
      Creates a JSlider 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 a JSlider builder based on the given attribute.
      Parameters:
      attribute - the attribute
      boundedRangeModel - the bounded range model
      Returns:
      a JSlider builder
    • integerSpinner

      public final NumberSpinnerBuilder<Integer> integerSpinner(Attribute<Integer> attribute)
      Creates a JSpinner builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a JSpinner builder
    • doubleSpinner

      public final NumberSpinnerBuilder<Double> doubleSpinner(Attribute<Double> attribute)
      Creates a JSpinner 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 a JSpinner builder based on the given attribute.
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      listModel - the spinner model
      Returns:
      a JSpinner builder
    • itemSpinner

      public final <T> ItemSpinnerBuilder<T> itemSpinner(Attribute<T> attribute)
      Creates a JSpinner builder based on the given attribute.
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      Returns:
      a JSpinner builder
    • maskedTextField

      public final MaskedTextFieldBuilder maskedTextField(Attribute<String> attribute)
      Creates a masked text field builder based on the given attribute.
      Parameters:
      attribute - the attribute
      Returns:
      a JFormattedTextField builder