Skip to content

Package: EEnumLiteralRenderer

EEnumLiteralRenderer

nameinstructionbranchcomplexitylinemethod
EEnumLiteralRenderer(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%
createBindings(Control)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createSWTControl(Composite)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getUnsetText()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isUnsettable()
M: 2 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-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: * Clemens Elflein - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.editor.ecore.controls;
15:
16: import javax.inject.Inject;
17:
18: import org.eclipse.core.databinding.Binding;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
20: import org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlSWTControlSWTRenderer;
21: import org.eclipse.emf.ecp.view.spi.model.VControl;
22: import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider;
23: import org.eclipse.emfforms.spi.common.report.ReportService;
24: import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
25: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
26: import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
27: import org.eclipse.swt.SWT;
28: import org.eclipse.swt.widgets.Composite;
29: import org.eclipse.swt.widgets.Control;
30: import org.eclipse.swt.widgets.Label;
31:
32: /**
33: * The Renderer for EENumLiterals.
34: *
35: * @author Clemens Elflein
36: *
37: */
38: public class EEnumLiteralRenderer extends SimpleControlSWTControlSWTRenderer {
39:
40:         /**
41:          * Default constructor.
42:          *
43:          * @param vElement the view model element to be rendered
44:          * @param viewContext the view context
45:          * @param reportService The {@link ReportService}
46:          * @param emfFormsDatabinding The {@link EMFFormsDatabinding}
47:          * @param emfFormsLabelProvider The {@link EMFFormsLabelProvider}
48:          * @param vtViewTemplateProvider The {@link VTViewTemplateProvider}
49:          */
50:         @Inject
51:         public EEnumLiteralRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService,
52:                 EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider,
53:                 VTViewTemplateProvider vtViewTemplateProvider) {
54:                 super(vElement, viewContext, reportService, emfFormsDatabinding, emfFormsLabelProvider, vtViewTemplateProvider);
55:         }
56:
57:         @Override
58:         protected Binding[] createBindings(Control control) {
59:                 return null;
60:         }
61:
62:         @Override
63:         protected Control createSWTControl(Composite parent) throws DatabindingFailedException {
64:                 // A Label is sufficient for this renderer, as this value is read-only.
65:                 final Label label = new Label(parent, SWT.None);
66:                 final Object value = getModelValue().getValue();
67:•                label.setText(value != null ? value.toString() : "(null)");
68:                 return label;
69:         }
70:
71:         @Override
72:         protected String getUnsetText() {
73:                 return null;
74:         }
75:
76:         @Override
77:         protected boolean isUnsettable() {
78:                 return false;
79:         }
80:
81: }