Package com.iizigo.prop
Class BaseEditor<PROP extends GProp<?>,PROP_VALUE> 
java.lang.Object
com.iizigo.prop.BaseEditor<PROP,PROP_VALUE> 
- All Implemented Interfaces:
- IThemeListener,- IEditedPropControllerOwner<PROP,,- PROP_VALUE> - IEditedPropertyEntry<PROP,,- PROP_VALUE> - IEditedPropertyEntryMultiProp<PROP,,- PROP_VALUE> - IPropertyDefined
- Direct Known Subclasses:
- BadgePropEditor,- BoolPropEditor,- BoxShadowPropEditor,- ClassReferencePropEditor,- ColorPropEditor,- DateTimePropEditor,- DropShadowPropEditor,- DurationPropEditor,- EncodingPropEditor,- FillPropEditor,- FontPropEditor,- GradientPropEditor,- IntChoicePropEditor,- IntPropEditor,- KStringPropEditor,- LongPropEditor,- MethodReferencePropEditor,- NumberPropEditor,- PanelAnimationPropEditor,- PasswordPropEditor,- PKCS12IdentityPropEditor,- ReferencePropEditor,- SessionConfigPropEditor,- SizePropEditor,- StringMapPropEditor,- StringPropEditor,- StrokePropEditor,- StylesReferencesPropEditor,- StylesStatesPropEditor,- TextShadowPropEditor,- ThemesPropEditor,- TooltipPropEditor,- TransformPropEditor,- UIDateTimeTypePropEditor,- UnitPropEditor,- UnitsPropEditor,- ValuePropEditor,- ValueTypePropEditor,- VSRelativeReferencePropEditor,- VSTableColumnReferencePropEditor
public abstract class BaseEditor<PROP extends GProp<?>,PROP_VALUE>  extends Object implements IEditedPropertyEntryMultiProp<PROP,PROP_VALUE>, IEditedPropControllerOwner<PROP,PROP_VALUE>, IPropertyDefined, IThemeListener  
The generic base editor for any property editor.
- Author:
- Christopher Mindus
- Field SummaryFieldsModifier and TypeFieldDescription- protected ApplicationUIThe ApplicationUI instance.- protected org.eclipse.swt.custom.CComboThe combobox or null for none.- protected org.eclipse.swt.widgets.ControlThe control for editing, a Text or CCombo.- protected IPropertyEditorControllerThe controller editor part.- protected DefinedButtonThe define-button or null for none.- protected org.eclipse.swt.widgets.DisplayThe display.- protected PropertyEditorThe property editor instance.- protected final org.eclipse.swt.events.FocusListenerSWT focus listener, should be added to all controls that can receive focus for this property editor.- protected booleanFlag for entry has been modified during focus.- protected PropertyEditorInfoThe information about edited item.- protected org.eclipse.swt.widgets.ButtonA "More..." button, null for none.- protected StringMultiple value warning input string, null for none.- protected String[]The options for the property editor, or null for none.- protected org.eclipse.swt.widgets.CompositeParent composite, where to place components.- protected EditedPropController<PROP,- PROP_VALUE> The edited property controller.- protected org.eclipse.swt.widgets.ShellShell for message boxes, etc.- protected org.eclipse.swt.widgets.TextThe Text control or null for none.- protected IEntryValidatorThe validator, or null for none.- protected booleanFlag for value defined when focus was received.
- Constructor SummaryConstructorsConstructorDescriptionDefault constructor called before createControls, to hold the instance of the edit-property-class for easy access.
- Method SummaryModifier and TypeMethodDescription- assignMaster- (MultiPropCnr master, Class<PROP> propertyClass, PropLabel label) Assigns the master property controller.- voidBegins processing events, blocking e.g.- booleanChecks if it's OK to process events.- protected void- checkInput- (boolean focusLost) Checks the input.- protected abstract void- create()Creates the property editor controls.- protected org.eclipse.swt.custom.CCombo- createCCombo- (String[] entries) Creates a combobox, fills and registers it.- createControls- (PropertyEditor editor, PropertyEditorInfo info, String[] options, org.eclipse.swt.widgets.Composite parent, PropCnr[] containers, Atom atom, DefinedButton definedButton) Creates the required controls in the composite.- protected org.eclipse.swt.layout.GridLayout- createGridLayout- (int count, int cxSpacing) Creates the grid layout for the composite parent and assigns it.- protected IzMenu- createIzMenu- (org.eclipse.swt.widgets.Control control) Creates the menu for a component.- protected void- createMoreButton- (String toolTipText) Creates a "more..." button.- protected IzMenuCreates the menu for a component.- protected org.eclipse.swt.widgets.TextCreates an entry field and registers it.- final void- dispose()Disposes of this instance, cannot be overridden (use onDispose instead).- protected boolean- doUndefineIfEmpty- (boolean focusLost) Keeps empty strings as defined, when input has been changed specifically to empty string, or if the entry was defined when editing began.- protected booleanReturns if the property value should be checked by converting current string input back-and-forth with the current value.- voidBegins processing events, blocking e.g.- abstract String- formatValue- (PROP_VALUE value) Formats the value for user input as a String.- static BaseEditor<?,- ?> - getBaseEditor- (org.eclipse.swt.widgets.Control control) Gets the property editor in question for a control that e.g.Gets the user input.Gets the current value from the property, not user input.Gets the array of values currently used.- abstract PROP_VALUEGets the default defined value to set in the property when defined.- protected org.eclipse.swt.events.ModifyListenerGets the modify listener.Gets a "native" tooltip to use.Gets the options of a specified name as "option=".- protected org.eclipse.swt.events.SelectionListenerGets the selection listener.- intThe error severity.- org.eclipse.swt.widgets.Shell- getShell()Gets the shell.- protected abstract StringGets the tooltip text to display in the entry fields (not the one for property errors or validator).- protected StringGets the tooltip text to display in the entry fields (not the one for property errors).- protected abstract PROP_VALUEGets the property value for a user input.- boolean- hasFocus()Checks if this editor has focus.- void- initialize- (PROP prop) Initializes a newly created property (e.g.- protected booleanChecks if read-only.- void- onDefine- (boolean on) Called from the PropertyDefinedButton.- protected voidCalled when the editor is disposed of.- protected void- onDoubleClick- (org.eclipse.swt.widgets.Event e) Called when mouse is double-clicked in the text or combobox.- void- onError- (String input, String message, int severity, boolean isMultipleValueWarning, boolean isChildError) Called when the property is updated due to an error.- void- onF4List()Called when F4 is pressed in a Text field.- protected voidUpon focus gained, the selection of an entry field is selected fully and for a combobox, cursor is placed first.- protected voidCalled when focus is lost.- void- onMore()Called when the "more..." button is pressed.- void- onReadOnly- (boolean on) Called when the read-only state changes.- final void- onThemeChanged- (ApplicationUI appUI) Called once the new theme has stabilized after a period of time.- voidCalled when the property is undefined.- void- onUpdate- (PROP_VALUE value) Called when the property is updated without errors, with a new value.- protected void- setColors- (org.eclipse.swt.widgets.Control... additional) Sets the colors for the controls depending on error, focus and define state.- void- setCurrentValue- (PROP_VALUE value) Sets the current value to all properties.- protected void- setEditable- (boolean on) Sets the input-capable editable state when e.g.- protected void- setFocus()Focuses the editor.- protected booleanUpdates the entry or visible part in the editor with a new property value that is not in error state.- protected void- setInputValue- (PROP_VALUE value) Sets the input value when editing, when formatting the value from a string.- protected void- setInputValueFromProp- (PROP_VALUE value) Sets the input value from an update of the property value.- protected void- setToolTipText- (String msg) Sets the tooltip text.- void- showMenu()Shows the menu.- voidUpdates the tooltip.- protected PROP_VALUERoutine to check the input from a text or combobox.
- Field Details- shellprotected org.eclipse.swt.widgets.Shell shellShell for message boxes, etc.
- displayprotected org.eclipse.swt.widgets.Display displayThe display.
- appUIThe ApplicationUI instance.
- editorThe property editor instance.
- controllerThe controller editor part.
- infoThe information about edited item.
- propControllerThe edited property controller.
- parentprotected org.eclipse.swt.widgets.Composite parentParent composite, where to place components.
- validatorThe validator, or null for none.
- optionsThe options for the property editor, or null for none.
- definedButtonThe define-button or null for none.
- moreprotected org.eclipse.swt.widgets.Button moreA "More..." button, null for none.
- controlprotected org.eclipse.swt.widgets.Control controlThe control for editing, a Text or CCombo.
- textprotected org.eclipse.swt.widgets.Text textThe Text control or null for none.
- comboprotected org.eclipse.swt.custom.CCombo comboThe combobox or null for none.
- wasDefinedAtFocusGainedprotected boolean wasDefinedAtFocusGainedFlag for value defined when focus was received.
- hasBeenModifiedprotected boolean hasBeenModifiedFlag for entry has been modified during focus.
- multipleValueWarningInputMultiple value warning input string, null for none.
- focusListenerprotected final org.eclipse.swt.events.FocusListener focusListenerSWT focus listener, should be added to all controls that can receive focus for this property editor.
 
