Class ItemProviderEnumCellEditor
- java.lang.Object
-
- org.eclipse.jface.viewers.CellEditor
-
- org.eclipse.emf.ecp.edit.spi.swt.table.ECPEnumCellEditor
-
- org.eclipse.emf.ecp.view.spi.table.swt.ItemProviderEnumCellEditor
-
- All Implemented Interfaces:
ECPCellEditor
public class ItemProviderEnumCellEditor extends ECPEnumCellEditor
GenericECPCellEditorwhich is applicable for allEAttributeswith a SingleEEnumdata type. This cell editor uses the EMF.Edit item provider to determine the model's proper choice of values for anEEnumattribute. Additionally, it filters out enum literals with are marked asisInputtable=falsewith a custom annotation.- Since:
- 1.22
- Author:
- Christian W. Damus, Lucas Koehler
-
-
Field Summary
-
Fields inherited from class org.eclipse.jface.viewers.CellEditor
COPY, CUT, DELETE, FIND, PASTE, REDO, SELECT_ALL, UNDO
-
Fields inherited from interface org.eclipse.emf.ecp.edit.spi.swt.table.ECPCellEditor
COPY_STRING_ALTERNATIVE, CUSTOM_VARIANT
-
-
Constructor Summary
Constructors Constructor Description ItemProviderEnumCellEditor(org.eclipse.swt.widgets.Composite parent)Initializes me with my parent.ItemProviderEnumCellEditor(org.eclipse.swt.widgets.Composite parent, int style)Initializes me with my parent and style.ItemProviderEnumCellEditor(org.eclipse.swt.widgets.Composite parent, int style, BundleResolver bundleResolver, EMFFormsLocalizationService l10n)Initializes me with my parent, style, and customBundleResolverandEMFFormsLocalizationService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent actEvent)protected org.eclipse.swt.widgets.ControlcreateControl(org.eclipse.swt.widgets.Composite parent)voiddeactivate()protected java.lang.ObjectdoGetValue()protected voiddoSetFocus()protected voiddoSetValue(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.intgetColumnWidthWeight()The returned value is used for layouting the table columns.org.eclipse.emf.ecore.EEnumgetEEnum()Returns theEEnumis cell editor responsible for.java.lang.StringgetFormatedString(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.ImagegetImage(java.lang.Object value)This returns the Image which will be shown in the table when no cell editor is open.intgetMinWidth()Returns the minimum width of the cell editor.org.eclipse.core.databinding.UpdateValueStrategygetModelToTargetStrategy(org.eclipse.core.databinding.DataBindingContext databindingContext)ThisUpdateValueStrategywill 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.UpdateValueStrategygetTargetToModelStrategy(org.eclipse.core.databinding.DataBindingContext databindingContext)ThisUpdateValueStrategywill be used as the target to model strategy during data binding.org.eclipse.core.databinding.property.value.IValuePropertygetValueProperty()Returns theIValuePropertyfor this cell editor which is used by the table to create anIObservableValue.voidinstantiate(org.eclipse.emf.ecore.EStructuralFeature feature, ViewModelContext viewModelContext)Instantiates this cell editor.voidsetEditable(boolean editable)Sets editable state of the cell editor.-
Methods inherited from class org.eclipse.emf.ecp.edit.spi.swt.table.ECPEnumCellEditor
getELiterals
-
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
-
Methods inherited from interface org.eclipse.emf.ecp.edit.spi.swt.table.ECPCellEditor
getStyle
-
-
-
-
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 compositestyle- my style bits
-
ItemProviderEnumCellEditor
public ItemProviderEnumCellEditor(org.eclipse.swt.widgets.Composite parent, int style, BundleResolver bundleResolver, EMFFormsLocalizationService l10n)Initializes me with my parent, style, and customBundleResolverandEMFFormsLocalizationService.- Parameters:
parent- my parent compositestyle- my style bitsbundleResolver- customBundleResolverl10n- customEMFFormsLocalizationService
-
-
Method Detail
-
getModelToTargetStrategy
public org.eclipse.core.databinding.UpdateValueStrategy getModelToTargetStrategy(org.eclipse.core.databinding.DataBindingContext databindingContext)
Description copied from interface:ECPCellEditorThisUpdateValueStrategywill be used as the model to target strategy during data binding.- Parameters:
databindingContext- TheDataBindingContextused by this strategy- Returns:
- the strategy
-
getTargetToModelStrategy
public org.eclipse.core.databinding.UpdateValueStrategy getTargetToModelStrategy(org.eclipse.core.databinding.DataBindingContext databindingContext)
Description copied from interface:ECPCellEditorThisUpdateValueStrategywill be used as the target to model strategy during data binding.- Parameters:
databindingContext- TheDataBindingContextused by this strategy- Returns:
- the strategy
-
createControl
protected org.eclipse.swt.widgets.Control createControl(org.eclipse.swt.widgets.Composite parent)
- Specified by:
createControlin classorg.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:ECPCellEditorThis 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:ECPCellEditorInstantiates this cell editor. This allows the cell editor to useViewModelServices.- Parameters:
feature- theEStructuralFeaturedisplayed in this cell editorviewModelContext- theViewModelContextused for the current view
-
getValueProperty
public org.eclipse.core.databinding.property.value.IValueProperty getValueProperty()
Description copied from interface:ECPCellEditorReturns theIValuePropertyfor this cell editor which is used by the table to create anIObservableValue.- Returns:
- the
IValuePropertyfor this cell editor
-
activate
public void activate(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent actEvent)
- Overrides:
activatein classorg.eclipse.jface.viewers.CellEditor
-
deactivate
public void deactivate()
- Overrides:
deactivatein classorg.eclipse.jface.viewers.CellEditor
-
getColumnWidthWeight
public int getColumnWidthWeight()
Description copied from interface:ECPCellEditorThe 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:ECPCellEditorReturns the minimum width of the cell editor.- Returns:
- the minimum width
-
getEEnum
public org.eclipse.emf.ecore.EEnum getEEnum()
Description copied from class:ECPEnumCellEditorReturns theEEnumis cell editor responsible for.- Specified by:
getEEnumin classECPEnumCellEditor- Returns:
- the enum
-
getImage
public org.eclipse.swt.graphics.Image getImage(java.lang.Object value)
Description copied from interface:ECPCellEditorThis 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:ECPCellEditorSets editable state of the cell editor.- Parameters:
editable-trueif editable,falseotherwise
-
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
IItemPropertyDescriptordescriptor of the current source if it is available
-
doGetValue
protected java.lang.Object doGetValue()
- Specified by:
doGetValuein classorg.eclipse.jface.viewers.CellEditor
-
doSetValue
protected void doSetValue(java.lang.Object value)
- Specified by:
doSetValuein classorg.eclipse.jface.viewers.CellEditor
-
doSetFocus
protected void doSetFocus()
- Specified by:
doSetFocusin classorg.eclipse.jface.viewers.CellEditor
-
-