Class ItemProviderEnumCellEditor

  • All Implemented Interfaces:
    ECPCellEditor

    public class ItemProviderEnumCellEditor
    extends ECPEnumCellEditor
    Generic ECPCellEditor which is applicable for all EAttributes with a Single EEnum data type. This cell editor uses the EMF.Edit item provider to determine the model's proper choice of values for an EEnum attribute. Additionally, it filters out enum literals with are marked as isInputtable=false with a custom annotation.
    Since:
    1.22
    Author:
    Christian W. Damus, Lucas Koehler
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jface.viewers.CellEditor

        org.eclipse.jface.viewers.CellEditor.LayoutData
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activate​(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent actEvent)  
      protected org.eclipse.swt.widgets.Control createControl​(org.eclipse.swt.widgets.Composite parent)  
      void deactivate()  
      protected java.lang.Object doGetValue()  
      protected void doSetFocus()  
      protected void doSetValue​(java.lang.Object value)  
      protected java.util.List<?> getChoiceOfValues()
      Gets the proper choice of values provided by the item-provider of the source object of our data binding for the attribute that is bound.
      int getColumnWidthWeight()
      The returned value is used for layouting the table columns.
      org.eclipse.emf.ecore.EEnum getEEnum()
      Returns the EEnum is cell editor responsible for.
      java.lang.String getFormatedString​(java.lang.Object value)
      This returns the String which will be shown in the table when no cell editor is open.
      org.eclipse.swt.graphics.Image getImage​(java.lang.Object value)
      This returns the Image which will be shown in the table when no cell editor is open.
      int getMinWidth()
      Returns the minimum width of the cell editor.
      org.eclipse.core.databinding.UpdateValueStrategy getModelToTargetStrategy​(org.eclipse.core.databinding.DataBindingContext databindingContext)
      This UpdateValueStrategy will be used as the model to target strategy during data binding.
      protected java.util.Optional<org.eclipse.emf.edit.provider.IItemPropertyDescriptor> getPropertyDescriptor()  
      protected java.util.Optional<org.eclipse.emf.ecore.EObject> getSource()  
      org.eclipse.core.databinding.UpdateValueStrategy getTargetToModelStrategy​(org.eclipse.core.databinding.DataBindingContext databindingContext)
      This UpdateValueStrategy will be used as the target to model strategy during data binding.
      org.eclipse.core.databinding.property.value.IValueProperty getValueProperty()
      Returns the IValueProperty for this cell editor which is used by the table to create an IObservableValue.
      void instantiate​(org.eclipse.emf.ecore.EStructuralFeature feature, ViewModelContext viewModelContext)
      Instantiates this cell editor.
      void setEditable​(boolean editable)
      Sets editable state of the cell editor.
      • Methods inherited from class org.eclipse.jface.viewers.CellEditor

        activate, addListener, addPropertyChangeListener, create, deactivate, dependsOnExternalFocusListener, dispose, fireApplyEditorValue, fireCancelEditor, fireEditorValueChanged, fireEnablementChanged, focusLost, getControl, getDoubleClickTimeout, getErrorMessage, getLayoutData, getStyle, getValidator, getValue, isActivated, isCopyEnabled, isCorrect, isCutEnabled, isDeleteEnabled, isDirty, isFindEnabled, isPasteEnabled, isRedoEnabled, isSelectAllEnabled, isUndoEnabled, isValueValid, keyReleaseOccured, markDirty, performCopy, performCut, performDelete, performFind, performPaste, performRedo, performSelectAll, performUndo, removeListener, removePropertyChangeListener, setErrorMessage, setFocus, setStyle, setValidator, setValue, setValueValid, valueChanged
      • Methods inherited from class java.lang.Object

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

      • ItemProviderEnumCellEditor

        public ItemProviderEnumCellEditor​(org.eclipse.swt.widgets.Composite parent)
        Initializes me with my parent.
        Parameters:
        parent - my parent composite
      • ItemProviderEnumCellEditor

        public ItemProviderEnumCellEditor​(org.eclipse.swt.widgets.Composite parent,
                                          int style)
        Initializes me with my parent and style.
        Parameters:
        parent - my parent composite
        style - my style bits
    • Method Detail

      • getModelToTargetStrategy

        public org.eclipse.core.databinding.UpdateValueStrategy getModelToTargetStrategy​(org.eclipse.core.databinding.DataBindingContext databindingContext)
        Description copied from interface: ECPCellEditor
        This UpdateValueStrategy will be used as the model to target strategy during data binding.
        Parameters:
        databindingContext - The DataBindingContext used by this strategy
        Returns:
        the strategy
      • getTargetToModelStrategy

        public org.eclipse.core.databinding.UpdateValueStrategy getTargetToModelStrategy​(org.eclipse.core.databinding.DataBindingContext databindingContext)
        Description copied from interface: ECPCellEditor
        This UpdateValueStrategy will be used as the target to model strategy during data binding.
        Parameters:
        databindingContext - The DataBindingContext used by this strategy
        Returns:
        the strategy
      • createControl

        protected org.eclipse.swt.widgets.Control createControl​(org.eclipse.swt.widgets.Composite parent)
        Specified by:
        createControl in class org.eclipse.jface.viewers.CellEditor
      • getChoiceOfValues

        protected java.util.List<?> getChoiceOfValues()
        Gets the proper choice of values provided by the item-provider of the source object of our data binding for the attribute that is bound. In addition, we remove all choices annotated by our custom annotation.
        If the property descriptor is not available or does not return any choice, the enum's literals minus the annotated ones are returned.
        Returns:
        The available enum values, might be empty but never null
      • getFormatedString

        public java.lang.String getFormatedString​(java.lang.Object value)
        Description copied from interface: ECPCellEditor
        This returns the String which will be shown in the table when no cell editor is open.
        Parameters:
        value - the Object to get the formated String for
        Returns:
        the formated String
      • instantiate

        public void instantiate​(org.eclipse.emf.ecore.EStructuralFeature feature,
                                ViewModelContext viewModelContext)
        Description copied from interface: ECPCellEditor
        Instantiates this cell editor. This allows the cell editor to use ViewModelServices.
        Parameters:
        feature - the EStructuralFeature displayed in this cell editor
        viewModelContext - the ViewModelContext used for the current view
      • getValueProperty

        public org.eclipse.core.databinding.property.value.IValueProperty getValueProperty()
        Description copied from interface: ECPCellEditor
        Returns the IValueProperty for this cell editor which is used by the table to create an IObservableValue.
        Returns:
        the IValueProperty for this cell editor
      • activate

        public void activate​(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent actEvent)
        Overrides:
        activate in class org.eclipse.jface.viewers.CellEditor
      • deactivate

        public void deactivate()
        Overrides:
        deactivate in class org.eclipse.jface.viewers.CellEditor
      • getColumnWidthWeight

        public int getColumnWidthWeight()
        Description copied from interface: ECPCellEditor
        The returned value is used for layouting the table columns. The value is a relative column weight. A column containing text has a weight of 100. Please consider this when defining you weight. E.g if you return 200 your column will be twice the width of a text column.
        Returns:
        the relative column width
      • getMinWidth

        public int getMinWidth()
        Description copied from interface: ECPCellEditor
        Returns the minimum width of the cell editor.
        Returns:
        the minimum width
      • getEEnum

        public org.eclipse.emf.ecore.EEnum getEEnum()
        Description copied from class: ECPEnumCellEditor
        Returns the EEnum is cell editor responsible for.
        Specified by:
        getEEnum in class ECPEnumCellEditor
        Returns:
        the enum
      • getImage

        public org.eclipse.swt.graphics.Image getImage​(java.lang.Object value)
        Description copied from interface: ECPCellEditor
        This returns the Image which will be shown in the table when no cell editor is open.
        Parameters:
        value - the Object to get the Image for
        Returns:
        the image
      • setEditable

        public void setEditable​(boolean editable)
        Description copied from interface: ECPCellEditor
        Sets editable state of the cell editor.
        Parameters:
        editable - true if editable, false otherwise
      • getSource

        protected java.util.Optional<org.eclipse.emf.ecore.EObject> getSource()
        Returns:
        The current source EObject
      • getPropertyDescriptor

        protected java.util.Optional<org.eclipse.emf.edit.provider.IItemPropertyDescriptor> getPropertyDescriptor()
        Returns:
        The IItemPropertyDescriptor descriptor of the current source if it is available
      • doGetValue

        protected java.lang.Object doGetValue()
        Specified by:
        doGetValue in class org.eclipse.jface.viewers.CellEditor
      • doSetValue

        protected void doSetValue​(java.lang.Object value)
        Specified by:
        doSetValue in class org.eclipse.jface.viewers.CellEditor
      • doSetFocus

        protected void doSetFocus()
        Specified by:
        doSetFocus in class org.eclipse.jface.viewers.CellEditor