Class MLItem

java.lang.Object
com.iizix.prop.ui.mlist.MLItem
All Implemented Interfaces:
IContentData<MLItemProp>, ICustomDataProvider
Direct Known Subclasses:
MLCheckBox, MLComboBox, MLDateTime, MLRadioButton, MLSimple, MLSlider, MLSpinner, MLSwitch, MLText

public abstract class MLItem extends Object implements IContentData<MLItemProp>, ICustomDataProvider
The list item for the mobile list.
Author:
Christopher Mindus
  • Field Details

  • Method Details

    • forbiddenGetCustomDataMap

      @Deprecated public Map<String,Object> forbiddenGetCustomDataMap(boolean doCreate)
      Deprecated.
      Gets or creates the provider map. This method is not intended to be called by user code, it is used by the system.

      Do not call this method!

      Specified by:
      forbiddenGetCustomDataMap in interface ICustomDataProvider
      Parameters:
      doCreate - Creates the map if required.
      Returns:
      The map or newly created map, null if not created.

      Note: the map returned is NOT synchronized thus not thread safe. It is up to the caller to synchronize on it to ensure thread safety.

    • getItemProp

      public MLItemProp getItemProp()
      Returns the item property assigned for this instance.

      If the property is disposed, it is unassigned.

      Specified by:
      getItemProp in interface IContentData<MLItemProp>
      Returns:
      The property instance.
    • getGroup

      public MLGroup getGroup()
      Gets the group associated with this item.
      Returns:
      The group if a property item is associated and not disposed of, null otherwise.
    • getType

      public abstract MLItemType getType()
      Gets the type of the list item.
      Returns:
      The type.
    • getLeadingTextColumn

      protected abstract int getLeadingTextColumn()
      Returns the column index for the leading text. Types supporting description text must override this method.
      Returns:
      The column index, or -1 for none.
    • getDescriptionColumn

      protected abstract int getDescriptionColumn()
      Returns the column index for the description. Types supporting description text must override this method.
      Returns:
      The column index, or -1 for none.
    • refreshFromVS

      public abstract void refreshFromVS(int[] columns)
      Refreshes contents from VirtualSpace.
      Specified by:
      refreshFromVS in interface IContentData<MLItemProp>
      Parameters:
      columns - The connected table columns indicies, -1 for none.
    • getVSRow

      public VSRow getVSRow()
      Gets the associated VSRow for this item.
      Specified by:
      getVSRow in interface IContentData<MLItemProp>
      Returns:
      The row, or null if not associated with VirtualSpace.
    • isVisible

      public boolean isVisible()
      Gets the visibility state.

      This is the items individual state and does not take parent states into account.

      Returns:
      true for visible, false for hidden.
    • isEnabled

      public boolean isEnabled()
      Gets the enabled state.

      This is the items individual state and does not take parent states into account.

      Returns:
      true for enabled, false for disabled.
    • isReadOnly

      public boolean isReadOnly()
      Gets the read-only state.

      This is the items individual state and does not take parent states into account.

      Returns:
      true for read-only, false otherwise.
    • isSelected

      public boolean isSelected()
      Gets the selection state of the item.
      Specified by:
      isSelected in interface IContentData<MLItemProp>
      Returns:
      The selected state.
    • hasActionSupport

      public boolean hasActionSupport()
      Returns if the list item has action support or not.
      Returns:
      true for action support (default) or not.
    • getSelectionState

      public int getSelectionState()
      Gets the selection state.
      Returns:
      0=unselected, 1=selected, 2=third state (when applicable).
    • setVisible

      public boolean setVisible(boolean newState)
      Gets the visibility state.

      This is the items individual state and does not take parent states into account.

      Parameters:
      newState - The new state: true for visible, false for hidden.
      Returns:
      true for changed state, false for no change.
    • setEnabled

      public boolean setEnabled(boolean newState)
      Gets the enabled state.

      This is the items individual state and does not take parent states into account.

      Parameters:
      newState - The new state: true for enabled, false for disabled.
      Returns:
      true for changed state, false for no change.
    • setReadOnly

      public boolean setReadOnly(boolean newState)
      Gets the read-only state.

      This is the items individual state and does not take parent states into account.

      Parameters:
      newState - The new state: true for read-only, false otherwise.
      Returns:
      true for changed state, false for no change.
    • setActionSupport

      public boolean setActionSupport(boolean newState)
      Sets the action support state, i.e. if the user can touch-click the item and cause an action even when no arrows are present.
      Parameters:
      newState - The new action enabled state.
      Returns:
      true for changed state, false for no change.
    • setSelection

      public String setSelection(boolean on)
      Sets the selection state of an item.
      Specified by:
      setSelection in interface IContentData<MLItemProp>
      Parameters:
      on - The new selection state.
      Returns:
      null for success, otherwise an error message why the selection failed.
    • setSelected

      public boolean setSelected(int state)
      Sets the selection state: 0=unselected, 1=selected, 2=third state.
      Parameters:
      state - The state.
      Returns:
      true for state changed, false for no change.
      Throws:
      IllegalArgumentException - If the component doesn't support third state and state==2.
    • setSelectionInternal

      public String setSelectionInternal(boolean on)
      Internal method to sets the selection state of an item. This method is not intended to be called as it is used by the framework and will not cause a callback or event notification of selection changes.
      Specified by:
      setSelectionInternal in interface IContentData<MLItemProp>
      Parameters:
      on - The new selection state.
      Returns:
      null for success, empty string for no change, otherwise an error message why the selection failed.
    • getSelectionPropName

      protected String getSelectionPropName()
      Returns the IntProp property name used to set the selection to.
      Returns:
      The selection property name, or null if not supported (default). Override this method to return the appropriate name when supported.
    • doBooleanSelectionOnly

      protected boolean doBooleanSelectionOnly()
      Returns if the selection property is a boolean value and a BoolProp is used to set the selection state that can be on/off or 1/0 only (2 = third state is not allowed).
      Returns:
      true To use BoolProp for selection and throw error for third state (2) selection value, false for checkboxes that use an IntProp for selection and supports third state.
    • getLeadingText

      public KString getLeadingText()
      Gets the leading text for the list item.
      Returns:
      The text, or null if none is set.
    • setLeadingText

      public boolean setLeadingText(KString text)
      Sets the leading text for the list item.
      Parameters:
      text - The new text, or null for none.
      Returns:
      true for changed, false for no change.
    • setDescription

      public boolean setDescription(KString descr)
      Sets the text for the list item.
      Parameters:
      descr - The new description string, or null for none.
      Returns:
      true for changed, false for no change.
    • getLeadingWidth

      public GUnit getLeadingWidth()
      Gets the width of leading text.
      Returns:
      The width, or null for none.
    • setLeadingWidth

      public boolean setLeadingWidth(GUnit width)
      Gets the width of leading text. The width must be Strict CSS and may not be a percent value or a formula.
      Parameters:
      width - The width, or null for to clear it.
      Returns:
      true for changed, false for no change.
      Throws:
      IllegalArgumentException - If the width is a formula or percent value.
    • getLeadingTextWrap

      public int getLeadingTextWrap()
      Gets option for leading text wrap.
      Returns:
      The leading text wrap, multiple(0), single line(1), ellipsis(2).
    • setLeadingTextWrap

      public boolean setLeadingTextWrap(int opt)
      Sets the option for leading text wrap.
      Parameters:
      opt - The wrap option:
      0 = wrap over multiple lines,
      1 = truncated to single line, or
      2 = ellipsis when single line overflows.
      Returns:
      true for changed, false for no change.
      Throws:
      IllegalArgumentException - If opt is not 0-2.
    • setLeadingTextWrap

      public boolean setLeadingTextWrap()
      Sets the option for leading text to wrap over multiple line.
      Returns:
      true for changed, false for no change.
    • setLeadingTextSingleLine

      public boolean setLeadingTextSingleLine()
      Sets the option for leading text to single line, truncated.
      Returns:
      true for changed, false for no change.
    • setLeadingTextEllipsis

      public boolean setLeadingTextEllipsis()
      Sets the option for leading text to single line with ellipsis when text overflows.
      Returns:
      true for changed, false for no change.
    • getIcon

      public IImageTarget getIcon()
      Gets the image assigned as the icon for the list item.
      Returns:
      The image instance, or null for none.
    • setIcon

      public boolean setIcon(IImageTarget image)
      Sets the image assigned as the icon for the list item.
      Parameters:
      image - The image instance, or null for none.
      Returns:
      true for changed, false for no changes.
      Throws:
      IllegalArgumentException - If the image target is not valid.
    • setIconPadding

      public boolean setIconPadding(GUnit margin)
      Sets the icon margin. All margins top/right/bottom/left are affected and set or cleared.
      Parameters:
      margin - The margin, null to remove it.
      Returns:
      true for changed, false for no change.
    • setIconMargins

      public boolean setIconMargins(GUnit[] margins)
      Sets the icon margins.
      Parameters:
      margins - The margins, null to remove them.

      The indicies in the array are:

      • [0] top
      • [1] right
      • [2] bottom
      • [3] left

      Any entry may be null where this means it is not defined. All entries set to null is the same as passing null as parameter.

      Returns:
      true for changed, false for no change.
      Throws:
      IllegalArgumentException - If the array is not of length 4.
    • getIconMargins

      public GUnit[] getIconMargins()
      Gets the margins for the icon.
      Returns:
      The margins, null for none, otherwise an array of 4 values where a null value means it is not set.

      The indicies in the array are:

      • [0] top
      • [1] right
      • [2] bottom
      • [3] left
    • getContextMenu

      public UIContextMenu getContextMenu()
      Gets the context menu assigned to the list item.
      Returns:
      The context menu, or null for none.
    • setContextMenu

      public boolean setContextMenu(UIContextMenu contextMenu)
      Sets the context menu to use for the item.
      Parameters:
      contextMenu - The context menu, or null to remove it.
      Returns:
      true for changed, false for no change.
    • addMappings

      public void addMappings(VSMappings mappings, String uiRef, MLItemProp item)
      Adds the mappings of a VirtualSpace to the panel components.

      The default is to find the relative references to VS and add those references. Override to provide other functionality.

      Specified by:
      addMappings in interface IContentData<MLItemProp>
      Parameters:
      mappings - The mappings instance to fill in.
      uiRef - The reference.
      item - The item property.