Skip to content

Package: EclipseContextViewServiceFactory

EclipseContextViewServiceFactory

nameinstructionbranchcomplexitylinemethod
EclipseContextViewServiceFactory()
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%
createService(EMFFormsViewContext)
M: 1 C: 11
92%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 2
100%
M: 0 C: 1
100%
getPolicy()
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%
getPriority()
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%
getScope()
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%
getType()
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019 Christian W. Damus 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: * Christian W. Damus - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.swt.core.di;
15:
16: import org.eclipse.e4.core.contexts.IEclipseContext;
17: import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewContext;
18: import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewServiceFactory;
19: import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewServicePolicy;
20: import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewServiceScope;
21: import org.eclipse.emfforms.spi.swt.core.di.EMFFormsContextProvider;
22: import org.osgi.service.component.annotations.Component;
23:
24: /**
25: * EMF Forms global view service factory that provides the Eclipse Context in the
26: * View Context.
27: *
28: * @since 1.22
29: */
30: @Component(name = "e4ContextViewServiceFactory")
31: public class EclipseContextViewServiceFactory implements EMFFormsViewServiceFactory<IEclipseContext> {
32:
33:         @Override
34:         public EMFFormsViewServiceScope getScope() {
35:                 return EMFFormsViewServiceScope.LOCAL;
36:         }
37:
38:         @Override
39:         public EMFFormsViewServicePolicy getPolicy() {
40:                 return EMFFormsViewServicePolicy.LAZY;
41:         }
42:
43:         @Override
44:         public double getPriority() {
45:                 return 0;
46:         }
47:
48:         @Override
49:         public Class<IEclipseContext> getType() {
50:                 return IEclipseContext.class;
51:         }
52:
53:         @Override
54:         public IEclipseContext createService(EMFFormsViewContext emfFormsViewContext) {
55:                 final EMFFormsContextProvider provider = emfFormsViewContext.getService(EMFFormsContextProvider.class);
56:
57:                 // Would be strange, indeed, if the service provided by this bundle were not there
58:•                return provider != null ? provider.getContext() : null;
59:         }
60:
61: }