Class ECPAbstractCustomControlSWT
- java.lang.Object
-
- org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT
-
- Direct Known Subclasses:
DICustomControlSWT
public abstract class ECPAbstractCustomControlSWT extends java.lang.Object
Extend this class in order to provide an own implementation of anECPAbstractCustomControlSWT
.- Since:
- 1.2
- Author:
- Eugen Neufeld
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ECPAbstractCustomControlSWT.SWTCustomControlHelper
TheECPAbstractCustomControlSWT.SWTCustomControlHelper
allows the retrieval of SWT specific elements.
-
Field Summary
Fields Modifier and Type Field Description static int
ADD_IMAGE
Constant for an add image.protected static java.lang.String
CUSTOM_VARIANT
Variant constant for indicating RAP controls.static int
DELETE_IMAGE
Constant for an delete image.static int
HELP_IMAGE
Constant for a help image.static int
VALIDATION_ERROR_IMAGE
Constant for an validation error image.
-
Constructor Summary
Constructors Constructor Description ECPAbstractCustomControlSWT()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
applyEnable(java.util.Map<SWTGridCell,org.eclipse.swt.widgets.Control> controls)
Applies the current enable state.void
applyReadOnly(java.util.Map<SWTGridCell,org.eclipse.swt.widgets.Control> controls)
Applies the current readOnlyState.void
applyValidation()
Called by the framework to apply validation changes.protected org.eclipse.core.databinding.Binding
bindTargetToModel(VDomainModelReference modelFeature, org.eclipse.core.databinding.observable.value.IObservableValue targetValue, org.eclipse.core.databinding.UpdateValueStrategy targetToModel, org.eclipse.core.databinding.UpdateValueStrategy modelToTarget)
Method for enabling databinding on the reference/attribute of the referenced object.protected boolean
canHandleControlProcessor()
Indicates if the given custom control takes the responsibility to call a possibly existingEMFFormsControlProcessorService
itself.protected org.eclipse.swt.widgets.Control
createLabel(org.eclipse.swt.widgets.Composite parent)
Create theControl
displaying the label of the currentVControl
.protected SWTGridDescription
createSimpleGrid(int rows, int columns)
Creates a simple grid.protected org.eclipse.swt.widgets.Label
createValidationIcon(org.eclipse.swt.widgets.Composite composite)
Creates a Label which is used to display the validation icon.protected void
createViewerBinding(VDomainModelReference customControlFeature, org.eclipse.jface.viewers.StructuredViewer viewer, org.eclipse.core.databinding.property.value.IValueProperty[] labelProperties)
Creates a binding for aStructuredViewer
based on aECPCustomControlFeature
and the array ofIValueProperties
for labels.void
dispose()
Is called by the framework to trigger a dispose of the control.protected abstract void
disposeCustomControl()
This method is called during dispose and allows to dispose necessary objects.protected <T extends ECPAbstractControl>
TgetControl(java.lang.Class<T> clazz, VDomainModelReference domainModelReference)
Use this method to get anECPControl
which can be used inside theECPCustomControl
.protected VCustomControl
getCustomControl()
Return theVCustomControl
.protected org.eclipse.core.databinding.DataBindingContext
getDataBindingContext()
Returns aDataBindingContext
for this control.protected org.eclipse.emf.edit.domain.EditingDomain
getEditingDomain()
Provides theEditingDomain
for this custom control.protected org.eclipse.emf.edit.domain.EditingDomain
getEditingDomain(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Returns theEditingDomain
for the providedEStructuralFeature.Setting
.abstract SWTGridDescription
getGridDescription()
Returns the GridDescription for this Renderer.protected ECPAbstractCustomControlSWT.SWTCustomControlHelper
getHelper()
This is a helper method which provides anECPAbstractCustomControlSWT.SWTCustomControlHelper
.protected org.eclipse.emf.edit.provider.IItemPropertyDescriptor
getItemPropertyDescriptor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Return theIItemPropertyDescriptor
describing thisEStructuralFeature.Setting
.protected org.eclipse.core.databinding.observable.list.IObservableList
getObservableList(VDomainModelReference domainModelReference)
Deprecated.This method is deprecated and must not be used anymore.protected VDomainModelReference
getResolvedDomainModelReference(org.eclipse.emf.ecore.EStructuralFeature feature)
Finds theVDomainModelReference
which provides a specificEStructuralFeature
.protected java.util.List<VDomainModelReference>
getResolvedDomainModelReferences()
Returns a list of allVDomainModelReferences
which were already resolved and thus can be used for binding etc.protected java.lang.Object
getValue(VDomainModelReference modelReference)
Returns the current set value of the feature.protected ViewModelContext
getViewModelContext()
Return theViewModelContext
.protected abstract void
handleContentValidation()
This is called so that an error can be shown by the user.protected boolean
hasLeftLabelAlignment()
Whether the label for this control should be rendered on the left of the control.void
init(VCustomControl customControl, ViewModelContext viewModelContext)
Called by the framework to trigger an initialization.protected void
postInit()
This method is called after the initialization.protected void
registerChangeListener(VDomainModelReference modelReference, ECPCustomControlChangeListener changeListener)
Registers a change listener on the referenced object.abstract org.eclipse.swt.widgets.Control
renderControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent)
Renders the control.protected void
setControlEnabled(SWTGridCell gridCell, org.eclipse.swt.widgets.Control control, boolean enabled)
Override this to control which and how controls should be enabled/disabled.protected boolean
setEditable(boolean editable)
Allows custom controls to call specific code for setting controls editable or not.protected void
setValue(VDomainModelReference modelReference, java.lang.Object newValue)
Sets the value of the feature to the new value.
-
-
-
Field Detail
-
CUSTOM_VARIANT
protected static final java.lang.String CUSTOM_VARIANT
Variant constant for indicating RAP controls.- Since:
- 1.3
- See Also:
- Constant Field Values
-
VALIDATION_ERROR_IMAGE
public static final int VALIDATION_ERROR_IMAGE
Constant for an validation error image.- See Also:
- Constant Field Values
-
ADD_IMAGE
public static final int ADD_IMAGE
Constant for an add image.- See Also:
- Constant Field Values
-
DELETE_IMAGE
public static final int DELETE_IMAGE
Constant for an delete image.- See Also:
- Constant Field Values
-
HELP_IMAGE
public static final int HELP_IMAGE
Constant for a help image.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public final void init(VCustomControl customControl, ViewModelContext viewModelContext)
Called by the framework to trigger an initialization.- Parameters:
customControl
- theVCustomControl
to useviewModelContext
- theViewModelContext
to use- Since:
- 1.3
-
postInit
protected void postInit()
This method is called after the initialization. Custom controls can overwrite this to execute specific initialization steps.- Since:
- 1.3
-
dispose
public final void dispose()
Is called by the framework to trigger a dispose of the control.
-
disposeCustomControl
protected abstract void disposeCustomControl()
This method is called during dispose and allows to dispose necessary objects.- Since:
- 1.3
-
getViewModelContext
protected final ViewModelContext getViewModelContext()
Return theViewModelContext
.- Returns:
- the
ViewModelContext
of this control - Since:
- 1.3
-
getCustomControl
protected final VCustomControl getCustomControl()
Return theVCustomControl
.- Returns:
- the
VCustomControl
of this control - Since:
- 1.3
-
getDataBindingContext
protected final org.eclipse.core.databinding.DataBindingContext getDataBindingContext()
Returns aDataBindingContext
for this control.- Returns:
- the
DataBindingContext
- Since:
- 1.3
-
handleContentValidation
protected abstract void handleContentValidation()
This is called so that an error can be shown by the user.- Since:
- 1.3
-
getHelper
protected final ECPAbstractCustomControlSWT.SWTCustomControlHelper getHelper()
This is a helper method which provides anECPAbstractCustomControlSWT.SWTCustomControlHelper
. It allows to get an image based on the constants defined inECPAbstractCustomControlSWT
.- Returns:
- the
ECPAbstractCustomControlSWT.SWTCustomControlHelper
to use to retrieve images. - Since:
- 1.3
-
hasLeftLabelAlignment
protected boolean hasLeftLabelAlignment()
Whether the label for this control should be rendered on the left of the control. This is the case if theVControl.getLabelAlignment()
is set toLabelAlignment.LEFT
orLabelAlignment.DEFAULT
.- Returns:
true
if label should be on the left,false
otherwise- Since:
- 1.7
-
createLabel
protected final org.eclipse.swt.widgets.Control createLabel(org.eclipse.swt.widgets.Composite parent) throws NoPropertyDescriptorFoundExeption
Create theControl
displaying the label of the currentVControl
.- Parameters:
parent
- theComposite
to render onto- Returns:
- the created
Control
or null - Throws:
NoPropertyDescriptorFoundExeption
- thrown if theEStructuralFeature
of theVControl
doesn't have a registeredIItemPropertyDescriptor
- Since:
- 1.3
-
createValidationIcon
protected final org.eclipse.swt.widgets.Label createValidationIcon(org.eclipse.swt.widgets.Composite composite)
Creates a Label which is used to display the validation icon.- Parameters:
composite
- theComposite
to render onto- Returns:
- the created Label
- Since:
- 1.3
-
createViewerBinding
protected final void createViewerBinding(VDomainModelReference customControlFeature, org.eclipse.jface.viewers.StructuredViewer viewer, org.eclipse.core.databinding.property.value.IValueProperty[] labelProperties)
Creates a binding for aStructuredViewer
based on aECPCustomControlFeature
and the array ofIValueProperties
for labels.- Parameters:
customControlFeature
- theECPCustomControlFeature
to useviewer
- theStructuredViewer
to bindlabelProperties
- the array ifIValueProperties
to use for labels
-
getObservableList
@Deprecated protected final org.eclipse.core.databinding.observable.list.IObservableList getObservableList(VDomainModelReference domainModelReference)
Deprecated.This method is deprecated and must not be used anymore. Use thedatabinding service
instead.Return anIObservableList
based on aVDomainModelReference
.- Parameters:
domainModelReference
- theVDomainModelReference
to use- Returns:
- the
IObservableList
- Since:
- 1.3
-
getEditingDomain
protected final org.eclipse.emf.edit.domain.EditingDomain getEditingDomain(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Returns theEditingDomain
for the providedEStructuralFeature.Setting
.- Parameters:
setting
- the providedEStructuralFeature.Setting
- Returns:
- the
EditingDomain
of thisEStructuralFeature.Setting
- Since:
- 1.3
-
getControl
protected final <T extends ECPAbstractControl> T getControl(java.lang.Class<T> clazz, VDomainModelReference domainModelReference)
Use this method to get anECPControl
which can be used inside theECPCustomControl
.- Type Parameters:
T
- the type of the control to retrieve- Parameters:
clazz
- theClass
of theECPControl
to retrievedomainModelReference
- theVDomainModelReference
to retrieve a control for- Returns:
- the
ECPControl
that is fitting the most for theECPCustomControlFeature
. Can also be null. - Since:
- 1.3
-
getItemPropertyDescriptor
protected final org.eclipse.emf.edit.provider.IItemPropertyDescriptor getItemPropertyDescriptor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Return theIItemPropertyDescriptor
describing thisEStructuralFeature.Setting
.- Parameters:
setting
- theEStructuralFeature.Setting
to use for identifying theIItemPropertyDescriptor
.- Returns:
- the
IItemPropertyDescriptor
- Since:
- 1.3
-
getResolvedDomainModelReferences
protected final java.util.List<VDomainModelReference> getResolvedDomainModelReferences()
Returns a list of allVDomainModelReferences
which were already resolved and thus can be used for binding etc.- Returns:
- the List of
VDomainModelReferences
- Since:
- 1.3
-
getResolvedDomainModelReference
protected final VDomainModelReference getResolvedDomainModelReference(org.eclipse.emf.ecore.EStructuralFeature feature)
Finds theVDomainModelReference
which provides a specificEStructuralFeature
.- Parameters:
feature
- theEStructuralFeature
to find theVDomainModelReference
for- Returns:
- the
VDomainModelReference
or null - Since:
- 1.3
-
bindTargetToModel
protected final org.eclipse.core.databinding.Binding bindTargetToModel(VDomainModelReference modelFeature, org.eclipse.core.databinding.observable.value.IObservableValue targetValue, org.eclipse.core.databinding.UpdateValueStrategy targetToModel, org.eclipse.core.databinding.UpdateValueStrategy modelToTarget)
Method for enabling databinding on the reference/attribute of the referenced object. Throws anIllegalStateException
if theVDomainModelReference
doesn't resolve to exactly oneEStructuralFeature.Setting
.- Parameters:
modelFeature
- theVDomainModelReference
to bindtargetValue
- the target observerabletargetToModel
- update strategy target to modelmodelToTarget
- update strategy model to target- Returns:
- the resulting binding
- Since:
- 1.3
-
getEditingDomain
protected final org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()
Provides theEditingDomain
for this custom control.- Returns:
- the
EditingDomain
for this control - Since:
- 1.3
-
getValue
protected final java.lang.Object getValue(VDomainModelReference modelReference)
Returns the current set value of the feature. Throws anIllegalStateException
if theVDomainModelReference
doesn't resolve to exactly oneEStructuralFeature.Setting
.- Parameters:
modelReference
- theVDomainModelReference
to get the value for- Returns:
- the value
- Since:
- 1.3
-
setValue
protected final void setValue(VDomainModelReference modelReference, java.lang.Object newValue)
Sets the value of the feature to the new value. Throws anIllegalStateException
if theVDomainModelReference
doesn't resolve to exactly oneEStructuralFeature.Setting
.- Parameters:
modelReference
- theVDomainModelReference
to get the value fornewValue
- the value to be set- Since:
- 1.3
-
registerChangeListener
protected final void registerChangeListener(VDomainModelReference modelReference, ECPCustomControlChangeListener changeListener)
Registers a change listener on the referenced object.ECPCustomControlChangeListener.notifyChanged()
will be called when a change on the referenced object is noticed. Throws anIllegalStateException
if theVDomainModelReference
doesn't resolve to exactly oneEStructuralFeature.Setting
.- Parameters:
modelReference
- theVDomainModelReference
to register a listener forchangeListener
- the change listener to register- Since:
- 1.3
-
getGridDescription
public abstract SWTGridDescription getGridDescription()
Returns the GridDescription for this Renderer.- Returns:
- the GridDescription
- Since:
- 1.6
-
renderControl
public abstract org.eclipse.swt.widgets.Control renderControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent) throws NoRendererFoundException, NoPropertyDescriptorFoundExeption
Renders the control.- Parameters:
cell
- theSWTGridCell
of the control to renderparent
- theComposite
to render on- Returns:
- the rendered
Control
- Throws:
NoRendererFoundException
- this is thrown when a renderer cannot be foundNoPropertyDescriptorFoundExeption
- this is thrown when no property descriptor can be found- Since:
- 1.6
-
applyValidation
public final void applyValidation()
Called by the framework to apply validation changes.- Since:
- 1.3
-
applyReadOnly
public final void applyReadOnly(java.util.Map<SWTGridCell,org.eclipse.swt.widgets.Control> controls)
Applies the current readOnlyState.- Parameters:
controls
- the controls provided- Since:
- 1.3
-
setControlEnabled
protected void setControlEnabled(SWTGridCell gridCell, org.eclipse.swt.widgets.Control control, boolean enabled)
Override this to control which and how controls should be enabled/disabled.- Parameters:
gridCell
- theSWTGridCell
to enable/disablecontrol
- theControl
to enable/disableenabled
- true if the control should be enabled false otherwise- Since:
- 1.6
-
applyEnable
public final void applyEnable(java.util.Map<SWTGridCell,org.eclipse.swt.widgets.Control> controls)
Applies the current enable state.- Parameters:
controls
- the controls- Since:
- 1.3
-
setEditable
protected boolean setEditable(boolean editable)
Allows custom controls to call specific code for setting controls editable or not. The result indicates whether to call the default editable- Parameters:
editable
- if the current state is editable- Returns:
- true if default editable modification should be executed
- Since:
- 1.3
-
createSimpleGrid
protected final SWTGridDescription createSimpleGrid(int rows, int columns)
Creates a simple grid.- Parameters:
rows
- the number of rowscolumns
- the number of columns- Returns:
- the
GridDescription
- Since:
- 1.6
-
canHandleControlProcessor
protected boolean canHandleControlProcessor()
Indicates if the given custom control takes the responsibility to call a possibly existing
EMFFormsControlProcessorService
itself.The default implementation returns
false
.- Returns:
true
if the custom control can handle theEMFFormsControlProcessorService
itself,false
otherwise.- Since:
- 1.8
-
-