Skip to content

Package: View

View

nameinstructionbranchcomplexitylinemethod
View()
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%
createPartControl(Composite)
M: 83 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 18 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 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%
setFocus()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 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.rap;
15:
16: import org.eclipse.emf.ecore.EClass;
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecore.util.EcoreUtil;
19: import org.eclipse.emf.ecp.makeithappen.model.task.TaskPackage;
20: import org.eclipse.emf.ecp.ui.view.ECPRendererException;
21: import org.eclipse.emf.ecp.ui.view.swt.ECPSWTView;
22: import org.eclipse.emf.ecp.ui.view.swt.ECPSWTViewRenderer;
23: import org.eclipse.jface.layout.GridDataFactory;
24: import org.eclipse.jface.layout.GridLayoutFactory;
25: import org.eclipse.swt.SWT;
26: import org.eclipse.swt.widgets.Composite;
27: import org.eclipse.ui.part.ViewPart;
28:
29: /**
30: * Example View for displaying a Forms Editor for an EObject.
31: */
32: public class View extends ViewPart {
33:         /**
34:          * View ID.
35:          */
36:         public static final String ID = "TestApp.view"; //$NON-NLS-1$
37:
38:         private ECPSWTView render;
39:
40:         private EObject getDummyEObject() {
41:                 // Replace this with your own model EClass to test the application with a custom model
42:                 final EClass eClass = TaskPackage.eINSTANCE.getUser();
43:                 return EcoreUtil.create(eClass);
44:         }
45:
46:         /**
47:          * This is a callback that will allow us to create the viewer and initialize
48:          * it.
49:          *
50:          * @param parent the {@link Composite} to render to
51:          */
52:         @Override
53:         public void createPartControl(Composite parent) {
54:
55:                 final EObject dummyObject = getDummyEObject();
56:
57:                 try {
58:                         parent.getShell().setMaximized(true);
59:                         parent.setLayout(GridLayoutFactory.fillDefaults().equalWidth(true).numColumns(1).create());
60:                         parent.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, true)
61:                                 .create());
62:                         parent.getParent().setLayout(GridLayoutFactory.fillDefaults().equalWidth(true).numColumns(1).create());
63:                         parent.getParent().setLayoutData(
64:                                 GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, true).create());
65:
66:                         final Composite content = new Composite(parent, SWT.NONE);
67:                         content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
68:                         content.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
69:                         content.setLayoutData(GridDataFactory.fillDefaults().create());
70:
71:                         render = ECPSWTViewRenderer.INSTANCE.render(content, dummyObject);
72:
73:                         content.layout();
74:
75:                 } catch (final ECPRendererException e) {
76:                         e.printStackTrace();
77:                 }
78:                 parent.layout();
79:         }
80:
81:         @Override
82:         public void setFocus() {
83:         }
84:
85:         @Override
86:         public void dispose() {
87:•                if (render != null) {
88:                         render.dispose();
89:                 }
90:         }
91: }