Class OptionalFieldEditor<T,​E extends Editor<? super T>>

  • Type Parameters:
    T - The type of data being managed
    E - The type of Editor
    All Implemented Interfaces:
    CompositeEditor<T,​T,​E>, Editor<T>, HasEditorDelegate<T>, LeafValueEditor<T>, ValueAwareEditor<T>, TakesValue<T>

    public class OptionalFieldEditor<T,​E extends Editor<? super T>>
    extends java.lang.Object
    implements CompositeEditor<T,​T,​E>, LeafValueEditor<T>
    This adapter can be used when a type being edited has an optional field that may be nullified or reassigned as part of the editing process. This consumer of this adapter will typically expose it via the IsEditor interface:
     class FooSelector extends Composite implements IsEditor<OptionalFieldEditor<Foo, FooEditor>> {
       private OptionalFieldEditor<Foo, FooEditor> editor = OptionalFieldEditor.of(new FooEditor());
       public OptionalFieldEditor<Foo, FooEditor> asEditor() {
         return editor;
       }
     }
     
    • Constructor Detail

      • OptionalFieldEditor

        protected OptionalFieldEditor​(E subEditor)
        Construct an OptionalFieldEditor backed by the given sub-Editor.
        Parameters:
        subEditor - the sub-Editor that will be attached to the Editor hierarchy
    • Method Detail

      • of

        public static <T,​E extends Editor<? super T>> OptionalFieldEditor<T,​E> of​(E subEditor)
        Construct an OptionalFieldEditor backed by the given sub-Editor.
        Type Parameters:
        T - The type of data being managed
        E - The type of Editor
        Parameters:
        subEditor - the sub-Editor that will be attached to the Editor hierarchy
        Returns:
        a new instance of OptionalFieldEditor
      • flush

        public void flush()
        Description copied from interface: ValueAwareEditor
        Indicates that the Editor cycle is finished. This method will be called in a depth-first order by the EditorDriver, so Editors do not generally need to flush their sub-editors.
        Specified by:
        flush in interface ValueAwareEditor<T>
      • getPathElement

        public java.lang.String getPathElement​(E subEditor)
        Returns an empty string because there is only ever one sub-editor used.
        Specified by:
        getPathElement in interface CompositeEditor<T,​T,​E extends Editor<? super T>>
        Parameters:
        subEditor - an instance of the Editor type previously passed into CompositeEditor.EditorChain.attach(C, E)
        Returns:
        the path element as a String
      • onPropertyChange

        public void onPropertyChange​(java.lang.String... paths)
        Description copied from interface: ValueAwareEditor
        Notifies the Editor that one or more value properties have changed. Not all backing services support property-based notifications.
        Specified by:
        onPropertyChange in interface ValueAwareEditor<T>
        Parameters:
        paths - a list of String paths
      • setValue

        public void setValue​(T value)
        Description copied from interface: ValueAwareEditor
        Called by the EditorDriver to set the object the Editor is peered with

        ValueAwareEditors should preferentially use sub-editors to alter the properties of the object being edited.

        Specified by:
        setValue in interface TakesValue<T>
        Specified by:
        setValue in interface ValueAwareEditor<T>
        Parameters:
        value - a value of type T
        See Also:
        TakesValue.getValue()