Class BaseEditor<PROP extends GProp<?>,​PROP_VALUE>

    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      protected ApplicationUIappUI
      The ApplicationUI instance.
      protected org.eclipse.swt.custom.CCombocombo
      The combobox or null for none.
      protected org.eclipse.swt.widgets.Controlcontrol
      The control for editing, a Text or CCombo.
      protected IPropertyEditorControllercontroller
      The controller editor part.
      protected DefinedButtondefinedButton
      The define-button or null for none.
      protected org.eclipse.swt.widgets.Displaydisplay
      The display.
      protected PropertyEditoreditor
      The property editor instance.
      protected org.eclipse.swt.events.FocusListenerfocusListener
      SWT focus listener, should be added to all controls that can receive focus for this property editor.
      protected booleanhasBeenModified
      Flag for entry has been modified during focus.
      protected PropertyEditorInfoinfo
      The information about edited item.
      protected org.eclipse.swt.widgets.Buttonmore
      A "More..." button, null for none.
      protected java.lang.StringmultipleValueWarningInput
      Multiple value warning input string, null for none.
      protected java.lang.String[]options
      The options for the property editor, or null for none.
      protected org.eclipse.swt.widgets.Compositeparent
      Parent composite, where to place components.
      protected EditedPropController<PROP,​PROP_VALUE>propController
      The edited property controller.
      protected org.eclipse.swt.widgets.Shellshell
      Shell for message boxes, etc.
      protected org.eclipse.swt.widgets.Texttext
      The Text control or null for none.
      protected IEntryValidatorvalidator
      The validator, or null for none.
      protected booleanwasDefinedAtFocusGained
      Flag for value defined when focus was received.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      BaseEditor()
      Default constructor called before createControls, to hold the instance of the edit-property-class for easy access.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and TypeMethodDescription
      EditedPropController<PROP,​PROP_VALUE>assignMaster​(MultiPropCnr master, java.lang.Class<PROP> propertyClass, PropLabel label)
      Assigns the master property controller.
      voidbeginProcessEvent()
      Begins processing events, blocking e.g.
      booleancanProcessEvents()
      Checks if it's OK to process events.
      protected voidcheckInput​(boolean focusLost)
      Checks the input.
      protected abstract voidcreate()
      Creates the property editor controls.
      protected org.eclipse.swt.custom.CCombocreateCCombo​(java.lang.String[] entries)
      Creates a combobox, fills and registers it.
      MultiPropEditorcreateControls​(PropertyEditor editor, PropertyEditorInfo info, java.lang.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.GridLayoutcreateGridLayout​(int count, int cxSpacing)
      Creates the grid layout for the composite parent and assigns it.
      protected IzMenucreateIzMenu​(org.eclipse.swt.widgets.Control control)
      Creates the menu for a component.
      protected voidcreateMoreButton​(java.lang.String toolTipText)
      Creates a "more..." button.
      protected IzMenucreateMoreIzMenu()
      Creates the menu for a component.
      protected org.eclipse.swt.widgets.TextcreateText()
      Creates an entry field and registers it.
      voiddispose()
      Disposes of this instance, cannot be overridden (use onDispose instead).
      protected booleandoUndefineIfEmpty​(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 booleandoValueChangeConversion()
      Returns if the property value should be checked by converting current string input back-and-forth with the current value.
      voidendProcessEvent()
      Begins processing events, blocking e.g.
      abstract java.lang.StringformatValue​(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.
      java.lang.StringgetCurrentInput()
      Gets the user input.
      PROP_VALUEgetCurrentValue()
      Gets the current value from the property, not user input.
      java.util.HashSet<PROP_VALUE>getCurrentValues()
      Gets the array of values currently used.
      abstract PROP_VALUEgetDefaultValue()
      Gets the default defined value to set in the property when defined.
      protected org.eclipse.swt.events.ModifyListenergetModifyListener()
      Gets the modify listener.
      IzToolTipgetNativeToolTip()
      Gets a "native" tooltip to use.
      java.lang.StringgetOption​(java.lang.String name)
      Gets the options of a specified name as "option=".
      protected org.eclipse.swt.events.SelectionListenergetSelectionListener()
      Gets the selection listener.
      intgetSeverity()
      The error severity.
      org.eclipse.swt.widgets.ShellgetShell()
      Gets the shell.
      protected abstract java.lang.StringgetToolTipText()
      Gets the tooltip text to display in the entry fields (not the one for property errors or validator).
      protected java.lang.StringgetToolTipText2()
      Gets the tooltip text to display in the entry fields (not the one for property errors).
      protected abstract PROP_VALUEgetValue​(java.lang.String input)
      Gets the property value for a user input.
      booleanhasFocus()
      Checks if this editor has focus.
      voidinitialize​(PROP prop)
      Initializes a newly created property (e.g.
      protected booleanisPropReadOnly()
      Checks if read-only.
      voidonDefine​(boolean on)
      Called from the PropertyDefinedButton.
      protected voidonDispose()
      Called when the editor is disposed of.
      protected voidonDoubleClick​(org.eclipse.swt.widgets.Event e)
      Called when mouse is double-clicked in the text or combobox.
      voidonError​(java.lang.String input, java.lang.String message, int severity, boolean isMultipleValueWarning, boolean isChildError)
      Called when the property is updated due to an error.
      voidonF4List()
      Called when F4 is pressed in a Text field.
      protected voidonFocusGained()
      Upon focus gained, the selection of an entry field is selected fully and for a combobox, cursor is placed first.
      protected voidonFocusLost()
      Called when focus is lost.
      voidonMore()
      Called when the "more..." button is pressed.
      voidonReadOnly​(boolean on)
      Called when the read-only state changes.
      voidonUndefined()
      Called when the property is undefined.
      voidonUpdate​(PROP_VALUE value)
      Called when the property is updated without errors, with a new value.
      protected voidsetColors​(org.eclipse.swt.widgets.Control... additional)
      Sets the colors for the controls depending on error, focus and define state.
      voidsetCurrentValue​(PROP_VALUE value)
      Sets the current value to all properties.
      protected voidsetEditable​(boolean on)
      Sets the input-capable editable state when e.g.
      protected voidsetFocus()
      Focuses the editor.
      protected booleansetInput​(java.lang.String input)
      Updates the entry or visible part in the editor with a new property value that is not in error state.
      protected voidsetInputValue​(PROP_VALUE value)
      Sets the input value when editing, when formatting the value from a string.
      protected voidsetInputValueFromProp​(PROP_VALUE value)
      Sets the input value from an update of the property value.
      protected voidsetToolTipText​(java.lang.String msg)
      Sets the tooltip text.
      voidshowMenu()
      Shows the menu.
      voidupdateTooltip()
      Updates the tooltip.
      protected PROP_VALUEvalidate​(java.lang.String input, boolean focusLost)
      Routine to check the input from a text or combobox.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • shell

        protected org.eclipse.swt.widgets.Shell shell
        Shell for message boxes, etc.
      • display

        protected org.eclipse.swt.widgets.Display display
        The display.
      • parent

        protected org.eclipse.swt.widgets.Composite parent
        Parent composite, where to place components.
      • validator

        protected IEntryValidator validator
        The validator, or null for none.
      • options

        protected java.lang.String[] options
        The options for the property editor, or null for none.
      • definedButton

        protected DefinedButton definedButton
        The define-button or null for none.
      • more

        protected org.eclipse.swt.widgets.Button more
        A "More..." button, null for none.
      • control

        protected org.eclipse.swt.widgets.Control control
        The control for editing, a Text or CCombo.
      • text

        protected org.eclipse.swt.widgets.Text text
        The Text control or null for none.
      • combo

        protected org.eclipse.swt.custom.CCombo combo
        The combobox or null for none.
      • wasDefinedAtFocusGained

        protected boolean wasDefinedAtFocusGained
        Flag for value defined when focus was received.
      • hasBeenModified

        protected boolean hasBeenModified
        Flag for entry has been modified during focus.
      • multipleValueWarningInput

        protected java.lang.String multipleValueWarningInput
        Multiple value warning input string, null for none.
      • focusListener

        protected final org.eclipse.swt.events.FocusListener focusListener
        SWT focus listener, should be added to all controls that can receive focus for this property editor.
    • Constructor Detail

      • BaseEditor

        public BaseEditor()
        Default constructor called before createControls, to hold the instance of the edit-property-class for easy access.
    • Method Detail

      • getBaseEditor

        public static BaseEditor<?,​?> getBaseEditor​(org.eclipse.swt.widgets.Control control)
        Gets 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.
      • createControls

        public MultiPropEditor createControls​(PropertyEditor editor,
                                              PropertyEditorInfo info,
                                              java.lang.String[] options,
                                              org.eclipse.swt.widgets.Composite parent,
                                              PropCnr[] containers,
                                              Atom atom,
                                              DefinedButton definedButton)
        Creates the required controls in the composite.
        Specified by:
        createControls in 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).
      • getShell

        public org.eclipse.swt.widgets.Shell getShell()
        Gets the shell.
      • onDispose

        protected void onDispose()
        Called when the editor is disposed of. Override to implement required code. By default, this method does nothing.
      • isPropReadOnly

        protected boolean isPropReadOnly()
        Checks if read-only.
      • createGridLayout

        protected org.eclipse.swt.layout.GridLayout createGridLayout​(int count,
                                                                     int cxSpacing)
        Creates the grid layout for the composite parent and assigns it.
      • createMoreButton

        protected void createMoreButton​(java.lang.String toolTipText)
        Creates a "more..." button.
      • createMoreIzMenu

        protected IzMenu createMoreIzMenu()
        Creates the menu for a component. The menu is shown upon onMore by default.
      • createIzMenu

        protected IzMenu createIzMenu​(org.eclipse.swt.widgets.Control control)
        Creates the menu for a component. The menu is shown upon onMore by default.
      • onMore

        public void onMore()
        Called when the "more..." button is pressed. Override to display dialog box.
      • showMenu

        public void showMenu()
        Shows the menu.
      • onF4List

        public void onF4List()
        Called when F4 is pressed in a Text field. Override to display dialog box.
      • createText

        protected org.eclipse.swt.widgets.Text createText()
        Creates an entry field and registers it.
      • createCCombo

        protected org.eclipse.swt.custom.CCombo createCCombo​(java.lang.String[] entries)
        Creates a combobox, fills and registers it.
      • onDoubleClick

        protected void onDoubleClick​(org.eclipse.swt.widgets.Event e)
        Called when mouse is double-clicked in the text or combobox.
      • onFocusGained

        protected void onFocusGained()
        Upon focus gained, the selection of an entry field is selected fully and for a combobox, cursor is placed first.
      • onFocusLost

        protected void onFocusLost()
        Called when focus is lost. The control can set the selection to the beginning of the field to show the text.
      • setToolTipText

        protected void setToolTipText​(java.lang.String msg)
        Sets 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.
      • updateTooltip

        public void updateTooltip()
        Updates the tooltip.
      • getNativeToolTip

        public IzToolTip getNativeToolTip()
        Gets a "native" tooltip to use.
        Returns:
        null for none, otherwise the IzToolTip instance.
      • getToolTipText2

        protected java.lang.String getToolTipText2()
        Gets the tooltip text to display in the entry fields (not the one for property errors).
      • setFocus

        protected 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.
      • onDefine

        public void onDefine​(boolean on)
        Called from the PropertyDefinedButton.
        Specified by:
        onDefine in interface IPropertyDefined
        Parameters:
        on - The defined state.
      • setEditable

        protected 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.

      • setInput

        protected boolean setInput​(java.lang.String input)
        Updates 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.
      • doValueChangeConversion

        protected 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.
      • setInputValueFromProp

        protected void setInputValueFromProp​(PROP_VALUE value)
        Sets 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.
      • setInputValue

        protected void setInputValue​(PROP_VALUE value)
        Sets 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.
      • hasFocus

        public boolean hasFocus()
        Checks if this editor has focus.
      • setColors

        protected void setColors​(org.eclipse.swt.widgets.Control... additional)
        Sets the colors for the controls depending on error, focus and define state.
      • getModifyListener

        protected org.eclipse.swt.events.ModifyListener getModifyListener()
        Gets the modify listener.
      • getSelectionListener

        protected org.eclipse.swt.events.SelectionListener getSelectionListener()
        Gets the selection listener.
      • canProcessEvents

        public boolean canProcessEvents()
        Checks if it's OK to process events.
      • beginProcessEvent

        public void beginProcessEvent()
        Begins processing events, blocking e.g. property events or callbacks in SWT events.
      • endProcessEvent

        public void endProcessEvent()
        Begins processing events, blocking e.g. property events or callbacks in SWT events.
      • checkInput

        protected void checkInput​(boolean focusLost)
        Checks the input.
      • getCurrentValue

        public PROP_VALUE getCurrentValue()
        Gets 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.
      • getCurrentValues

        public java.util.HashSet<PROP_VALUE> getCurrentValues()
        Gets the array of values currently used. Null entries may be present.
      • setCurrentValue

        public void setCurrentValue​(PROP_VALUE value)
        Sets the current value to all properties.
      • validate

        protected PROP_VALUE validate​(java.lang.String input,
                                      boolean focusLost)
                               throws java.lang.Exception
        Routine 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:
        java.lang.Exception - For validation errors.
      • doUndefineIfEmpty

        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.
      • onError

        public void onError​(java.lang.String input,
                            java.lang.String message,
                            int severity,
                            boolean isMultipleValueWarning,
                            boolean isChildError)
        Called when the property is updated due to an error.
        Specified by:
        onError in interface IEditedPropControllerOwner<PROP extends GProp<?>,​PROP_VALUE>
      • getSeverity

        public int getSeverity()
        The error severity.
      • getOption

        public java.lang.String getOption​(java.lang.String name)
        Gets the options of a specified name as "option=".
        Parameters:
        name - The name.
        Returns:
        The String after the equal sign, null if not found.
      • create

        protected abstract void create()
        Creates the property editor controls.
      • getToolTipText

        protected abstract java.lang.String getToolTipText()
        Gets the tooltip text to display in the entry fields (not the one for property errors or validator).
      • getValue

        protected abstract PROP_VALUE getValue​(java.lang.String input)
                                        throws java.lang.Exception
        Gets 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:
        java.lang.Exception - For validation errors.