Skip to content

Package: DIContainerSWTRenderer

DIContainerSWTRenderer

nameinstructionbranchcomplexitylinemethod
DIContainerSWTRenderer(VElement, ViewModelContext, ReportService, EMFFormsRendererFactory)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
doGetComposite()
M: 17 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getComposite(Composite)
M: 26 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
putInContext(IEclipseContext, VElement)
M: 24 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 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.ContainerSWTRenderer;
22: import org.eclipse.emf.ecp.view.spi.model.VElement;
23: import org.eclipse.emfforms.spi.common.report.ReportService;
24: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererFactory;
25: import org.eclipse.swt.widgets.Composite;
26:
27: /**
28: * DI Renderer for Container.
29: *
30: * @author jfaltermeier
31: *
32: */
33: @SuppressWarnings("restriction")
34: public class DIContainerSWTRenderer extends ContainerSWTRenderer<VElement> {
35:
36:         /**
37:          * Default constructor.
38:          *
39:          * @param vElement the view model element to be rendered
40:          * @param viewContext the view context
41:          * @param reportService the {@link ReportService}
42:          * @param factory the {@link EMFFormsRendererFactory}
43:          */
44:         public DIContainerSWTRenderer(VElement vElement, ViewModelContext viewContext, ReportService reportService,
45:                 EMFFormsRendererFactory factory) {
46:                 super(vElement, viewContext, reportService, factory);
47:         }
48:
49:         /**
50:          * Named string for the children of a container.
51:          */
52:         public static final String CHILDREN = "containerChildren"; //$NON-NLS-1$
53:         private Object pojo;
54:
55:         /**
56:          * {@inheritDoc}
57:          *
58:          * @see org.eclipse.emf.ecp.view.spi.core.swt.ContainerSWTRenderer#getComposite(org.eclipse.swt.widgets.Composite)
59:          */
60:         @Override
61:         protected Composite getComposite(Composite parent) {
62:                 final IEclipseContext childContext = DIRendererUtil.getContextForElement(getVElement(), getViewModelContext());
63:                 SWTContextUtil.setAbstractSWTRendererObjects(childContext, getVElement(), getViewModelContext(), parent);
64:                 childContext.set(CHILDREN, getChildren());
65:                 putInContext(childContext, getVElement());
66:                 return doGetComposite();
67:         }
68:
69:         private void putInContext(IEclipseContext context, VElement element) {
70:•                for (final Class<?> clazz : element.getClass().getInterfaces()) {
71:                         context.set(clazz.getName(), element);
72:                 }
73:         }
74:
75:         /**
76:          * Invokes the get composite call on the pojo.
77:          *
78:          * @return the composite
79:          */
80:         protected Composite doGetComposite() {
81:                 pojo = POJORendererFactory.getInstance().getRenderer(getVElement(), getViewModelContext());
82:                 return (Composite) DIRendererUtil.render(pojo, getVElement(), getViewModelContext());
83:         }
84: }