Skip to content

Package: Activator

Activator

nameinstructionbranchcomplexitylinemethod
Activator()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getDefault()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getECPControlFactory()
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getImage(String)
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%
getReportService()
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%
log(Throwable)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
start(BundleContext)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
stop(BundleContext)
M: 5 C: 9
64%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
M: 0 C: 1
100%
ungetECPControlFactory()
M: 0 C: 15
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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.view.internal.custom.swt;
15:
16: import org.eclipse.core.runtime.IStatus;
17: import org.eclipse.core.runtime.Plugin;
18: import org.eclipse.core.runtime.Status;
19: import org.eclipse.emf.ecp.edit.spi.ECPControlFactory;
20: import org.eclipse.emfforms.spi.common.report.ReportService;
21: import org.eclipse.swt.graphics.Image;
22: import org.osgi.framework.BundleContext;
23: import org.osgi.framework.ServiceReference;
24:
25: /**
26: * The activator class controls the plug-in life cycle.
27: */
28: @SuppressWarnings("deprecation")
29: public class Activator extends Plugin {
30:
31:         /** The plug-in ID. */
32:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ui.view.custom.swt"; //$NON-NLS-1$
33:
34:         // The shared instance
35:         private static Activator plugin;
36:
37:         /**
38:          * The constructor.
39:          */
40:         public Activator() {
41:         }
42:
43:         /*
44:          * (non-Javadoc)
45:          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
46:          */
47:         @Override
48:         public void start(BundleContext context) throws Exception {
49:                 super.start(context);
50:                 plugin = this;
51:         }
52:
53:         /*
54:          * (non-Javadoc)
55:          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
56:          */
57:         @Override
58:         public void stop(BundleContext context) throws Exception {
59:                 plugin = null;
60:•                if (reportServiceReference != null) {
61:                         context.ungetService(reportServiceReference);
62:                 }
63:                 super.stop(context);
64:         }
65:
66:         /**
67:          * Returns the shared instance.
68:          *
69:          * @return the shared instance
70:          */
71:         public static Activator getDefault() {
72:                 return plugin;
73:         }
74:
75:         // Not API, delegating to reuse same images
76:         /**
77:          * Get an Image based on an path. This just delegates to
78:          * {@link org.eclipse.emf.ecp.edit.internal.swt.Activator#getImage(String)}.
79:          *
80:          * @param path the path of the image to load
81:          * @return the loaded image
82:          */
83:         @SuppressWarnings("restriction")
84:         public static Image getImage(String path) {
85:                 return org.eclipse.emf.ecp.edit.internal.swt.Activator.getImage(path);
86:
87:         }
88:
89:         /**
90:          * Helper for logging {@link Throwable Throwables}.
91:          *
92:          * @param throwable the {@link Throwable} to log
93:          */
94:         public static void log(Throwable throwable) {
95:                 plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, throwable.getMessage(), throwable));
96:         }
97:
98:         private ServiceReference<ECPControlFactory> controlFactoryReference;
99:
100:         private ServiceReference<ReportService> reportServiceReference;
101:
102:         /**
103:          * Returns the {@link ECPControlFactory}.
104:          *
105:          * @return the {@link ECPControlFactory}
106:          */
107:         public ECPControlFactory getECPControlFactory() {
108:•                if (controlFactoryReference == null) {
109:                         controlFactoryReference = plugin.getBundle().getBundleContext()
110:                                 .getServiceReference(ECPControlFactory.class);
111:                 }
112:                 return plugin.getBundle().getBundleContext().getService(controlFactoryReference);
113:         }
114:
115:         /**
116:          * Frees the {@link ECPControlFactory} from use, allowing the OSGi Bundle to be shutdown.
117:          */
118:         public void ungetECPControlFactory() {
119:•                if (controlFactoryReference == null) {
120:                         return;
121:                 }
122:                 plugin.getBundle().getBundleContext().ungetService(controlFactoryReference);
123:                 controlFactoryReference = null;
124:         }
125:
126:         /**
127:          * Returns the {@link ReportService}.
128:          *
129:          * @return the {@link ReportService}
130:          */
131:         public ReportService getReportService() {
132:•                if (reportServiceReference == null) {
133:                         reportServiceReference = plugin.getBundle().getBundleContext()
134:                                 .getServiceReference(ReportService.class);
135:                 }
136:                 return plugin.getBundle().getBundleContext().getService(reportServiceReference);
137:         }
138:
139: }