Skip to content

Package: CompoundControlSWTRenderer

CompoundControlSWTRenderer

nameinstructionbranchcomplexitylinemethod
CompoundControlSWTRenderer(VCompoundControl, ViewModelContext, ReportService, EMFFormsLabelProvider, EMFFormsRendererFactory, VTViewTemplateProvider, EMFFormsDatabindingEMF)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
createControls(Composite)
M: 2 C: 8
80%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
createControls(Composite, int)
M: 18 C: 136
88%
M: 1 C: 11
92%
M: 1 C: 6
86%
M: 5 C: 25
83%
M: 0 C: 1
100%
createDummyValidationIcon(Composite)
M: 0 C: 19
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
createLabel(Composite)
M: 0 C: 92
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 21
100%
M: 0 C: 1
100%
createValidationIcon(Composite)
M: 0 C: 56
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
dispose()
M: 0 C: 9
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
getColumnLayout(int, boolean)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getDataBindingContext()
M: 0 C: 11
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getDatabindingService()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getElementRendererMap()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getGridDescription(SWTGridDescription)
M: 0 C: 72
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 17
100%
M: 0 C: 1
100%
getLabelDescriptionObservables()
M: 9 C: 32
78%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 1 C: 6
86%
M: 0 C: 1
100%
getLabelDisplayNameObservables()
M: 19 C: 49
72%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 3 C: 11
79%
M: 0 C: 1
100%
getLabelProvider()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getLabelStyleBits()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getLabelWidth()
M: 0 C: 22
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 8
100%
M: 0 C: 1
100%
getLayoutData(SWTGridCell, SWTGridDescription, SWTGridDescription, SWTGridDescription, VElement, EObject, Control)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getRendererFactory()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSpanningLayoutData(VContainedElement, int, int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getViewTemplateProvider()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
initChildRendererMap()
M: 19 C: 41
68%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 3 C: 9
75%
M: 0 C: 1
100%
renderControl(SWTGridCell, Composite)
M: 0 C: 42
100%
M: 0 C: 6
100%
M: 0 C: 5
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
setElementRendererMap(LinkedHashMap)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setFirstControlValidationIconUsed(boolean)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Johannes Faltermeier - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.spi.compoundcontrol.swt;
15:
16: import java.util.AbstractMap;
17: import java.util.ArrayList;
18: import java.util.LinkedHashMap;
19: import java.util.List;
20: import java.util.Map;
21: import java.util.Map.Entry;
22:
23: import javax.inject.Inject;
24:
25: import org.eclipse.core.databinding.DataBindingContext;
26: import org.eclipse.core.databinding.UpdateValueStrategy;
27: import org.eclipse.core.databinding.observable.value.IObservableValue;
28: import org.eclipse.core.runtime.IStatus;
29: import org.eclipse.emf.databinding.EMFDataBindingContext;
30: import org.eclipse.emf.databinding.EMFUpdateValueStrategy;
31: import org.eclipse.emf.ecore.EObject;
32: import org.eclipse.emf.ecore.EStructuralFeature;
33: import org.eclipse.emf.ecp.view.model.common.util.RendererUtil;
34: import org.eclipse.emf.ecp.view.spi.compoundcontrol.model.VCompoundControl;
35: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
36: import org.eclipse.emf.ecp.view.spi.core.swt.AbstractControlSWTRendererUtil;
37: import org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlSWTRendererUtil;
38: import org.eclipse.emf.ecp.view.spi.model.LabelAlignment;
39: import org.eclipse.emf.ecp.view.spi.model.VContainedElement;
40: import org.eclipse.emf.ecp.view.spi.model.VControl;
41: import org.eclipse.emf.ecp.view.spi.model.VElement;
42: import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
43: import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
44: import org.eclipse.emf.ecp.view.spi.swt.layout.LayoutProviderHelper;
45: import org.eclipse.emf.ecp.view.spi.swt.reporting.RenderingFailedReport;
46: import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider;
47: import org.eclipse.emf.ecp.view.template.style.labelwidth.model.VTLabelWidthStyleProperty;
48: import org.eclipse.emf.ecp.view.template.style.mandatory.model.VTMandatoryStyleProperty;
49: import org.eclipse.emfforms.common.Optional;
50: import org.eclipse.emfforms.spi.common.report.AbstractReport;
51: import org.eclipse.emfforms.spi.common.report.ReportService;
52: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
53: import org.eclipse.emfforms.spi.core.services.databinding.emf.EMFFormsDatabindingEMF;
54: import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
55: import org.eclipse.emfforms.spi.core.services.label.NoLabelFoundException;
56: import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
57: import org.eclipse.emfforms.spi.swt.core.EMFFormsNoRendererException;
58: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererFactory;
59: import org.eclipse.emfforms.spi.swt.core.SWTDataElementIdHelper;
60: import org.eclipse.emfforms.spi.swt.core.layout.GridDescriptionFactory;
61: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell;
62: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription;
63: import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
64: import org.eclipse.swt.SWT;
65: import org.eclipse.swt.widgets.Composite;
66: import org.eclipse.swt.widgets.Control;
67: import org.eclipse.swt.widgets.Label;
68: import org.eclipse.swt.widgets.Layout;
69:
70: /**
71: * {@link AbstractSWTRenderer} for the {@link VCompoundControl} view model.
72: *
73: * @author jfaltermeier
74: *
75: */
76: public class CompoundControlSWTRenderer extends AbstractSWTRenderer<VCompoundControl> {
77:
78:         private static final String SEPARATOR = " / "; //$NON-NLS-1$
79:
80:         private SWTGridDescription rendererGridDescription;
81:
82:         private final EMFFormsLabelProvider labelProvider;
83:         private EMFDataBindingContext dataBindingContext;
84:         private final EMFFormsRendererFactory rendererFactory;
85:
86:         private LinkedHashMap<VContainedElement, AbstractSWTRenderer<VElement>> elementRendererMap;
87:
88:         private final VTViewTemplateProvider viewTemplateProvider;
89:
90:         private boolean firstControlValidationIconUsed;
91:
92:         private final EMFFormsDatabindingEMF databindingService;
93:
94:         /**
95:          * Default constructor.
96:          *
97:          * @param vElement the view model element to be rendered
98:          * @param viewContext the view context
99:          * @param reportService the {@link ReportService}
100:          * @param labelProvider the {@link EMFFormsLabelProvider label provider}
101:          * @param rendererFactory the {@link EMFFormsRendererFactory renderer factory}
102:          * @param viewTemplateProvider {@link VTViewTemplateProvider}
103:          * @param databindingService {@link EMFFormsDatabindingEMF}
104:          * @since 1.17
105:          */
106:         @Inject
107:         public CompoundControlSWTRenderer(
108:                 VCompoundControl vElement,
109:                 ViewModelContext viewContext,
110:                 ReportService reportService,
111:                 EMFFormsLabelProvider labelProvider,
112:                 EMFFormsRendererFactory rendererFactory,
113:                 VTViewTemplateProvider viewTemplateProvider,
114:                 EMFFormsDatabindingEMF databindingService) {
115:                 super(vElement, viewContext, reportService);
116:                 this.labelProvider = labelProvider;
117:                 this.rendererFactory = rendererFactory;
118:                 this.viewTemplateProvider = viewTemplateProvider;
119:                 this.databindingService = databindingService;
120:         }
121:
122:         /**
123:          * Returns the {@link EMFFormsLabelProvider}.
124:          *
125:          * @return the label provider
126:          * @since 1.8
127:          */
128:         protected EMFFormsLabelProvider getLabelProvider() {
129:                 return labelProvider;
130:         }
131:
132:         /**
133:          * Returns the {@link EMFFormsRendererFactory}.
134:          *
135:          * @return the renderer factory
136:          * @since 1.8
137:          */
138:         protected EMFFormsRendererFactory getRendererFactory() {
139:                 return rendererFactory;
140:         }
141:
142:         /**
143:          * @return the {@link EMFFormsDatabindingEMF}.
144:          * @since 1.17
145:          */
146:         protected EMFFormsDatabindingEMF getDatabindingService() {
147:                 return databindingService;
148:         }
149:
150:         /**
151:          * Returns the {@link DataBindingContext}.
152:          *
153:          * @return the databining context
154:          * @since 1.8
155:          */
156:         protected DataBindingContext getDataBindingContext() {
157:•                if (dataBindingContext == null) {
158:                         dataBindingContext = new EMFDataBindingContext();
159:                 }
160:                 return dataBindingContext;
161:         }
162:
163:         /**
164:          * @return child control to renderer map
165:          * @since 1.16
166:          */
167:         protected LinkedHashMap<VContainedElement, AbstractSWTRenderer<VElement>> getElementRendererMap() {
168:                 initChildRendererMap();
169:                 return elementRendererMap;
170:         }
171:
172:         private void setElementRendererMap(
173:                 LinkedHashMap<VContainedElement, AbstractSWTRenderer<VElement>> elementRendererMap) {
174:                 this.elementRendererMap = elementRendererMap;
175:         }
176:
177:         /**
178:          * @return the viewTemplateProvider
179:          * @since 1.16
180:          */
181:         protected VTViewTemplateProvider getViewTemplateProvider() {
182:                 return viewTemplateProvider;
183:         }
184:
185:         @Override
186:         public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
187:•                if (rendererGridDescription == null) {
188:                         final int columns = SimpleControlSWTRendererUtil
189:•                                .showLabel(getVElement(), getReportService(), getClass().getName()) ? 3 : 2;
190:
191:                         rendererGridDescription = GridDescriptionFactory.INSTANCE.createEmptyGridDescription();
192:                         rendererGridDescription.setRows(1);
193:                         rendererGridDescription.setColumns(columns);
194:
195:                         final List<SWTGridCell> grid = new ArrayList<SWTGridCell>();
196:
197:•                        if (columns == 3) {
198:                                 final SWTGridCell labelCell = SimpleControlSWTRendererUtil
199:                                         .createLabelCell(grid.size(), this, getLabelWidth());
200:                                 grid.add(labelCell);
201:                         }
202:
203:                         final SWTGridCell validationCell = SimpleControlSWTRendererUtil.createValidationCell(grid.size(), this);
204:                         grid.add(validationCell);
205:
206:                         final SWTGridCell controlCel = SimpleControlSWTRendererUtil.createControlCell(grid.size(), this);
207:                         grid.add(controlCel);
208:
209:                         rendererGridDescription.setGrid(grid);
210:                 }
211:                 return rendererGridDescription;
212:         }
213:
214:         @Override
215:         protected Control renderControl(SWTGridCell cell, Composite parent)
216:                 throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
217:                 int controlIndex = cell.getColumn();
218:•                if (getVElement().getLabelAlignment() == LabelAlignment.NONE) {
219:                         controlIndex++;
220:                 }
221:•                switch (controlIndex) {
222:                 case 0:
223:                         return createLabel(parent);
224:                 case 1:
225:                         return createValidationIcon(parent);
226:                 case 2:
227:                         return createControls(parent);
228:                 default:
229:                         throw new IllegalArgumentException(
230:                                 String.format("The provided SWTGridCell (%1$s) cannot be used by this (%2$s) renderer.", //$NON-NLS-1$
231:                                         cell.toString(), toString()));
232:                 }
233:         }
234:
235:         /**
236:          * Creates the label composite.
237:          *
238:          * @param parent the parent composite
239:          * @return the label
240:          * @since 1.8
241:          */
242:         protected Control createLabel(Composite parent) {
243:                 final Label label = new Label(parent, getLabelStyleBits());
244:                 label.setData(CUSTOM_VARIANT, "org_eclipse_emf_ecp_control_label"); //$NON-NLS-1$
245:                 SWTDataElementIdHelper
246:                         .setElementIdDataWithSubId(label, getVElement(), "control_label", getViewModelContext()); //$NON-NLS-1$
247:                 label.setBackground(parent.getBackground());
248:
249:                 final IObservableValue textObservable = WidgetProperties.text().observe(label);
250:                 final Map<IObservableValue, Map.Entry<VControl, EStructuralFeature>> displayNameObservables = getLabelDisplayNameObservables();
251:
252:•                for (final IObservableValue displayNameObservable : displayNameObservables.keySet()) {
253:                         getDataBindingContext().bindValue(
254:                                 textObservable,
255:                                 displayNameObservable,
256:                                 new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
257:                                 new CompoundControlDisplayNameUpdateValueStrategy(displayNameObservables));
258:                 }
259:
260:                 final IObservableValue tooltipObservable = WidgetProperties.tooltipText().observe(label);
261:                 final List<IObservableValue> labelDescriptionObservables = getLabelDescriptionObservables();
262:•                for (final IObservableValue descriptionObservable : labelDescriptionObservables) {
263:                         getDataBindingContext().bindValue(
264:                                 tooltipObservable,
265:                                 descriptionObservable,
266:                                 new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
267:                                 new EMFUpdateValueStrategy() {
268:                                         @Override
269:                                         public Object convert(Object value) {
270:                                                 final StringBuilder stringBuilder = new StringBuilder();
271:                                                 for (final IObservableValue obs : labelDescriptionObservables) {
272:                                                         if (stringBuilder.length() > 0) {
273:                                                                 stringBuilder.append("\n"); //$NON-NLS-1$
274:                                                         }
275:                                                         stringBuilder.append(obs.getValue());
276:                                                 }
277:                                                 return stringBuilder.toString();
278:                                         }
279:                                 });
280:
281:                 }
282:
283:                 return label;
284:         }
285:
286:         private Map<IObservableValue, Map.Entry<VControl, EStructuralFeature>> getLabelDisplayNameObservables() {
287:                 final LinkedHashMap<IObservableValue, Entry<VControl, EStructuralFeature>> displayNames = new LinkedHashMap<IObservableValue, Map.Entry<VControl, EStructuralFeature>>();
288:
289:•                for (final VControl control : getVElement().getControls()) {
290:                         try {
291:                                 final IObservableValue displayName = labelProvider
292:                                         .getDisplayName(control.getDomainModelReference(), getViewModelContext().getDomainModel());
293:
294:                                 final EStructuralFeature feature = getDatabindingService()
295:                                         .getValueProperty(control.getDomainModelReference(), getViewModelContext().getDomainModel())
296:                                         .getStructuralFeature();
297:
298:                                 displayNames.put(displayName,
299:                                         new AbstractMap.SimpleEntry<VControl, EStructuralFeature>(control, feature));
300:                         } catch (final NoLabelFoundException ex) {
301:                                 getReportService().report(new AbstractReport(ex, IStatus.WARNING));
302:                         } catch (final DatabindingFailedException ex) {
303:                                 getReportService().report(new AbstractReport(ex, IStatus.WARNING));
304:                         }
305:                 }
306:
307:                 return displayNames;
308:         }
309:
310:         private List<IObservableValue> getLabelDescriptionObservables() {
311:                 final List<IObservableValue> labelDescriptionObservables = new ArrayList<IObservableValue>();
312:•                for (final VControl control : getVElement().getControls()) {
313:                         try {
314:                                 labelDescriptionObservables.add(labelProvider.getDescription(control.getDomainModelReference(),
315:                                         getViewModelContext().getDomainModel()));
316:                         } catch (final NoLabelFoundException ex) {
317:                                 getReportService().report(new AbstractReport(ex, IStatus.WARNING));
318:                         }
319:                 }
320:                 return labelDescriptionObservables;
321:         }
322:
323:         /**
324:          * @return the style bits for the control's label
325:          * @since 1.17
326:          */
327:         protected int getLabelStyleBits() {
328:                 return AbstractControlSWTRendererUtil
329:                         .getLabelStyleBits(getViewTemplateProvider(), getVElement(), getViewModelContext());
330:         }
331:
332:         /**
333:          * @return an optional width for the control's label
334:          * @since 1.16
335:          */
336:         protected Optional<Integer> getLabelWidth() {
337:                 final VTLabelWidthStyleProperty styleProperty = RendererUtil.getStyleProperty(
338:                         getViewTemplateProvider(),
339:                         getVElement(),
340:                         getViewModelContext(),
341:                         VTLabelWidthStyleProperty.class);
342:•                if (styleProperty == null || !styleProperty.isSetWidth()) {
343:                         return Optional.empty();
344:                 }
345:                 return Optional.of(styleProperty.getWidth());
346:         }
347:
348:         /**
349:          * Return the validation cell of the fist child. If no children or strange first cell, return a dummy validation
350:          * icon.
351:          *
352:          * @param parent the parent to render on
353:          * @return the validation control
354:          *
355:          * @throws NoRendererFoundException this is thrown when a renderer cannot be found
356:          * @throws NoPropertyDescriptorFoundExeption this is thrown when no property descriptor can be found
357:          * @since 1.17
358:          */
359:         protected Control createValidationIcon(Composite parent)
360:                 throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
361:•                if (getVElement().getControls().isEmpty()) {
362:                         return createDummyValidationIcon(parent);
363:                 }
364:                 final AbstractSWTRenderer<VElement> renderer = getElementRendererMap()
365:                         .get(getVElement().getControls().get(0));
366:•                if (renderer == null) {
367:                         return createDummyValidationIcon(parent);
368:                 }
369:                 final SWTGridDescription gridDescription = renderer
370:                         .getGridDescription(GridDescriptionFactory.INSTANCE.createEmptyGridDescription());
371:•                if (gridDescription.getColumns() < 2) {
372:                         return createDummyValidationIcon(parent);
373:                 }
374:                 /* use child renderer cell */
375:                 setFirstControlValidationIconUsed(true);
376:                 final SWTGridCell validationCell = gridDescription.getGrid().get(0);
377:                 return validationCell.getRenderer().render(validationCell, parent);
378:         }
379:
380:         /**
381:          * Whether the first cell of the first child control was used to renderer our validation icon.
382:          *
383:          * @param used <code>true</code> if used, <code>false</code> otherwise
384:          * @since 1.17
385:          */
386:         protected void setFirstControlValidationIconUsed(boolean used) {
387:                 firstControlValidationIconUsed = used;
388:         }
389:
390:         /**
391:          * Creates the validation icon of the first cell of the first child may not be used as the validation icon.
392:          *
393:          * @param parent the parent
394:          * @return the validation icon
395:          * @since 1.17
396:          */
397:         protected Control createDummyValidationIcon(Composite parent) {
398:                 final Label validationLabel = new Label(parent, SWT.NONE);
399:                 SWTDataElementIdHelper
400:                         .setElementIdDataWithSubId(validationLabel, getVElement(), "control_validation", getViewModelContext()); //$NON-NLS-1$
401:                 validationLabel.setBackground(parent.getBackground());
402:                 return validationLabel;
403:         }
404:
405:         /**
406:          * Creates the controls composite.
407:          *
408:          * @param parent the parent composite
409:          * @return the controls
410:          * @since 1.8
411:          */
412:         protected Control createControls(Composite parent) {
413:•                return createControls(parent, firstControlValidationIconUsed ? 1 : 0);
414:         }
415:
416:         /**
417:          * Creates the controls composite. May skip the first cell(s).
418:          *
419:          * @param parent the parent composite
420:          * @param cellsToSkip number of cells to skip
421:          * @return the controls
422:          * @since 1.16
423:          */
424:         protected Control createControls(Composite parent, int cellsToSkip) {
425:                 final Composite columnComposite = new Composite(parent, SWT.NONE);
426:                 columnComposite.setBackground(parent.getBackground());
427:
428:                 columnComposite.setLayout(getColumnLayout(getElementRendererMap().size(), false));
429:•                for (final VContainedElement child : getElementRendererMap().keySet()) {
430:                         final AbstractSWTRenderer<VElement> renderer = getElementRendererMap().get(child);
431:                         final Composite column = new Composite(columnComposite, SWT.NONE);
432:                         column.setBackground(parent.getBackground());
433:
434:                         column.setLayoutData(getSpanningLayoutData(child, 1, 1));
435:
436:                         final SWTGridDescription gridDescription = renderer.getGridDescription(GridDescriptionFactory.INSTANCE
437:                                 .createEmptyGridDescription());
438:                         final int columns = gridDescription.getColumns() - cellsToSkip;
439:•                        column.setLayout(getColumnLayout(columns < 1 ? 1 : columns, false));
440:
441:                         try {
442:•                                for (final SWTGridCell childGridCell : gridDescription.getGrid()) {
443:•                                        if (cellsToSkip > 0) {
444:                                                 cellsToSkip--;
445:                                                 continue;
446:                                         }
447:                                         final Control control = childGridCell.getRenderer().render(childGridCell, column);
448:•                                        if (control == null) {
449:                                                 continue;
450:                                         }
451:                                         control.setLayoutData(getLayoutData(childGridCell, gridDescription,
452:                                                 gridDescription, gridDescription, childGridCell.getRenderer().getVElement(),
453:                                                 getViewModelContext().getDomainModel(), control));
454:                                 }
455:•                                for (final SWTGridCell childGridCell : gridDescription.getGrid()) {
456:                                         childGridCell.getRenderer().finalizeRendering(column);
457:                                 }
458:                         } catch (final NoPropertyDescriptorFoundExeption e) {
459:                                 getReportService().report(new RenderingFailedReport(e));
460:                                 continue;
461:                         } catch (final NoRendererFoundException ex) {
462:                                 getReportService().report(new RenderingFailedReport(ex));
463:                                 continue;
464:                         }
465:                 }
466:
467:                 return columnComposite;
468:         }
469:
470:         /**
471:          * Initialises the child control to renderer map.
472:          *
473:          * @since 1.16
474:          */
475:         protected void initChildRendererMap() {
476:•                if (elementRendererMap != null) {
477:                         return;
478:                 }
479:                 setElementRendererMap(new LinkedHashMap<VContainedElement, AbstractSWTRenderer<VElement>>());
480:•                for (final VControl child : getVElement().getControls()) {
481:                         child.setLabelAlignment(LabelAlignment.NONE);
482:                         AbstractSWTRenderer<VElement> renderer;
483:                         try {
484:                                 renderer = getRendererFactory().getRendererInstance(child, getViewModelContext());
485:                         } catch (final EMFFormsNoRendererException ex) {
486:                                 getReportService().report(
487:                                         new AbstractReport(ex, String.format("No Renderer for %s found.", child.eClass().getName()))); //$NON-NLS-1$
488:                                 continue;
489:                         }
490:                         getElementRendererMap().put(child, renderer);
491:                 }
492:         }
493:
494:         /**
495:          * For testing purposes.
496:          *
497:          * @param numColumns numColumns
498:          * @param equalWidth equalWidth
499:          * @return ColumnLayout
500:          * @since 1.8
501:          */
502:         protected Layout getColumnLayout(int numColumns, boolean equalWidth) {
503:                 return LayoutProviderHelper.getColumnLayout(numColumns, equalWidth);
504:         }
505:
506:         /**
507:          * For testing purposes.
508:          *
509:          * @param child the element for which the spanning layout is requested
510:          * @param spanX spanX
511:          * @param spanY spanY
512:          * @return SpanningLayoutData
513:          * @since 1.8
514:          */
515:         protected Object getSpanningLayoutData(VContainedElement child, int spanX, int spanY) {
516:                 return LayoutProviderHelper.getSpanningLayoutData(spanX, spanY);
517:         }
518:
519:         /**
520:          * For testing purposes.
521:          *
522:          * @param gridCell gridCell
523:          * @param controlGridDescription controlGridDescription
524:          * @param currentRowGridDescription currentRowGridDescription
525:          * @param fullGridDescription fullGridDescription
526:          * @param vElement vElement
527:          * @param domainModel domainModel
528:          * @param control control
529:          * @return LayoutData
530:          * @since 1.8
531:          */
532:         protected Object getLayoutData(SWTGridCell gridCell, SWTGridDescription controlGridDescription,
533:                 SWTGridDescription currentRowGridDescription, SWTGridDescription fullGridDescription, VElement vElement,
534:                 EObject domainModel, Control control) {
535:                 return LayoutProviderHelper.getLayoutData(gridCell, controlGridDescription, currentRowGridDescription,
536:                         fullGridDescription, vElement, domainModel, control);
537:         }
538:
539:         @Override
540:         protected void dispose() {
541:•                if (getDataBindingContext() != null) {
542:                         getDataBindingContext().dispose();
543:                 }
544:                 super.dispose();
545:         }
546:
547:         /**
548:          * Model to target for display names which concats all display names.
549:          *
550:          * @author Johannes Faltermeier
551:          *
552:          */
553:         private final class CompoundControlDisplayNameUpdateValueStrategy extends EMFUpdateValueStrategy {
554:                 private final Map<IObservableValue, Entry<VControl, EStructuralFeature>> displayNameObservables;
555:
556:                 /**
557:                  * @param displayNameObservables
558:                  */
559:                 private CompoundControlDisplayNameUpdateValueStrategy(
560:                         Map<IObservableValue, Entry<VControl, EStructuralFeature>> displayNameObservables) {
561:                         this.displayNameObservables = displayNameObservables;
562:                 }
563:
564:                 @Override
565:                 public Object convert(Object value) {
566:                         final StringBuilder stringBuilder = new StringBuilder();
567:
568:                         for (final Entry<IObservableValue, Map.Entry<VControl, EStructuralFeature>> obs : displayNameObservables
569:                                 .entrySet()) {
570:                                 if (stringBuilder.length() > 0) {
571:                                         stringBuilder.append(SEPARATOR);
572:                                 }
573:                                 stringBuilder.append(
574:                                         getDisplayName(obs.getKey(), obs.getValue().getKey(), obs.getValue().getValue()));
575:
576:                         }
577:                         return stringBuilder.toString();
578:                 }
579:
580:                 private Object getDisplayName(
581:                         final IObservableValue obs,
582:                         VControl control,
583:                         EStructuralFeature structuralFeature) {
584:
585:                         final Object value = obs.getValue();
586:                         String extra = ""; //$NON-NLS-1$
587:                         final VTMandatoryStyleProperty mandatoryStyle = AbstractControlSWTRendererUtil
588:                                 .getMandatoryStyle(getViewTemplateProvider(), control, getViewModelContext());
589:                         if (mandatoryStyle.isHighliteMandatoryFields() && structuralFeature.getLowerBound() > 0) {
590:                                 extra = mandatoryStyle.getMandatoryMarker();
591:                         }
592:                         return value + extra;
593:                 }
594:         }
595: }