aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Pospychala2012-09-07 06:13:21 (EDT)
committerJacek Pospychala2012-09-07 06:13:21 (EDT)
commit03c6188f5a07f9e149a56d51f3d497c36298f04c (patch)
tree145a5283b9648167c98eeef94430b06e319cad31
parentcf2cc95b8b6a20493b07f02029ee618a0e2272d2 (diff)
downloadorg.eclipse.pdt-03c6188f5a07f9e149a56d51f3d497c36298f04c.zip
org.eclipse.pdt-03c6188f5a07f9e149a56d51f3d497c36298f04c.tar.gz
org.eclipse.pdt-03c6188f5a07f9e149a56d51f3d497c36298f04c.tar.bz2
Bug 388972 - Support for Facets
-rw-r--r--plugins/org.eclipse.php.core/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.php.core/plugin.properties9
-rw-r--r--plugins/org.eclipse.php.core/plugin.xml65
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/DummyActionDelegate.java16
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacets.java73
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacetsConstants.java11
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/PHPProjectCreationWizard.java12
7 files changed, 188 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF
index 4d8e288..26abd4b 100644
--- a/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.php.core/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.wst.xml.core,
com.ibm.icu;bundle-version="4.0.1",
org.eclipse.php.core.parser,
- org.eclipse.dltk.core.index.sql
+ org.eclipse.dltk.core.index.sql,
+ org.eclipse.wst.common.project.facet.core
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.php.core.codeassist,
org.eclipse.php.core.compiler,
@@ -454,6 +455,7 @@ Export-Package: org.eclipse.php.core.codeassist,
org.eclipse.php.ui,
org.eclipse.php.ui.performance.tests,
org.eclipse.php.ui.tests",
+ org.eclipse.php.internal.core.facet,
org.eclipse.php.internal.core.filenetwork;
x-friends:="org.eclipse.php.core.performance.tests,
org.eclipse.php.core.tests,
diff --git a/plugins/org.eclipse.php.core/plugin.properties b/plugins/org.eclipse.php.core/plugin.properties
index 6c43224..daccdb3 100644
--- a/plugins/org.eclipse.php.core/plugin.properties
+++ b/plugins/org.eclipse.php.core/plugin.properties
@@ -15,4 +15,11 @@ content-type.name.0 = PHP Content Type
#PHP task marker
PHPTaskMarker.label=PHP Task
-parserBuildParticipant.name = PHP Parser \ No newline at end of file
+parserBuildParticipant.name = PHP Parser
+
+#PHP facet
+PHPFacet.label=PHP Facet
+PHPFacet.description=PHP Facet
+PHPFacet.core.label=PHP Core Facet
+PHPFacet.core.description=PHP Core Facet
+PHPFacet.preset.label=PHP Project
diff --git a/plugins/org.eclipse.php.core/plugin.xml b/plugins/org.eclipse.php.core/plugin.xml
index f3895c2..c69e14b 100644
--- a/plugins/org.eclipse.php.core/plugin.xml
+++ b/plugins/org.eclipse.php.core/plugin.xml
@@ -311,4 +311,69 @@
nature="org.eclipse.php.core.PHPNature">
</enable>
</extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.facets">
+ <project-facet
+ id="php.core.component">
+ <label>%PHPFacet.core.label</label>
+ <description>%PHPFacet.core.description</description>
+ </project-facet>
+ <project-facet-version facet="php.core.component" version="1">
+ <constraint>
+ <and>
+ <conflicts facet="jst.java" />
+ <conflicts group="modules" />
+ </and>
+ </constraint>
+ </project-facet-version>
+ <project-facet
+ id="php.component">
+ <label>%PHPFacet.label</label>
+ <description>%PHPFacet.description</description>
+ </project-facet>
+ <project-facet-version facet="php.component" version="4">
+ <constraint>
+ <and>
+ <requires facet="php.core.component" />
+ </and>
+ </constraint>
+ </project-facet-version>
+ <project-facet-version facet="php.component" version="5">
+ <constraint>
+ <and>
+ <requires facet="php.core.component" />
+ </and>
+ </constraint>
+ </project-facet-version>
+ <project-facet-version facet="php.component" version="5.3">
+ <constraint>
+ <and>
+ <requires facet="php.core.component" />
+ </and>
+ </constraint>
+ </project-facet-version>
+ <project-facet-version facet="php.component" version="5.4">
+ <constraint>
+ <and>
+ <requires facet="php.core.component" />
+ </and>
+ </constraint>
+ </project-facet-version>
+
+ <action facet="php.core.component" version="1" type="install">
+ <delegate class="org.eclipse.php.internal.core.facet.DummyActionDelegate" />
+ </action>
+ <action facet="php.component" version="4" type="install">
+ <delegate class="org.eclipse.php.internal.core.facet.DummyActionDelegate" />
+ </action>
+ <action facet="php.component" version="5" type="install">
+ <delegate class="org.eclipse.php.internal.core.facet.DummyActionDelegate" />
+ </action>
+ <action facet="php.component" version="5.3" type="install">
+ <delegate class="org.eclipse.php.internal.core.facet.DummyActionDelegate" />
+ </action>
+ <action facet="php.component" version="5.4" type="install">
+ <delegate class="org.eclipse.php.internal.core.facet.DummyActionDelegate" />
+ </action>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/DummyActionDelegate.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/DummyActionDelegate.java
new file mode 100644
index 0000000..3ab7588
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/DummyActionDelegate.java
@@ -0,0 +1,16 @@
+package org.eclipse.php.internal.core.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public class DummyActionDelegate implements IDelegate {
+
+ public void execute(IProject arg0, IProjectFacetVersion arg1, Object arg2,
+ IProgressMonitor arg3) throws CoreException {
+ // does nothing
+ }
+
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacets.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacets.java
new file mode 100644
index 0000000..40da395
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacets.java
@@ -0,0 +1,73 @@
+package org.eclipse.php.internal.core.facet;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.php.internal.core.PHPVersion;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+public class PHPFacets {
+
+ /**
+ * Adds PHP facet for project
+ *
+ * @param project
+ * Project to add facet for
+ * @param phpVersion
+ * PHP version to properly set facet
+ * @param monitor
+ * @throws CoreException
+ */
+ public static void createFacetedProject(IProject project,
+ PHPVersion phpVersion, IProgressMonitor monitor)
+ throws CoreException {
+ final IFacetedProject facetedProject = ProjectFacetsManager.create(
+ project, true, monitor);
+
+ // set the fixed facets (they will not be removable by the user)
+ // the php.component facet will be set to the correct version
+ // programmatically
+ final Set<IProjectFacet> fixedFacets = new HashSet<IProjectFacet>();
+ IProjectFacet coreFacet = ProjectFacetsManager
+ .getProjectFacet(PHPFacetsConstants.PHP_CORE_COMPONENT);
+ fixedFacets.add(coreFacet);
+ IProjectFacet phpFacet = ProjectFacetsManager
+ .getProjectFacet(PHPFacetsConstants.PHP_COMPONENT);
+ fixedFacets.add(phpFacet);
+ facetedProject.setFixedProjectFacets(fixedFacets);
+
+ // install the fixed facets
+ facetedProject.installProjectFacet(coreFacet.getDefaultVersion(), null,
+ new NullProgressMonitor());
+ // Fetch and activate the correct php version
+ switch (phpVersion) {
+ case PHP4:
+ facetedProject.installProjectFacet(phpFacet
+ .getVersion(PHPFacetsConstants.PHP_COMPONENT_VERSION_4),
+ null, monitor);
+ break;
+ case PHP5:
+ facetedProject.installProjectFacet(phpFacet
+ .getVersion(PHPFacetsConstants.PHP_COMPONENT_VERSION_5),
+ null, monitor);
+ break;
+ case PHP5_3:
+ facetedProject.installProjectFacet(phpFacet
+ .getVersion(PHPFacetsConstants.PHP_COMPONENT_VERSION_5_3),
+ null, monitor);
+ break;
+ case PHP5_4:
+ default:
+ facetedProject.installProjectFacet(phpFacet
+ .getVersion(PHPFacetsConstants.PHP_COMPONENT_VERSION_5_4),
+ null, monitor);
+ break;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacetsConstants.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacetsConstants.java
new file mode 100644
index 0000000..af14269
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/facet/PHPFacetsConstants.java
@@ -0,0 +1,11 @@
+package org.eclipse.php.internal.core.facet;
+
+public class PHPFacetsConstants {
+
+ public static final String PHP_CORE_COMPONENT = "php.core.component";
+ public static final String PHP_COMPONENT = "php.component";
+ public static final String PHP_COMPONENT_VERSION_4 = "4";
+ public static final String PHP_COMPONENT_VERSION_5 = "5";
+ public static final String PHP_COMPONENT_VERSION_5_3 = "5.3";
+ public static final String PHP_COMPONENT_VERSION_5_4 = "5.4";
+}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/PHPProjectCreationWizard.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/PHPProjectCreationWizard.java
index ac10ce6..4b6cfaa 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/PHPProjectCreationWizard.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/wizards/PHPProjectCreationWizard.java
@@ -13,12 +13,15 @@ package org.eclipse.php.internal.ui.wizards;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.ui.DLTKUIPlugin;
import org.eclipse.dltk.ui.wizards.NewElementWizard;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.php.internal.core.PHPCorePlugin;
+import org.eclipse.php.internal.core.facet.PHPFacets;
import org.eclipse.php.internal.ui.PHPUIMessages;
import org.eclipse.php.internal.ui.util.PHPPluginImages;
import org.eclipse.ui.INewWizard;
@@ -90,6 +93,15 @@ public class PHPProjectCreationWizard extends NewElementWizard implements
}
selectAndReveal(fLastPage.getScriptProject().getProject());
+ IProject project = fLastPage.getScriptProject().getProject();
+ try {
+ PHPFacets.createFacetedProject(project,
+ fFirstPage.getPHPVersionValue(),
+ new NullProgressMonitor());
+ } catch (CoreException ex) {
+ PHPCorePlugin.log(ex);
+ }
+
WizardModel model = fFirstPage.getWizardData();
Object eanblement = null;