RC2 compatibility
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / java / hover / JavaEditorTextHoverDescriptor.java
index 410463d..e2820e6 100644 (file)
@@ -25,14 +25,13 @@ import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginPrerequisite;
-import org.eclipse.core.runtime.IPluginRegistry;
+import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.text.Assert;
 import org.eclipse.swt.SWT;
+import org.osgi.framework.Bundle;
 
 /**
  * Describes a Java editor text hover.
@@ -59,18 +58,16 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
 
        private IConfigurationElement fElement;
        
-       
        /**
         * Returns all Java editor text hovers contributed to the workbench.
         */
        public static JavaEditorTextHoverDescriptor[] getContributedHovers() {
-               IPluginRegistry registry= Platform.getPluginRegistry();
+               IExtensionRegistry registry= Platform.getExtensionRegistry();
                IConfigurationElement[] elements= registry.getConfigurationElementsFor(JAVA_EDITOR_TEXT_HOVER_EXTENSION_POINT);
                JavaEditorTextHoverDescriptor[] hoverDescs= createDescriptors(elements);
                initializeFromPreferences(hoverDescs);
                return hoverDescs;
        } 
-
        /**
         * Computes the state mask for the given modifier string.
         * 
@@ -107,7 +104,8 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
         * Creates the Java editor text hover.
         */
        public IJavaEditorTextHover createTextHover() {
-               boolean isHoversPlugInActivated= fElement.getDeclaringExtension().getDeclaringPluginDescriptor().isPluginActivated();
+               String pluginId = fElement.getDeclaringExtension().getNamespace();
+               boolean isHoversPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
                if (isHoversPlugInActivated || canActivatePlugIn()) {
                        try {
                                return (IJavaEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
@@ -118,7 +116,6 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
                
                return null;
        }
-       
        //---- XML Attribute accessors ---------------------------------------------
        
        /**
@@ -183,35 +180,35 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
                return Collator.getInstance().compare(getLabel(), ((JavaEditorTextHoverDescriptor)o).getLabel());
        }
 
-       /**
-        * @param descriptor a JavaEditorTextHoverDescriptor
-        * @return <code>true</code> if this contributed hover depends on the other one
-        */
-       public boolean dependsOn(JavaEditorTextHoverDescriptor descriptor) {
-               if (descriptor == null)
-                       return false;
-               
-               IPluginDescriptor thisPluginDescriptor= fElement.getDeclaringExtension().getDeclaringPluginDescriptor();
-               IPluginDescriptor otherPluginDescriptor= descriptor.fElement.getDeclaringExtension().getDeclaringPluginDescriptor();
-               return dependsOn(thisPluginDescriptor, otherPluginDescriptor);
-       }
-
-       private boolean dependsOn(IPluginDescriptor descriptor0, IPluginDescriptor descriptor1) {
-
-               IPluginRegistry registry= Platform.getPluginRegistry();
-               IPluginPrerequisite[] prerequisites= descriptor0.getPluginPrerequisites();
-
-               for (int i= 0; i < prerequisites.length; i++) {
-                       IPluginPrerequisite prerequisite= prerequisites[i];
-                       String id= prerequisite.getUniqueIdentifier();                  
-                       IPluginDescriptor descriptor= registry.getPluginDescriptor(id);
-                       
-                       if (descriptor != null && (descriptor.equals(descriptor1) || dependsOn(descriptor, descriptor1)))
-                               return true;
-               }
-               
-               return false;
-       }
+//     /**
+//      * @param descriptor a JavaEditorTextHoverDescriptor
+//      * @return <code>true</code> if this contributed hover depends on the other one
+//      */
+//     public boolean dependsOn(JavaEditorTextHoverDescriptor descriptor) {
+//             if (descriptor == null)
+//                     return false;
+//             
+//             IPluginDescriptor thisPluginDescriptor= fElement.getDeclaringExtension().getDeclaringPluginDescriptor();
+//             IPluginDescriptor otherPluginDescriptor= descriptor.fElement.getDeclaringExtension().getDeclaringPluginDescriptor();
+//             return dependsOn(thisPluginDescriptor, otherPluginDescriptor);
+//     }
+
+//     private boolean dependsOn(IPluginDescriptor descriptor0, IPluginDescriptor descriptor1) {
+//
+//             IPluginRegistry registry= Platform.getPluginRegistry();
+//             IPluginPrerequisite[] prerequisites= descriptor0.getPluginPrerequisites();
+//
+//             for (int i= 0; i < prerequisites.length; i++) {
+//                     IPluginPrerequisite prerequisite= prerequisites[i];
+//                     String id= prerequisite.getUniqueIdentifier();                  
+//                     IPluginDescriptor descriptor= registry.getPluginDescriptor(id);
+//                     
+//                     if (descriptor != null && (descriptor.equals(descriptor1) || dependsOn(descriptor, descriptor1)))
+//                             return true;
+//             }
+//             
+//             return false;
+//     }
 
        private static JavaEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
                List result= new ArrayList(elements.length);