modification to debug on a remote server
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPeclipsePlugin.java
index 8cdd585..735cda1 100644 (file)
@@ -23,8 +23,13 @@ import java.util.Set;
 import net.sourceforge.phpdt.externaltools.internal.model.ColorManager;
 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin;
 import net.sourceforge.phpdt.externaltools.internal.model.VariableContextManager;
+import net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferenceCache;
 import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage;
+import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
 import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry;
+import net.sourceforge.phpdt.internal.ui.viewsupport.ProblemMarkerManager;
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
+import net.sourceforge.phpdt.ui.IWorkingCopyManager;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpdt.ui.text.JavaTextTools;
 import net.sourceforge.phpeclipse.builder.ExternalEditorInput;
@@ -33,6 +38,7 @@ import net.sourceforge.phpeclipse.builder.FileStorage;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
 import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider;
 import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
+import net.sourceforge.phpeclipse.phpeditor.WorkingCopyManager;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
 import net.sourceforge.phpeclipse.resourcesview.PHPElement;
 import net.sourceforge.phpeclipse.resourcesview.PHPElementAdapterFactory;
@@ -52,6 +58,9 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.text.BadLocationException;
@@ -66,6 +75,7 @@ import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.eclipse.ui.texteditor.ITextEditor;
@@ -83,7 +93,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
    * id of builder - matches plugin.xml (concatenate pluginid.builderid) 
    */
   public static final String BUILDER_PARSER_ID = PLUGIN_ID + ".parserbuilder";
-//public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder";
+  //public static final String BUILDER_INDEX_ID = PLUGIN_ID + ".indexbuilder";
 
   /** General debug flag*/
   public static final boolean DEBUG = false;
@@ -134,14 +144,20 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
 
   /** Windows NT  */
   private static final int WINDOWS_NT = 5;
-  private PHPDocumentProvider fCompilationUnitDocumentProvider;
 
   private ImageDescriptorRegistry fImageDescriptorRegistry;
   private HashMap fIndexManagerMap = new HashMap();
 
+  private IWorkingCopyManager fWorkingCopyManager;
+  private PHPDocumentProvider fCompilationUnitDocumentProvider;
   private JavaTextTools fJavaTextTools;
+  private ProblemMarkerManager fProblemMarkerManager;
+       private MembersOrderPreferenceCache fMembersOrderPreferenceCache;
+
   private IFile fLastEditorFile = null;
 
+       private JavaEditorTextHoverDescriptor[] fJavaEditorTextHoverDescriptors;
+       
   /**
    * The constructor.
    */
@@ -156,7 +172,50 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     //      resourceBundle = null;
     //    }
   }
-
+       /**
+        * Returns all Java editor text hovers contributed to the workbench.
+        * 
+        * @return an array of JavaEditorTextHoverDescriptor
+        * @since 2.1
+        */
+       public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {
+               if (fJavaEditorTextHoverDescriptors == null)
+                       fJavaEditorTextHoverDescriptors= JavaEditorTextHoverDescriptor.getContributedHovers();
+               return fJavaEditorTextHoverDescriptors;
+       } 
+
+       /**
+        * Resets the Java editor text hovers contributed to the workbench.
+        * <p>
+        * This will force a rebuild of the descriptors the next time
+        * a client asks for them.
+        * </p>
+        * 
+        * @return an array of JavaEditorTextHoverDescriptor
+        * @since 2.1
+        */
+       public void resetJavaEditorTextHoverDescriptors() {
+               fJavaEditorTextHoverDescriptors= null;
+       }
+       /**
+        * Creates the PHP plugin standard groups in a context menu.
+        */
+       public static void createStandardGroups(IMenuManager menu) {
+               if (!menu.isEmpty())
+                       return;
+                       
+               menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
+               menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
+               menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+               menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
+               menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
+               menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+               menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
+               menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
+               menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+               menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
+               menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
+       }
   public static IWorkbenchPage getActivePage() {
     return getDefault().internalGetActivePage();
   }
@@ -332,6 +391,26 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     return indexManager;
   }
 
