1 package net.sourceforge.phpdt.internal.debug.ui;
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.resources.IWorkspace;
6 import org.eclipse.core.runtime.IStatus;
7 import org.eclipse.core.runtime.Status;
8 import org.eclipse.jface.dialogs.ErrorDialog;
9 import org.eclipse.swt.widgets.Display;
10 import org.eclipse.swt.widgets.Shell;
11 import org.eclipse.ui.IWorkbenchPage;
12 import org.eclipse.ui.IWorkbenchWindow;
13 import org.eclipse.ui.plugin.AbstractUIPlugin;
14 import org.osgi.framework.BundleContext;
16 public class PHPDebugUiPlugin extends AbstractUIPlugin {
17 public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.debug.ui"; //$NON-NLS-1$
19 protected static PHPDebugUiPlugin plugin;
21 public PHPDebugUiPlugin() {
26 public static IWorkbenchWindow getActiveWorkbenchWindow() {
27 return getDefault().getWorkbench().getActiveWorkbenchWindow();
30 public static IWorkbenchPage getActivePage() {
31 return PHPDebugUiPlugin.getActiveWorkbenchWindow().getActivePage();
34 public static PHPDebugUiPlugin getDefault() {
38 public static IWorkspace getWorkspace() {
39 return PHPeclipsePlugin.getWorkspace();
43 * Convenience method which returns the unique identifier of this plugin.
45 // public static String getUniqueIdentifier()
47 // if ( getDefault() == null )
49 // // If the default instance is not yet initialized,
50 // // return a static identifier. This identifier must
51 // // match the plugin id defined in plugin.xml
54 // return getDefault().getDescriptor().getUniqueIdentifier();
57 * Returns the standard display to be used. The method first checks, if the
58 * thread calling this method has an associated display. If so, this display
59 * is returned. Otherwise the method returns the default display.
61 public static Display getStandardDisplay() {
63 display = Display.getCurrent();
65 display = Display.getDefault();
70 * Returns the active workbench shell or <code>null</code> if none
72 * @return the active workbench shell or <code>null</code> if none
74 public static Shell getActiveWorkbenchShell() {
75 IWorkbenchWindow window = getActiveWorkbenchWindow();
77 return window.getShell();
82 public static void errorDialog(String message, IStatus status) {
84 Shell shell = getActiveWorkbenchShell();
86 ErrorDialog.openError(shell, "Error", message, status);
90 public static void errorDialog(String message, Throwable t) {
92 Shell shell = getActiveWorkbenchShell();
94 IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, /* ICDebugUIConstants.INTERNAL_ERROR */
95 150, t.getMessage(), null); //$NON-NLS-1$
96 ErrorDialog.openError(shell, "Error", message, status);
100 public static void log(IStatus status) {
101 getDefault().getLog().log(status);
104 public static void log(Throwable e) {
105 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR,
107 .getString("RdtDebugUiPlugin.internalErrorOccurred"), e)); //$NON-NLS-1$
111 * This method is called upon plug-in activation
113 public void start(BundleContext context) throws Exception {
114 super.start(context);
118 * This method is called when the plug-in is stopped
120 public void stop(BundleContext context) throws Exception {
124 // protected void initializeDefaultPreferences(IPreferenceStore store) {
125 // super.initializeDefaultPreferences(store);
127 // store.setDefault(RdtDebugUiConstants.PREFERENCE_KEYWORDS,
128 // getDefaultKeywords());
131 // protected String getDefaultKeywords() {
132 // return "class,def,end,if,module,new,puts,require,rescue,throw,while";