Skip to content

Package: DICustomControlSWT

DICustomControlSWT

nameinstructionbranchcomplexitylinemethod
DICustomControlSWT(Object, IEclipseContext)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
disposeCustomControl()
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()
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
handleContentValidation()
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%
postInit()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
renderControl(SWTGridCell, Composite)
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%

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.custom.ui.swt.di.renderer;
15:
16: import javax.annotation.PreDestroy;
17:
18: import org.eclipse.e4.core.contexts.ContextInjectionFactory;
19: import org.eclipse.e4.core.contexts.IEclipseContext;
20: import org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT;
21: import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
22: import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
23: import org.eclipse.emfforms.spi.swt.core.layout.GridDescriptionFactory;
24: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell;
25: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription;
26: import org.eclipse.swt.widgets.Composite;
27: import org.eclipse.swt.widgets.Control;
28:
29: /**
30: * {@link ECPAbstractCustomControlSWT} that will delegate its calls to a POJO.
31: *
32: * @author jfaltermeier
33: *
34: */
35: public class DICustomControlSWT extends ECPAbstractCustomControlSWT {
36:
37:         private final Object pojo;
38:         private final IEclipseContext eclipseContext;
39:         private SWTGridDescription rendererGridDescription;
40:
41:         /**
42:          * Constructs a new {@link DICustomControlSWT}.
43:          *
44:          * @param pojo the pojo custom control
45:          * @param eclipseContext the eclipse context
46:          */
47:         /* package */ DICustomControlSWT(Object pojo, IEclipseContext eclipseContext) {
48:                 super();
49:                 this.pojo = pojo;
50:                 this.eclipseContext = eclipseContext;
51:         }
52:
53:         /**
54:          * {@inheritDoc}
55:          *
56:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#postInit()
57:          */
58:         @Override
59:         protected void postInit() {
60:                 super.postInit();
61:         }
62:
63:         /**
64:          * {@inheritDoc}
65:          *
66:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#disposeCustomControl()
67:          */
68:         @Override
69:         protected void disposeCustomControl() {
70:                 ContextInjectionFactory.invoke(pojo, PreDestroy.class, eclipseContext, null);
71:         }
72:
73:         /**
74:          * {@inheritDoc}
75:          *
76:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#handleContentValidation()
77:          */
78:         @Override
79:         protected void handleContentValidation() {
80:         }
81:
82:         /**
83:          * {@inheritDoc}
84:          *
85:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#getGridDescription()
86:          */
87:         @Override
88:         public SWTGridDescription getGridDescription() {
89:•                if (rendererGridDescription == null) {
90:                         rendererGridDescription = GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 1, null);
91:                 }
92:                 return rendererGridDescription;
93:         }
94:
95:         /**
96:          * {@inheritDoc}
97:          *
98:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#renderControl(org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell,
99:          * org.eclipse.swt.widgets.Composite)
100:          */
101:         @SuppressWarnings("restriction")
102:         @Override
103:         public Control renderControl(SWTGridCell cell, Composite parent) throws NoRendererFoundException,
104:                 NoPropertyDescriptorFoundExeption {
105:                 return (Control) org.eclipse.emf.ecp.view.model.common.di.renderer.DIRendererUtil.render(pojo,
106:                         getCustomControl(), getViewModelContext());
107:         }
108:
109: }