Skip to content

Package: SWTCategorizationRendererService

SWTCategorizationRendererService

nameinstructionbranchcomplexitylinemethod
SWTCategorizationRendererService()
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%
getRendererClass()
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%
isApplicable(VElement, ViewModelContext)
M: 0 C: 36
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 10
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.categorization.swt;
15:
16: import org.eclipse.emf.ecore.EObject;
17: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorization;
18: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategorizationElement;
19: import org.eclipse.emf.ecp.view.spi.categorization.swt.SWTCategorizationRenderer;
20: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
21: import org.eclipse.emf.ecp.view.spi.model.VElement;
22: import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
23: import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService;
24:
25: /**
26: * SWTCategorizationRendererService which provides the SWTCategorizationRenderer.
27: *
28: * @author Eugen Neufeld
29: *
30: */
31: public class SWTCategorizationRendererService implements EMFFormsDIRendererService<VCategorization> {
32:
33:         /**
34:          * {@inheritDoc}
35:          *
36:          * @see org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService#isApplicable(VElement,ViewModelContext)
37:          */
38:         @Override
39:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
40:•                if (VCategorization.class.isInstance(vElement)) {
41:                         final VCategorization categorization = VCategorization.class.cast(vElement);
42:                         int depth = 0;
43:                         EObject parent = categorization.eContainer();
44:•                        while (!VCategorizationElement.class.isInstance(parent)) {
45:                                 parent = parent.eContainer();
46:                                 depth++;
47:                         }
48:•                        if (VCategorizationElement.class.cast(parent).getMainCategoryDepth() < depth + 1) {
49:                                 return 1;
50:                         }
51:                 }
52:                 return NOT_APPLICABLE;
53:         }
54:
55:         /**
56:          * {@inheritDoc}
57:          *
58:          * @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#getRendererClass()
59:          */
60:         @Override
61:         public Class<? extends AbstractSWTRenderer<VCategorization>> getRendererClass() {
62:                 return SWTCategorizationRenderer.class;
63:         }
64:
65: }