Class MultiAttributeSWTRenderer
- 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.emfforms.spi.view.control.multiattribute.MultiAttributeSWTRenderer
-
- All Implemented Interfaces:
RootDomainModelChangeListener
- Direct Known Subclasses:
EcorePathsRenderer
public class MultiAttributeSWTRenderer extends AbstractControlSWTRenderer<VControl>
Renderer for MultiReferenceControl.- Author:
- David Soto Setzke, Johannes Faltermeier
-
-
Field Summary
-
Fields inherited from class org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer
CUSTOM_VARIANT
-
-
Constructor Summary
Constructors Constructor Description MultiAttributeSWTRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, ImageRegistryService imageRegistryService)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyEnable()Allows implementers to set a control to enabled.protected voidapplyReadOnly()Marks a controls as readonly.protected voidapplyValidation()Allows implementers to display the validation state of the control.protected org.eclipse.swt.widgets.CompositecreateButtonComposite(org.eclipse.swt.widgets.Composite parent, org.eclipse.core.databinding.observable.list.IObservableList list)Create the button composite.protected org.eclipse.swt.widgets.CompositecreateControlComposite(org.eclipse.swt.widgets.Composite composite)Creates the composite which will be the parent for the table.protected VTTableStylePropertycreateDefaultTableStyleProperty()Creates the defaultVTTableStyleProperty.protected org.eclipse.swt.widgets.ControlcreateErrorLabel(org.eclipse.swt.widgets.Composite parent, java.lang.Exception ex)Creates an error label for the givenException.protected org.eclipse.swt.widgets.CompositecreateTitleComposite(org.eclipse.swt.widgets.Composite parent)Creates the Title Composite containing validation and buttons.protected voidcreateUpDownButtons(org.eclipse.swt.widgets.Composite composite, org.eclipse.core.databinding.observable.list.IObservableList list)Create the up and down buttons.voiddispose()Disposes all resources used by the renderer.SWTGridDescriptiongetGridDescription(SWTGridDescription gridDescription)Returns the GridDescription for this Renderer.protected org.eclipse.swt.graphics.ImagegetImage(java.lang.String path)Returns anImagefrom the image registry.protected intgetTableHeightHint()Returns the height for the table that will be created.protected VTTableStylePropertygetTableStyleProperty()Returns theVTTableStyleProperty.protected org.eclipse.jface.viewers.TableViewergetTableViewer()Gives access to the tableViewer used to display the attributes.protected java.lang.ObjectgetValueForNewRow(org.eclipse.emf.ecore.EAttribute attribute)Returns the attribute value which should be added as a new element.protected booleanignoreEnableOnReadOnly()Returnstruewhen read only will always force control to be disabled.protected voidinitButtons(org.eclipse.core.databinding.observable.list.IObservableList list)Initializes the buttons.protected voidpostRemove(org.eclipse.jface.viewers.IStructuredSelection selection)This is called after the selected elements were deleted so that the user can handle this removal.protected org.eclipse.swt.widgets.ControlrenderControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent)Renders the passedVElement.protected org.eclipse.swt.widgets.ControlrenderMultiAttributeControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent)Renders the MultiAttribute Control.protected voidrootDomainModelChanged()This method is called inAbstractControlSWTRenderer.notifyChange()when the root domain model of the view model context changes.protected voidupdateButtonEnabling()Updates the enablement of 'addExisting', 'addNew', 'delete', 'moveUp' and 'moveDown' buttons according to the bound input.protected voidupdateButtons()Updates button visibility and enablement.protected voidupdateButtonVisibility()Updates the visibility of 'Add', 'Remove', 'Up', 'Down' buttons according to the bound input.-
Methods inherited from class org.eclipse.emf.ecp.view.spi.core.swt.AbstractControlSWTRenderer
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, init, isRenderingFinished, preInit, scrollToReveal, scrollToReveal, setControlEnabled
-
Methods inherited from class org.eclipse.emf.ecp.view.model.common.AbstractRenderer
checkRenderer, getRenderer, getReportService, getVElement, getViewModelContext, register
-
-
-
-
Constructor Detail
-
MultiAttributeSWTRenderer
@Inject public MultiAttributeSWTRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService, EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider, ImageRegistryService imageRegistryService)
Default constructor.- Parameters:
vElement- the view model element to be renderedviewContext- the view contextemfFormsDatabinding- TheEMFFormsDatabindingemfFormsLabelProvider- TheEMFFormsLabelProviderreportService- TheReportServicevtViewTemplateProvider- TheVTViewTemplateProviderimageRegistryService- TheImageRegistryService
-
-
Method Detail
-
createDefaultTableStyleProperty
protected VTTableStyleProperty createDefaultTableStyleProperty()
Creates the defaultVTTableStyleProperty.- Returns:
- the default
VTTableStyleProperty - Since:
- 1.14
-
getTableStyleProperty
protected VTTableStyleProperty getTableStyleProperty()
Returns theVTTableStyleProperty.- Returns:
- the
VTTableStyleProperty - Since:
- 1.14
-
getGridDescription
public SWTGridDescription getGridDescription(SWTGridDescription gridDescription)
Description copied from class:AbstractSWTRendererReturns the GridDescription for this Renderer.- Specified by:
getGridDescriptionin classAbstractSWTRenderer<VControl>- Parameters:
gridDescription- the currentSWTGridDescription- Returns:
- the number of controls per row
-
getTableHeightHint
protected int getTableHeightHint()
Returns the height for the table that will be created.- Returns:
- the height hint
-
getTableViewer
protected org.eclipse.jface.viewers.TableViewer getTableViewer()
Gives access to the tableViewer used to display the attributes.- Returns:
- the viewer
-
createControlComposite
protected org.eclipse.swt.widgets.Composite createControlComposite(org.eclipse.swt.widgets.Composite composite)
Creates the composite which will be the parent for the table.- Parameters:
composite- the parent composite- Returns:
- the table composite
-
getImage
protected org.eclipse.swt.graphics.Image getImage(java.lang.String path)
Returns anImagefrom the image registry.- Parameters:
path- the path to the image- Returns:
- the image
-
applyReadOnly
protected void applyReadOnly()
Description copied from class:AbstractControlSWTRendererMarks a controls as readonly.- Overrides:
applyReadOnlyin classAbstractControlSWTRenderer<VControl>- See Also:
AbstractSWTRenderer.applyReadOnly()
-
ignoreEnableOnReadOnly
protected boolean ignoreEnableOnReadOnly()
Description copied from class:AbstractSWTRendererReturnstruewhen read only will always force control to be disabled.- Overrides:
ignoreEnableOnReadOnlyin classAbstractSWTRenderer<VControl>- Returns:
truewhen read only will always force control to be disabled.
-
updateButtons
protected void updateButtons()
Updates button visibility and enablement.
-
updateButtonVisibility
protected void updateButtonVisibility()
Updates the visibility of 'Add', 'Remove', 'Up', 'Down' buttons according to the bound input.
-
updateButtonEnabling
protected void updateButtonEnabling()
Updates the enablement of 'addExisting', 'addNew', 'delete', 'moveUp' and 'moveDown' buttons according to the bound input.
-
renderControl
protected org.eclipse.swt.widgets.Control renderControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent) throws NoPropertyDescriptorFoundExeption, NoRendererFoundException
Description copied from class:AbstractSWTRendererRenders the passedVElement.- Specified by:
renderControlin classAbstractSWTRenderer<VControl>- Parameters:
cell- theGridCellof the control to renderparent- theCompositeto render on- Returns:
- the rendered
Control - Throws:
NoPropertyDescriptorFoundExeption- this is thrown when no property descriptor can be foundNoRendererFoundException- this is thrown when a renderer cannot be found
-
renderMultiAttributeControl
protected org.eclipse.swt.widgets.Control renderMultiAttributeControl(SWTGridCell cell, org.eclipse.swt.widgets.Composite parent) throws NoRendererFoundException, NoPropertyDescriptorFoundExeption
Renders the MultiAttribute Control. Renders the MultiReference control including validation and buttons whenRenderModeis set toRenderMode.DEFAULT. Only renders the MultiReferfence control without validation and buttons when renderMode is set toRenderMode.COMPACT_VERTICALLY.- Parameters:
cell- theSWTGridCell.parent- theComposite.- Returns:
- the rendered
Control - Throws:
NoRendererFoundException- theNoRendererFoundException.NoPropertyDescriptorFoundExeption- theNoPropertyDescriptorFoundExeption.- Since:
- 1.14
-
createTitleComposite
protected org.eclipse.swt.widgets.Composite createTitleComposite(org.eclipse.swt.widgets.Composite parent)
Creates the Title Composite containing validation and buttons. Buttons have to be initialized afterwards.- Parameters:
parent- the parentComposite.- Returns:
- the created
Composite. - Since:
- 1.14
-
createButtonComposite
protected org.eclipse.swt.widgets.Composite createButtonComposite(org.eclipse.swt.widgets.Composite parent, org.eclipse.core.databinding.observable.list.IObservableList list)Create the button composite. Buttons have to be initialized after the table is created.- Parameters:
parent- theCompositeparent.list- theIObservableList.- Returns:
- the created
Composite. - Since:
- 1.14
-
initButtons
protected void initButtons(org.eclipse.core.databinding.observable.list.IObservableList list)
Initializes the buttons. Call this after table is created.- Parameters:
list- theIObservableList.- Since:
- 1.14
-
createUpDownButtons
protected void createUpDownButtons(org.eclipse.swt.widgets.Composite composite, org.eclipse.core.databinding.observable.list.IObservableList list)Create the up and down buttons.- Parameters:
composite- TheCompositeto create the buttons onlist- TheIObservableListof the currentMultiAttributeSWTRenderer- Since:
- 1.17
-
getValueForNewRow
protected java.lang.Object getValueForNewRow(org.eclipse.emf.ecore.EAttribute attribute)
Returns the attribute value which should be added as a new element.- Parameters:
attribute- theEAttributewith the data type- Returns:
- the new value
- Since:
- 1.13
-
applyValidation
protected void applyValidation()
Description copied from class:AbstractSWTRendererAllows implementers to display the validation state of the control. The default implementation does nothing.- Overrides:
applyValidationin classAbstractSWTRenderer<VControl>
-
applyEnable
protected void applyEnable()
Allows implementers to set a control to enabled.- Overrides:
applyEnablein classAbstractControlSWTRenderer<VControl>- See Also:
AbstractControlSWTRenderer.applyEnable()
-
dispose
public void dispose()
Disposes all resources used by the renderer. Don't forget to call super.dispose if overwriting this method.- Overrides:
disposein classAbstractControlSWTRenderer<VControl>
-
rootDomainModelChanged
protected void rootDomainModelChanged() throws DatabindingFailedExceptionThis method is called inAbstractControlSWTRenderer.notifyChange()when the root domain model of the view model context changes.- Overrides:
rootDomainModelChangedin classAbstractControlSWTRenderer<VControl>- Throws:
DatabindingFailedException- If the databinding failed- See Also:
AbstractControlSWTRenderer.rootDomainModelChanged()
-
postRemove
protected void postRemove(org.eclipse.jface.viewers.IStructuredSelection selection)
This is called after the selected elements were deleted so that the user can handle this removal.- Parameters:
selection- TheIStructuredSelectionof the TableViewer before deletion.- Since:
- 1.17
-
createErrorLabel
protected org.eclipse.swt.widgets.Control createErrorLabel(org.eclipse.swt.widgets.Composite parent, java.lang.Exception ex)Creates an error label for the givenException.- Parameters:
parent- The parent of theLabelex- TheExceptioncausing the error- Returns:
- The error
Label - Since:
- 1.14
-
-