Class TextControlSWTRenderer
- 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>
-
- org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlSWTRenderer
-
- org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlSWTControlSWTRenderer
-
- org.eclipse.emf.ecp.view.spi.core.swt.renderer.TextControlSWTRenderer
-
- All Implemented Interfaces:
RootDomainModelChangeListener
- Direct Known Subclasses:
InstanceTypeNameSWTRenderer
,NumberControlSWTRenderer
,RichTextControlSWTRenderer
,XMLDateControlSWTRenderer
public class TextControlSWTRenderer extends SimpleControlSWTControlSWTRenderer
Renders texts.- Since:
- 1.5
- Author:
- Eugen Neufeld
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
TextControlSWTRenderer.ModelToTargetUpdateStrategy
The strategy to convert from model to target.protected class
TextControlSWTRenderer.TargetToModelUpdateStrategy
The strategy to convert from target to model.
-
Field Summary
-
Fields inherited from class org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer
CUSTOM_VARIANT
-
-
Constructor Summary
Constructors Constructor Description TextControlSWTRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, EMFFormsEditSupport emfFormsEditSupport)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.core.databinding.Binding
bindValue(org.eclipse.swt.widgets.Control text, org.eclipse.core.databinding.observable.value.IObservableValue modelValue, org.eclipse.core.databinding.DataBindingContext dataBindingContext, org.eclipse.core.databinding.UpdateValueStrategy targetToModel, org.eclipse.core.databinding.UpdateValueStrategy modelToTarget)
Creates a focus out binding for this control.protected java.lang.Object
convert(org.eclipse.swt.widgets.Text text, org.eclipse.emf.ecore.EDataType attributeType, java.lang.String value)
Convert the given value from target to model.protected org.eclipse.core.databinding.Binding[]
createBindings(org.eclipse.swt.widgets.Control control)
Create theBindings
for this controls.protected org.eclipse.swt.widgets.Control
createSWTControl(org.eclipse.swt.widgets.Composite parent)
Creates the Control.protected org.eclipse.core.databinding.Binding
createTooltipBinding(org.eclipse.swt.widgets.Control text, org.eclipse.core.databinding.observable.value.IObservableValue modelValue, org.eclipse.core.databinding.DataBindingContext dataBindingContext, org.eclipse.core.databinding.UpdateValueStrategy targetToModel, org.eclipse.core.databinding.UpdateValueStrategy modelToTarget)
Creates a tooltip binding for this control.protected org.eclipse.swt.widgets.Control
getControlCompositeFromControl(org.eclipse.swt.widgets.Control control)
Returns the control composite that contains the text field from the parent composite created by theSimpleControlSWTRenderer
.protected int
getDefaultAlignment()
Return the default alignment value for this renderer.protected EMFFormsEditSupport
getEMFFormsEditSupport()
protected java.lang.String
getTextFromTextField(org.eclipse.swt.widgets.Text text, org.eclipse.emf.ecore.EDataType attributeType)
Gets the text displayed in the textfield.protected java.lang.String
getTextMessage()
Returns the text which should be set as the message text on the Text field.protected java.lang.String
getTextVariantID()
The VariantId to use e.g.protected int
getTextWidgetStyle()
The style to apply to the text widget.protected java.lang.String
getUnsetText()
Provide the unset text to show on the label when value is unset.protected boolean
isUnsetButtonLeftOfControlComposite()
Returns whether the unset button is placed left of the control composite containing the text field.protected void
setControlEnabled(SWTGridCell gridCell, org.eclipse.swt.widgets.Control control, boolean enabled)
Wraps the call to enable/disable a control.protected void
setValidationColor(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color validationColor)
Set the provided validation color as the background for the provided control.protected void
setValidationForegroundColor(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color validationColor)
Set the provided validation color as the foreground for the provided control.protected boolean
useOnModifyDatabinding()
WhetherSWT.Modify
orSWT.FocusOut
shall be used as the target databinding trigger.-
Methods inherited from class org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlSWTControlSWTRenderer
createControl, getFeature, rootDomainModelChanged, withPreSetValidation
-
Methods inherited from class org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlSWTRenderer
applyReadOnly, applyValidation, createControlCell, createDefaultUnsettableStyleProperty, createLabelCell, createValidationCell, dispose, getGridDescription, getLabelWidth, getUnsettableStyleProperty, isUnsettable, renderControl, setControlIdData
-
Methods inherited from class org.eclipse.emf.ecp.view.spi.core.swt.AbstractControlSWTRenderer
applyEnable, applyUnchangeableFeature, canHandleControlProcessor, createLabel, createValidationIcon, defaultHandleControlProcessor, defaultHandleControlProcessorForCell, getDataBindingContext, getEditingDomain, getEMFFormsDatabinding, getEMFFormsLabelProvider, getLabelStyleBits, getModelValue, getValidationBackgroundColor, getValidationBackgroundColor, getValidationForegroundColor, getValidationForegroundColor, getValidationIcon, getValidationIcon, getVTViewTemplateProvider, hasLeftLabelAlignment, isUnchangeableFeature, notifyChange, postInit, render
-
Methods inherited from class org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer
applyValidation, applyVisible, canReveal, finalizeRendering, getControls, getDefaultFontName, ignoreEnableOnReadOnly, init, isRenderingFinished, preInit, scrollToReveal, scrollToReveal
-
Methods inherited from class org.eclipse.emf.ecp.view.model.common.AbstractRenderer
checkRenderer, getRenderer, getReportService, getVElement, getViewModelContext, register
-
-
-
-
Constructor Detail
-
TextControlSWTRenderer
@Inject public TextControlSWTRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, EMFFormsEditSupport emfFormsEditSupport)
Default constructor.- Parameters:
vElement
- the view model element to be renderedviewContext
- the view contextreportService
- TheReportService
emfFormsDatabinding
- TheEMFFormsDatabinding
emfFormsLabelProvider
- TheEMFFormsLabelProvider
vtViewTemplateProvider
- TheVTViewTemplateProvider
emfFormsEditSupport
- TheEMFFormsEditSupport
- Since:
- 1.6
-
-
Method Detail
-
createBindings
protected org.eclipse.core.databinding.Binding[] createBindings(org.eclipse.swt.widgets.Control control) throws DatabindingFailedException
Description copied from class:SimpleControlSWTControlSWTRenderer
Create theBindings
for this controls.- Specified by:
createBindings
in classSimpleControlSWTControlSWTRenderer
- Parameters:
control
- theControl
to create the binding for- Returns:
- all the bindings created by this renderer
- Throws:
DatabindingFailedException
- if the creation of the bindings fails.
-
createSWTControl
protected org.eclipse.swt.widgets.Control createSWTControl(org.eclipse.swt.widgets.Composite parent)
Description copied from class:SimpleControlSWTControlSWTRenderer
Creates the Control.- Specified by:
createSWTControl
in classSimpleControlSWTControlSWTRenderer
- Parameters:
parent
- theComposite
to use as a parent- Returns:
- the created control
-
convert
protected java.lang.Object convert(org.eclipse.swt.widgets.Text text, org.eclipse.emf.ecore.EDataType attributeType, java.lang.String value) throws DatabindingFailedException
Convert the given value from target to model.- Parameters:
text
- the Text controlattributeType
- the model data typevalue
- the target value to convert- Returns:
- the converted value
- Throws:
DatabindingFailedException
- in case the databinding failed- Since:
- 1.13
-
getTextMessage
protected java.lang.String getTextMessage()
Returns the text which should be set as the message text on the Text field.- Returns:
- the string to show as the message
- Since:
- 1.6
-
bindValue
protected org.eclipse.core.databinding.Binding bindValue(org.eclipse.swt.widgets.Control text, org.eclipse.core.databinding.observable.value.IObservableValue modelValue, org.eclipse.core.databinding.DataBindingContext dataBindingContext, org.eclipse.core.databinding.UpdateValueStrategy targetToModel, org.eclipse.core.databinding.UpdateValueStrategy modelToTarget)
Creates a focus out binding for this control.- Parameters:
text
- theText
to bindmodelValue
- theIObservableValue
to binddataBindingContext
- theDataBindingContext
to usetargetToModel
- theUpdateValueStrategy
from target to ModelmodelToTarget
- theUpdateValueStrategy
from model to target- Returns:
- the created
Binding
-
useOnModifyDatabinding
protected boolean useOnModifyDatabinding()
WhetherSWT.Modify
orSWT.FocusOut
shall be used as the target databinding trigger.- Returns:
true
if Modify should be used,false
otherwise- Since:
- 1.9
-
createTooltipBinding
protected org.eclipse.core.databinding.Binding createTooltipBinding(org.eclipse.swt.widgets.Control text, org.eclipse.core.databinding.observable.value.IObservableValue modelValue, org.eclipse.core.databinding.DataBindingContext dataBindingContext, org.eclipse.core.databinding.UpdateValueStrategy targetToModel, org.eclipse.core.databinding.UpdateValueStrategy modelToTarget)
Creates a tooltip binding for this control.- Parameters:
text
- theText
to bindmodelValue
- theIObservableValue
to binddataBindingContext
- theDataBindingContext
to usetargetToModel
- theUpdateValueStrategy
from target to ModelmodelToTarget
- theUpdateValueStrategy
from model to target- Returns:
- the created
Binding
-
getTextWidgetStyle
protected int getTextWidgetStyle()
The style to apply to the text widget. This can be changed by the concrete classes.- Returns:
- the style to apply
-
getEMFFormsEditSupport
protected EMFFormsEditSupport getEMFFormsEditSupport()
- Returns:
- the
EMFFormsEditSupport
- Since:
- 1.10
-
getDefaultAlignment
protected int getDefaultAlignment()
Return the default alignment value for this renderer.- Returns:
- the alignment to use if no style was defined
-
getTextVariantID
protected java.lang.String getTextVariantID()
The VariantId to use e.g. for RAP- Returns:
- the String identifying this control
-
setControlEnabled
protected void setControlEnabled(SWTGridCell gridCell, org.eclipse.swt.widgets.Control control, boolean enabled)
Description copied from class:AbstractSWTRenderer
Wraps the call to enable/disable a control.- Overrides:
setControlEnabled
in classSimpleControlSWTRenderer
- Parameters:
gridCell
- theSWTGridCell
to enable/disablecontrol
- theControl
to enable/disableenabled
- true if control should be enabled, false otherwise
-
getTextFromTextField
protected java.lang.String getTextFromTextField(org.eclipse.swt.widgets.Text text, org.eclipse.emf.ecore.EDataType attributeType)
Gets the text displayed in the textfield.- Parameters:
text
- theText
attributeType
- theEDataType
- Returns:
- the string displayed in the
Text
- Since:
- 1.13
-
getUnsetText
protected java.lang.String getUnsetText()
Provide the unset text to show on the label when value is unset.- Specified by:
getUnsetText
in classSimpleControlSWTRenderer
- Returns:
- the text to show on the unset label
- See Also:
SimpleControlSWTRenderer.getUnsetText()
-
setValidationColor
protected void setValidationColor(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color validationColor)
Description copied from class:SimpleControlSWTRenderer
Set the provided validation color as the background for the provided control.- Overrides:
setValidationColor
in classSimpleControlSWTRenderer
- Parameters:
control
- the control to set the color onvalidationColor
- the validation color to set
-
setValidationForegroundColor
protected void setValidationForegroundColor(org.eclipse.swt.widgets.Control control, org.eclipse.swt.graphics.Color validationColor)
Description copied from class:SimpleControlSWTRenderer
Set the provided validation color as the foreground for the provided control.- Overrides:
setValidationForegroundColor
in classSimpleControlSWTRenderer
- Parameters:
control
- the control to set the color onvalidationColor
- the validation color to set
-
isUnsetButtonLeftOfControlComposite
protected boolean isUnsetButtonLeftOfControlComposite()
Returns whether the unset button is placed left of the control composite containing the text field.- Returns:
true
if the control is unsettable and the unset button is left of the text field,false
otherwise- Since:
- 1.14
-
getControlCompositeFromControl
protected org.eclipse.swt.widgets.Control getControlCompositeFromControl(org.eclipse.swt.widgets.Control control)
Returns the control composite that contains the text field from the parent composite created by theSimpleControlSWTRenderer
.- Parameters:
control
- The edit control created by theSimpleControlSWTRenderer
- Returns:
- the control composite containing the text field
- Since:
- 1.14
-
-