Skip to content

Package: Activator

Activator

nameinstructionbranchcomplexitylinemethod
Activator()
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%
getEMFFormsLabelProvider()
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getImage(String)
M: 16 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getImageRegistryService()
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getInstance()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
start(BundleContext)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
stop(BundleContext)
M: 22 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.diffmerge.swt;
15:
16: import org.eclipse.core.runtime.Plugin;
17: import org.eclipse.emf.ecp.view.spi.util.swt.ImageRegistryService;
18: import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
19: import org.eclipse.swt.graphics.Image;
20: import org.osgi.framework.BundleContext;
21: import org.osgi.framework.ServiceReference;
22:
23: /**
24: * Activator for this plugin.
25: *
26: * @author Eugen Neufeld
27: *
28: */
29: public class Activator extends Plugin {
30:
31:         private static Activator instance;
32:
33:         // BEGIN SUPRESS CATCH EXCEPTION
34:         @Override
35:         public void start(BundleContext bundleContext) throws Exception {
36:                 instance = this;
37:                 super.start(bundleContext);
38:         }
39:
40:         @Override
41:         public void stop(BundleContext bundleContext) throws Exception {
42:•                if (imageRegistryServiceReference != null) {
43:                         bundleContext.ungetService(imageRegistryServiceReference);
44:                 }
45:•                if (emfformsLabelProviderserviceReference != null) {
46:                         bundleContext.ungetService(emfformsLabelProviderserviceReference);
47:                 }
48:                 instance = null;
49:                 super.stop(bundleContext);
50:         }
51:
52:         // END SUPRESS CATCH EXCEPTION
53:
54:         /**
55:          * Returns the shared instance.
56:          *
57:          * @return the shared instance
58:          */
59:         public static Activator getInstance() {
60:                 return instance;
61:         }
62:
63:         /**
64:          * Finds and returns an image for the provided path.
65:          *
66:          * @param path the path to get the image from
67:          * @return the image or null if nothing could be found
68:          */
69:         public static Image getImage(String path) {
70:
71:                 final Image image = instance.getImageRegistryService().getImage(instance.getBundle(), path);
72:
73:                 instance.getBundle().getBundleContext().ungetService(instance.imageRegistryServiceReference);
74:
75:                 return image;
76:         }
77:
78:         private ServiceReference<ImageRegistryService> imageRegistryServiceReference;
79:         private ServiceReference<EMFFormsLabelProvider> emfformsLabelProviderserviceReference;
80:
81:         private ImageRegistryService getImageRegistryService() {
82:•                if (imageRegistryServiceReference == null) {
83:                         imageRegistryServiceReference = getBundle().getBundleContext()
84:                                 .getServiceReference(ImageRegistryService.class);
85:                 }
86:                 return getBundle().getBundleContext().getService(imageRegistryServiceReference);
87:         }
88:
89:         /**
90:          * Returns the {@link EMFFormsLabelProvider} service.
91:          *
92:          * @return The {@link EMFFormsLabelProvider}
93:          */
94:         public EMFFormsLabelProvider getEMFFormsLabelProvider() {
95:•                if (emfformsLabelProviderserviceReference == null) {
96:                         emfformsLabelProviderserviceReference = getBundle().getBundleContext()
97:                                 .getServiceReference(EMFFormsLabelProvider.class);
98:                 }
99:
100:                 return getBundle().getBundleContext().getService(emfformsLabelProviderserviceReference);
101:         }
102: }