Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreklein2008-10-28 11:50:55 -0400
committereklein2008-10-28 11:50:55 -0400
commitfe60d9cd6d96b63a9fea3ea1ad82b60dd29141eb (patch)
tree9f4c5ff079bb456e93ca8edee81e4806521cad45
parente07413d7c538f6756425042f6fffa150772062e9 (diff)
downloadorg.eclipse.pdt-fe60d9cd6d96b63a9fea3ea1ad82b60dd29141eb.tar.gz
org.eclipse.pdt-fe60d9cd6d96b63a9fea3ea1ad82b60dd29141eb.tar.xz
org.eclipse.pdt-fe60d9cd6d96b63a9fea3ea1ad82b60dd29141eb.zip
fix bug#252110 - [Project Structure] Default project structure should be changed
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCoreConstants.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/project/PHPNature.java46
2 files changed, 50 insertions, 3 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCoreConstants.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCoreConstants.java
index 6d138f14f..8ef3a7965 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCoreConstants.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCoreConstants.java
@@ -18,6 +18,13 @@ public interface PHPCoreConstants {
public static final String IP_VARIABLE_INITIALIZER_EXTPOINT_ID = "includePathVariables"; //$NON-NLS-1$
//
+ // Project default folders names
+ //
+ public static final String PROJECT_DEFAULT_SOURCE_FOLDER = "src"; //$NON-NLS-1$
+ public static final String PROJECT_DEFAULT_RESOURCES_FOLDER = "resources"; //$NON-NLS-1$
+
+
+ //
// Project Option names
//
public static final String PHPOPTION_DEFAULT_ENCODING = PLUGIN_ID + ".defaultEncoding"; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/project/PHPNature.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/project/PHPNature.java
index e345fb2eb..02c0653c2 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/project/PHPNature.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/project/PHPNature.java
@@ -12,16 +12,18 @@ package org.eclipse.php.internal.core.project;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.IScriptProject;
-import org.eclipse.dltk.core.ScriptNature;
+import org.eclipse.dltk.core.*;
+import org.eclipse.php.internal.core.PHPCoreConstants;
import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.core.language.LanguageModelInitializer;
+import org.eclipse.wst.sse.core.internal.Logger;
import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
public class PHPNature extends ScriptNature {
@@ -148,6 +150,44 @@ public class PHPNature extends ScriptNature {
IScriptProject scriptProject = DLTKCore.create(getProject());
LanguageModelInitializer.enableLanguageModelFor(scriptProject);
+
+ try {
+ configureBuildPath(scriptProject);
+ } catch (ModelException e){
+ Logger.logException("Failed updating buildpath", e); // //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Updates the project buildpath.
+ * Remove the project from the buildpath (it is there as a default) and add the default project
+ * src folder to it
+ * @param scriptProject
+ * @throws ModelException
+ */
+ private void configureBuildPath(IScriptProject scriptProject) throws ModelException {
+
+ IBuildpathEntry[] rawBuildpath = scriptProject.getRawBuildpath();
+
+ // get the current buildpath entries, in order to add/remove entries
+ List<IBuildpathEntry> newRawBuildpath = new ArrayList<IBuildpathEntry>();
+
+ // remove the project itself from the buildpath
+ for (IBuildpathEntry buildpathEntry : rawBuildpath) {
+ if(! buildpathEntry.getPath().equals(scriptProject.getPath())){
+ newRawBuildpath.add(buildpathEntry);
+ }
+ }
+
+ // add the default src folder to the buildpath
+ IFolder folder = getProject().getFolder(new Path(PHPCoreConstants.PROJECT_DEFAULT_SOURCE_FOLDER));
+ IBuildpathEntry newSourceEntry = DLTKCore.newSourceEntry(folder.getFullPath());
+ newRawBuildpath.add(newSourceEntry);
+
+ // set the new updated buildpath for the project
+ scriptProject.setRawBuildpath(newRawBuildpath.toArray(new IBuildpathEntry[newRawBuildpath.size()]), null);
+
+
}
/**

Back to the top