Skip to content

Package: SWTCategoryRenderer

SWTCategoryRenderer

nameinstructionbranchcomplexitylinemethod
SWTCategoryRenderer(VCategory, ViewModelContext, ReportService, EMFFormsRendererFactory)
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%
getChildren()
M: 0 C: 12
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getCustomVariant()
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) 2011-2013 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: * Edagr Mueller - initial API and implementation
13: * Eugen Neufeld - Refactoring
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.spi.categorization.swt;
16:
17: import java.util.Collection;
18: import java.util.Collections;
19:
20: import javax.inject.Inject;
21:
22: import org.eclipse.emf.ecp.view.spi.categorization.model.VCategory;
23: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
24: import org.eclipse.emf.ecp.view.spi.core.swt.ContainerSWTRenderer;
25: import org.eclipse.emf.ecp.view.spi.model.VContainedElement;
26: import org.eclipse.emfforms.spi.common.report.ReportService;
27: import org.eclipse.emfforms.spi.swt.core.EMFFormsRendererFactory;
28:
29: /**
30: * Renderer for {@link VCategory VCategories}.
31: *
32: * @author Eugen Neufeld
33: *
34: */
35: public class SWTCategoryRenderer extends ContainerSWTRenderer<VCategory> {
36:
37:         /**
38:          * Default constructor.
39:          *
40:          * @param vElement the view model element to be rendered
41:          * @param viewContext the view context
42:          * @param reportService the {@link ReportService}
43:          * @param factory the {@link EMFFormsRendererFactory}
44:          * @since 1.6
45:          */
46:         @Inject
47:         public SWTCategoryRenderer(VCategory vElement, ViewModelContext viewContext, ReportService reportService,
48:                 EMFFormsRendererFactory factory) {
49:                 super(vElement, viewContext, reportService, factory);
50:         }
51:
52:         /**
53:          * {@inheritDoc}
54:          *
55:          * @see org.eclipse.emf.ecp.view.spi.core.swt.ContainerSWTRenderer#getCustomVariant()
56:          */
57:         @Override
58:         protected String getCustomVariant() {
59:                 return "org_eclipse_emf_ecp_view_categorization_category"; //$NON-NLS-1$
60:         }
61:
62:         /**
63:          * {@inheritDoc}
64:          *
65:          * @see org.eclipse.emf.ecp.view.spi.core.swt.ContainerSWTRenderer#getChildren()
66:          */
67:         @Override
68:         protected Collection<VContainedElement> getChildren() {
69:                 final VContainedElement element = getVElement().getComposite();
70:•                if (element == null) {
71:                         return Collections.emptySet();
72:                 }
73:                 return Collections.singleton(element);
74:         }
75:
76:         // /**
77:         // * {@inheritDoc}
78:         // *
79:         // * @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#renderControl(int, org.eclipse.swt.widgets.Composite,
80:         // * org.eclipse.emf.ecp.view.spi.model.VElement, org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
81:         // */
82:         // @Override
83:         // protected Control renderControl(SWTGridCell gridCell, Composite parent)
84:         // throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
85:         // final Composite categoryComposite = new Composite(parent, SWT.NONE);
86:         // categoryComposite.setBackground(parent.getBackground());
87:         //
88:         // final AbstractSWTRenderer<VElement> renderer = getSWTRendererFactory().getRenderer(
89:         // getVElement().getComposite(),
90:         // getViewModelContext());
91:         // if (renderer == null) {
92:         // Activator
93:         // .getDefault()
94:         // .getLog()
95:         // .log(
96:         // new Status(IStatus.INFO, Activator.PLUGIN_ID, String.format(
97:         // "No Renderer for %s found.", getVElement().getComposite().eClass().getName()))); //$NON-NLS-1$
98:         // return categoryComposite;
99:         // }
100:         // final SWTGridDescription gridDescription = renderer.getGridDescription(GridDescriptionFactory.INSTANCE
101:         // .createEmptyGridDescription());
102:         // categoryComposite.setLayout(getLayoutHelper().getColumnLayout(
103:         // gridDescription.getColumns(), false));
104:         //
105:         // for (final SWTGridCell childGridCell : gridDescription.getGrid()) {
106:         // try {
107:         // final Control control = renderer.render(
108:         // childGridCell,
109:         // categoryComposite);
110:         // // TODO who should apply the layout
111:         // setLayoutDataForControl(childGridCell, gridDescription, gridDescription.getColumns(),
112:         // new LinkedHashSet<GridCellDescription>(),
113:         // new LinkedHashSet<GridCellDescription>(),
114:         // control);
115:         // // resultRows = SWTRendererFactory.INSTANCE.render(columnComposite, child, viewContext);
116:         // } catch (final NoPropertyDescriptorFoundExeption ex) {
117:         // Activator.getDefault().getLog()
118:         // .log(new Status(IStatus.INFO, Activator.PLUGIN_ID, ex.getMessage(), ex));
119:         // continue;
120:         // }
121:         // }
122:         // renderer.finalizeRendering(categoryComposite);
123:         //
124:         // return categoryComposite;
125:         // }
126:         //
127:         // /**
128:         // * {@inheritDoc}
129:         // *
130:         // * @see org.eclipse.emf.ecp.view.spi.swt.AbstractSWTRenderer#getGridDescription(SWTGridDescription)
131:         // */
132:         // @Override
133:         // public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
134:         // if (rendererGridDescription == null) {
135:         // rendererGridDescription = GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 1, this);
136:         // }
137:         // return rendererGridDescription;
138:         // }
139: }