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%
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(String, Throwable)
M: 23 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 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: 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: /*******************************************************************************
2: * Copyright (c) 2011-2013 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: * Johannes Faltermeier - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.internal.diagnostician;
16:
17: import org.eclipse.core.runtime.CoreException;
18: import org.eclipse.core.runtime.IStatus;
19: import org.eclipse.core.runtime.Plugin;
20: import org.eclipse.core.runtime.Status;
21: import org.osgi.framework.BundleContext;
22:
23: /**
24: * The activator class controls the plug-in life cycle.
25: *
26: * @author jfaltermeier
27: */
28: public class Activator extends Plugin {
29:
30:         /**
31:          * The PlugIn ID.
32:          */
33:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.validation.diagnostician"; //$NON-NLS-1$
34:
35:         private static Activator instance;
36:
37:         @Override
38:         public void start(BundleContext context) throws Exception {
39:                 super.start(context);
40:                 instance = this;
41:         }
42:
43:         @Override
44:         public void stop(BundleContext context) throws Exception {
45:                 instance = null;
46:                 super.stop(context);
47:         }
48:
49:         /**
50:          * Returns the shared instance.
51:          *
52:          * @return the shared instance
53:          */
54:         public static Activator getInstance() {
55:                 return instance;
56:         }
57:
58:         /**
59:          * Logs messages.
60:          *
61:          * @param message the message
62:          */
63:         public static void log(String message) {
64:                 instance.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
65:         }
66:
67:         /**
68:          * Logs messages and {@link Throwable}.
69:          *
70:          * @param message the message
71:          * @param t the throwable
72:          */
73:         public static void log(String message, Throwable t) {
74:•                if (t instanceof CoreException) {
75:                         final CoreException coreException = (CoreException) t;
76:                         instance.getLog().log(coreException.getStatus());
77:                 } else {
78:                         instance.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, t));
79:                 }
80:         }
81:
82:         /**
83:          * Logs {@link IStatus}.
84:          *
85:          * @param status the {@link IStatus}
86:          */
87:         public static void log(IStatus status) {
88:                 instance.getLog().log(status);
89:         }
90:
91:         /**
92:          * Logs {@link Throwable}.
93:          *
94:          * @param t the {@link Throwable}
95:          * @return the message of the created status
96:          */
97:         public static String log(Throwable t) {
98:                 final IStatus status = getStatus(t);
99:                 log(status);
100:                 return status.getMessage();
101:         }
102:
103:         /**
104:          * Gets a {@link IStatus} for a throwable.
105:          *
106:          * @param t the {@link Throwable}
107:          * @return the created {@link IStatus}
108:          */
109:         public static IStatus getStatus(Throwable t) {
110:•                if (t instanceof CoreException) {
111:                         final CoreException coreException = (CoreException) t;
112:                         return coreException.getStatus();
113:                 }
114:
115:                 String msg = t.getLocalizedMessage();
116:•                if (msg == null || msg.length() == 0) {
117:                         msg = t.getClass().getName();
118:                 }
119:
120:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
121:         }
122:
123: }