Skip to content

Package: ECPAbstractCustomControlSWTStub

ECPAbstractCustomControlSWTStub

nameinstructionbranchcomplexitylinemethod
ECPAbstractCustomControlSWTStub()
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%
ECPAbstractCustomControlSWTStub(boolean)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createValidationLabelInStub(Composite)
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%
disposeCustomControl()
M: 9 C: 13
59%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 3 C: 5
63%
M: 0 C: 1
100%
getButton()
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%
getGridDescription()
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getLabel()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getLastValidationFeature()
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%
getLastValidationSeverity()
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%
getNeededDomainModelReferences()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getResolvedReferences()
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%
getStubSWTHelper()
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%
getTextControl()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getValidationLabel()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
handleContentValidation()
M: 7 C: 44
86%
M: 2 C: 6
75%
M: 2 C: 3
60%
M: 3 C: 10
77%
M: 0 C: 1
100%
isDisposed()
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%
isRendered()
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%
isValidationReseted()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
renderControl(SWTGridCell, Composite)
M: 36 C: 37
51%
M: 6 C: 4
40%
M: 4 C: 2
33%
M: 10 C: 8
44%
M: 0 C: 1
100%
setDisposed(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%
setLastValidationFeature(EStructuralFeature)
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%
setLastValidationSeverity(int)
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%
setRendered(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%
setTextControl(Composite)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setValidationReseted(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-2013 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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.custom.ui.swt.test;
15:
16: import java.util.Collections;
17: import java.util.List;
18: import java.util.Set;
19:
20: import org.eclipse.emf.common.util.Diagnostic;
21: import org.eclipse.emf.ecore.EStructuralFeature;
22: import org.eclipse.emf.ecp.edit.internal.swt.util.SWTControl;
23: import org.eclipse.emf.ecp.view.spi.custom.model.ECPHardcodedReferences;
24: import org.eclipse.emf.ecp.view.spi.custom.model.VCustomPackage;
25: import org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT;
26: import org.eclipse.emf.ecp.view.spi.model.VDiagnostic;
27: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
28: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
29: import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption;
30: import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException;
31: import org.eclipse.emfforms.spi.swt.core.layout.GridDescriptionFactory;
32: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell;
33: import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription;
34: import org.eclipse.swt.SWT;
35: import org.eclipse.swt.widgets.Button;
36: import org.eclipse.swt.widgets.Composite;
37: import org.eclipse.swt.widgets.Control;
38: import org.eclipse.swt.widgets.Label;
39:
40: /**
41: * @author Jonas
42: *
43: */
44: public class ECPAbstractCustomControlSWTStub extends ECPAbstractCustomControlSWT implements ECPHardcodedReferences {
45:
46:         private static final String TEST_MESSAGE = "TestMessage";
47:         private static final String TEST_TITEL = "TestTitel";
48:         private boolean rendered;
49:         private int lastValidationSeverity;
50:         private EStructuralFeature lastValidationFeature;
51:         private boolean disposed;
52:         private Label label;
53:         private Composite textControl;
54:         private final boolean withControl;
55:         private boolean validationReseted;
56:         private Label validationLabel;
57:         private Button button;
58:
59:         /**
60:          * @return the validationLabel
61:          */
62:         public Label getValidationLabel() {
63:                 return validationLabel;
64:         }
65:
66:         public ECPAbstractCustomControlSWTStub() {
67:                 this(false);
68:         }
69:
70:         public ECPAbstractCustomControlSWTStub(boolean withControl) {
71:                 super();
72:                 this.withControl = withControl;
73:         }
74:
75:         /**
76:          * {@inheritDoc}
77:          *
78:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#handleContentValidation()
79:          */
80:         @Override
81:         protected void handleContentValidation() {
82:•                if (getCustomControl().getDiagnostic() == null) {
83:                         setValidationReseted(true);
84:                 }
85:                 final VDiagnostic diagnostic = getCustomControl().getDiagnostic();
86:•                if (diagnostic.getDiagnostics().size() == 0) {
87:                         setValidationReseted(true);
88:                 }
89:•                for (final Object diagnosticObject : diagnostic.getDiagnostics()) {
90:                         final Diagnostic diagnostic2 = (Diagnostic) diagnosticObject;
91:•                        if (diagnostic2.getSeverity() == Diagnostic.OK) {
92:                                 setValidationReseted(true);
93:                         } else {
94:                                 setLastValidationSeverity(diagnostic2.getSeverity());
95:                                 setLastValidationFeature((EStructuralFeature) diagnostic2.getData().get(1));
96:                         }
97:                 }
98:         }
99:
100:         /**
101:          * {@inheritDoc}
102:          *
103:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#getGridDescription()
104:          */
105:         @Override
106:         public SWTGridDescription getGridDescription() {
107:•                if (!withControl) {
108:                         return GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 2, null);
109:                 }
110:                 return GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 3, null);
111:         }
112:
113:         /**
114:          * {@inheritDoc}
115:          *
116:          * @see org.eclipse.emf.ecp.view.spi.custom.swt.ECPAbstractCustomControlSWT#renderControl(org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell,
117:          * org.eclipse.swt.widgets.Composite)
118:          */
119:         @Override
120:         public Control renderControl(SWTGridCell cell, Composite parent) throws NoRendererFoundException,
121:                 NoPropertyDescriptorFoundExeption {
122:•                if (cell.getColumn() == 0) {
123:                         label = new Label(parent, SWT.NONE);
124:                         label.setText(ECPAbstractCustomControlSWT_PTest.LABELTEXT);
125:                         setRendered(true);
126:                         return label;
127:                 }
128:•                if (cell.getColumn() == 1 && !withControl) {
129:                         button = new Button(parent, SWT.PUSH);
130:                         return getButton();
131:                 }
132:•                if (cell.getColumn() == 1) {
133:                         validationLabel = createValidationIcon(parent);
134:                         return validationLabel;
135:                 }
136:•                if (cell.getColumn() == 2) {
137:                         final VFeaturePathDomainModelReference controlFeature = (VFeaturePathDomainModelReference) getResolvedDomainModelReference(
138:                                 VCustomPackage.eINSTANCE
139:                                         .getCustomControl_BundleName());
140:                         setTextControl(getControl(SWTControl.class, controlFeature).createControl(parent));
141:                         return getTextControl();
142:                 }
143:                 return null;
144:         }
145:
146:         /**
147:          * {@inheritDoc}
148:          *
149:          * @see org.eclipse.emf.ecp.view.spi.custom.ui.ECPAbstractCustomControl#disposeCustomControl()
150:          */
151:         @Override
152:         protected void disposeCustomControl() {
153:                 setDisposed(true);
154:•                if (label != null) {
155:                         label.dispose();
156:                 }
157:•                if (textControl != null) {
158:                         textControl.dispose();
159:                 }
160:•                if (validationLabel != null) {
161:                         validationLabel.dispose();
162:                 }
163:         }
164:
165:         /**
166:          * @param composite
167:          */
168:         public void createValidationLabelInStub(Composite composite) {
169:                 super.createValidationIcon(composite);
170:
171:         }
172:
173:         /**
174:          * @return the rendered
175:          */
176:         public boolean isRendered() {
177:                 return rendered;
178:         }
179:
180:         /**
181:          * @param rendered the rendered to set
182:          */
183:         public void setRendered(boolean rendered) {
184:                 this.rendered = rendered;
185:         }
186:
187:         /**
188:          * @return the lastValidationSeverity
189:          */
190:         public int getLastValidationSeverity() {
191:                 return lastValidationSeverity;
192:         }
193:
194:         /**
195:          * @param lastValidationSeverity the lastValidationSeverity to set
196:          */
197:         public void setLastValidationSeverity(int lastValidationSeverity) {
198:                 this.lastValidationSeverity = lastValidationSeverity;
199:         }
200:
201:         /**
202:          * @return the lastValidationFeature
203:          */
204:         public EStructuralFeature getLastValidationFeature() {
205:                 return lastValidationFeature;
206:         }
207:
208:         /**
209:          * @param lastValidationFeature the lastValidationFeature to set
210:          */
211:         public void setLastValidationFeature(EStructuralFeature lastValidationFeature) {
212:                 this.lastValidationFeature = lastValidationFeature;
213:         }
214:
215:         /**
216:          * @return the disposed
217:          */
218:         public boolean isDisposed() {
219:                 return disposed;
220:         }
221:
222:         /**
223:          * @param disposed the disposed to set
224:          */
225:         public void setDisposed(boolean disposed) {
226:                 this.disposed = disposed;
227:         }
228:
229:         /**
230:          * @return the textControl
231:          */
232:         public Composite getTextControl() {
233:                 return textControl;
234:         }
235:
236:         public Label getLabel() {
237:                 return label;
238:         }
239:
240:         /**
241:          * @param textControl the textControl to set
242:          */
243:         public void setTextControl(Composite textControl) {
244:                 this.textControl = textControl;
245:         }
246:
247:         /**
248:          * @return the validationReseted
249:          */
250:         public boolean isValidationReseted() {
251:                 return validationReseted;
252:         }
253:
254:         /**
255:          * @param validationReseted the validationReseted to set
256:          */
257:         public void setValidationReseted(boolean validationReseted) {
258:                 this.validationReseted = validationReseted;
259:         }
260:
261:         /**
262:          * {@inheritDoc}
263:          *
264:          * @see org.eclipse.emf.ecp.view.spi.custom.model.ECPHardcodedReferences#getNeededDomainModelReferences()
265:          */
266:         @Override
267:         public Set<VDomainModelReference> getNeededDomainModelReferences() {
268:                 return Collections.emptySet();
269:         }
270:
271:         public List<VDomainModelReference> getResolvedReferences() {
272:                 return getResolvedDomainModelReferences();
273:         }
274:
275:         public SWTCustomControlHelper getStubSWTHelper() {
276:                 return super.getHelper();
277:         }
278:
279:         public Button getButton() {
280:                 return button;
281:         }
282:
283: }