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.IPluginDescriptor;
7 import org.eclipse.core.runtime.IStatus;
8 import org.eclipse.core.runtime.Status;
9 import org.eclipse.jface.dialogs.ErrorDialog;
10 import org.eclipse.swt.widgets.Display;
11 import org.eclipse.swt.widgets.Shell;
12 import org.eclipse.ui.IWorkbenchPage;
13 import org.eclipse.ui.IWorkbenchWindow;
14 import org.eclipse.ui.plugin.AbstractUIPlugin;
15 import org.osgi.framework.BundleContext;
17 public class PHPDebugUiPlugin extends AbstractUIPlugin {
18 public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.debug.ui"; //$NON-NLS-1$
19 protected static PHPDebugUiPlugin plugin;
21 public PHPDebugUiPlugin(IPluginDescriptor descriptor) {
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();
58 * Returns the standard display to be used. The method first checks, if
59 * the thread calling this method has an associated display. If so, this
60 * display is returned. Otherwise the method returns the default display.
62 public static Display getStandardDisplay() {
64 display= Display.getCurrent();
66 display= Display.getDefault();
71 * Returns the active workbench shell or <code>null</code> if none
73 * @return the active workbench shell or <code>null</code> if none
75 public static Shell getActiveWorkbenchShell() {
76 IWorkbenchWindow window = getActiveWorkbenchWindow();
78 return window.getShell();
83 public static void errorDialog( String message, IStatus status )
86 Shell shell = getActiveWorkbenchShell();
89 ErrorDialog.openError( shell, "Error", message, status );
93 public static void errorDialog( String message, Throwable t )
96 Shell shell = getActiveWorkbenchShell();
99 IStatus status = new Status( IStatus.ERROR, PLUGIN_ID, /*ICDebugUIConstants.INTERNAL_ERROR*/ 150, t.getMessage(), null ); //$NON-NLS-1$
100 ErrorDialog.openError( shell, "Error", message, status );
104 public static void log(IStatus status) {
105 getDefault().getLog().log(status);
108 public static void log(Throwable e) {
109 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, PHPDebugUiMessages.getString("RdtDebugUiPlugin.internalErrorOccurred"), e)); //$NON-NLS-1$
113 * This method is called upon plug-in activation
115 public void start(BundleContext context) throws Exception {
116 super.start(context);
120 * This method is called when the plug-in is stopped
122 public void stop(BundleContext context) throws Exception {
126 // protected void initializeDefaultPreferences(IPreferenceStore store) {
127 // super.initializeDefaultPreferences(store);
129 // store.setDefault(RdtDebugUiConstants.PREFERENCE_KEYWORDS, getDefaultKeywords());
132 // protected String getDefaultKeywords() {
133 // return "class,def,end,if,module,new,puts,require,rescue,throw,while";