de.esprit.appsuite.database.dbgui.field

## Interface Field<T>

- All Superinterfaces:
    Clearable
  All Known Subinterfaces:
    OptionField<T>
  All Known Implementing Classes:
    AbstractBooleanField, AbstractButtonField, AbstractCharField, AbstractChoiceField, AbstractDecimalField, AbstractFieldContainer, AbstractLabelField, AbstractNumberField, AbstractPasswordField, AbstractTextAreaField, AbstractTextField, AbstractTristateField, BooleanField, BooleanOptionField, CalendarDateField, CalendarTimestampField, CharField, ClassBrowseField, ColumnChoiceField, CompressionLevelChoiceField, CountryChoiceField, DateField, DecimalDisplayField, DirectoryField, DisplayField, DoubleField, DurationField, EnumChoiceField, FileField, FileNameInputField, FilterChoiceField, FloatField, GenderField, GroupChoiceField, IntegerField, IntegerOptionField, JavaXmsOptionField, JavaXmxOptionField, LabelField, LanguageChoiceField, ListCountField, LogChannelChoiceField, LogLevelChoiceField, LongField, OnlineUsersChoiceField, PasswordField, RadioButtonField, SliderField, SpinnerField, StringOptionField, TimeField, TimeSpanField, TimestampField, TristateField, VarcharField, VarcharScrollField, YearChoice

      public interface Field<T>
      extends Clearable

  This interface must be implemented by all input fields in order to ensure a common behavior. A field is basically a GUI component that allows to enter a value for a database column. Therefore it is recommended that each field should get a unique name that matches the name of the according database column in the format `table.column`.
  Fields are usually placed in a FieldPanel which provides helper methods for managing fields as a group.
  Author:
    Rainer Buesch
  See Also:
    `FieldPanel`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `createValue()` Creates the input Object typically from the textual String input.
    `javax.swing.JLabel` | `getJLabel()` Returns a JLabel component labeled with the translated field name.
    `java.lang.String` | `getLabel()` Returns the translated name for the field.
    `java.lang.String` | `getName()` Returns the unique name of the field.
    `NlsDatabaseKey` | `getNlsKey()` Returns the translation key used to name this Field
    `java.lang.String` | `getStringValue()` Returns the field value as a String - or an empty String if the field is empty.
    `java.awt.Component` | `getUnitComponent()` Returns the unit component for this field if one is set
    `T` | `getValue()` Returns the field value as an Object - or null if the field is empty.
    `javax.swing.JComponent` | `getWidget()` Returns a JComponent that represents the layoutable GUI component.
    `boolean` | `inputEquals(boolean b)` Tests if the field input is equal to the given boolean value.
    `boolean` | `inputEquals(double d)` Tests if the field input is equal to the given double number.
    `boolean` | `inputEquals(int i)` Tests if the field input is equal to the given int number.
    `boolean` | `inputEquals(java.lang.Object o)` Tests if the field input is equal to the given object.
    `boolean` | `isEmpty()` Tests if the field has input.
    `boolean` | `isLocked()` Tells wasCancelled the field is locked for editing.
    `boolean` | `isNotNull()` Tells wasCancelled the field requires input.
    `boolean` | `isPrimaryKey()` Tells whether this field is (or is part of) the primary key.
    `boolean` | `isRecordTypeField()` Tells whether this field defines the record type (only valid for composed persistent objects).
    `boolean` | `isStretchableX()` Tells whether this field should fill all the horizontal space in it's container.
    `boolean` | `isStretchableY()` Tells whether this field should fill all the vertical space in it's container.
    `void` | `setInsertDefaultValue()` Requests the field to search for insert-default values in the 'insert_defaults' database table.
    `void` | `setLocked(boolean b)` Locks the field for editing.
    `void` | `setModifyFlag(ModifyFlag flag)` Gives the field a reference to a ModifyFlag which is set if the field was edited.
    `void` | `setNotNull(boolean b)` Sets the field to not-null.
    `void` | `setPrimaryKey(boolean isPk)` Tells this field to be the primary key (affects input checking).
    `void` | `setStretchableX(boolean isStretchableX)` Tells whether this field should fill all the horizontal space in it's container.
    `void` | `setStretchableY(boolean isStretchableY)` Tells whether this field should fill all the vertical space in it's container.
    `void` | `setUnitComponent(java.awt.Component comp)` Sets the unit component for this field which is placed behind the field, when the field is added to a FieldPanel
    `void` | `setUnitString(java.lang.String unit)` Sets the unit string for this field which is placed as a JLabel behind the field, when the field is added to a FieldPanel
    `void` | `setValue(T o)` Sets the field value to the given object.
    `java.lang.String` | `toString()` Returns a string representation of the field typically it's unique name and it's current value.
    `java.lang.String` | `toString(java.lang.Object o)` Converts the object to a String according to the policy of the affected field component.
    `T` | `toValue(java.lang.Object o)` Tries to convert any object value to the target data type of this field.

    - ### Methods inherited from interface de.esprit.common.type.Clearable

      `clear`

