01: /*
02: * (c) Copyright IBM Corp. 2000, 2001.
03: * All Rights Reserved.
04: */
05: package org.eclipse.pde.internal.junit.ui;
06:
07: import java.net.MalformedURLException;
08: import java.net.URL;
09:
10: import org.eclipse.core.runtime.IPluginDescriptor;
11:
12: import org.eclipse.swt.widgets.Shell;
13:
14: import org.eclipse.ui.IWorkbench;
15: import org.eclipse.ui.IWorkbenchWindow;
16: import org.eclipse.ui.plugin.AbstractUIPlugin;
17:
18: /**
19: * The plug-in runtime class for the JUnitPde plug-in.
20: */
21: public class JUnitPdePlugin extends AbstractUIPlugin {
22: /**
23: * The single instance of this plug-in runtime class.
24: */
25: private static JUnitPdePlugin fgPlugin = null;
26:
27: public static final String PLUGIN_ID = "org.eclipse.pde.junit"; //$NON-NLS-1$
28: // getPlugin().getDescriptor().getUniqueIdentifier();
29:
30: private static URL fgIconBaseURL;
31:
32: public JUnitPdePlugin(IPluginDescriptor desc) {
33: super (desc);
34: fgPlugin = this ;
35: String pathSuffix = "icons/full/"; //$NON-NLS-1$
36: try {
37: fgIconBaseURL = new URL(getDescriptor().getInstallURL(),
38: pathSuffix);
39: } catch (MalformedURLException e) {
40: // do nothing
41: }
42:
43: }
44:
45: public static JUnitPdePlugin getDefault() {
46: return fgPlugin;
47: }
48:
49: public static Shell getActiveShell() {
50: if (fgPlugin == null)
51: return null;
52: IWorkbench workBench = fgPlugin.getWorkbench();
53: if (workBench == null)
54: return null;
55: IWorkbenchWindow workBenchWindow = workBench
56: .getActiveWorkbenchWindow();
57: if (workBenchWindow == null)
58: return null;
59: return workBenchWindow.getShell();
60: }
61:
62: /**
63: * Method makeIconFileURL.
64: */
65: public static URL makeIconFileURL(String name)
66: throws MalformedURLException {
67: if (JUnitPdePlugin.fgIconBaseURL == null)
68: throw new MalformedURLException();
69: return new URL(JUnitPdePlugin.fgIconBaseURL, name);
70: }
71:
72: }
|