Class AbstractControlSWTRenderer<VCONTROL extends VControl>
- java.lang.Object
-
- org.eclipse.emf.ecp.view.model.common.AbstractRenderer<VELEMENT>
-
- org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer<VCONTROL>
-
- org.eclipse.emf.ecp.view.spi.core.swt.AbstractControlSWTRenderer<VCONTROL>
-
- Type Parameters:
VCONTROL
- theVControl
of this renderer.
- All Implemented Interfaces:
RootDomainModelChangeListener
- Direct Known Subclasses:
DIControlSWTRenderer
,MultiAttributeSWTRenderer
,MultiReferenceSWTRenderer
,SimpleControlSWTRenderer
,TableControlSWTRenderer
,TypedElementBoundsRenderer
public abstract class AbstractControlSWTRenderer<VCONTROL extends VControl> extends AbstractSWTRenderer<VCONTROL> implements RootDomainModelChangeListener
Super class for all kinds of control renderer.- Author:
- Eugen Neufeld
-
-
Field Summary
-
Fields inherited from class org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer
CUSTOM_VARIANT
-
-
Constructor Summary
Constructors Constructor Description AbstractControlSWTRenderer(VCONTROL vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider)
Default constructor.AbstractControlSWTRenderer(VCONTROL vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, SWTValidationHelper swtValidationHelper)
Additional constructor allowing to specify a customSWTValidationHelper
.AbstractControlSWTRenderer(VCONTROL vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, SWTValidationUiService validationUiService)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
applyEnable()
Allows implementers to set a control to enabled.protected void
applyReadOnly()
Marks a controls as readonly.protected void
applyUnchangeableFeature()
This method is applied if the control's feature is configured as unchangeable.protected boolean
canHandleControlProcessor()
Indicates if the given Control SWT renderer 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 org.eclipse.swt.widgets.Label
createValidationIcon(org.eclipse.swt.widgets.Composite composite)
Creates a validation icon.protected void
defaultHandleControlProcessor(org.eclipse.swt.widgets.Control control)
Calls a possibly existingEMFFormsControlProcessorService
for the givencontrol
.protected void
defaultHandleControlProcessorForCell(org.eclipse.swt.widgets.Control control, SWTGridCell cell)
This method is called by {linkrender(SWTGridCell, Composite)
for eachcontrol
andcell
ifcanHandleControlProcessor()
returnsfalse
.protected void
dispose()
Disposes all resources used by the renderer.protected org.eclipse.core.databinding.DataBindingContext
getDataBindingContext()
Creates a newDataBindingContext
.protected org.eclipse.emf.edit.domain.EditingDomain
getEditingDomain(org.eclipse.emf.ecore.EObject domainModel)
Returns theEditingDomain
for the provideddomain model
.protected EMFFormsDatabinding
getEMFFormsDatabinding()
TheEMFFormsDatabinding
to use.protected EMFFormsLabelProvider
getEMFFormsLabelProvider()
TheEMFFormsLabelProvider
to use.protected int
getLabelStyleBits()
protected org.eclipse.core.databinding.observable.value.IObservableValue
getModelValue()
Returns anIObservableValue
based on the control's domain model reference and domain model.protected org.eclipse.swt.graphics.Color
getValidationBackgroundColor()
Returns the background color for the current validation result of this control'sVElement
.protected org.eclipse.swt.graphics.Color
getValidationBackgroundColor(int severity)
Deprecated.usegetValidationBackgroundColor()
for default behavior or use theSWTValidationUiService
if you need to get the color for a specific diagnostic.protected org.eclipse.swt.graphics.Color
getValidationForegroundColor()
Returns the foreground color for the current validation result of this control'sVElement
.protected org.eclipse.swt.graphics.Color
getValidationForegroundColor(int severity)
Deprecated.usegetValidationForegroundColor()
for default behavior or use theSWTValidationUiService
if you need to get the color for a specific diagnostic.protected org.eclipse.swt.graphics.Image
getValidationIcon()
Returns the validation icon for the current validation result of this control'sVElement
.protected org.eclipse.swt.graphics.Image
getValidationIcon(int severity)
Deprecated.usegetValidationIcon()
for default behavior or use theSWTValidationUiService
if you need to get the color for a specific diagnostic.protected VTViewTemplateProvider
getVTViewTemplateProvider()
TheVTViewTemplateProvider
to use.protected boolean
hasLeftLabelAlignment()
Whether the label for this control should be rendered on the left of the control.protected boolean
isUnchangeableFeature()
Checks if the value referenced by the DMR can be changed or not by the user.void
notifyChange()
Notifies this listener that the domain model of theEMFFormsViewContext
has changed.protected void
postInit()
Use this method to initialize objects which are needed during rendering.org.eclipse.swt.widgets.Control
render(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent)
Renders the passedVElement
.protected void
rootDomainModelChanged()
This method is called innotifyChange()
when the root domain model of the view model context changes.-
Methods inherited from class org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer
applyValidation, applyValidation, applyVisible, canReveal, finalizeRendering, getControls, getDefaultFontName, getGridDescription, ignoreEnableOnReadOnly, init, isRenderingFinished, preInit, renderControl, scrollToReveal, scrollToReveal, setControlEnabled
-
Methods inherited from class org.eclipse.emf.ecp.view.model.common.AbstractRenderer
checkRenderer, getRenderer, getReportService, getVElement, getViewModelContext, register
-
-
-
-
Constructor Detail
-
AbstractControlSWTRenderer
public AbstractControlSWTRenderer(VCONTROL vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider)
Default constructor.- Parameters:
vElement
- the view model element to be renderedviewContext
- the view contextemfFormsDatabinding
- TheEMFFormsDatabinding
emfFormsLabelProvider
- TheEMFFormsLabelProvider
reportService
- TheReportService
vtViewTemplateProvider
- TheVTViewTemplateProvider
- Since:
- 1.6
-
AbstractControlSWTRenderer
public AbstractControlSWTRenderer(VCONTROL vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, SWTValidationHelper swtValidationHelper)
Additional constructor allowing to specify a customSWTValidationHelper
.- Parameters:
vElement
- the view model element to be renderedviewContext
- the view contextemfFormsDatabinding
- TheEMFFormsDatabinding
emfFormsLabelProvider
- TheEMFFormsLabelProvider
reportService
- TheReportService
vtViewTemplateProvider
- TheVTViewTemplateProvider
swtValidationHelper
- TheSWTValidationHelper
- Since:
- 1.23
-
AbstractControlSWTRenderer
public AbstractControlSWTRenderer(VCONTROL vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, SWTValidationUiService validationUiService)
Default constructor.- Parameters:
vElement
- the view model element to be renderedviewContext
- the view contextemfFormsDatabinding
- TheEMFFormsDatabinding
emfFormsLabelProvider
- TheEMFFormsLabelProvider
reportService
- TheReportService
vtViewTemplateProvider
- TheVTViewTemplateProvider
validationUiService
- TheSWTValidationUiService
- Since:
- 1.23
-
-
Method Detail
-
getEMFFormsDatabinding
protected EMFFormsDatabinding getEMFFormsDatabinding()
TheEMFFormsDatabinding
to use.- Returns:
- The EMFFormsDatabinding
- Since:
- 1.6
-
getEMFFormsLabelProvider
protected EMFFormsLabelProvider getEMFFormsLabelProvider()
TheEMFFormsLabelProvider
to use.- Returns:
- The EMFFormsLabelProvider
- Since:
- 1.6
-
getVTViewTemplateProvider
protected VTViewTemplateProvider getVTViewTemplateProvider()
TheVTViewTemplateProvider
to use.- Returns:
- The VTViewTemplateProvider
- Since:
- 1.6
-
postInit
protected void postInit()
Description copied from class:AbstractSWTRenderer
Use this method to initialize objects which are needed during rendering.- Overrides:
postInit
in classAbstractSWTRenderer<VCONTROL extends VControl>
-
isUnchangeableFeature
protected boolean isUnchangeableFeature()
Checks if the value referenced by the DMR can be changed or not by the user.- Returns:
true
if the value cannot be changed.
-
render
public org.eclipse.swt.widgets.Control render(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent) throws NoRendererFoundException, NoPropertyDescriptorFoundExeption
Description copied from class:AbstractSWTRenderer
Renders the passedVElement
.- Overrides:
render
in classAbstractSWTRenderer<VCONTROL extends VControl>
- 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
-
applyUnchangeableFeature
protected void applyUnchangeableFeature()
This method is applied if the control's feature is configured as unchangeable. The renderer is usually disabled when feature is not changeable.- Since:
- 1.20
-
canHandleControlProcessor
protected boolean canHandleControlProcessor()
Indicates if the given Control SWT renderer takes the responsibility to call a possibly existing
EMFFormsControlProcessorService
itself.The default implementation returns
false
.- Returns:
true
if the Control SWT renderer can handle theEMFFormsControlProcessorService
itself,false
otherwise.- Since:
- 1.8
-
defaultHandleControlProcessorForCell
protected void defaultHandleControlProcessorForCell(org.eclipse.swt.widgets.Control control, SWTGridCell cell)
This method is called by {linkrender(SWTGridCell, Composite)
for eachcontrol
andcell
ifcanHandleControlProcessor()
returnsfalse
. The default implementation forwards todefaultHandleControlProcessor(Control)
if the cell's column is2
.- Parameters:
control
- TheControl
which is to be processed by theEMFFormsControlProcessorService
.cell
- TheSWTGridCell
for the givencontrol
.- Since:
- 1.8
-
defaultHandleControlProcessor
protected void defaultHandleControlProcessor(org.eclipse.swt.widgets.Control control)
Calls a possibly existingEMFFormsControlProcessorService
for the givencontrol
.- Parameters:
control
- TheControl
which is to be processed by theEMFFormsControlProcessorService
.- Since:
- 1.8
-
dispose
protected void dispose()
Description copied from class:AbstractSWTRenderer
Disposes all resources used by the renderer. Don't forget to call super.dispose if overwriting this method.- Overrides:
dispose
in classAbstractSWTRenderer<VCONTROL extends VControl>
-
getValidationIcon
@Deprecated protected final org.eclipse.swt.graphics.Image getValidationIcon(int severity)
Deprecated.usegetValidationIcon()
for default behavior or use theSWTValidationUiService
if you need to get the color for a specific diagnostic.Returns the validation icon matching the given severity.- Parameters:
severity
- the severity of theDiagnostic
- Returns:
- the icon to be displayed, or
null
when no icon is to be displayed
-
getValidationIcon
protected final org.eclipse.swt.graphics.Image getValidationIcon()
Returns the validation icon for the current validation result of this control'sVElement
.- Returns:
- the icon to be displayed, or
null
when no icon is to be displayed - Since:
- 1.23
-
getValidationBackgroundColor
@Deprecated protected final org.eclipse.swt.graphics.Color getValidationBackgroundColor(int severity)
Deprecated.usegetValidationBackgroundColor()
for default behavior or use theSWTValidationUiService
if you need to get the color for a specific diagnostic.Returns the background color for a control with the given validation severity.- Parameters:
severity
- severity the severity of theDiagnostic
- Returns:
- the color to be used as a background color
-
getValidationBackgroundColor
protected final org.eclipse.swt.graphics.Color getValidationBackgroundColor()
Returns the background color for the current validation result of this control'sVElement
.- Returns:
- the color to be used as a background color
- Since:
- 1.23
-
getValidationForegroundColor
@Deprecated protected final org.eclipse.swt.graphics.Color getValidationForegroundColor(int severity)
Deprecated.usegetValidationForegroundColor()
for default behavior or use theSWTValidationUiService
if you need to get the color for a specific diagnostic.Returns the foreground color for a control with the given validation severity.- Parameters:
severity
- severity the severity of theDiagnostic
- Returns:
- the color to be used as a foreground color
- Since:
- 1.10
-
getValidationForegroundColor
protected final org.eclipse.swt.graphics.Color getValidationForegroundColor()
Returns the foreground color for the current validation result of this control'sVElement
.- Returns:
- the color to be used as a foreground color
- Since:
- 1.23
-
getDataBindingContext
protected final org.eclipse.core.databinding.DataBindingContext getDataBindingContext()
Creates a newDataBindingContext
.- Returns:
- a new
DataBindingContext
each time this method is called
-
getModelValue
protected final org.eclipse.core.databinding.observable.value.IObservableValue getModelValue() throws DatabindingFailedException
Returns anIObservableValue
based on the control's domain model reference and domain model.- Returns:
- the
IObservableValue
- Throws:
DatabindingFailedException
- if the databinding of the domain model object fails.- Since:
- 1.6
-
getEditingDomain
protected final org.eclipse.emf.edit.domain.EditingDomain getEditingDomain(org.eclipse.emf.ecore.EObject domainModel)
Returns theEditingDomain
for the provideddomain model
.- Parameters:
domainModel
- The provideddomain model
- Returns:
- The
EditingDomain
of thisdomain model
- Since:
- 1.6
-
createLabel
protected org.eclipse.swt.widgets.Control createLabel(org.eclipse.swt.widgets.Composite parent)
Create theControl
displaying the label of the currentVControl
.- Parameters:
parent
- theComposite
to render onto- Returns:
- the created
Control
or null
-
getLabelStyleBits
protected int getLabelStyleBits()
- Returns:
- the style bits for the control's label
- Since:
- 1.16
-
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
-
createValidationIcon
protected org.eclipse.swt.widgets.Label createValidationIcon(org.eclipse.swt.widgets.Composite composite)
Creates a validation icon.- Parameters:
composite
- theComposite
to create onto- Returns:
- the created Label
-
applyEnable
protected void applyEnable()
Allows implementers to set a control to enabled.- Overrides:
applyEnable
in classAbstractSWTRenderer<VCONTROL extends VControl>
- Since:
- 1.6
- See Also:
AbstractSWTRenderer.applyEnable()
-
notifyChange
public void notifyChange()
Notifies this listener that the domain model of theEMFFormsViewContext
has changed.- Specified by:
notifyChange
in interfaceRootDomainModelChangeListener
- Since:
- 1.9
- See Also:
RootDomainModelChangeListener.notifyChange()
-
rootDomainModelChanged
protected void rootDomainModelChanged() throws DatabindingFailedException
This method is called innotifyChange()
when the root domain model of the view model context changes.- Throws:
DatabindingFailedException
- If the databinding failed- Since:
- 1.9
-
applyReadOnly
protected void applyReadOnly()
Marks a controls as readonly.- Overrides:
applyReadOnly
in classAbstractSWTRenderer<VCONTROL extends VControl>
- See Also:
AbstractSWTRenderer.applyReadOnly()
-
-