Open PHP "include" relative to the projects root inside the editor (right mouse click)
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / PHPDebugUiPlugin.java
1 package net.sourceforge.phpdt.internal.debug.ui;
2
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
4
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;
16
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;
20
21         public PHPDebugUiPlugin(IPluginDescriptor descriptor) {
22                 super(descriptor);
23                 plugin = this;
24         }
25
26         public static IWorkbenchWindow getActiveWorkbenchWindow() {
27                 return getDefault().getWorkbench().getActiveWorkbenchWindow();
28         }
29
30         public static IWorkbenchPage getActivePage() {
31                 return PHPDebugUiPlugin.getActiveWorkbenchWindow().getActivePage();
32         }
33
34         public static PHPDebugUiPlugin getDefault() {
35                 return plugin;
36         }
37
38         public static IWorkspace getWorkspace() {
39                 return PHPeclipsePlugin.getWorkspace();
40         }
41         
42         /**
43          * Convenience method which returns the unique identifier of this plugin.
44          */
45 //      public static String getUniqueIdentifier()
46 //      {
47 //              if ( getDefault() == null )
48 //              {
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
52 //                      return PLUGIN_ID;
53 //              }
54 //              return getDefault().getDescriptor().getUniqueIdentifier();
55 //      }
56         
57         /**
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.
61          */
62         public static Display getStandardDisplay() {
63                 Display display;
64                 display= Display.getCurrent();
65                 if (display == null)
66                         display= Display.getDefault();
67                 return display;         
68         }
69         
70         /**
71          * Returns the active workbench shell or <code>null</code> if none
72          * 
73          * @return the active workbench shell or <code>null</code> if none
74          */
75         public static Shell getActiveWorkbenchShell() {
76                 IWorkbenchWindow window = getActiveWorkbenchWindow();
77                 if (window != null) {
78                         return window.getShell();
79                 }
80                 return null;
81         }
82         
83         public static void errorDialog( String message, IStatus status )
84                 {
85                         log( status );
86                         Shell shell = getActiveWorkbenchShell();
87                         if ( shell != null )
88                         {
89                                 ErrorDialog.openError( shell, "Error", message, status );
90                         }
91                 }
92
93                 public static void errorDialog( String message, Throwable t )
94                 {
95                         log( t );
96                         Shell shell = getActiveWorkbenchShell();
97                         if ( shell != null )
98                         {
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 );
101                         }
102                 }                       
103
104         public static void log(IStatus status) {
105                 getDefault().getLog().log(status);
106         }
107
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$
110         }
111
112         /**
113          * This method is called upon plug-in activation
114          */
115         public void start(BundleContext context) throws Exception {
116                 super.start(context);
117         }
118
119         /**
120          * This method is called when the plug-in is stopped
121          */
122         public void stop(BundleContext context) throws Exception {
123                 super.stop(context);
124         }
125         
126 //      protected void initializeDefaultPreferences(IPreferenceStore store) {
127 //              super.initializeDefaultPreferences(store);
128 //              
129 //              store.setDefault(RdtDebugUiConstants.PREFERENCE_KEYWORDS, getDefaultKeywords());
130 //      }
131
132 //      protected String getDefaultKeywords() {
133 //              return "class,def,end,if,module,new,puts,require,rescue,throw,while";
134 //      }
135 }