Class WEditor

java.lang.Object
org.adempiere.webui.editor.WEditor
All Implemented Interfaces:
PropertyChangeListener, EventListener, IInputValidator, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event>
Direct Known Subclasses:
SchedulerStateEditor, WAccountEditor, WAssignmentEditor, WBinaryEditor, WButtonEditor, WChartEditor, WChosenboxListEditor, WChosenboxSearchEditor, WColorEditor, WDashboardContentEditor, WDateEditor, WDatetimeEditor, WFileDirectoryEditor, WFilenameEditor, WGridTabMultiSelectionEditor, WGridTabSingleSelectionEditor, WHtmlEditor, WHTMLEditor, WImageEditor, WInfoPAttributeEditor, WLocationEditor, WLocationEditor, WLocatorEditor, WNumberEditor, WPAttributeEditor, WPaymentEditor, WRadioGroupEditor, WRecordEditor, WSearchEditor, WStringEditor, WSurveyEditor, WTableDirEditor, WTaxesEditor, WTimeEditor, WTimeZoneEditor, WUrlEditor, WYesNoEditor

public abstract class WEditor extends Object implements org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.Event>, PropertyChangeListener, IInputValidator
Base class for field editor.
Version:
$Revision: 0.10 $
Author:
Ashley G Ramdass
  • Field Details

    • IDEMPIERE_EDITOR_ATTR

      public static final String IDEMPIERE_EDITOR_ATTR
      Component attribute to store reference to WEditor instance
      See Also:
    • MAX_DISPLAY_LENGTH

      public static final int MAX_DISPLAY_LENGTH
      Max display length for string editor
      See Also:
    • INIT_EDIT_EVENT

      public static final String INIT_EDIT_EVENT
      Event to indicate start of editing a text field
      See Also:
    • gridField

      protected GridField gridField
    • gridTab

      protected GridTab gridTab
    • label

      protected Label label
    • component

      protected org.zkoss.zk.ui.Component component
      Component of this editor
    • mandatory

      protected boolean mandatory
    • listeners

      protected ArrayList<ValueChangeListener> listeners
    • readOnly

      protected boolean readOnly
    • popupMenu

      protected WEditorPopupMenu popupMenu
      Context menu
    • tableEditor

      protected boolean tableEditor
      true if it is use inside a grid/list view
  • Constructor Details

    • WEditor

      public WEditor(org.zkoss.zk.ui.Component comp, GridField gridField)
      Parameters:
      comp -
      gridField -
    • WEditor

      public WEditor(org.zkoss.zk.ui.Component comp, GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration)
      Parameters:
      comp -
      gridField -
      tableEditor -
      editorConfiguration -
    • WEditor

      public WEditor(org.zkoss.zk.ui.Component comp, GridField gridField, int rowIndex)
      Parameters:
      comp -
      gridField -
      rowIndex -
    • WEditor

      public WEditor(org.zkoss.zk.ui.Component comp, GridField gridField, int rowIndex, boolean tableEditor, IEditorConfiguration editorConfiguration)
      Parameters:
      comp -
      gridField -
      rowIndex -
      tableEditor - editor for Grid
      editorConfiguration -
    • WEditor

      public WEditor(org.zkoss.zk.ui.Component comp, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
      Constructor to use if a grid field is unavailable
      Parameters:
      comp - The editor's component
      label - field label
      description - description of component
      mandatory - whether field is mandatory
      readonly - whether or not the editor is read only
      updateable - whether the editor contents can be changed
    • WEditor

      public WEditor(org.zkoss.zk.ui.Component comp, String columnName, String label, String description, boolean mandatory, boolean readonly, boolean updateable)
      Constructor to use if a grid field is unavailable
      Parameters:
      comp - The editor's component
      columnName - column name
      label - field label
      description - description of component
      mandatory - whether field is mandatory
      readonly - whether or not the editor is read only
      updateable - whether the editor contents can be changed
  • Method Details

    • showMenu

      public void showMenu()
      call to show context menu of this field.
      must call after append component of this field to parent
    • setChangeEventWhenEditing

      public void setChangeEventWhenEditing(boolean isChangeEventWhenEditing)
      By default, zk component fire onChange event when component loss focus.
      Call this method with true value let component fire event when user type first character.
      Note: editor that set this to true also need to handle INIT_EDIT_EVENT to take effect, please see implementation at WStringEditor.onEvent(Event) for reference.
      Parameters:
      isChangeEventWhenEditing -
    • getDescription

      public String getDescription()
      Returns:
      description
    • setComponent

      protected void setComponent(org.zkoss.zk.ui.Component comp)
      Set the editor component.
      Parameters:
      comp - the editor component
    • getGridField

      public GridField getGridField()
      Returns:
      grid field for this editor ( can be null )
    • getColumnName

      public String getColumnName()
      Returns:
      column name
    • cleanColumnName

      protected String cleanColumnName(String originalColumnName)
      Remove the table qualifier from the supplied column name.

      The column name may be prefixed with the table name i.e. [table name].[column name]. The function returns the [column name] part.

      Parameters:
      originalColumnName - The column name to clean
      Returns:
      the column name with any table qualifier removed i.e. [column name]
    • setColumnName

      protected void setColumnName(String columnName)
      Parameters:
      columnName -
    • getComponent

      public org.zkoss.zk.ui.Component getComponent()
      Returns:
      Component
    • setGridTab

      public void setGridTab(GridTab gridTab)
      Parameters:
      gridTab -
    • getPopupMenu

      public WEditorPopupMenu getPopupMenu()
      Returns:
      popup menu instance ( if available )
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Handle PropertyChangeEvent from gridField.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      evt -
    • addValueChangeListener

      public void addValueChangeListener(ValueChangeListener listener)
      Parameters:
      listener - ValueChangeListener
    • removeValuechangeListener

      public boolean removeValuechangeListener(ValueChangeListener listener)
      Parameters:
      listener -
      Returns:
      true if listener is found and remove from listeners
    • fireValueChange

      public void fireValueChange(ValueChangeEvent event)
      Fire ValueChangeEvent to ValueChangeListener in listeners
      Parameters:
      event -
    • getLabel

      public Label getLabel()
      Returns:
      Label
    • setReadWrite

      public abstract void setReadWrite(boolean readWrite)
      Parameters:
      readWrite -
    • isReadWrite

      public abstract boolean isReadWrite()
      Returns:
      true if editable
    • setVisible

      public void setVisible(boolean visible)
      Parameters:
      visible -
    • setVisible

      public void setVisible(boolean visible, boolean labelVisible)
      Parameters:
      visible - visibility for component
      labelVisible - visibility for label
    • isVisible

      public boolean isVisible()
      Returns:
      true if component is visible
    • setBackground

      public void setBackground(boolean error)
      Indicating error with changing the style.
      No op. here, for subclass to implement.
      Parameters:
      error -
    • setBackground

      public void setBackground(Color color)
      Set background color of component.
      No op. here, for subclass to implement.
      Parameters:
      color -
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setValue

      public abstract void setValue(Object value)
      Set editor value
      Parameters:
      value -
    • getValue

      public abstract Object getValue()
      Returns:
      Object, current value of editor
    • getDisplay

      public abstract String getDisplay()
      Returns:
      display text
    • getDisplayTextForGridView

      public String getDisplayTextForGridView(Object value)
      Parameters:
      value -
      Returns:
      display text for grid view, for consumption by getDisplayComponent()
    • getDisplayTextForGridView

      public String getDisplayTextForGridView(GridRowCtx gridRowCtx, Object value)
      Parameters:
      gridRowCtx - GridRowCtx
      value -
      Returns:
      display text for grid view, for consumption by getDisplayComponent()
    • getEvents

      public String[] getEvents()
      Returns:
      list of component events that this editor will listen to
    • setMandatory

      public void setMandatory(boolean mandatory)
      Set whether the editor represents a mandatory field.
      Parameters:
      mandatory - whether the field is mandatory
    • isMandatory

      public boolean isMandatory()
      Returns:
      true if field is mandatory
    • dynamicDisplay

      public void dynamicDisplay()
      Dynamic update of component state
    • dynamicDisplay

      public void dynamicDisplay(Properties ctx)
      Dynamic update of component state
      Parameters:
      ctx -
    • updateStyle

      public void updateStyle(boolean applyDictionaryStyle)
      Update label and component style
      Parameters:
      applyDictionaryStyle -
    • updateStyle

      public void updateStyle()
      Update label and component style
    • applyLabelStyles

      protected void applyLabelStyles(boolean applyDictionaryStyle)
      Update label styles
      Parameters:
      applyDictionaryStyle -
    • setLabelStyle

      protected void setLabelStyle(String style)
      Set label style
      Parameters:
      style - sclass name (@sclass=) or zclass name (@zclass=) or css style string
    • applyFieldStyles

      protected void applyFieldStyles(boolean applyDictionaryStyle)
      Update field styles
      Parameters:
      applyDictionaryStyle -
    • setFieldStyle

      protected void setFieldStyle(String style)
      Set field style
      Parameters:
      style - sclass name (@sclass=) or zclass name (@zclass=) or css style string
    • isSearchable

      public boolean isSearchable()
      Returns:
      true if usable in find window, false otherwise
    • buildStyle

      protected String buildStyle(int AD_Style_ID)
      Build css inline style from AD_Style record
      Parameters:
      AD_Style_ID -
      Returns:
      css inline style string
    • fillHorizontal

      public void fillHorizontal()
      Stretch editor component to fill parent
    • updateLabelStyle

      public void updateLabelStyle()
      Deprecated.
    • isMandatoryStyle

      public boolean isMandatoryStyle()
      Returns:
      true if mandatory style should be added to editor
    • isNullOrEmpty

      public boolean isNullOrEmpty()
      Returns:
      true if current value of editor is null or empty
    • isZoomable

      public boolean isZoomable()
      Returns:
      true if editor support zoom command
    • setTableEditor

      public void setTableEditor(boolean tableEditorMode)
      Set grid view mode. Have no effect if editor doesn't has a separate grid view mode.
      Parameters:
      tableEditorMode -
    • isShowPreference

      protected boolean isShowPreference()
      Returns:
      true if preference dialog is available and accessible
    • addChangeLogMenu

      protected void addChangeLogMenu(WEditorPopupMenu popupMenu)
      Add record info entry to context menu
      Parameters:
      popupMenu -
    • addTextEditorMenu

      protected void addTextEditorMenu(WEditorPopupMenu popupMenu)
      Add text editor dialog entry to context menu
      Parameters:
      popupMenu -
    • isComponentOfEditor

      public boolean isComponentOfEditor(org.zkoss.zk.ui.Component comp)
      Parameters:
      comp -
      Returns:
      true if comp is own by this editor instance
    • isProcessParameter

      public boolean isProcessParameter()
      Returns:
      true if editor is use for process parameter field
    • setProcessParameter

      public void setProcessParameter(boolean isProcessParameter)
      Set to true if editor is use for process parameter field
      Parameters:
      isProcessParameter -
    • getDisplayComponent

      public org.zkoss.zk.ui.Component getDisplayComponent()
      Return component use for display mode in ADTabpanel grid view (GridTabRowRenderer) or custom editor of WListItemRenderer.
      For GridTabRowRenderer, only Html is supported and will use content from getDisplayTextForGridView(GridRowCtx, Object).
      For WListItemRenderer, Html, Label and InputElement is supported.
      Return null to use the default of ADTabpanel or WListbox.
      Note: because each row must has one instance of this component, don't reuse, must always create new instance.
      Returns:
      Display Component
    • focusNext

      protected void focusNext()
      Set focus to next editor
    • getStyleEvaluatee

      protected Evaluatee getStyleEvaluatee()
      Return Evaluatee for buildStyle(int) use.
      Returns:
      Evaluatee
    • getValidInput

      public String getValidInput()
      Description copied from interface: IInputValidator
      Get Valid Input
      Specified by:
      getValidInput in interface IInputValidator
      Returns:
      Expected input string from user
    • setValidInput

      public void setValidInput(String validInput)
      Description copied from interface: IInputValidator
      Set string to validate against user input
      Specified by:
      setValidInput in interface IInputValidator
    • isValid

      public boolean isValid(String input)
      Description copied from interface: IInputValidator
      Is Input Valid
      Specified by:
      isValid in interface IInputValidator
      Returns:
      true if input validate against IInputValidator.getValidInput()
    • addDynamicDisplayListener

      public void addDynamicDisplayListener(WEditor.DynamicDisplayListener listener)
      Parameters:
      listener - WEditor.DynamicDisplayListener
    • removeDynamicDisplayListener

      public boolean removeDynamicDisplayListener(WEditor.DynamicDisplayListener listener)
      Parameters:
      listener - WEditor.DynamicDisplayListener
      Returns:
      true if listener is found and remove from listener list (dynamicDisplayListeners).