+  public synchronized IWorkingCopyManager getWorkingCopyManager() {
+    if (fWorkingCopyManager == null) {
+      PHPDocumentProvider provider = getCompilationUnitDocumentProvider();
+      fWorkingCopyManager = new WorkingCopyManager(provider);
+    }
+    return fWorkingCopyManager;
+  }
+  
+       public synchronized MembersOrderPreferenceCache getMemberOrderPreferenceCache() {
+               if (fMembersOrderPreferenceCache == null)
+                       fMembersOrderPreferenceCache= new MembersOrderPreferenceCache();
+               return fMembersOrderPreferenceCache;
+       }       
+       
+  public synchronized ProblemMarkerManager getProblemMarkerManager() {
+    if (fProblemMarkerManager == null)
+      fProblemMarkerManager = new ProblemMarkerManager();
+    return fProblemMarkerManager;
+  }
+
   public synchronized JavaTextTools getJavaTextTools() {
     if (fJavaTextTools == null)
       fJavaTextTools = new JavaTextTools(getPreferenceStore());
@@ -425,7 +504,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
 
     PreferenceConverter.setDefault(store, PHP_MULTILINE_COMMENT, PHPColorProvider.MULTI_LINE_COMMENT);
     PreferenceConverter.setDefault(store, PHP_SINGLELINE_COMMENT, PHPColorProvider.SINGLE_LINE_COMMENT);
-               PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
+    PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
     PreferenceConverter.setDefault(store, PHP_KEYWORD, PHPColorProvider.KEYWORD);
     PreferenceConverter.setDefault(store, PHP_VARIABLE, PHPColorProvider.VARIABLE);
     PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME, PHPColorProvider.FUNCTION_NAME);
@@ -477,11 +556,11 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     //      PHPColorProvider.BACKGROUND_COLOR);
 
     //language stuff
-    store.setDefault(RESOURCE_BUNDLE, LANGUAGE_DEFAULT);
-    store.setDefault(RESOURCE_BUNDLE_EN_GB, "true");
-    store.setDefault(RESOURCE_BUNDLE_DE, "false");
-    store.setDefault(RESOURCE_BUNDLE_FR, "false");
-    store.setDefault(RESOURCE_BUNDLE_ES, "false");
+    //    store.setDefault(RESOURCE_BUNDLE, LANGUAGE_DEFAULT);
+    //    store.setDefault(RESOURCE_BUNDLE_EN_GB, "true");
+    //    store.setDefault(RESOURCE_BUNDLE_DE, "false");
+    //    store.setDefault(RESOURCE_BUNDLE_FR, "false");
+    //    store.setDefault(RESOURCE_BUNDLE_ES, "false");
 
     store.setDefault(PHP_OUTLINE_CLASS, "true"); //$NON-NLS-1$
     store.setDefault(PHP_OUTLINE_FUNC, "true"); //$NON-NLS-1$
@@ -531,7 +610,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
     IEditorPart editor;
     ITextEditor textEditor;
     if (file != null && file.exists()) {
-      editor = page.openEditor(file);
+      editor = IDE.openEditor(page, file, true);
       textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
     } else {
       // Otherwise open the stream directly
@@ -627,7 +706,8 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
    * @see org.eclipse.ui.plugin.AbstractUIPlugin#shutdown()
    */
   public void shutdown() throws CoreException {
-    super.shutdown();
+       // moved down:
+    //    super.shutdown();
 
     //  externalTools.shutDown();
     ColorManager.getDefault().dispose();
@@ -641,6 +721,32 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon
       indexManager.writeFile();
     }
 
+    if (fImageDescriptorRegistry != null)
+      fImageDescriptorRegistry.dispose();
+
+    //                         unregisterAdapters();
+
+    super.shutdown();
+
+    if (fWorkingCopyManager != null) {
+      fWorkingCopyManager.shutdown();
+      fWorkingCopyManager = null;
+    }
+
+    if (fCompilationUnitDocumentProvider != null) {
+      fCompilationUnitDocumentProvider.shutdown();
+      fCompilationUnitDocumentProvider = null;
+    }
+
+    if (fJavaTextTools != null) {
+      fJavaTextTools.dispose();
+      fJavaTextTools = null;
+    }
+
+    //                         JavaDocLocations.shutdownJavadocLocations();
+    //         
+    //                         JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener);
+
   }
 
   public void startup() throws CoreException {