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(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-2012 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: * Eugen Neufeld - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.emfstore.internal.ui;
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: public class Activator extends Plugin {
27:         /** The plug-in ID. **/
28:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.emfstore.ui"; //$NON-NLS-1$
29:
30:         private static Activator instance;
31:
32:         /**
33:          * The constructor.
34:          */
35:         public Activator() {
36:         }
37:
38:         @Override
39:         public void start(BundleContext context) throws Exception {
40:                 super.start(context);
41:                 instance = this;
42:         }
43:
44:         @Override
45:         public void stop(BundleContext context) throws Exception {
46:                 instance = null;
47:                 super.stop(context);
48:         }
49:
50:         /**
51:          * Returns the shared instance.
52:          *
53:          * @return the shared instance
54:          */
55:         public static Activator getInstance() {
56:                 return instance;
57:         }
58:
59:         private static void log(IStatus status) {
60:                 instance.getLog().log(status);
61:         }
62:
63:         /**
64:          * Logs a message with a specific status.
65:          *
66:          * @param status the {@link IStatus} value
67:          * @param message the message to log
68:          */
69:         public static void log(int status, String message) {
70:                 instance.getLog().log(new Status(status, PLUGIN_ID, message));
71:         }
72:
73:         /**
74:          * Logs a {@link Throwable}.
75:          *
76:          * @param t the {@link Throwable}
77:          * @return the message of the {@link Throwable}
78:          */
79:         public static String log(Throwable t) {
80:                 final IStatus status = getStatus(t);
81:                 log(status);
82:                 return status.getMessage();
83:         }
84:
85:         private static IStatus getStatus(Throwable t) {
86:•                if (t instanceof CoreException) {
87:                         final CoreException coreException = (CoreException) t;
88:                         return coreException.getStatus();
89:                 }
90:
91:                 String msg = t.getLocalizedMessage();
92:•                if (msg == null || msg.length() == 0) {
93:                         msg = t.getClass().getName();
94:                 }
95:
96:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
97:         }
98:
99: }