Skip to content

Package: TableControlHandle

TableControlHandle

nameinstructionbranchcomplexitylinemethod
TableControlHandle(VTableControl)
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%
addFirstTableColumn(VDomainModelReference)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
addSecondTableColumn(VDomainModelReference)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getTableColumn1()
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%
getTableColumn2()
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%
getTableControl()
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%
getView()
M: 28 C: 35
56%
M: 7 C: 3
30%
M: 5 C: 1
17%
M: 6 C: 9
60%
M: 0 C: 1
100%
setTableColumn1(VDomainModelReference)
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%
setTableColumn2(VDomainModelReference)
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%
setTableControl(VTableControl)
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-2019 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: * Jonas - initial API and implementation
13: * Christian W. Damus - bug 527686
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.table.test.common;
16:
17: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
18: import org.eclipse.emf.ecp.view.spi.model.VFeaturePathDomainModelReference;
19: import org.eclipse.emf.ecp.view.spi.model.VView;
20: import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
21: import org.eclipse.emf.ecp.view.spi.table.model.VTableControl;
22: import org.eclipse.emf.ecp.view.spi.table.model.VTableDomainModelReference;
23:
24: /**
25: * @author Jonas
26: *
27: */
28: public class TableControlHandle {
29:
30:         public TableControlHandle(VTableControl tableControl) {
31:                 setTableControl(tableControl);
32:         }
33:
34:         /**
35:          * Some services expect everything to be in a view, such as the
36:          * {@code EMFFormsMappingProviderTable}.
37:          */
38:         private VView view;
39:         private VTableControl tableControl;
40:         private VDomainModelReference tableColumn1;
41:         private VDomainModelReference tableColumn2;
42:
43:         /**
44:          * @param tableColumn1
45:          */
46:         public void addFirstTableColumn(VDomainModelReference tableColumn1) {
47:                 setTableColumn1(tableColumn1);
48:                 VTableDomainModelReference.class.cast(getTableControl().getDomainModelReference())
49:                         .getColumnDomainModelReferences().add(tableColumn1);
50:
51:         }
52:
53:         /**
54:          * @param tableColumn2
55:          */
56:         public void addSecondTableColumn(VDomainModelReference tableColumn2) {
57:                 setTableColumn2(tableColumn2);
58:                 VTableDomainModelReference.class.cast(getTableControl().getDomainModelReference())
59:                         .getColumnDomainModelReferences().add(tableColumn2);
60:
61:         }
62:
63:         /**
64:          * @return the tableControl
65:          */
66:         public VTableControl getTableControl() {
67:                 return tableControl;
68:         }
69:
70:         /**
71:          * @param tableControl the tableControl to set
72:          */
73:         public void setTableControl(VTableControl tableControl) {
74:                 this.tableControl = tableControl;
75:         }
76:
77:         /**
78:          * @return the tableColumn1
79:          */
80:         public VDomainModelReference getTableColumn1() {
81:                 return tableColumn1;
82:         }
83:
84:         /**
85:          * @param tableColumn1 the tableColumn1 to set
86:          */
87:         public void setTableColumn1(VDomainModelReference tableColumn1) {
88:                 this.tableColumn1 = tableColumn1;
89:         }
90:
91:         /**
92:          * @return the tableColumn2
93:          */
94:         public VDomainModelReference getTableColumn2() {
95:                 return tableColumn2;
96:         }
97:
98:         /**
99:          * @param tableColumn2 the tableColumn2 to set
100:          */
101:         public void setTableColumn2(VDomainModelReference tableColumn2) {
102:                 this.tableColumn2 = tableColumn2;
103:         }
104:
105:         /**
106:          * Obtain a view containing the table, for tests that need it.
107:          *
108:          * @return a view containing the table
109:          *
110:          * @since 1.22
111:          */
112:         public VView getView() {
113:•                if (view == null && getTableControl() != null) {
114:                         view = VViewFactory.eINSTANCE.createView();
115:
116:                         // Infer the root EClass from the table's DMR
117:                         final VTableDomainModelReference tdmr = (VTableDomainModelReference) getTableControl()
118:                                 .getDomainModelReference();
119:•                        if (tdmr.getDomainModelEFeature() != null) {
120:                                 view.setRootEClass(tdmr.getDomainModelEFeature().getEContainingClass());
121:•                        } else if (tdmr.getDomainModelReference() instanceof VFeaturePathDomainModelReference) {
122:                                 final VFeaturePathDomainModelReference fpdmr = (VFeaturePathDomainModelReference) tdmr
123:                                         .getDomainModelReference();
124:•                                if (!fpdmr.getDomainModelEReferencePath().isEmpty()) {
125:                                         view.setRootEClass(fpdmr.getDomainModelEReferencePath().get(0).getEContainingClass());
126:                                 } else {
127:                                         view.setRootEClass(fpdmr.getDomainModelEFeature().getEContainingClass());
128:                                 }
129:                         }
130:
131:                         view.getChildren().add(getTableControl());
132:                 }
133:
134:                 return view;
135:         }
136: }