- Constructor Details- BaseEditorpublic BaseEditor()Default constructor called before createControls, to hold the instance of the edit-property-class for easy access.
 
- Method Details- getBaseEditorGets the property editor in question for a control that e.g. has focus.- Parameters:
- control- The control that has focus.
- Returns:
- The instance of the base editor, null for none.
 
- createControlspublic MultiPropEditor createControls- (PropertyEditor editor, PropertyEditorInfo info, String[] options, org.eclipse.swt.widgets.Composite parent, PropCnr[] containers, Atom atom, DefinedButton definedButton) Creates the required controls in the composite.- Specified by:
- createControlsin interface- IEditedPropertyEntry<PROP extends GProp<?>,- PROP_VALUE> 
- Parameters:
- editor- The property editor instance.
- info- The information about edited item.
- options- The options.
- parent- Parent composite, where to place components.
- containers- The containers for the edited property.
- atom- Atom name of the property in the containers.
- definedButton- The define-button or null for none.
- Returns:
- null for normal editors, the instance of the multi-property editor in case of multiple editable entries (lines).
 
- assignMasterpublic EditedPropController<PROP,- PROP_VALUE> assignMaster- (MultiPropCnr master, Class<PROP> propertyClass, PropLabel label) Assigns the master property controller.- Specified by:
- assignMasterin interface- IEditedPropertyEntryMultiProp<PROP extends GProp<?>,- PROP_VALUE> 
- Parameters:
- master- The master property container of the MultiPropCnr.
- propertyClass- Property class for items.
- label- Label for this entry.
- Returns:
- The instance of the item property controller.
 
