Skip to content

Package: ECPSWTViewImpl

ECPSWTViewImpl

nameinstructionbranchcomplexitylinemethod
ECPSWTViewImpl(Composite, ViewModelContext)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
dispose()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getSWTControl()
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%
getViewModelContext()
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%
lambda$0(DisposeEvent)
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * Jonas - initial API and implementation
13: * Christian W. Damus - bug 527686
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.internal.swt;
16:
17: import org.eclipse.emf.ecp.ui.view.swt.ECPSWTView;
18: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
19: import org.eclipse.swt.widgets.Composite;
20: import org.eclipse.swt.widgets.Control;
21:
22: /**
23: * @author Jonas
24: *
25: */
26: public class ECPSWTViewImpl implements ECPSWTView {
27:
28:         private final Composite composite;
29:         private final ViewModelContext viewContext;
30:
31:         /**
32:          * @param composite the composite containing the view
33:          * @param viewContext the view context of the view
34:          */
35:         public ECPSWTViewImpl(Composite composite, ViewModelContext viewContext) {
36:                 this.composite = composite;
37:                 this.viewContext = viewContext;
38:
39:                 composite.addDisposeListener(__ -> dispose());
40:
41:                 // I don't own this context so I cannot dispose it, but I need it while I am active
42:                 viewContext.addContextUser(this);
43:         }
44:
45:         @Override
46:         public Control getSWTControl() {
47:                 return composite;
48:         }
49:
50:         @Override
51:         public void dispose() {
52:                 // I don't own this context, so I cannot dispose it (unless there are no other users)
53:                 viewContext.removeContextUser(this);
54:
55:                 composite.dispose();
56:         }
57:
58:         @Override
59:         public ViewModelContext getViewModelContext() {
60:                 return viewContext;
61:         }
62:
63: }