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%
getEMFFormsEditSupport()
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getLayoutProvider()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getReportService()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
log(Exception)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
start(BundleContext)
M: 18 C: 8
31%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 4 C: 4
50%
M: 0 C: 1
100%
stop(BundleContext)
M: 11 C: 31
74%
M: 3 C: 7
70%
M: 3 C: 3
50%
M: 3 C: 10
77%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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: * Edgar Mueller - initial API and implementation
13: * Martin Fleck - Bug 490708: Add layout provider service
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.internal.swt;
16:
17: import org.eclipse.core.runtime.IStatus;
18: import org.eclipse.core.runtime.Plugin;
19: import org.eclipse.core.runtime.Status;
20: import org.eclipse.emf.ecp.ui.view.swt.DebugSWTReportConsumer;
21: import org.eclipse.emf.ecp.ui.view.swt.InvalidGridDescriptionReportConsumer;
22: import org.eclipse.emf.ecp.view.spi.model.util.ViewModelUtil;
23: import org.eclipse.emfforms.spi.common.report.ReportService;
24: import org.eclipse.emfforms.spi.common.report.ReportServiceConsumer;
25: import org.eclipse.emfforms.spi.core.services.editsupport.EMFFormsEditSupport;
26: import org.eclipse.emfforms.spi.swt.core.layout.LayoutProvider;
27: import org.osgi.framework.BundleContext;
28: import org.osgi.framework.ServiceReference;
29: import org.osgi.framework.ServiceRegistration;
30:
31: /**
32: * The activator class controls the plug-in life cycle.
33: */
34: public class Activator extends Plugin {
35:
36:         /** The plug-in ID. */
37:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.ui.view.swt"; //$NON-NLS-1$
38:
39:         // The shared instance
40:         private static Activator plugin;
41:
42:         private ServiceRegistration<ReportServiceConsumer> registerDebugConsumerService;
43:
44:         private ServiceRegistration<ReportServiceConsumer> registerInvalidGridConsumerService;
45:
46:         private ServiceReference<ReportService> reportServiceReference;
47:
48:         private ServiceReference<EMFFormsEditSupport> editSupportServiceReference;
49:
50:         private ServiceReference<LayoutProvider> layoutServiceReference;
51:
52:         /**
53:          * The constructor.
54:          */
55:         public Activator() {
56:         }
57:
58:         /*
59:          * (non-Javadoc)
60:          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
61:          */
62:         @Override
63:         public void start(BundleContext context) throws Exception {
64:                 super.start(context);
65:•                if (ViewModelUtil.isDebugMode()) {
66:                         registerDebugConsumerService = context.registerService(ReportServiceConsumer.class,
67:                                 new DebugSWTReportConsumer(), null);
68:                         registerInvalidGridConsumerService = context.registerService(ReportServiceConsumer.class,
69:                                 new InvalidGridDescriptionReportConsumer(), null);
70:                 }
71:                 plugin = this;
72:         }
73:
74:         /*
75:          * (non-Javadoc)
76:          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
77:          */
78:         @Override
79:         public void stop(BundleContext context) throws Exception {
80:                 plugin = null;
81:•                if (editSupportServiceReference != null) {
82:                         context.ungetService(editSupportServiceReference);
83:                 }
84:•                if (reportServiceReference != null) {
85:                         context.ungetService(reportServiceReference);
86:                 }
87:•                if (registerDebugConsumerService != null) {
88:                         registerDebugConsumerService.unregister();
89:                 }
90:•                if (registerInvalidGridConsumerService != null) {
91:                         registerInvalidGridConsumerService.unregister();
92:                 }
93:•                if (layoutServiceReference != null) {
94:                         context.ungetService(layoutServiceReference);
95:                 }
96:                 super.stop(context);
97:         }
98:
99:         /**
100:          * Returns the shared instance.
101:          *
102:          * @return the shared instance
103:          */
104:         public static Activator getDefault() {
105:                 return plugin;
106:         }
107:
108:         /**
109:          * Logs exception.
110:          *
111:          * @param e
112:          * the {@link Exception} to log
113:          */
114:         public static void log(Exception e) {
115:                 getDefault().getLog().log(
116:                         new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e
117:                                 .getMessage(), e));
118:         }
119:
120:         /**
121:          * Returns the {@link ReportService}.
122:          *
123:          * @return the {@link ReportService}
124:          */
125:         public ReportService getReportService() {
126:                 final BundleContext bundleContext = getBundle().getBundleContext();
127:                 reportServiceReference = bundleContext.getServiceReference(ReportService.class);
128:                 return bundleContext.getService(reportServiceReference);
129:         }
130:
131:         /**
132:          * Returns the {@link EMFFormsEditSupport} service.
133:          *
134:          * @return The {@link EMFFormsEditSupport}
135:          */
136:         public EMFFormsEditSupport getEMFFormsEditSupport() {
137:                 editSupportServiceReference = plugin.getBundle().getBundleContext()
138:                         .getServiceReference(EMFFormsEditSupport.class);
139:
140:                 return plugin.getBundle().getBundleContext().getService(editSupportServiceReference);
141:         }
142:
143:         /**
144:          * Returns the {@link LayoutProvider} service.
145:          *
146:          * @return The {@link LayoutProvider}
147:          */
148:         public LayoutProvider getLayoutProvider() {
149:                 layoutServiceReference = plugin.getBundle().getBundleContext()
150:                         .getServiceReference(LayoutProvider.class);
151:                 return plugin.getBundle().getBundleContext()
152:                         .getService(layoutServiceReference);
153:         }
154:
155: }