- getShellpublic org.eclipse.swt.widgets.Shell getShell()Gets the shell.
- onThemeChangedCalled once the new theme has stabilized after a period of time. This method cannot be overridden.- Specified by:
- onThemeChangedin interface- IThemeListener
- Parameters:
- appUI- The new ApplicationUI instance.
 
- disposepublic final void dispose()Disposes of this instance, cannot be overridden (use onDispose instead).- Specified by:
- disposein interface- IEditedPropertyEntry<PROP extends GProp<?>,- PROP_VALUE> 
 
- onDisposeprotected void onDispose()Called when the editor is disposed of. Override to implement required code. By default, this method does nothing.
- isPropReadOnlyprotected boolean isPropReadOnly()Checks if read-only.
- createGridLayoutprotected org.eclipse.swt.layout.GridLayout createGridLayout- (int count, int cxSpacing) Creates the grid layout for the composite parent and assigns it.
- createMoreButtonCreates a "more..." button.
- createMoreIzMenuCreates the menu for a component. The menu is shown upon onMore by default.
- createIzMenuCreates the menu for a component. The menu is shown upon onMore by default.
- onMorepublic void onMore()Called when the "more..." button is pressed. Override to display dialog box.
- showMenupublic void showMenu()Shows the menu.
- onF4Listpublic void onF4List()Called when F4 is pressed in a Text field. Override to display dialog box.
- createTextprotected org.eclipse.swt.widgets.Text createText()Creates an entry field and registers it.
- createCComboCreates a combobox, fills and registers it.
- onDoubleClickprotected void onDoubleClick- (org.eclipse.swt.widgets.Event e) Called when mouse is double-clicked in the text or combobox.
- getCurrentInputGets the user input.- Specified by:
- getCurrentInputin interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
 
- onFocusGainedprotected void onFocusGained()Upon focus gained, the selection of an entry field is selected fully and for a combobox, cursor is placed first.
- onFocusLostprotected void onFocusLost()Called when focus is lost. The control can set the selection to the beginning of the field to show the text.
- setToolTipTextSets the tooltip text. The default is to apply the getToolTipText() text to the edit control.- Parameters:
- msg- Message in tooltip (normally error), null for none, in which case the getToolTipText2() is used.
 
- updateTooltippublic void updateTooltip()Updates the tooltip.
- getNativeToolTipGets a "native" tooltip to use.- Returns:
- null for none, otherwise the IzToolTip instance.
 
- getToolTipText2Gets the tooltip text to display in the entry fields (not the one for property errors).
- setFocusprotected void setFocus()Focuses the editor. The default is to place focus in the control (text or combobox), or the "more..." button. Other behavior must override this method.
- onDefinepublic void onDefine- (boolean on) Called from the PropertyDefinedButton.- Specified by:
- onDefinein interface- IPropertyDefined
- Parameters:
- on- The defined state.
 
