misc changes in the internal builder
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / JavaModelManager.java
index 1838edf..4c295b7 100644 (file)
@@ -39,8 +39,8 @@ import net.sourceforge.phpdt.core.IPackageFragment;
 import net.sourceforge.phpdt.core.IPackageFragmentRoot;
 import net.sourceforge.phpdt.core.IWorkingCopy;
 import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
-import net.sourceforge.phpeclipse.PHPCore;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpdt.internal.core.builder.PHPBuilder;
 
@@ -248,13 +248,13 @@ public class JavaModelManager implements ISaveParticipant {
                int type = resource.getType();
                switch (type) {
                        case IResource.PROJECT :
-                               return PHPCore.create((IProject) resource);
+                               return JavaCore.create((IProject) resource);
                        case IResource.FILE :
                                return create((IFile) resource, project);
                        case IResource.FOLDER :
                                return create((IFolder) resource, project);
                        case IResource.ROOT :
-                               return PHPCore.create((IWorkspaceRoot) resource);
+                               return JavaCore.create((IWorkspaceRoot) resource);
                        default :
                                return null;
                }
@@ -280,7 +280,7 @@ public class JavaModelManager implements ISaveParticipant {
                        return null;
                }
                if (project == null) {
-                       project = PHPCore.create(file.getProject());
+                       project = JavaCore.create(file.getProject());
                }
        
                if (file.getFileExtension() != null) {
@@ -311,7 +311,7 @@ public class JavaModelManager implements ISaveParticipant {
                        return null;
                }
                if (project == null) {
-                       project = PHPCore.create(folder.getProject());
+                       project = JavaCore.create(folder.getProject());
                }
                IJavaElement element = determineIfOnClasspath(folder, project);
                if (conflictsWithOutputLocation(folder.getFullPath(), (JavaProject)project)
@@ -355,7 +355,7 @@ public class JavaModelManager implements ISaveParticipant {
                if (file == null) return null;
 
                if (project == null) {
-                       project = PHPCore.create(file.getProject());
+                       project = JavaCore.create(file.getProject());
                }
                IPackageFragment pkg = (IPackageFragment) determineIfOnClasspath(file, project);
                if (pkg == null) {
@@ -655,7 +655,7 @@ public class JavaModelManager implements ISaveParticipant {
         * Configure the plugin with respect to option settings defined in ".options" file
         */
        public void configurePluginDebugOptions(){
-               if(PHPCore.getPlugin().isDebugging()){
+               if(JavaCore.getPlugin().isDebugging()){
 //             TODO khartlage temp-del
                        String option = Platform.getDebugOption(BUILDER_DEBUG);
 //                     if(option != null) JavaBuilder.DEBUG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
@@ -1000,7 +1000,7 @@ public class JavaModelManager implements ISaveParticipant {
                JavaModelManager.PerProjectInfo info = getPerProjectInfo(project, false /* don't create info */);
                if (info == null) {
                        if (!JavaProject.hasJavaNature(project)) {
-                               throw ((JavaProject)PHPCore.create(project)).newNotPresentException();
+                               throw ((JavaProject)JavaCore.create(project)).newNotPresentException();
                        }
                        info = getPerProjectInfo(project, true /* create info */);
                }
@@ -1012,7 +1012,7 @@ public class JavaModelManager implements ISaveParticipant {
         */
        public static String[] getRegisteredVariableNames(){
                
-               Plugin jdtCorePlugin = PHPCore.getPlugin();
+               Plugin jdtCorePlugin = JavaCore.getPlugin();
                if (jdtCorePlugin == null) return null;
 
                ArrayList variableList = new ArrayList(5);
@@ -1062,7 +1062,7 @@ public class JavaModelManager implements ISaveParticipant {
         */
        private File getSerializationFile(IProject project) {
                if (!project.exists()) return null;
-               IPluginDescriptor descr= PHPCore.getJavaCore().getDescriptor();
+               IPluginDescriptor descr= JavaCore.getJavaCore().getDescriptor();
                IPath workingLocation= project.getPluginWorkingLocation(descr);
                return workingLocation.append("state.dat").toFile(); //$NON-NLS-1$
        }
@@ -1094,18 +1094,18 @@ public class JavaModelManager implements ISaveParticipant {
                                } else { // internal resource (not an IFile or not existing)
                                        IPath location;
                                        if (file.getType() != IResource.FILE || (location = file.getLocation()) == null) {
-                                               throw new CoreException(new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, -1, Util.bind("file.notFound", path.toString()), null)); //$NON-NLS-1$
+                                               throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("file.notFound", path.toString()), null)); //$NON-NLS-1$
                                        }
                                        fileSystemPath= location.toOSString();
                                }
                        } else if (!path.isAbsolute()) {
                                file= root.getFile(path);
                                if (file == null || file.getType() != IResource.FILE) {
-                                       throw new CoreException(new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, -1, Util.bind("file.notFound", path.toString()), null)); //$NON-NLS-1$
+                                       throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("file.notFound", path.toString()), null)); //$NON-NLS-1$
                                }
                                IPath location = file.getLocation();
                                if (location == null) {
-                                       throw new CoreException(new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, -1, Util.bind("file.notFound", path.toString()), null)); //$NON-NLS-1$
+                                       throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("file.notFound", path.toString()), null)); //$NON-NLS-1$
                                }
                                fileSystemPath= location.toOSString();
                        } else {
@@ -1122,7 +1122,7 @@ public class JavaModelManager implements ISaveParticipant {
                                }
                                return zipFile;
                        } catch (IOException e) {
-                               throw new CoreException(new Status(Status.ERROR, PHPCore.PLUGIN_ID, -1, Util.bind("status.IOException"), e)); //$NON-NLS-1$
+                               throw new CoreException(new Status(Status.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("status.IOException"), e)); //$NON-NLS-1$
                        }
                }
        }
@@ -1297,7 +1297,7 @@ public class JavaModelManager implements ISaveParticipant {
                                DataInputStream in= new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
                                try {
                                        String pluginID= in.readUTF();
-                                       if (!pluginID.equals(PHPCore.PLUGIN_ID))
+                                       if (!pluginID.equals(JavaCore.PLUGIN_ID))
                                                throw new IOException(Util.bind("build.wrongFileFormat")); //$NON-NLS-1$
                                        String kind= in.readUTF();
                                        if (!kind.equals("STATE")) //$NON-NLS-1$
@@ -1311,7 +1311,7 @@ public class JavaModelManager implements ISaveParticipant {
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
-                               throw new CoreException(new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, Platform.PLUGIN_ERROR, "Error reading last build state for project "+ project.getName(), e)); //$NON-NLS-1$
+                               throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR, "Error reading last build state for project "+ project.getName(), e)); //$NON-NLS-1$
                        }
                }
                return null;
