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%
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%
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%
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(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%
log(int, 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%
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: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: package org.eclipse.emf.ecp.emfstore.internal.ui.e3;
2:
3: import org.eclipse.core.runtime.CoreException;
4: import org.eclipse.core.runtime.IStatus;
5: import org.eclipse.core.runtime.Status;
6: import org.eclipse.jface.resource.ImageDescriptor;
7: import org.eclipse.ui.plugin.AbstractUIPlugin;
8: import org.osgi.framework.BundleContext;
9:
10: public class Activator extends AbstractUIPlugin {
11:         /** The plug-in ID. **/
12:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.emfstore.ui.e3"; //$NON-NLS-1$
13:
14:         /**
15:          * Delegate for @see {@link #imageDescriptorFromPlugin(String, String)}
16:          *
17:          * @param imagePath the path to the image to load
18:          * @return the {@link ImageDescriptor}
19:          */
20:         public static ImageDescriptor getImageDescriptor(String imagePath) {
21:                 return imageDescriptorFromPlugin(PLUGIN_ID, imagePath);
22:         }
23:
24:         private static Activator instance;
25:
26:         /**
27:          * The constructor.
28:          */
29:         public Activator() {
30:         }
31:
32:         @Override
33:         public void start(BundleContext context) throws Exception {
34:                 super.start(context);
35:                 instance = this;
36:         }
37:
38:         @Override
39:         public void stop(BundleContext context) throws Exception {
40:                 instance = null;
41:                 super.stop(context);
42:         }
43:
44:         /**
45:          * Returns the shared instance.
46:          *
47:          * @return the shared instance
48:          */
49:         public static Activator getInstance() {
50:                 return instance;
51:         }
52:
53:         private static void log(IStatus status) {
54:                 instance.getLog().log(status);
55:         }
56:
57:         /**
58:          * Logs a message with a specific status.
59:          *
60:          * @param status the {@link IStatus} value
61:          * @param message the message to log
62:          */
63:         public static void log(int status, String message) {
64:                 instance.getLog().log(new Status(status, PLUGIN_ID, message));
65:         }
66:
67:         /**
68:          * Logs a {@link Throwable}.
69:          *
70:          * @param t the {@link Throwable}
71:          * @return the message of the {@link Throwable}
72:          */
73:         public static String log(Throwable t) {
74:                 final IStatus status = getStatus(t);
75:                 log(status);
76:                 return status.getMessage();
77:         }
78:
79:         private static IStatus getStatus(Throwable t) {
80:•                if (t instanceof CoreException) {
81:                         final CoreException coreException = (CoreException) t;
82:                         return coreException.getStatus();
83:                 }
84:
85:                 String msg = t.getLocalizedMessage();
86:•                if (msg == null || msg.length() == 0) {
87:                         msg = t.getClass().getName();
88:                 }
89:
90:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
91:         }
92: }