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%
getImage(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%
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(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.cdo.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.swt.graphics.Image;
21: import org.eclipse.ui.plugin.AbstractUIPlugin;
22: import org.osgi.framework.BundleContext;
23:
24: /**
25: * The activator class controls the plug-in life cycle.
26: *
27: * @author Eike Stepper
28: */
29: public final class Activator extends AbstractUIPlugin {
30:         /**
31:          * The PlugIn ID.
32:          */
33:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.cdo.ui"; //$NON-NLS-1$
34:
35:         private static Activator instance;
36:
37:         /**
38:          * The constructor.
39:          */
40:         public Activator() {
41:         }
42:
43:         // BEGIN SUPRESS CATCH EXCEPTION
44:         @Override
45:         public void start(BundleContext context) throws Exception {
46:                 super.start(context);
47:                 instance = this;
48:         }
49:
50:         @Override
51:         public void stop(BundleContext context) throws Exception {
52:                 instance = null;
53:                 super.stop(context);
54:         }
55:
56:         // END SUPRESS CATCH EXCEPTION
57:         /**
58:          * Returns the shared instance.
59:          *
60:          * @return the shared instance
61:          */
62:         public static Activator getInstance() {
63:                 return instance;
64:         }
65:
66:         /**
67:          * Logs messages.
68:          *
69:          * @param message the message
70:          */
71:         public static void log(String message) {
72:                 instance.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
73:         }
74:
75:         /**
76:          * Logs {@link IStatus}.
77:          *
78:          * @param status the {@link IStatus}
79:          */
80:         public static void log(IStatus status) {
81:                 instance.getLog().log(status);
82:         }
83:
84:         /**
85:          * Logs {@link Throwable}.
86:          *
87:          * @param t the {@link Throwable}
88:          * @return the message of the created status
89:          */
90:         public static String log(Throwable t) {
91:                 final IStatus status = getStatus(t);
92:                 log(status);
93:                 return status.getMessage();
94:         }
95:
96:         /**
97:          * Gets a {@link IStatus} for a throwable.
98:          *
99:          * @param t the {@link Throwable}
100:          * @return the created {@link IStatus}
101:          */
102:         public static IStatus getStatus(Throwable t) {
103:•                if (t instanceof CoreException) {
104:                         final CoreException coreException = (CoreException) t;
105:                         return coreException.getStatus();
106:                 }
107:
108:                 String msg = t.getLocalizedMessage();
109:•                if (msg == null || msg.length() == 0) {
110:                         msg = t.getClass().getName();
111:                 }
112:
113:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
114:         }
115:
116:         /**
117:          * Returns an {@link ImageDescriptor} for a path.
118:          *
119:          * @param path the path to an image
120:          * @return the {@link ImageDescriptor}
121:          */
122:         public static ImageDescriptor getImageDescriptor(String path) {
123:                 return ResourceManager.getPluginImageDescriptor(PLUGIN_ID, path);
124:         }
125:
126:         /**
127:          * Gets an {@link Image} for a path.
128:          *
129:          * @param path the path to an image
130:          * @return the image
131:          */
132:         public static Image getImage(String path) {
133:                 return ResourceManager.getPluginImage(PLUGIN_ID, path);
134:         }
135: }