@@ -1453,7 +1453,7 @@ public class JavaModelManager implements ISaveParticipant {
                try {
                        DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
                        try {
-                               out.writeUTF(PHPCore.PLUGIN_ID);
+                               out.writeUTF(JavaCore.PLUGIN_ID);
                                out.writeUTF("STATE"); //$NON-NLS-1$
                                if (info.savedState == null) {
                                        out.writeBoolean(false);
@@ -1467,12 +1467,12 @@ public class JavaModelManager implements ISaveParticipant {
                } catch (RuntimeException e) {
                        try {file.delete();} catch(SecurityException se) {}
                        throw new CoreException(
-                               new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
+                               new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
                                        Util.bind("build.cannotSaveState", info.project.getName()), e)); //$NON-NLS-1$
                } catch (IOException e) {
                        try {file.delete();} catch(SecurityException se) {}
                        throw new CoreException(
-                               new Status(IStatus.ERROR, PHPCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
+                               new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
                                        Util.bind("build.cannotSaveState", info.project.getName()), e)); //$NON-NLS-1$
                }
                if (PHPBuilder.DEBUG) {
@@ -1508,7 +1508,7 @@ public class JavaModelManager implements ISaveParticipant {
                if (vStats != null) {
                        IStatus[] stats= new IStatus[vStats.size()];
                        vStats.toArray(stats);
-                       throw new CoreException(new MultiStatus(PHPCore.PLUGIN_ID, IStatus.ERROR, stats, Util.bind("build.cannotSaveStates"), null)); //$NON-NLS-1$
+                       throw new CoreException(new MultiStatus(JavaCore.PLUGIN_ID, IStatus.ERROR, stats, Util.bind("build.cannotSaveStates"), null)); //$NON-NLS-1$
                }
        }
 
@@ -1520,7 +1520,7 @@ public class JavaModelManager implements ISaveParticipant {
 
                // optional behaviour
                // possible value of index 0 is Compute
-               if (!PHPCore.COMPUTE.equals(PHPCore.getOption(PHPCore.CORE_JAVA_BUILD_ORDER))) return; // cannot be customized at project level
+               if (!JavaCore.COMPUTE.equals(JavaCore.getOption(JavaCore.CORE_JAVA_BUILD_ORDER))) return; // cannot be customized at project level
                
                if (javaBuildOrder == null || javaBuildOrder.length <= 1) return;
                
@@ -1661,11 +1661,11 @@ public class JavaModelManager implements ISaveParticipant {
                if (variablePath == JavaModelManager.VariableInitializationInProgress){
                        return;
                } 
-               Preferences preferences = PHPCore.getPlugin().getPluginPreferences();
+               Preferences preferences = JavaCore.getPlugin().getPluginPreferences();
                String variableKey = CP_VARIABLE_PREFERENCES_PREFIX+variableName;
                String variableString = variablePath == null ? CP_ENTRY_IGNORE : variablePath.toString();
                preferences.setDefault(variableKey, CP_ENTRY_IGNORE); // use this default to get rid of removed ones
                preferences.setValue(variableKey, variableString);
-               PHPCore.getPlugin().savePluginPreferences();
+               JavaCore.getPlugin().savePluginPreferences();
        }
 }