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: 1
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%
getEMFFormsDatabinding()
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%
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: 7 C: 19
73%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 6
86%
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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.rule.model;
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.emfforms.spi.common.report.ReportService;
20: import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
21: import org.osgi.framework.BundleContext;
22: import org.osgi.framework.ServiceReference;
23:
24: /**
25: * The Class Activator.
26: *
27: * @author Lucas Koehler
28: * @since 1.6
29: */
30: public class Activator extends Plugin {
31:
32:         /**
33:          * The constant holding the id of this plugin.
34:          */
35:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.view.rule.model"; //$NON-NLS-1$
36:
37:         private static Activator plugin;
38:         private ServiceReference<ReportService> reportServiceReference;
39:         private ServiceReference<EMFFormsDatabinding> emfformsDatabindingServiceReference;
40:
41:         // BEGIN SUPRESS CATCH EXCEPTION
42:         /**
43:          * {@inheritDoc}
44:          *
45:          * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
46:          */
47:         @Override
48:         public void start(BundleContext bundleContext) throws Exception {
49:                 super.start(bundleContext);
50:                 plugin = this;
51:         }
52:
53:         /**
54:          * {@inheritDoc}
55:          *
56:          * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
57:          */
58:         @Override
59:         public void stop(BundleContext bundleContext) throws Exception {
60:•                if (reportServiceReference != null) {
61:                         plugin.getBundle().getBundleContext().ungetService(reportServiceReference);
62:                 }
63:•                if (emfformsDatabindingServiceReference != null) {
64:                         plugin.getBundle().getBundleContext().ungetService(emfformsDatabindingServiceReference);
65:                 }
66:                 plugin = null;
67:                 super.stop(bundleContext);
68:         }
69:
70:         // END SUPRESS CATCH EXCEPTION
71:         /**
72:          * Returns the instance of this Activator.
73:          *
74:          * @return the saved instance
75:          */
76:         public static Activator getDefault() {
77:                 return plugin;
78:         }
79:
80:         /**
81:          * Logs a {@link Throwable}.
82:          *
83:          * @param t the {@link Throwable} to log
84:          */
85:         public static void log(Throwable t) {
86:                 getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
87:         }
88:
89:         /**
90:          * Returns the {@link ReportService}.
91:          *
92:          * @return the {@link ReportService}
93:          */
94:         public ReportService getReportService() {
95:•                if (reportServiceReference == null) {
96:                         reportServiceReference = plugin.getBundle().getBundleContext()
97:                                 .getServiceReference(ReportService.class);
98:                 }
99:                 return plugin.getBundle().getBundleContext().getService(reportServiceReference);
100:         }
101:
102:         /**
103:          * Returns the {@link EMFFormsDatabinding} service.
104:          *
105:          * @return The {@link EMFFormsDatabinding}
106:          */
107:         public EMFFormsDatabinding getEMFFormsDatabinding() {
108:•                if (emfformsDatabindingServiceReference == null) {
109:                         emfformsDatabindingServiceReference = plugin.getBundle().getBundleContext()
110:                                 .getServiceReference(EMFFormsDatabinding.class);
111:                 }
112:                 return plugin.getBundle().getBundleContext().getService(emfformsDatabindingServiceReference);
113:         }
114: }