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%
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%
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: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: package org.eclipse.emf.ecp.view.edapt;
15:
16: import org.eclipse.core.runtime.CoreException;
17: import org.eclipse.core.runtime.IStatus;
18: import org.eclipse.core.runtime.Plugin;
19: import org.eclipse.core.runtime.Status;
20: import org.osgi.framework.BundleContext;
21:
22: /**
23: * The Activator for the edapt view model migration.
24: *
25: * @author jfaltermeier
26: *
27: */
28: public class Activator extends Plugin {
29:
30:         /**
31:          * The constant holding the id of this plugin.
32:          */
33:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.core"; //$NON-NLS-1$
34:
35:         private static Activator instance;
36:
37:         /**
38:          * Default constructor.
39:          */
40:         public Activator() {
41:         }
42:
43:         @Override
44:         public void start(BundleContext bundleContext) throws Exception {
45:                 instance = this;
46:                 super.start(bundleContext);
47:         }
48:
49:         @Override
50:         public void stop(BundleContext bundleContext) throws Exception {
51:                 instance = null;
52:                 super.stop(bundleContext);
53:         }
54:
55:         /**
56:          * Returns the instance of this Activator.
57:          *
58:          * @return the saved instance
59:          */
60:         public static Activator getInstance() {
61:                 return instance;
62:         }
63:
64:         /**
65:          * Logs and Info message.
66:          *
67:          * @param message the message to log
68:          */
69:         public static void log(String message) {
70:                 instance.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
71:         }
72:
73:         /**
74:          * Logs a message with a specific status.
75:          *
76:          * @param status the {@link IStatus} value
77:          * @param message the message to log
78:          */
79:         public static void log(int status, String message) {
80:                 instance.getLog().log(new Status(status, PLUGIN_ID, message));
81:         }
82:
83:         private static void log(IStatus status) {
84:                 instance.getLog().log(status);
85:         }
86:
87:         /**
88:          * Logs a {@link Throwable}.
89:          *
90:          * @param t the {@link Throwable} to log
91:          * @return the message of the {@link Throwable}
92:          */
93:         public static String log(Throwable t) {
94:                 final IStatus status = getStatus(t);
95:                 log(status);
96:                 return status.getMessage();
97:         }
98:
99:         private static IStatus getStatus(Throwable t) {
100:•                if (t instanceof CoreException) {
101:                         final CoreException coreException = (CoreException) t;
102:                         return coreException.getStatus();
103:                 }
104:
105:                 String msg = t.getLocalizedMessage();
106:•                if (msg == null || msg.length() == 0) {
107:                         msg = t.getClass().getName();
108:                 }
109:
110:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
111:         }
112:
113: }