Class UIAbstractListChoice

All Implemented Interfaces:
EventListener, IFocusComp, IMessageBox, IComponent, ICodeItemArrayContainer, ICodeItemsOwner, ICodeItemsOwnerSelectionSupport, ICustomDataProvider, IGProp<GProp<?>[]>, IKStringArrayContainer, IPropCnr, IStringArrayContainer, IUIComp, IUICompRelativeTarget, IUIContextMenuOwner, IUIFocusComp, IUIHint, IUILabelForTarget, IUIIndexedSelectionComp, IUISelectionComp, IUISingleIndexedSelectionComp, IUIPlainTextComponent, IUITextComponent, IVSColumnBestValueListener, IVSColumnListener, IVSComponentListener, IVSComponentState, IVSFieldListener, Cloneable
Direct Known Subclasses:
UIComboBox, UISpinner

Abstract list choice UI component used for combobox and spinner.
Author:
Christopher Mindus
  • Field Details

    • SELECTED_ROW_ATOM

      protected static final Atom SELECTED_ROW_ATOM
      The property name: selected row.
    • PN_ITEMS_CNR

      protected static final String PN_ITEMS_CNR
      The items container property name = "items".
      See Also:
    • ATOM_ITEMS_CNR

      protected static final Atom ATOM_ITEMS_CNR
      The items container property atom.
  • Constructor Details

    • UIAbstractListChoice

      public UIAbstractListChoice()
      Creates the component without a name. The name must be set in all cases using the setPropertyAtom call.
    • UIAbstractListChoice

      public UIAbstractListChoice(Atom propertyAtom)
      Creates the component with the specified name. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - the name of the component, unique within it's parent.
  • Method Details

    • clone

      public UIAbstractListChoice clone()
      Creates a clone out of this property. The cloning is overridden by the subclasses in order to handle cloning of its class variables appropriately.

      Cloning is used for "virtualization" of a property tree in the server. Client property classes will therefore throw CloneNotSupportedException.

      Once a tree has been cloned, the change-flag is reset, and the create-flag is set. All listeners are also removed! The new cloned property is an orphan, i.e. has no parent set. All children properties are also (deep) cloned.

      Note that the cloning process is done WITHOUT thread synchronization for performance reasons, thus no modifications should be done to the tree!

      Overrides:
      clone in class UIComp
    • getCodeArrayArrayContainer

      public ICodeItemArrayContainer getCodeArrayArrayContainer()
      Gets the target implementor of the interface.
      Specified by:
      getCodeArrayArrayContainer in interface ICodeItemArrayContainer
      Returns:
      The target implements of the interface, null for none (this instance).
    • getStringArrayContainer

      public IStringArrayContainer getStringArrayContainer()
      Gets the target implementor of the interface.
      Specified by:
      getStringArrayContainer in interface IStringArrayContainer
      Returns:
      The target implements of the interface, null for none (this instance).
    • getKStringArrayContainer

      public IKStringArrayContainer getKStringArrayContainer()
      Gets the target implementor of the interface.
      Specified by:
      getKStringArrayContainer in interface IKStringArrayContainer
      Returns:
      The target implements of the interface, null for none (this instance).
    • isHTMLKStringSupported

      public boolean isHTMLKStringSupported()
      Checks if KString's of HTML type are supported.
      Specified by:
      isHTMLKStringSupported in interface IKStringArrayContainer
      Returns:
      true for HTML support, false if it must be plain KString's.
    • getSelectionPropAtom

      public Atom getSelectionPropAtom()
      Returns the selection property atom for verification of selection changes.

      This method is used by the framework in UIComp to fire selection events when the property value changes.

      Specified by:
      getSelectionPropAtom in interface IUISelectionComp
      Returns:
      The atom of the selection property.
    • getSelectionListenerHandler

      public GenericListener<IUISelectionListener> getSelectionListenerHandler(boolean doCreate)
      Returns the generic selection listener.
      Specified by:
      getSelectionListenerHandler in interface IUISelectionComp
      Parameters:
      doCreate - Create the listener handler if it doesn't exist, false not to.
      Returns:
      The selection listener handler, or null if not created.
    • getDeviceType

      public final int getDeviceType()
      Gets the device type: -1=mobile, 0=both, 1=desktop.
      Specified by:
      getDeviceType in interface IUIComp
    • isMobileContextMenuSupported

      public boolean isMobileContextMenuSupported()
      Returns if the component can show the context menu in mobile mode.
      Specified by:
      isMobileContextMenuSupported in interface IUIContextMenuOwner
      Returns:
      Combobox component supports context menus for mobile.
    • shouldCreateProps

      protected boolean shouldCreateProps(Element element)
      Checks if a child Element should be created as properties or if it should be skipped. Override this method (and call super.shouldCreateProps(element)) if the container creates other child elements.
      Overrides:
      shouldCreateProps in class PropCnr
      Parameters:
      element - The element in question.
      Returns:
      true to create properties out of it, false to ignore the element.
    • addPredefinedProps

      protected void addPredefinedProps() throws PropException
      Adds the predefined properties for this container. This method is called once just after construction of the property container and sometimes population of it.

      The method should add properties to create or get reference to using the maybeAddProp method. When the PropCnr instance is cloned, the method getPredefinedProps() is called in order for the subclass to be able to retrieve the new instances to these properties, if stored in instance variables.

      Overrides:
      addPredefinedProps in class PropCnr
      Throws:
      PropException - for property exceptions.
    • getPredefinedProps

      public void getPredefinedProps()
      Gets potential references to predefined properties for this container. This method is called once just after cloning of the property container.

      The method should get reference to using the getProp(...) methods. This allows the subclass to be able to retrieve the new instances to the properties created during addPredefinedProps() if stored in instance variables.

      Subclasses must override this method to do the appropriate initialization, as this method does nothing for the PropCnr class implementation.

      Overrides:
      getPredefinedProps in class UIComp
    • onEventSelf

      public void onEventSelf(GEvent event)
      Updates a VirtualSpace Field when a component text changes.
      Specified by:
      onEventSelf in interface IGProp<GProp<?>[]>
      Overrides:
      onEventSelf in class UIComp
      Parameters:
      event - The property event.
    • onSelectionChanged

      protected void onSelectionChanged(GEvent event)
      Method called when the selection of the component changed due to a property change (value changed, property added or removed).
      Overrides:
      onSelectionChanged in class UIComp
      Parameters:
      event - The event that causes the selection change.
    • setComponentToVSField

      public int setComponentToVSField()
      Sets the text or value from this text or value component to its VirtualSpace Field, if any.
      Specified by:
      setComponentToVSField in interface IUIComp
      Overrides:
      setComponentToVSField in class UIComp
      Returns:
      1 for update completed, 0 for nothing done and -1 for error occurred.
    • isVSTableSelectionSynchronized

      public boolean isVSTableSelectionSynchronized()
      Returns whether the VSTable selection processing is enabled or not.
      Returns:
      true when combobox selection should be synchronized with the VSTable.
    • isVSFieldSelectionIndex

      public boolean isVSFieldSelectionIndex()
      Returns if the VS field is used for the selection index or the text of the combobox entry field.
      Returns:
      true if VSField is selection index, false if it's the combobox text.
    • onValueChanged

      public void onValueChanged(VSField field, Value value, GProp<?> trigger, IPostEventProcessing postProcessing)
      Called when the field value is set.

      Components must override to provide the implementation when they are not implementing IPlainTextComponent, in this case the default implementation transports the field string value to this text components plain text.

      Specified by:
      onValueChanged in interface IVSFieldListener
      Overrides:
      onValueChanged in class UIComp
      Parameters:
      field - The VS field.
      value - The value, never null, but value.isNull() could be true.
      trigger - The trigger property that may be null.
      postProcessing - Post-processing instance.
    • isSelected

      public boolean isSelected()
      Returns the selection of state of the component.

      For a multiple-selection capable component, this indicates any selection, i.e. true is returned as soon as at least one element is selected, false for none.

      The checkbox for example has two "selected states": checked and third state: in this case, true is returned for the third state as well as the checked state.

      Specified by:
      isSelected in interface IUISelectionComp
      Returns:
      true if the component is selected, false otherwise.
    • getSelectedIndex

      public int getSelectedIndex()
      Gets the first selected index.
      Specified by:
      getSelectedIndex in interface ICodeItemsOwnerSelectionSupport
      Specified by:
      getSelectedIndex in interface IUISingleIndexedSelectionComp
      Returns:
      The first index in the current selection, or -1 for none.
    • getSelectionType

      public int getSelectionType()
      Gets the selection type of the component.
      Specified by:
      getSelectionType in interface IUISelectionComp
      Returns:
      A value indicating the selection capability as the SELECTION_TYPE_* values define.
    • getSelection

      public IUISelection getSelection()
      Gets the current selection of the component.
      Specified by:
      getSelection in interface IUISelectionComp
      Returns:
      The current selection of the component.
    • setSelection

      public String setSelection(int index)
      Sets the selection as a single selected item at specified index.
      Specified by:
      setSelection in interface ICodeItemsOwnerSelectionSupport
      Specified by:
      setSelection in interface IUIIndexedSelectionComp
      Parameters:
      index - The single item to select at index, negative value to clear the selection.
      Returns:
      null for success, otherwise an error message why the selection failed.
    • clearSelection

      public String clearSelection()
      Clear the selection.
      Specified by:
      clearSelection in interface ICodeItemsOwnerSelectionSupport
      Specified by:
      clearSelection in interface IUIIndexedSelectionComp
      Returns:
      null for OK.
    • onPrepare

      protected void onPrepare(ClassReference cr, List<Throwable> errors)
      Called to resolve methods for the component from main "onPrepare" once the ClassReference has been found.

      Components should override this method to load it's required methods.

      Overrides:
      onPrepare in class UIComp
      Parameters:
      cr - The class reference with a valid reference.
      errors - The list of errors that is returned to the caller in case resolving fails.
    • getOnUISelectionMethod

      public Method getOnUISelectionMethod()
      Returns the method to use for onUISelection notifications that is attached to this selection component. The method name is not important, but must have the annotation and signature:

      @OnUISelection(name = "some/property")
      public void onUISelection(UISelectionEvent event)

      Specified by:
      getOnUISelectionMethod in interface IUISelectionComp
      Returns:
      The method, or null if none is registered.
    • isHTMLItemSupportEnabled

      public boolean isHTMLItemSupportEnabled()
      Returns if list data items support HTML or not.
      Returns:
      true if items are as HTML KStrings are allowed or not.
    • getListDataColumn

      public VSColumnHeader getListDataColumn()
      Gets the VS column for the list data.
      Returns:
      The instance of the VS Column used for the list data, or null for none.
    • getTranslationColumn

      public VSColumnHeader getTranslationColumn()
      Gets the VS column for the translation list.
      Returns:
      The instance of the VS Column used for translation, or null for none.
    • onResolved

      public void onResolved(VSRelativeReference<?> reference, VSColumnHeader column)
      Called when the property reference has been resolved. UI components use this method to set its state according to the field. The contents of the list data is refreshed at a later stage.
      Specified by:
      onResolved in interface IVSColumnListener
      Parameters:
      reference - The VSRelativeReference instance holding the reference.
      column - The target reference.
    • onBroken

      public void onBroken(VSRelativeReference<?> reference, VSColumnHeader column)
      Called when the property reference has been broken, i.e. unresolved.
      Specified by:
      onBroken in interface IVSColumnListener
      Parameters:
      reference - The VSRelativeReference instance holding the reference.
      column - The target reference.
    • getBestVSColumnHeaderValueType

      public Value.Type getBestVSColumnHeaderValueType(VSRelativeReference<?> reference)
      Requests the value type that would best suit the listener.
      Specified by:
      getBestVSColumnHeaderValueType in interface IVSColumnBestValueListener
      Parameters:
      reference - The VSRelativeReference instance holding the reference.
      Returns:
      Type.String is the best representation of the column data for a combobox.
    • onStateChanged

      public void onStateChanged(VSColumnHeader column, IVSComponentState.State state, boolean on)
      Called when the column changes state.
      Specified by:
      onStateChanged in interface IVSColumnListener
      Parameters:
      column - The VS table column.
      state - The state change, possible values ENABLED, READONLY, VISIBLE or SELECTED.
      on - New state.
    • onSingleSelectionChanged

      public void onSingleSelectionChanged(VSColumnHeader column, int rowIndex)
      Called when the row selection in table single-selection mode is changed to forward to column listeners.
      Specified by:
      onSingleSelectionChanged in interface IVSColumnListener
      Parameters:
      column - The column.
      rowIndex - The row index selected, -1 for none.
    • onSelectionChanged

      public void onSelectionChanged(VSColumnHeader column, VSRow row, int rowIndex, boolean isSelected)
      Called when the row selection is changed to forward to column listeners.
      Specified by:
      onSelectionChanged in interface IVSColumnListener
      Parameters:
      column - The column.
      row - The row that was changed.
      rowIndex - The row index.
      isSelected - The selected state.
    • onRowAdded

      public void onRowAdded(VSColumnHeader column, VSRow row, int rowIndex)
      Called when a row has been added to the table.
      Specified by:
      onRowAdded in interface IVSColumnListener
      Parameters:
      column - The column.
      row - The row that was added.
      rowIndex - The row index where it was inserted.
    • onRowRemoved

      public void onRowRemoved(VSColumnHeader column, VSRow row, int rowIndex)
      Called when a row has been removed from the table.
      Specified by:
      onRowRemoved in interface IVSColumnListener
      Parameters:
      column - The column.
      row - The row that was removed.
      rowIndex - The row index before removal.
    • onStateChanged

      public void onStateChanged(VSColumnHeader column, VSField cell, IVSComponentState.State state, boolean on)
      Called when a cell in the column changes state.
      Specified by:
      onStateChanged in interface IVSColumnListener
      Parameters:
      column - The VS column.
      cell - The VS field.
      state - The state change.
      on - New state.
    • onCellValueChanged

      public void onCellValueChanged(VSColumnHeader column, VSField cell, Value value, GProp<?> trigger, IPostEventProcessing postProcessing)
      Called when the cell value is set in the column.
      Specified by:
      onCellValueChanged in interface IVSColumnListener
      Parameters:
      column - The VS column.
      cell - The VS field.
      value - The value, never null, but value.isNull() could be true.
      trigger - The trigger property that may be null.
      postProcessing - Post-processing instance.
    • updateContents

      protected void updateContents(int flags)
      Called to update the contents if required with new data. The method does nothing if e.g. a call to refresh(int) hasn't been called.
    • getVisualLength

      public int getVisualLength()
      Returns the visual length of the entry field.
      Returns:
      The visual length or 15 by default.
    • getApproximateSize

      public Size getApproximateSize()
      Returns the size of the component in pixels. The size is a calculation and does not exactly reflect the real size that may be different due to additional styles not taken into account by this method. The size is calculated from the font of the component and default or defined values (such as character length or number of lines for text area).
      Specified by:
      getApproximateSize in class UIComp
      Returns:
      The size of the component: 16x16.