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.ui.IWorkbenchPage;
10 import org.eclipse.ui.IWorkbenchWindow;
11 import org.eclipse.ui.plugin.AbstractUIPlugin;
12 import org.eclipse.swt.widgets.Shell;
13 import org.eclipse.jface.dialogs.ErrorDialog;
14 import org.eclipse.swt.widgets.Display;
16 public class PHPDebugUiPlugin extends AbstractUIPlugin {
17 public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.debug.ui"; //$NON-NLS-1$
18 protected static PHPDebugUiPlugin plugin;
20 public PHPDebugUiPlugin(IPluginDescriptor descriptor) {
25 public static IWorkbenchWindow getActiveWorkbenchWindow() {
26 return getDefault().getWorkbench().getActiveWorkbenchWindow();
29 public static IWorkbenchPage getActivePage() {
30 return PHPDebugUiPlugin.getActiveWorkbenchWindow().getActivePage();
33 public static PHPDebugUiPlugin getDefault() {
37 public static IWorkspace getWorkspace() {
38 return PHPeclipsePlugin.getWorkspace();
42 * Convenience method which returns the unique identifier of this plugin.
44 public static String getUniqueIdentifier()
46 if ( getDefault() == null )
48 // If the default instance is not yet initialized,
49 // return a static identifier. This identifier must
50 // match the plugin id defined in plugin.xml
53 return getDefault().getDescriptor().getUniqueIdentifier();
57 * Returns the standard display to be used. The method first checks, if
58 * the thread calling this method has an associated display. If so, this
59 * display 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 )
85 Shell shell = getActiveWorkbenchShell();
88 ErrorDialog.openError( shell, "Error", message, status );
92 public static void errorDialog( String message, Throwable t )
95 Shell shell = getActiveWorkbenchShell();
98 IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), /*ICDebugUIConstants.INTERNAL_ERROR*/ 150, t.getMessage(), null ); //$NON-NLS-1$
99 ErrorDialog.openError( shell, "Error", message, status );
103 public static void log(IStatus status) {
104 getDefault().getLog().log(status);
107 public static void log(Throwable e) {
108 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, PHPDebugUiMessages.getString("RdtDebugUiPlugin.internalErrorOccurred"), e)); //$NON-NLS-1$
111 // protected void initializeDefaultPreferences(IPreferenceStore store) {
112 // super.initializeDefaultPreferences(store);
114 // store.setDefault(RdtDebugUiConstants.PREFERENCE_KEYWORDS, getDefaultKeywords());
117 // protected String getDefaultKeywords() {
118 // return "class,def,end,if,module,new,puts,require,rescue,throw,while";