Class AbstractSWTRenderer<VELEMENT extends VElement>
- java.lang.Object
-
- org.eclipse.emf.ecp.view.model.common.AbstractRenderer<VELEMENT>
-
- org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer<VELEMENT>
-
- Type Parameters:
VELEMENT
- the actual type of theVElement
to be drawn
- Direct Known Subclasses:
AbstractAdditionalSWTRenderer
,AbstractControlSWTRenderer
,AbstractJFaceTreeRenderer
,AbstractSectionSWTRenderer
,AbstractSWTRenderer_PTest.TestAbstractSWTRenderer
,AbstractSWTTabRenderer
,CompoundControlSWTRenderer
,CompoundControlSWTRenderer_ITest.DummyRenderer
,ContainerSWTRenderer
,ControlGridSWTRenderer
,CustomControlSWTRenderer
,EmbeddedGroupSWTRenderer
,EmptyVElementSWTRenderer
,ExpandBarCategorizationElementRenderer
,GroupedGridSWTRenderer
,HorizontalLayoutSWTRenderer
,LabelSWTRenderer
,SectionedAreaSWTRenderer
,SWTCategorizationRenderer
,SWTStackLayoutRenderer
,TreeMasterDetailSWTRenderer
,UnknownVElementSWTRenderer
public abstract class AbstractSWTRenderer<VELEMENT extends VElement> extends AbstractRenderer<VELEMENT>
Common base class for all SWT specific renderer classes. A renderer using other renderers to render its contents must call this methods in this order:getGridDescription(SWTGridDescription)
for each SWTGridCellrender(SWTGridCell, Composite)
finalizeRendering(Composite)
finalizeRendering(Composite)
after the rendering, the automatic disposing of the renderer will not work, as well as the initial validation check.- Since:
- 1.2
- Author:
- Eugen Neufeld
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CUSTOM_VARIANT
Variant constant for indicating RAP controls.
-
Constructor Summary
Constructors Constructor Description AbstractSWTRenderer(VELEMENT vElement, ViewModelContext viewContext, ReportService reportService)
Default Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete 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
applyValidation()
Allows implementers to display the validation state of the control.protected void
applyValidation(VDiagnostic oldDiagnostic, VDiagnostic newDiagnostic)
Called before theapplyValidation()
.protected void
applyVisible()
Allows implementers to check and set the visibility on the whole result row.protected boolean
canReveal(org.eclipse.swt.widgets.Control control)
Query whether a givencontrol
can plausibly be revealed.protected void
dispose()
Disposes all resources used by the renderer.void
finalizeRendering(org.eclipse.swt.widgets.Composite parent)
Called by the framework to initialize listener.protected java.util.Map<SWTGridCell,org.eclipse.swt.widgets.Control>
getControls()
Returns a copy of theGridCell
toControl
map.protected java.lang.String
getDefaultFontName(org.eclipse.swt.widgets.Control control)
abstract SWTGridDescription
getGridDescription(SWTGridDescription gridDescription)
Returns the GridDescription for this Renderer.protected boolean
ignoreEnableOnReadOnly()
Returnstrue
when read only will always force control to be disabled.void
init()
Initializes theAbstractSWTRenderer
.protected boolean
isRenderingFinished()
Query whether rendering has completed and I am ready for user interaction.protected void
postInit()
Use this method to initialize objects which are needed during rendering.protected void
preInit()
Use this method to initialize objects which are needed already before rendering.org.eclipse.swt.widgets.Control
render(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent)
Renders the passedVElement
.protected abstract org.eclipse.swt.widgets.Control
renderControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent)
Renders the passedVElement
.void
scrollToReveal()
If my control is rendered within a scrolled composite, scroll that composite to reveal me.protected boolean
scrollToReveal(org.eclipse.swt.widgets.Control control)
Scroll composites as necessary to reveal the givencontrol
and then request focus.protected void
setControlEnabled(SWTGridCell gridCell, org.eclipse.swt.widgets.Control control, boolean enabled)
Wraps the call to enable/disable a control.-
Methods inherited from class org.eclipse.emf.ecp.view.model.common.AbstractRenderer
checkRenderer, getRenderer, getReportService, getVElement, getViewModelContext, register
-
-
-
-
Field Detail
-
CUSTOM_VARIANT
protected static final java.lang.String CUSTOM_VARIANT
Variant constant for indicating RAP controls.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractSWTRenderer
public AbstractSWTRenderer(VELEMENT vElement, ViewModelContext viewContext, ReportService reportService)
Default Constructor.- Parameters:
vElement
- the view element to be renderedviewContext
- The view model contextreportService
- the ReportService to use- Since:
- 1.6
-
-
Method Detail
-
getGridDescription
public abstract SWTGridDescription getGridDescription(SWTGridDescription gridDescription)
Returns the GridDescription for this Renderer.- Parameters:
gridDescription
- the currentSWTGridDescription
- Returns:
- the number of controls per row
- Since:
- 1.3
-
init
public final void init()
Initializes theAbstractSWTRenderer
.- Since:
- 1.6
-
getControls
protected final java.util.Map<SWTGridCell,org.eclipse.swt.widgets.Control> getControls()
Returns a copy of theGridCell
toControl
map.- Returns:
- a copy of the controls map
- Since:
- 1.3
-
preInit
protected void preInit()
Use this method to initialize objects which are needed already before rendering.- Since:
- 1.3
-
postInit
protected void postInit()
Use this method to initialize objects which are needed during rendering.- Since:
- 1.3
-
dispose
protected void dispose()
Disposes all resources used by the renderer. Don't forget to call super.dispose if overwriting this method.- Overrides:
dispose
in classAbstractRenderer<VELEMENT extends VElement>
- Since:
- 1.3
-
render
public org.eclipse.swt.widgets.Control render(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent) throws NoRendererFoundException, NoPropertyDescriptorFoundExeption
Renders the passedVElement
.- 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.3
-
finalizeRendering
public void finalizeRendering(org.eclipse.swt.widgets.Composite parent)
Called by the framework to initialize listener.- Parameters:
parent
- the parent used during render- Since:
- 1.3
-
isRenderingFinished
protected boolean isRenderingFinished()
Query whether rendering has completed and I am ready for user interaction.- Returns:
- whether rendering has finished
- Since:
- 1.22
-
ignoreEnableOnReadOnly
protected boolean ignoreEnableOnReadOnly()
Returnstrue
when read only will always force control to be disabled.- Returns:
true
when read only will always force control to be disabled.
-
renderControl
protected abstract org.eclipse.swt.widgets.Control renderControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent) throws NoRendererFoundException, NoPropertyDescriptorFoundExeption
Renders the passedVElement
.- Parameters:
cell
- theGridCell
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.3
-
applyReadOnly
protected void applyReadOnly()
Marks a controls as readonly.- Since:
- 1.3
-
applyEnable
protected void applyEnable()
Allows implementers to set a control to enabled.- Since:
- 1.3
-
setControlEnabled
protected void setControlEnabled(SWTGridCell gridCell, org.eclipse.swt.widgets.Control control, boolean enabled)
Wraps the call to enable/disable a control.- Parameters:
gridCell
- theSWTGridCell
to enable/disablecontrol
- theControl
to enable/disableenabled
- true if control should be enabled, false otherwise- Since:
- 1.3
-
applyVisible
protected void applyVisible()
Allows implementers to check and set the visibility on the whole result row.- Since:
- 1.3
-
applyValidation
protected void applyValidation()
Allows implementers to display the validation state of the control. The default implementation does nothing.- Since:
- 1.3
-
applyValidation
protected void applyValidation(VDiagnostic oldDiagnostic, VDiagnostic newDiagnostic)
Called before theapplyValidation()
. This method allows to create a diff between the old diagnostic and the new diagnostic and thus improve the performance of the overlay apply by triggering it only on the relevant elements.- Parameters:
oldDiagnostic
- The previousVDiagnostic
newDiagnostic
- The currentVDiagnostic
- Since:
- 1.14
-
getDefaultFontName
protected java.lang.String getDefaultFontName(org.eclipse.swt.widgets.Control control)
- Parameters:
control
- The control to derive the default font name from- Returns:
- String the default font name on the system.
- Since:
- 1.5
-
scrollToReveal
public void scrollToReveal()
If my control is rendered within a scrolled composite, scroll that composite to reveal me.- Since:
- 1.22
-
scrollToReveal
protected boolean scrollToReveal(org.eclipse.swt.widgets.Control control)
Scroll composites as necessary to reveal the givencontrol
and then request focus.- Parameters:
control
- the control to reveal and focus- Returns:
- whether the focus was successfully set (usually because the control is one that can receive input focus)
- Since:
- 1.22
-
canReveal
protected boolean canReveal(org.eclipse.swt.widgets.Control control)
Query whether a givencontrol
can plausibly be revealed.- Parameters:
control
- a control to be revealed- Returns:
- whether it reasonably can be revealed
- Since:
- 1.22
-
-