Skip to content

Package: DIControlSWTRenderer

DIControlSWTRenderer

nameinstructionbranchcomplexitylinemethod
DIControlSWTRenderer(VControl, ViewModelContext, ReportService, EMFFormsDatabinding, EMFFormsLabelProvider, VTViewTemplateProvider)
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%
getGridDescription(SWTGridDescription)
M: 23 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
renderControl(SWTGridCell, Composite)
M: 34 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
rootDomainModelChanged()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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: * jfaltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ui.view.swt.di.renderer;
15:
16: import org.eclipse.e4.core.contexts.IEclipseContext;
17: import org.eclipse.emf.ecp.ui.view.swt.di.util.SWTContextUtil;
18: import org.eclipse.emf.ecp.view.model.common.di.renderer.DIRendererUtil;
19: import org.eclipse.emf.ecp.view.model.common.di.renderer.POJORendererFactory;
20: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
21: import org.eclipse.emf.ecp.view.spi.core.swt.AbstractControlSWTRenderer;
22: import org.eclipse.emf.ecp.view.spi.model.VControl;
23: import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
24: import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
25: import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider;
26: import org.eclipse.emfforms.spi.common.report.ReportService;
27: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
28: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
29: import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
30: import org.eclipse.emfforms.spi.swt.core.layout.GridDescriptionFactory;
31: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell;
32: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription;
33: import org.eclipse.swt.widgets.Composite;
34: import org.eclipse.swt.widgets.Control;
35:
36: /**
37: * @author jfaltermeier
38: *
39: */
40: @SuppressWarnings("restriction")
41: public class DIControlSWTRenderer extends AbstractControlSWTRenderer<VControl> {
42:
43:         /**
44:          * Default constructor.
45:          *
46:          * @param vElement the view model element to be rendered
47:          * @param viewContext the view context
48:          * @param emfFormsDatabinding The {@link EMFFormsDatabinding}
49:          * @param emfFormsLabelProvider The {@link EMFFormsLabelProvider}
50:          * @param reportService The {@link ReportService}
51:          * @param vtViewTemplateProvider The {@link VTViewTemplateProvider}
52:          */
53:         public DIControlSWTRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService,
54:                 EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider,
55:                 VTViewTemplateProvider vtViewTemplateProvider) {
56:                 super(vElement, viewContext, reportService, emfFormsDatabinding, emfFormsLabelProvider, vtViewTemplateProvider);
57:         }
58:
59:         private SWTGridDescription rendererGridDescription;
60:         private Object pojo;
61:
62:         /**
63:          * {@inheritDoc}
64:          *
65:          * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#getGridDescription(org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription)
66:          */
67:         @Override
68:         public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
69:•                if (rendererGridDescription == null) {
70:                         rendererGridDescription = GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 1, this);
71:                         final SWTGridCell swtGridCell = rendererGridDescription.getGrid().get(0);
72:                         swtGridCell.setHorizontalFill(false);
73:                 }
74:                 return rendererGridDescription;
75:         }
76:
77:         /**
78:          * {@inheritDoc}
79:          *
80:          * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#renderControl(org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell,
81:          * org.eclipse.swt.widgets.Composite)
82:          */
83:         @Override
84:         protected Control renderControl(SWTGridCell cell, Composite parent) throws NoRendererFoundException,
85:                 NoPropertyDescriptorFoundExeption {
86:                 pojo = POJORendererFactory.getInstance().getRenderer(getVElement(), getViewModelContext());
87:                 final IEclipseContext childContext = DIRendererUtil.getContextForElement(getVElement(), getViewModelContext());
88:                 SWTContextUtil.setAbstractSWTRendererObjects(childContext, getVElement(), getViewModelContext(), parent);
89:                 childContext.set(SWTGridCell.class, cell);
90:                 return (Control) DIRendererUtil.render(pojo, getVElement(), getViewModelContext());
91:         }
92:
93:         /**
94:          * {@inheritDoc}
95:          *
96:          * @see org.eclipse.emf.ecp.view.spi.core.swt.AbstractControlSWTRenderer#rootDomainModelChanged()
97:          */
98:         @Override
99:         protected void rootDomainModelChanged() throws DatabindingFailedException {
100:                 // Do nothing
101:         }
102: }