Skip to content

Package: Activator

Activator

nameinstructionbranchcomplexitylinemethod
Activator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 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%
getStatus(Throwable)
M: 29 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
loadImageDescriptor(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%
log(IStatus)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
log(String)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
log(Throwable)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 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 Eike Stepper (Berlin, Germany) 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: * Eike Stepper - initial API and implementation
13: *******************************************************************************/
14: package org.eclipse.emf.ecp.workspace.internal.ui;
15:
16: import org.eclipse.core.runtime.CoreException;
17: import org.eclipse.core.runtime.IStatus;
18: import org.eclipse.core.runtime.Status;
19: import org.eclipse.jface.resource.ImageDescriptor;
20: import org.eclipse.ui.plugin.AbstractUIPlugin;
21: import org.osgi.framework.BundleContext;
22:
23: /**
24: * The activator class controls the plug-in life cycle.
25: *
26: * @author Eike Stepper
27: */
28: public final class Activator extends AbstractUIPlugin {
29:         /**
30:          * The plug-in ID.
31:          */
32:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.workspace.ui"; //$NON-NLS-1$
33:
34:         private static Activator instance;
35:
36:         /**
37:          * The constructor.
38:          */
39:         public Activator() {
40:         }
41:
42:         // BEGIN SUPRESS CATCH EXCEPTION
43:         @Override
44:         public void start(BundleContext context) throws Exception {
45:                 super.start(context);
46:                 instance = this;
47:         }
48:
49:         @Override
50:         public void stop(BundleContext context) throws Exception {
51:                 instance = null;
52:                 super.stop(context);
53:         }
54:
55:         // END SUPRESS CATCH EXCEPTION
56:         /**
57:          * Returns the shared instance.
58:          *
59:          * @return the shared instance
60:          */
61:         public static Activator getInstance() {
62:                 return instance;
63:         }
64:
65:         /**
66:          * Logs and Info message.
67:          *
68:          * @param message the message to log
69:          */
70:         public static void log(String message) {
71:                 instance.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
72:         }
73:
74:         private static void log(IStatus status) {
75:                 instance.getLog().log(status);
76:         }
77:
78:         /**
79:          * Logs a {@link Throwable}.
80:          *
81:          * @param t the {@link Throwable} to log
82:          * @return the message of the {@link Throwable}
83:          */
84:         public static String log(Throwable t) {
85:                 final IStatus status = getStatus(t);
86:                 log(status);
87:                 return status.getMessage();
88:         }
89:
90:         private static IStatus getStatus(Throwable t) {
91:•                if (t instanceof CoreException) {
92:                         final CoreException coreException = (CoreException) t;
93:                         return coreException.getStatus();
94:                 }
95:
96:                 String msg = t.getLocalizedMessage();
97:•                if (msg == null || msg.length() == 0) {
98:                         msg = t.getClass().getName();
99:                 }
100:
101:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
102:         }
103:
104:         /**
105:          * Returns an {@link ImageDescriptor} for a path.
106:          *
107:          * @param path the path to an image
108:          * @return the {@link ImageDescriptor}
109:          */
110:         public static ImageDescriptor loadImageDescriptor(String path) {
111:                 return imageDescriptorFromPlugin(PLUGIN_ID, path);
112:         }
113: }