Skip to content

Package: ViewModelContextContextFunction

ViewModelContextContextFunction

nameinstructionbranchcomplexitylinemethod
ViewModelContextContextFunction()
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%
compute(IEclipseContext, String)
M: 0 C: 12
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 2
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.emf.ecp.view.internal.context;
15:
16: import org.eclipse.e4.core.contexts.ContextFunction;
17: import org.eclipse.e4.core.contexts.IContextFunction;
18: import org.eclipse.e4.core.contexts.IEclipseContext;
19: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
20: import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewContext;
21: import org.osgi.service.component.annotations.Component;
22:
23: /**
24: * A context function that casts the {@link EMFFormsViewContext} as a
25: * {@link ViewModelContext}.
26: *
27: * @since 1.22
28: */
29: @Component(name = "viewModelContextCF", service = IContextFunction.class, property = "service.context.key=org.eclipse.emf.ecp.view.spi.context.ViewModelContext")
30: public class ViewModelContextContextFunction extends ContextFunction {
31:
32:         @Override
33:         public Object compute(IEclipseContext context, String contextKey) {
34:                 final EMFFormsViewContext result = context.get(EMFFormsViewContext.class);
35:•                return result instanceof ViewModelContext ? result : null;
36:         }
37:
38: }