Skip to content

Package: SamplePart

SamplePart

nameinstructionbranchcomplexitylinemethod
SamplePart()
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%
createComposite(Composite)
M: 36 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getDummyEObject()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /**
2: * Copyright (c) 2011-2014 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: * EclipseSource Munich - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.makeithappen.application.sample.e4.parts;
15:
16: import javax.annotation.PostConstruct;
17:
18: import org.eclipse.emf.ecore.EClass;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.util.EcoreUtil;
21: import org.eclipse.emf.ecp.makeithappen.model.task.TaskPackage;
22: import org.eclipse.emf.ecp.ui.view.ECPRendererException;
23: import org.eclipse.emf.ecp.ui.view.swt.ECPSWTViewRenderer;
24: import org.eclipse.jface.layout.GridLayoutFactory;
25: import org.eclipse.swt.SWT;
26: import org.eclipse.swt.widgets.Composite;
27:
28: /**
29: * Example Part for displaying a Forms Editor for an EObject.
30: */
31: public class SamplePart {
32:
33:         private EObject getDummyEObject() {
34:                 // Replace this with your own model EClass to test the application with a custom model
35:                 final EClass eClass = TaskPackage.eINSTANCE.getUser();
36:                 return EcoreUtil.create(eClass);
37:         }
38:
39:         /**
40:          * Render the editor.
41:          *
42:          * @param parent the {@link Composite} to render to
43:          */
44:         @PostConstruct
45:         public void createComposite(Composite parent) {
46:                 final EObject dummyObject = getDummyEObject();
47:                 try {
48:                         final Composite content = new Composite(parent, SWT.NONE);
49:                         content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
50:                         content.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
51:
52:                         ECPSWTViewRenderer.INSTANCE.render(content, dummyObject);
53:                         content.layout();
54:                 } catch (final ECPRendererException e) {
55:                         e.printStackTrace();
56:                 }
57:                 parent.layout();
58:         }
59: }