Skip to content

Package: EGFTaskUIPlugin

EGFTaskUIPlugin

nameinstructionbranchcomplexitylinemethod
EGFTaskUIPlugin()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getActiveWorkbenchShell()
M: 21 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getActiveWorkbenchWindow()
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%
getDefault()
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%
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>
3: *
4: * Copyright (c) 2009-2010 Thales Corporate Services S.A.S.
5: * This program and the accompanying materials
6: * are made available under the terms of the Eclipse Public License v2.0
7: * which accompanies this distribution, and is available at
8: * https://www.eclipse.org/legal/epl-v2.0.
9: *
10: * SPDX-License-Identifier: EPL-2.0
11: *
12: * Contributors:
13: * Thales Corporate Services S.A.S - initial API and implementation
14: *
15: * </copyright>
16: */
17: package org.eclipse.egf.task.ui;
18:
19: import org.eclipse.egf.common.ui.activator.EGFAbstractUIPlugin;
20: import org.eclipse.swt.widgets.Shell;
21: import org.eclipse.ui.IWorkbenchWindow;
22: import org.osgi.framework.BundleContext;
23:
24: /**
25: * @author Thomas Guiu
26: *
27: */
28: public class EGFTaskUIPlugin extends EGFAbstractUIPlugin {
29:
30: // The shared instance
31: private static EGFTaskUIPlugin __plugin;
32:
33: /**
34: *
35: * Returns the currently active window for this workbench (if any). Returns
36: * <code>null</code> if there is no active workbench window. Returns
37: * <code>null</code> if called from a non-UI thread.
38: *
39: * @return the active workbench window, or <code>null</code> if there is
40: * no active workbench window or if called from a non-UI thread
41: */
42: public static IWorkbenchWindow getActiveWorkbenchWindow() {
43: return getDefault().getWorkbench().getActiveWorkbenchWindow();
44: }
45:
46: /**
47: * Returns the currently active shell for this workbench (if any).
48: *
49: * @return the active workbench shell.
50: */
51: public static Shell getActiveWorkbenchShell() {
52: IWorkbenchWindow window = getActiveWorkbenchWindow();
53:• if (window == null) {
54: IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
55:• if (windows.length > 0) {
56: return windows[0].getShell();
57: }
58: } else {
59: return window.getShell();
60: }
61: return null;
62: }
63:
64: /*
65: * (non-Javadoc)
66: *
67: * @see
68: * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
69: */
70: @Override
71: public void start(BundleContext context) throws Exception {
72: super.start(context);
73: __plugin = this;
74: }
75:
76: /*
77: * (non-Javadoc)
78: *
79: * @see
80: * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
81: */
82: @Override
83: public void stop(BundleContext context) throws Exception {
84: super.stop(context);
85: __plugin = null;
86: }
87:
88: /**
89: * Returns the shared instance
90: *
91: * @return the shared instance
92: */
93: public static EGFTaskUIPlugin getDefault() {
94: return __plugin;
95: }
96:
97: }