Skip to content

Package: EMFFormsSpreadsheetViewModelContext

EMFFormsSpreadsheetViewModelContext

nameinstructionbranchcomplexitylinemethod
EMFFormsSpreadsheetViewModelContext(VView, EObject)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
EMFFormsSpreadsheetViewModelContext(VView, EObject, ViewModelContext)
M: 0 C: 28
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
addContextUser(Object)
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%
changeDomainModel(EObject)
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%
dispose()
M: 0 C: 10
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
getChildContext(EObject, VElement, VView, ViewModelServiceProvider)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getChildContext(EObject, VElement, VView, ViewModelService[])
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getContextValue(String)
M: 0 C: 20
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getControlsFor(EStructuralFeature.Setting)
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%
getControlsFor(UniqueSetting)
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%
getDomainModel()
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%
getParentContext()
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%
getParentVElement()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getService(Class)
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%
getViewModel()
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%
hasService(Class)
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%
pause()
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%
putContextValue(String, Object)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
reactivate()
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%
registerDisposeListener(ViewModelContextDisposeListener)
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%
registerDomainChangeListener(ModelChangeListener)
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%
registerEMFFormsContextListener(EMFFormsContextListener)
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%
registerRootDomainModelChangeListener(RootDomainModelChangeListener)
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%
registerViewChangeListener(ModelChangeListener)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
removeContextUser(Object)
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%
unregisterDomainChangeListener(ModelChangeListener)
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%
unregisterEMFFormsContextListener(EMFFormsContextListener)
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%
unregisterRootDomainModelChangeListener(RootDomainModelChangeListener)
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%
unregisterViewChangeListener(ModelChangeListener)
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2017 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: * Christian W. Damus - bug 527740
14: ******************************************************************************/
15: package org.eclipse.emfforms.internal.spreadsheet.core;
16:
17: import java.util.LinkedHashMap;
18: import java.util.Map;
19: import java.util.Set;
20:
21: import org.eclipse.emf.ecore.EObject;
22: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
23: import org.eclipse.emf.ecp.common.spi.UniqueSetting;
24: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
25: import org.eclipse.emf.ecp.view.spi.context.ViewModelContextDisposeListener;
26: import org.eclipse.emf.ecp.view.spi.context.ViewModelService;
27: import org.eclipse.emf.ecp.view.spi.context.ViewModelServiceProvider;
28: import org.eclipse.emf.ecp.view.spi.model.ModelChangeListener;
29: import org.eclipse.emf.ecp.view.spi.model.VControl;
30: import org.eclipse.emf.ecp.view.spi.model.VElement;
31: import org.eclipse.emf.ecp.view.spi.model.VView;
32: import org.eclipse.emfforms.internal.view.model.localization.LocalizationViewModelService;
33: import org.eclipse.emfforms.spi.core.services.view.EMFFormsContextListener;
34: import org.eclipse.emfforms.spi.core.services.view.RootDomainModelChangeListener;
35:
36: /**
37: * Spreadsheet specific implementation of the {@link ViewModelContext}.
38: * This implementation doesn't do anything, it serves only as a container for a {@link VView} and the {@link EObject}.
39: *
40: * @author Eugen Neufeld
41: * @noextend This class is not intended to be subclassed by clients.
42: */
43: @SuppressWarnings("restriction")
44: public class EMFFormsSpreadsheetViewModelContext implements ViewModelContext {
45:
46:         private final VView view;
47:         private final EObject domainModel;
48:         private final Map<String, Object> contextValues = new LinkedHashMap<String, Object>();
49:         private final ViewModelContext parentContext;
50:         private LocalizationViewModelService vms;
51:
52:         /**
53:          * Default Constructor.
54:          *
55:          * @param view The {@link VView}
56:          * @param domainModel The {@link EObject}
57:          */
58:
59:         public EMFFormsSpreadsheetViewModelContext(VView view, EObject domainModel) {
60:                 this(view, domainModel, null);
61:         }
62:
63:         /**
64:          * Default Constructor for child contexts.
65:          *
66:          * @param view The {@link VView}
67:          * @param domainModel The {@link EObject}
68:          * @param parentContext The parent {@link ViewModelContext}
69:          */
70:         public EMFFormsSpreadsheetViewModelContext(VView view, EObject domainModel, ViewModelContext parentContext) {
71:                 this.view = view;
72:                 this.domainModel = domainModel;
73:                 this.parentContext = parentContext;
74:
75:                 // we need this only on the root context
76:•                if (parentContext == null) {
77:                         vms = new LocalizationViewModelService();
78:                         vms.instantiate(this);
79:                 }
80:         }
81:
82:         @Override
83:         public void registerDomainChangeListener(ModelChangeListener modelChangeListener) {
84:                 // intentionally left empty
85:         }
86:
87:         @Override
88:         public void unregisterDomainChangeListener(ModelChangeListener modelChangeListener) {
89:                 // intentionally left empty
90:         }
91:
92:         @Override
93:         public VElement getViewModel() {
94:                 return view;
95:         }
96:
97:         @Override
98:         public EObject getDomainModel() {
99:                 return domainModel;
100:         }
101:
102:         @Override
103:         public void registerViewChangeListener(ModelChangeListener modelChangeListener) {
104:                 // intentionally left empty
105:         }
106:
107:         @Override
108:         public void unregisterViewChangeListener(ModelChangeListener modelChangeListener) {
109:                 // intentionally left empty
110:         }
111:
112:         @Override
113:         public void dispose() {
114:•                if (vms != null) {
115:                         vms.dispose();
116:                 }
117:                 contextValues.clear();
118:         }
119:
120:         @Override
121:         public <T> boolean hasService(Class<T> serviceType) {
122:                 return false;
123:         }
124:
125:         @Override
126:         public <T> T getService(Class<T> serviceType) {
127:                 return null;
128:         }
129:
130:         @Deprecated
131:         @Override
132:         public Set<VControl> getControlsFor(Setting setting) {
133:                 return null;
134:         }
135:
136:         @Deprecated
137:         @Override
138:         public Set<VElement> getControlsFor(UniqueSetting setting) {
139:                 return null;
140:         }
141:
142:         @Override
143:         public Object getContextValue(String key) {
144:•                if (contextValues.containsKey(key)) {
145:                         return contextValues.get(key);
146:                 }
147:•                if (parentContext != null) {
148:                         return parentContext.getContextValue(key);
149:                 }
150:                 return null;
151:         }
152:
153:         @Override
154:         public void putContextValue(String key, Object value) {
155:                 contextValues.put(key, value);
156:         }
157:
158:         @Deprecated
159:         @Override
160:         public ViewModelContext getChildContext(EObject eObject, VElement parent, VView vView,
161:                 ViewModelService... viewModelServices) {
162:                 return new EMFFormsSpreadsheetViewModelContext(vView, eObject, this);
163:         }
164:
165:         @Override
166:         public ViewModelContext getChildContext(EObject eObject, VElement parent, VView vView,
167:                 ViewModelServiceProvider viewModelServiceProvider) {
168:
169:                 return new EMFFormsSpreadsheetViewModelContext(vView, eObject, this);
170:         }
171:
172:         @Override
173:         public void registerDisposeListener(ViewModelContextDisposeListener listener) {
174:                 // intentionally left empty
175:         }
176:
177:         @Override
178:         public void addContextUser(Object user) {
179:                 // intentionally left empty
180:         }
181:
182:         @Override
183:         public void removeContextUser(Object user) {
184:                 // intentionally left empty
185:         }
186:
187:         @Override
188:         public void registerEMFFormsContextListener(EMFFormsContextListener contextListener) {
189:         }
190:
191:         @Override
192:         public void unregisterEMFFormsContextListener(EMFFormsContextListener contextListener) {
193:         }
194:
195:         @Override
196:         public ViewModelContext getParentContext() {
197:                 return parentContext;
198:         }
199:
200:         @Override
201:         public VElement getParentVElement() {
202:                 throw new UnsupportedOperationException();
203:         }
204:
205:         @Override
206:         public void changeDomainModel(EObject newDomainModel) {
207:                 // Do not support feature
208:         }
209:
210:         @Override
211:         public void registerRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener) {
212:                 // Do not support feature
213:         }
214:
215:         @Override
216:         public void unregisterRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener) {
217:                 // Do not support feature
218:         }
219:
220:         @Override
221:         public void pause() {
222:                 // Do not support feature
223:         }
224:
225:         @Override
226:         public void reactivate() {
227:                 // Do not support feature
228:         }
229:
230: }