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%
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: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 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.internal.renderer.swt;
15:
16: import org.eclipse.core.runtime.Plugin;
17: import org.eclipse.emf.ecp.view.spi.util.swt.ImageRegistryService;
18: import org.eclipse.swt.graphics.Image;
19: import org.osgi.framework.BundleContext;
20: import org.osgi.framework.ServiceReference;
21:
22: /**
23: * Activator for this plugin.
24: *
25: * @author Eugen Neufeld
26: *
27: */
28: public class Activator extends Plugin {
29:
30:         private static Activator instance;
31:         private ServiceReference<ImageRegistryService> imageRegistryServiceReference;
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:                 instance = null;
43:                 super.stop(bundleContext);
44:         }
45:
46:         // END SUPRESS CATCH EXCEPTION
47:
48:         /**
49:          * Finds and returns an image for the provided path.
50:          *
51:          * @param path the path to get the image from
52:          * @return the image or null if nothing could be found
53:          */
54:         public static Image getImage(String path) {
55:
56:                 final Image image = instance.getImageRegistryService().getImage(instance.getBundle(), path);
57:
58:                 instance.getBundle().getBundleContext().ungetService(instance.imageRegistryServiceReference);
59:
60:                 return image;
61:         }
62:
63:         private ImageRegistryService getImageRegistryService() {
64:•                if (imageRegistryServiceReference == null) {
65:                         imageRegistryServiceReference = getBundle().getBundleContext()
66:                                 .getServiceReference(ImageRegistryService.class);
67:                 }
68:                 return getBundle().getBundleContext().getService(imageRegistryServiceReference);
69:         }
70:
71:         /**
72:          * Returns the shared instance.
73:          *
74:          * @return the shared instance
75:          */
76:         public static Activator getInstance() {
77:                 return instance;
78:         }
79:
80: }