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(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: 10
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 5
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: * Eugen Neufeld - initial API and implementation
13: ******************************************************************************/
14: /*
15: * Copyright (c) 2011 Eike Stepper (Berlin, Germany) and others.
16: * All rights reserved. This program and the accompanying materials
17: * are made available under the terms of the Eclipse Public License 2.0
18: * which accompanies this distribution, and is available at
19: * https://www.eclipse.org/legal/epl-2.0/
20: * SPDX-License-Identifier: EPL-2.0
21: * Contributors:
22: * Eike Stepper - initial API and implementation
23: */
24: package org.eclipse.emf.ecp.workspace.internal.core;
25:
26: import org.eclipse.core.runtime.CoreException;
27: import org.eclipse.core.runtime.IStatus;
28: import org.eclipse.core.runtime.Plugin;
29: import org.eclipse.core.runtime.Status;
30: import org.osgi.framework.BundleContext;
31:
32: /**
33: * The activator class controls the plug-in life cycle.
34: *
35: * @author Eike Stepper
36: */
37: public class Activator extends Plugin {
38:         /**
39:          * The plug-in ID.
40:          */
41:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.workspace.core"; //$NON-NLS-1$
42:
43:         private static Activator instance;
44:
45:         // BEGIN SUPRESS CATCH EXCEPTION
46:         @Override
47:         public void start(BundleContext bundleContext) throws Exception {
48:                 super.start(bundleContext);
49:                 instance = this;
50:         }
51:
52:         @Override
53:         public void stop(BundleContext bundleContext) throws Exception {
54:•                if (WorkspaceProvider.INSTANCE != null) {
55:                         WorkspaceProvider.INSTANCE.dispose();
56:                 }
57:
58:                 instance = null;
59:                 super.stop(bundleContext);
60:         }
61:
62:         // END SUPRESS CATCH EXCEPTION
63:         /**
64:          * Returns the shared instance.
65:          *
66:          * @return the shared instance
67:          */
68:         public static final Activator getInstance() {
69:                 return instance;
70:         }
71:
72:         /**
73:          * Logs and Info message.
74:          *
75:          * @param message the message to log
76:          */
77:         public static void log(String message) {
78:                 instance.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
79:         }
80:
81:         private static void log(IStatus status) {
82:                 instance.getLog().log(status);
83:         }
84:
85:         /**
86:          * Logs a {@link Throwable}.
87:          *
88:          * @param t the {@link Throwable} to log
89:          * @return the message of the {@link Throwable}
90:          */
91:         public static String log(Throwable t) {
92:                 final IStatus status = getStatus(t);
93:                 log(status);
94:                 return status.getMessage();
95:         }
96:
97:         private static IStatus getStatus(Throwable t) {
98:•                if (t instanceof CoreException) {
99:                         final CoreException coreException = (CoreException) t;
100:                         return coreException.getStatus();
101:                 }
102:
103:                 String msg = t.getLocalizedMessage();
104:•                if (msg == null || msg.length() == 0) {
105:                         msg = t.getClass().getName();
106:                 }
107:
108:                 return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
109:         }
110: }