Package org.adempiere.webui.editor
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
,WImageEditor
,WImageURLEditor
,WInfoPAttributeEditor
,WLocationEditor
,WLocatorEditor
,WNumberEditor
,WPAttributeEditor
,WPaymentEditor
,WRadioGroupEditor
,WRecordEditor
,WSearchEditor
,WStringEditor
,WTableDirEditor
,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.
- Author:
- Ashley G Ramdass
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
interface for dynamic display listener -
Field Summary
Modifier and TypeFieldDescriptionprotected org.zkoss.zk.ui.Component
Component of this editorprotected GridField
protected GridTab
static final String
Component attribute to store reference to WEditor instancestatic final String
Event to indicate start of editing a text fieldprotected Label
protected ArrayList<ValueChangeListener>
protected boolean
static final int
Max display length for string editorprotected WEditorPopupMenu
Context menuprotected boolean
protected boolean
true if it is use inside a grid/list view -
Constructor Summary
ConstructorDescriptionWEditor
(org.zkoss.zk.ui.Component comp, String label, String description, boolean mandatory, boolean readonly, boolean updateable) Constructor to use if a grid field is unavailableWEditor
(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 unavailableWEditor
(org.zkoss.zk.ui.Component comp, GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) WEditor
(org.zkoss.zk.ui.Component comp, GridField gridField, int rowIndex, boolean tableEditor, IEditorConfiguration editorConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addChangeLogMenu
(WEditorPopupMenu popupMenu) Add record info entry to context menuvoid
add listener fordynamicDisplay(Properties)
protected void
addTextEditorMenu
(WEditorPopupMenu popupMenu) Add text editor dialog entry to context menuvoid
addValueChangeListener
(ValueChangeListener listener) protected void
applyFieldStyles
(boolean applyDictionaryStyle) Update field stylesprotected void
applyLabelStyles
(boolean applyDictionaryStyle) Update label stylesprotected String
buildStyle
(int AD_Style_ID) Build css inline style from AD_Style recordprotected String
cleanColumnName
(String originalColumnName) Remove the table qualifier from the supplied column name.void
Dynamic update of component statevoid
dynamicDisplay
(Properties ctx) Dynamic update of component statevoid
Stretch editor component to fill parentvoid
fireValueChange
(ValueChangeEvent event) Fire ValueChangeEvent to ValueChangeListener inlisteners
protected void
Set focus to next editororg.zkoss.zk.ui.Component
abstract String
org.zkoss.zk.ui.Component
Return component use for display mode inADTabpanel
grid view (GridTabRowRenderer
) or custom editor ofWListItemRenderer
.
ForGridTabRowRenderer
, onlyHtml
is supported and will use content fromgetDisplayTextForGridView(GridRowCtx, Object)
.
ForWListItemRenderer
,Html
,Label
andInputElement
is supported.
Return null to use the default ofADTabpanel
orWListbox
.
Note: because each row must has one instance of this component, don't reuse, must always create new instance.getDisplayTextForGridView
(Object value) getDisplayTextForGridView
(GridRowCtx gridRowCtx, Object value) String[]
getLabel()
protected Evaluatee
Return Evaluatee forbuildStyle(int)
use.Get text for input validationabstract Object
getValue()
boolean
isComponentOfEditor
(org.zkoss.zk.ui.Component comp) boolean
boolean
boolean
boolean
abstract boolean
boolean
protected boolean
boolean
Is Input Validboolean
boolean
void
Handle PropertyChangeEvent fromgridField
.boolean
boolean
removeValuechangeListener
(ValueChangeListener listener) void
setBackground
(boolean error) Indicating error with changing the style.
No op. here, for subclass to implement.void
setBackground
(Color color) Set background color of component.
No op. here, for subclass to implement.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.protected void
setColumnName
(String columnName) protected void
setComponent
(org.zkoss.zk.ui.Component comp) Set the editor component.protected void
setFieldStyle
(String style) Set field stylevoid
setGridTab
(GridTab gridTab) protected void
setLabelStyle
(String style) Set label stylevoid
setMandatory
(boolean mandatory) Set whether the editor represents a mandatory field.void
setProcessParameter
(boolean isProcessParameter) Set to true if editor is use for process parameter fieldabstract void
setReadWrite
(boolean readWrite) void
setTableEditor
(boolean tableEditorMode) Set grid view mode.void
setValidInput
(String validInput) Set string to validate against user inputabstract void
Set editor valuevoid
setVisible
(boolean visible) void
setVisible
(boolean visible, boolean labelVisible) void
showMenu()
call to show context menu of this field.
must call after append component of this field to parenttoString()
void
Deprecated.void
Update label and component stylevoid
updateStyle
(boolean applyDictionaryStyle) Update label and component styleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.zkoss.zk.ui.event.EventListener
onEvent
-
Field Details
-
IDEMPIERE_EDITOR_ATTR
Component attribute to store reference to WEditor instance- See Also:
-
MAX_DISPLAY_LENGTH
public static final int MAX_DISPLAY_LENGTHMax display length for string editor- See Also:
-
INIT_EDIT_EVENT
Event to indicate start of editing a text field- See Also:
-
gridField
-
gridTab
-
label
-
component
protected org.zkoss.zk.ui.Component componentComponent of this editor -
mandatory
protected boolean mandatory -
listeners
-
readOnly
protected boolean readOnly -
popupMenu
Context menu -
tableEditor
protected boolean tableEditortrue if it is use inside a grid/list view
-
-
Constructor Details
-
WEditor
- Parameters:
comp
-gridField
-
-
WEditor
public WEditor(org.zkoss.zk.ui.Component comp, GridField gridField, boolean tableEditor, IEditorConfiguration editorConfiguration) - Parameters:
comp
-gridField
-tableEditor
-editorConfiguration
-
-
WEditor
- 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 GrideditorConfiguration
-
-
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 componentlabel
- field labeldescription
- description of componentmandatory
- whether field is mandatoryreadonly
- whether or not the editor is read onlyupdateable
- 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 componentcolumnName
- column namelabel
- field labeldescription
- description of componentmandatory
- whether field is mandatoryreadonly
- whether or not the editor is read onlyupdateable
- 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 atWStringEditor.onEvent(Event)
for reference.- Parameters:
isChangeEventWhenEditing
-
-
getDescription
- Returns:
- description
-
setComponent
protected void setComponent(org.zkoss.zk.ui.Component comp) Set the editor component.- Parameters:
comp
- the editor component
-
getGridField
- Returns:
- grid field for this editor ( can be null )
-
getColumnName
- Returns:
- column name
-
cleanColumnName
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
- Parameters:
columnName
-
-
getComponent
public org.zkoss.zk.ui.Component getComponent()- Returns:
- Component
-
setGridTab
- Parameters:
gridTab
-
-
getPopupMenu
- Returns:
- popup menu instance ( if available )
-
propertyChange
Handle PropertyChangeEvent fromgridField
.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
evt
-
-
addValueChangeListener
- Parameters:
listener
- ValueChangeListener
-
removeValuechangeListener
- Parameters:
listener
-- Returns:
- true if listener is found and remove from
listeners
-
fireValueChange
Fire ValueChangeEvent to ValueChangeListener inlisteners
- Parameters:
event
-
-
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 componentlabelVisible
- 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
Set background color of component.
No op. here, for subclass to implement.- Parameters:
color
-
-
toString
-
setValue
Set editor value- Parameters:
value
-
-
getValue
- Returns:
- Object, current value of editor
-
getDisplay
- Returns:
- display text
-
getDisplayTextForGridView
- Parameters:
value
-- Returns:
- display text for grid view, for consumption by
getDisplayComponent()
-
getDisplayTextForGridView
- Parameters:
gridRowCtx
-GridRowCtx
value
-- Returns:
- display text for grid view, for consumption by
getDisplayComponent()
-
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
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
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
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
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
Add record info entry to context menu- Parameters:
popupMenu
-
-
addTextEditorMenu
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 inADTabpanel
grid view (GridTabRowRenderer
) or custom editor ofWListItemRenderer
.
ForGridTabRowRenderer
, onlyHtml
is supported and will use content fromgetDisplayTextForGridView(GridRowCtx, Object)
.
ForWListItemRenderer
,Html
,Label
andInputElement
is supported.
Return null to use the default ofADTabpanel
orWListbox
.
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
Return Evaluatee forbuildStyle(int)
use.- Returns:
- Evaluatee
-
getValidInput
Description copied from interface:IInputValidator
Get text for input validation- Specified by:
getValidInput
in interfaceIInputValidator
- Returns:
- Expected input string from user
-
setValidInput
Description copied from interface:IInputValidator
Set string to validate against user input- Specified by:
setValidInput
in interfaceIInputValidator
-
isValid
Description copied from interface:IInputValidator
Is Input Valid- Specified by:
isValid
in interfaceIInputValidator
- Returns:
- true if input validate against
IInputValidator.getValidInput()
-
addDynamicDisplayListener
add listener fordynamicDisplay(Properties)
- Parameters:
listener
-WEditor.DynamicDisplayListener
-
removeDynamicDisplayListener
- Parameters:
listener
-WEditor.DynamicDisplayListener
- Returns:
- true if listener is found and remove from listener list (
dynamicDisplayListeners
).
-