- setEditableprotected void setEditable- (boolean on) Sets the input-capable editable state when e.g. and extends-final property is encountered. This also sets the enabled state of the "more..." button.- Override this method if additional enabled states must be processed. 
- setInputUpdates the entry or visible part in the editor with a new property value that is not in error state. The default implementation updates the combo box or text with the value.toString() representation. The existing input should be checked for difference in order not to update the entry if not required. If the input is null, it means no change of the current input the user has made or was previously set.- Returns:
- true if changed, false for no change.
 
- doValueChangeConversionprotected boolean doValueChangeConversion()Returns if the property value should be checked by converting current string input back-and-forth with the current value.- Returns:
- The default is to perform this (i.e. return true) if there is a Text or Combo input control.
 
- setInputValueFromPropSets the input value from an update of the property value. If the input is null, it means the same as setting an empty value.- The default is to call - doValueChangeConversion()and if it returns true, the value is retrieved using- getCurrentValue()with try-catch, and if the returned value is the same as the value passed into this method, nothing is performed. Otherwise- setInputValue(Object)is called.- Parameters:
- value- The value to set, null for empty.
 
- setInputValueSets the input value when editing, when formatting the value from a string. If the input is null, it means the same as setting an empty value.- Parameters:
- value- The value to set, null for empty.
 
- hasFocuspublic boolean hasFocus()Checks if this editor has focus.
- setColorsprotected void setColors- (org.eclipse.swt.widgets.Control... additional) Sets the colors for the controls depending on error, focus and define state.
- getModifyListenerprotected org.eclipse.swt.events.ModifyListener getModifyListener()Gets the modify listener.
- getSelectionListenerprotected org.eclipse.swt.events.SelectionListener getSelectionListener()Gets the selection listener.
- canProcessEventspublic boolean canProcessEvents()Checks if it's OK to process events.
- beginProcessEventpublic void beginProcessEvent()Begins processing events, blocking e.g. property events or callbacks in SWT events.
- endProcessEventpublic void endProcessEvent()Begins processing events, blocking e.g. property events or callbacks in SWT events.
- checkInputprotected void checkInput- (boolean focusLost) Checks the input.
- getCurrentValueGets the current value from the property, not user input. If several properties are selected, the value is only returned when the value is the same for all properties (otherwise null is returned).- Returns:
- The property value, or null if not defined.
 
- getCurrentValuesGets the array of values currently used. Null entries may be present.
- setCurrentValueSets the current value to all properties.
- validateRoutine to check the input from a text or combobox. It is called whenever a selection is done in the combobox or text input in either the entry field or the combobox. A potential validator is called by default.- Parameters:
- input- The user input.
- focusLost- Flag for validation at focus lost resulting in e.g. removal of value for empty strings.
- Returns:
- The value object or null to remove or un-define it.
- Throws:
- Exception- For validation errors.
 
- doUndefineIfEmptyprotected boolean doUndefineIfEmpty- (boolean focusLost) Keeps empty strings as defined, when input has been changed specifically to empty string, or if the entry was defined when editing began.
- onUpdateCalled when the property is updated without errors, with a new value.- Specified by:
- onUpdatein interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
 
- onErrorpublic void onError- (String input, String message, int severity, boolean isMultipleValueWarning, boolean isChildError) Called when the property is updated due to an error.- Specified by:
- onErrorin interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
 
- onUndefinedpublic void onUndefined()Called when the property is undefined.- Specified by:
- onUndefinedin interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
 
- getSeveritypublic int getSeverity()The error severity.
- onReadOnlypublic void onReadOnly- (boolean on) Called when the read-only state changes.- Specified by:
- onReadOnlyin interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
 
- initializeInitializes a newly created property (e.g. a reference property for accepted classes, etc).- Specified by:
- initializein interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
- Parameters:
- prop- The newly created orphan property.
- Throws:
- PropException- For property errors.
 
- getOptionGets the options of a specified name as "option=".- Parameters:
- name- The name.
- Returns:
- The String after the equal sign, null if not found.
 
- createprotected abstract void create()Creates the property editor controls.
- getToolTipTextGets the tooltip text to display in the entry fields (not the one for property errors or validator).
- getDefaultValueGets the default defined value to set in the property when defined.- Specified by:
- getDefaultValuein interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
 
- getValueGets the property value for a user input.- Parameters:
- input- The current user input.
- Returns:
- The property value for the input, or null to un-define the property.
- Throws:
- Exception- For validation errors.
 
- formatValueFormats the value for user input as a String.- Specified by:
- formatValuein interface- IEditedPropControllerOwner<PROP extends GProp<?>,- PROP_VALUE> 
- Parameters:
- value- The value.
- Returns:
- The formatted value.