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%
getImageDescriptor(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMarkerHelperProviders()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getValidationDelegateProviders()
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
log(String, Throwable)
M: 11 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: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
stop(BundleContext)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * EclipseSource - initial API and implementation
13: * Christian W. Damus - bug 544499
14: ******************************************************************************/
15: package org.eclipse.emfforms.ide.internal.builder;
16:
17: import java.util.Arrays;
18: import java.util.Collection;
19:
20: import org.eclipse.core.runtime.IStatus;
21: import org.eclipse.core.runtime.Status;
22: import org.eclipse.emfforms.ide.builder.MarkerHelperProvider;
23: import org.eclipse.emfforms.ide.builder.ValidationDelegateProvider;
24: import org.eclipse.jface.resource.ImageDescriptor;
25: import org.eclipse.ui.plugin.AbstractUIPlugin;
26: import org.osgi.framework.BundleContext;
27: import org.osgi.util.tracker.ServiceTracker;
28:
29: /**
30: * The activator class controls the plug-in life cycle.
31: */
32: public class Activator extends AbstractUIPlugin {
33:
34:         /** plug-in ID. */
35:         public static final String PLUGIN_ID = "org.eclipse.emfforms.ide.builder"; //$NON-NLS-1$
36:
37:         /** Shared instance. */
38:         private static Activator plugin;
39:
40:         private ServiceTracker<ValidationDelegateProvider, ValidationDelegateProvider> validationDelegateProviders;
41:         private ServiceTracker<MarkerHelperProvider, MarkerHelperProvider> markerHelperProviders;
42:
43:         @Override
44:         public void start(BundleContext context) throws Exception {
45:                 super.start(context);
46:                 plugin = this;
47:
48:                 validationDelegateProviders = new ServiceTracker<ValidationDelegateProvider, ValidationDelegateProvider>(
49:                         context, ValidationDelegateProvider.class, null);
50:                 validationDelegateProviders.open();
51:
52:                 markerHelperProviders = new ServiceTracker<MarkerHelperProvider, MarkerHelperProvider>(
53:                         context, MarkerHelperProvider.class, null);
54:                 markerHelperProviders.open();
55:         }
56:
57:         @Override
58:         public void stop(BundleContext context) throws Exception {
59:                 markerHelperProviders.close();
60:                 validationDelegateProviders.close();
61:                 plugin = null;
62:                 super.stop(context);
63:         }
64:
65:         /**
66:          * Returns the shared instance.
67:          *
68:          * @return the shared instance
69:          */
70:         public static Activator getDefault() {
71:                 return plugin;
72:         }
73:
74:         /**
75:          * Returns an image descriptor for the image file at the given
76:          * plug-in relative path.
77:          *
78:          * @param path the path
79:          * @return the image descriptor
80:          */
81:         public static ImageDescriptor getImageDescriptor(String path) {
82:                 return imageDescriptorFromPlugin(PLUGIN_ID, path);
83:         }
84:
85:         /**
86:          * Logs an exception for this plugin.
87:          *
88:          * @param message the specific message to log
89:          * @param t throwable causing this log
90:          */
91:         public static void log(String message, Throwable t) {
92:                 getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, t));
93:
94:         }
95:
96:         /**
97:          * Obtain the currently registered validation delegate providers.
98:          *
99:          * @return the validation delegate providers
100:          */
101:         public Collection<ValidationDelegateProvider> getValidationDelegateProviders() {
102:                 final ValidationDelegateProvider[] result = {};
103:                 return Arrays.asList(validationDelegateProviders.getServices(result));
104:         }
105:
106:         /**
107:          * Obtain the currently registered marker helper providers.
108:          *
109:          * @return the marker helper providers
110:          */
111:         public Collection<MarkerHelperProvider> getMarkerHelperProviders() {
112:                 final MarkerHelperProvider[] result = {};
113:                 return Arrays.asList(markerHelperProviders.getServices(result));
114:         }
115:
116: }