Skip to content

Package: CategorizationElementExpandBarRendererService

CategorizationElementExpandBarRendererService

nameinstructionbranchcomplexitylinemethod
CategorizationElementExpandBarRendererService()
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%
getRendererClass()
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%
isApplicable(VElement, ViewModelContext)
M: 66 C: 0
0%
M: 14 C: 0
0%
M: 8 C: 0
0%
M: 15 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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.emfforms.internal.swt.categorization.expandbar;
15:
16: import org.eclipse.emf.ecp.view.spi.categorization.model.VAbstractCategorization;
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.model.VCategory;
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: import org.eclipse.swt.widgets.Display;
25: import org.osgi.framework.FrameworkUtil;
26: import org.osgi.service.component.annotations.Component;
27:
28: /**
29: * CategorizationElementExpandBarRendererService which provides the ExpandBarCategorizationElementRenderer.
30: *
31: * @author Eugen Neufeld
32: *
33: */
34: @Component
35: public class CategorizationElementExpandBarRendererService
36:         implements EMFFormsDIRendererService<VCategorizationElement> {
37:
38:         /**
39:          * {@inheritDoc}
40:          *
41:          * @see org.eclipse.emfforms.spi.swt.core.EMFFormsRendererService#isApplicable(VElement,ViewModelContext)
42:          */
43:         @Override
44:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
45:                 if (!FrameworkUtil.getBundle(Display.class).getSymbolicName()
46:•                        .contains(".rwt")) { //$NON-NLS-1$
47:                         return NOT_APPLICABLE;
48:                 }
49:•                if (!VCategorizationElement.class.isInstance(vElement)) {
50:                         return NOT_APPLICABLE;
51:                 }
52:•                if (VCategorizationElement.class.isInstance(vElement)) {
53:                         final VCategorizationElement categorizationElement = VCategorizationElement.class.cast(vElement);
54:•                        for (final VAbstractCategorization abstractCategorization : categorizationElement.getCategorizations()) {
55:•                                if (!VCategorization.class.isInstance(abstractCategorization)) {
56:                                         return NOT_APPLICABLE;
57:                                 }
58:                                 final VCategorization categorization = VCategorization.class.cast(abstractCategorization);
59:•                                for (final VAbstractCategorization innerAbstractCategorization : categorization.getCategorizations()) {
60:•                                        if (!VCategory.class.isInstance(innerAbstractCategorization)) {
61:                                                 return NOT_APPLICABLE;
62:                                         }
63:                                 }
64:                         }
65:                 }
66:                 return 10d;
67:         }
68:
69:         /**
70:          * {@inheritDoc}
71:          *
72:          * @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#getRendererClass()
73:          */
74:         @Override
75:         public Class<? extends AbstractSWTRenderer<VCategorizationElement>> getRendererClass() {
76:                 return ExpandBarCategorizationElementRenderer.class;
77:         }
78:
79: }