Skip to content

Package: Activator$1

Activator$1

nameinstructionbranchcomplexitylinemethod
objectsChanged(ECPProject, Collection)
M: 27 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
{...}
M: 6 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-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: * EclipseSource Muenchen - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.ui.view.internal.editor.controls.legacy;
16:
17: import java.util.ArrayList;
18: import java.util.Collection;
19:
20: import org.eclipse.emf.common.util.EList;
21: import org.eclipse.emf.ecp.core.ECPProject;
22: import org.eclipse.emf.ecp.core.util.ECPUtil;
23: import org.eclipse.emf.ecp.core.util.observer.ECPProjectContentChangedObserver;
24: import org.eclipse.emf.ecp.view.model.provider.xmi.ViewModelFileExtensionsManager;
25: import org.eclipse.emf.ecp.view.spi.model.VView;
26: import org.eclipse.emf.ecp.workspace.internal.core.WorkspaceProvider;
27: import org.eclipse.ui.plugin.AbstractUIPlugin;
28: import org.osgi.framework.BundleContext;
29:
30: /**
31: * The activator class controls the plug-in life cycle.
32: */
33: @SuppressWarnings("restriction")
34: public class Activator extends AbstractUIPlugin {
35:
36:         // The shared instance
37:         private static Activator plugin;
38:
39:         /*
40:          * (non-Javadoc)
41:          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
42:          */
43:         @Override
44:         public void start(BundleContext context) throws Exception {
45:                 super.start(context);
46:                 plugin = this;
47:                 /**
48:                  * Listen to changes in file projects. If a view is affected, reload the view models provided over file
49:                  * extension point.
50:                  */
51:                 ECPUtil.getECPObserverBus().register(new ECPProjectContentChangedObserver() {
52:
53:                         @Override
54:                         public Collection<Object> objectsChanged(ECPProject project, Collection<Object> objects) {
55:•                                if (project.getProvider().getName().equals(WorkspaceProvider.NAME)) {
56:                                         final EList<Object> contents = project.getContents();
57:•                                        for (final Object object : contents) {
58:•                                                if (object instanceof VView) {
59:                                                         ViewModelFileExtensionsManager.dispose();
60:                                                 }
61:                                         }
62:                                 }
63:                                 return new ArrayList<Object>();
64:
65:                         }
66:
67:                 });
68:         }
69:
70:         /*
71:          * (non-Javadoc)
72:          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
73:          */
74:         @Override
75:         public void stop(BundleContext context) throws Exception {
76:                 plugin = null;
77:                 super.stop(context);
78:         }
79:
80:         /**
81:          * Returns the shared instance.
82:          *
83:          * @return the shared instance
84:          */
85:         public static Activator getDefault() {
86:                 return plugin;
87:         }
88:
89: }