changes for VariableHover
[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.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
15 public class PHPDebugUiPlugin extends AbstractUIPlugin {
16         public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.debug.ui"; //$NON-NLS-1$
17         protected static PHPDebugUiPlugin plugin;
18
19         public PHPDebugUiPlugin(IPluginDescriptor descriptor) {
20                 super(descriptor);
21                 plugin = this;
22         }
23
24         public static IWorkbenchWindow getActiveWorkbenchWindow() {
25                 return getDefault().getWorkbench().getActiveWorkbenchWindow();
26         }
27
28         public static IWorkbenchPage getActivePage() {
29                 return PHPDebugUiPlugin.getActiveWorkbenchWindow().getActivePage();
30         }
31
32         public static PHPDebugUiPlugin getDefault() {
33                 return plugin;
34         }
35
36         public static IWorkspace getWorkspace() {
37                 return PHPeclipsePlugin.getWorkspace();
38         }
39         
40         /**
41          * Convenience method which returns the unique identifier of this plugin.
42          */
43         public static String getUniqueIdentifier()
44         {
45                 if ( getDefault() == null )
46                 {
47                         // If the default instance is not yet initialized,
48                         // return a static identifier. This identifier must
49                         // match the plugin id defined in plugin.xml
50                         return PLUGIN_ID;
51                 }
52                 return getDefault().getDescriptor().getUniqueIdentifier();
53         }       
54         
55         /**
56          * Returns the active workbench shell or <code>null</code> if none
57          * 
58          * @return the active workbench shell or <code>null</code> if none
59          */
60         public static Shell getActiveWorkbenchShell() {
61                 IWorkbenchWindow window = getActiveWorkbenchWindow();
62                 if (window != null) {
63                         return window.getShell();
64                 }
65                 return null;
66         }
67         
68         public static void errorDialog( String message, IStatus status )
69                 {
70                         log( status );
71                         Shell shell = getActiveWorkbenchShell();
72                         if ( shell != null )
73                         {
74                                 ErrorDialog.openError( shell, "Error", message, status );
75                         }
76                 }
77
78                 public static void errorDialog( String message, Throwable t )
79                 {
80                         log( t );
81                         Shell shell = getActiveWorkbenchShell();
82                         if ( shell != null )
83                         {
84                                 IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), /*ICDebugUIConstants.INTERNAL_ERROR*/ 150, t.getMessage(), null ); //$NON-NLS-1$     
85                                 ErrorDialog.openError( shell, "Error", message, status );
86                         }
87                 }                       
88
89         public static void log(IStatus status) {
90                 getDefault().getLog().log(status);
91         }
92
93         public static void log(Throwable e) {
94                 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, PHPDebugUiMessages.getString("RdtDebugUiPlugin.internalErrorOccurred"), e)); //$NON-NLS-1$
95         }
96
97 //      protected void initializeDefaultPreferences(IPreferenceStore store) {
98 //              super.initializeDefaultPreferences(store);
99 //              
100 //              store.setDefault(RdtDebugUiConstants.PREFERENCE_KEYWORDS, getDefaultKeywords());
101 //      }
102
103 //      protected String getDefaultKeywords() {
104 //              return "class,def,end,if,module,new,puts,require,rescue,throw,while";
105 //      }
106 }