- - ### Method Detail

    - #### getValue

          T getValue()

      Returns the field value as an Object - or null if the field is empty.

    - #### createValue

          T createValue()
                        throws InvalidFieldInputException

      Creates the input Object typically from the textual String input.
      Throws:
        `InvalidFieldInputException` - If the input Object cannot be created due to a parsing error.

    - #### getStringValue

          java.lang.String getStringValue()

      Returns the field value as a String - or an empty String if the field is empty.

    - #### getName

          java.lang.String getName()

      Returns the unique name of the field. Usually the name should identify a database field in the format `table.column`.

    - #### getLabel

          java.lang.String getLabel()

      Returns the translated name for the field. Translation is done through the class DBTranslation where a match for the field name must be found.
      See Also:
        `Translation`

    - #### getJLabel

          javax.swing.JLabel getJLabel()

      Returns a JLabel component labeled with the translated field name.

    - #### getWidget

          javax.swing.JComponent getWidget()

      Returns a JComponent that represents the layoutable GUI component.

    - #### toString

          java.lang.String toString(java.lang.Object o)

      Converts the object to a String according to the policy of the affected field component. This is important for DecimalField and DateField which eventually use localized strings. Note that this method must return an empty string if the object cannot be parsed.

    - #### toValue

          T toValue(java.lang.Object o)

      Tries to convert any object value to the target data type of this field. An `IllegalArgumentException` is thrown when the type is not supported by the field.

    - #### setLocked

          void setLocked(boolean b)

      Locks the field for editing.

    - #### setNotNull

          void setNotNull(boolean b)

      Sets the field to not-null. This causes the field to show up with a yellow background for indicating to the user that a value must be entered. If no value is entered the input check with isInputValid() will fail.

    - #### isLocked

          boolean isLocked()

      Tells wasCancelled the field is locked for editing.

    - #### isNotNull

          boolean isNotNull()

      Tells wasCancelled the field requires input.

    - #### isEmpty

          boolean isEmpty()

      Tests if the field has input.

    - #### inputEquals

          boolean inputEquals(java.lang.Object o)

      Tests if the field input is equal to the given object.

    - #### inputEquals

          boolean inputEquals(int i)

      Tests if the field input is equal to the given int number.

    - #### inputEquals

          boolean inputEquals(double d)

      Tests if the field input is equal to the given double number.

    - #### inputEquals

          boolean inputEquals(boolean b)

      Tests if the field input is equal to the given boolean value.

    - #### setValue

          void setValue(T o)

      Sets the field value to the given object. The implementation may be very different in different classes.

    - #### setInsertDefaultValue

          void setInsertDefaultValue()

      Requests the field to search for insert-default values in the 'insert_defaults' database table. The field uses its own name as a key for the lookup. If an insert-default value is found, it will be displayed as a default value in this field.

    - #### toString

          java.lang.String toString()

      Returns a string representation of the field typically it's unique name and it's current value.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### setModifyFlag

          void setModifyFlag(ModifyFlag flag)

      Gives the field a reference to a ModifyFlag which is set if the field was edited.

    - #### setPrimaryKey

          void setPrimaryKey(boolean isPk)

      Tells this field to be the primary key (affects input checking).

    - #### isPrimaryKey

          boolean isPrimaryKey()

      Tells whether this field is (or is part of) the primary key.

    - #### isRecordTypeField

          boolean isRecordTypeField()

      Tells whether this field defines the record type (only valid for composed persistent objects).

    - #### isStretchableX

          boolean isStretchableX()

      Tells whether this field should fill all the horizontal space in it's container.

    - #### isStretchableY

          boolean isStretchableY()

      Tells whether this field should fill all the vertical space in it's container.

    - #### setStretchableX

          void setStretchableX(boolean isStretchableX)

      Tells whether this field should fill all the horizontal space in it's container.

    - #### setStretchableY

          void setStretchableY(boolean isStretchableY)

      Tells whether this field should fill all the vertical space in it's container.

    - #### setUnitComponent

          void setUnitComponent(java.awt.Component comp)

      Sets the unit component for this field which is placed behind the field, when the field is added to a FieldPanel

    - #### getUnitComponent

          java.awt.Component getUnitComponent()

      Returns the unit component for this field if one is set
      See Also:
        `setUnitComponent(Component)`

    - #### setUnitString

          void setUnitString(java.lang.String unit)

      Sets the unit string for this field which is placed as a JLabel behind the field, when the field is added to a FieldPanel
      See Also:
        `setUnitComponent(Component)`

    - #### getNlsKey

          NlsDatabaseKey getNlsKey()

      Returns the translation key used to name this Field

Copyright © 2014 EsprIT-Systems. All Rights Reserved.