Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-02-14 14:09:22 +0000
committerptessier2014-02-14 14:09:22 +0000
commit420cf917b5c3b13d4d8ef6bd708a3b3e40b6bdb0 (patch)
treea083340770062420f23ceab12dc3b18393d94620 /plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core
parent64ee2ce1efd7404b1818daea15cb8300b316e982 (diff)
downloadorg.eclipse.papyrus-420cf917b5c3b13d4d8ef6bd708a3b3e40b6bdb0.tar.gz
org.eclipse.papyrus-420cf917b5c3b13d4d8ef6bd708a3b3e40b6bdb0.tar.xz
org.eclipse.papyrus-420cf917b5c3b13d4d8ef6bd708a3b3e40b6bdb0.zip
386118: [EMF Facet] Papyrus should progressively support EMF Facet 0.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386118
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.checkstyle18
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.classpath7
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.project34
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.runtime.prefs3
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/META-INF/MANIFEST.MF20
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/OSGI-INF/l10n/bundle.properties13
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/about.html28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/build.properties20
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/plugin.xml32
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/resources/Activator.java.template32
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/schema/builderRegistration.exsd138
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Activator.java42
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectBuilder.java203
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectNature.java59
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Messages.java26
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/CommonConstants.java25
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/IEmfFacetProjectBuilder.java51
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/utils/ProjectUtils.java355
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/messages.properties12
21 files changed, 1132 insertions, 0 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.checkstyle b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.checkstyle
new file mode 100644
index 00000000000..cc4564edfe6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.checkstyle
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2010 Mia-Software.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+ Nicolas Bros (Mia-Software) - initial API and implementation
+-->
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <local-check-config name="EmfFacet" location="/org.eclipse.emf.facet.archi.tech.rules/checkstyle/EmfFacet.checkstyle" type="project" description=""/>
+ <fileset name="all" enabled="true" check-config-name="EmfFacet" local="true">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ <file-match-pattern match-pattern="Messages.java" include-pattern="false"/>
+ </fileset>
+</fileset-config>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.project b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.project
new file mode 100644
index 00000000000..738d34ba621
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.emf.facet.common.sdk.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.resources.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..0f5d1bd2ce1
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//src/org/eclipse/emf/facet/common/sdk/core/internal/messages.properties=ISO-8859-1
+encoding/<project>=UTF-8
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.runtime.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.runtime.prefs
new file mode 100644
index 00000000000..dea8d10ff97
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,3 @@
+#Tue Dec 13 09:46:07 CET 2011
+eclipse.preferences.version=1
+line.separator=\n
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..060c5ee3d2e
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..86ae6de9f34
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.common.sdk.core;singleton:=true
+Bundle-Version: 0.4.0.qualifier
+Bundle-Activator: org.eclipse.emf.facet.common.sdk.core.internal.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;bundle-version="2.6.0",
+ org.eclipse.papyrus.emf.facet.util.emf.catalog;bundle-version="0.1.0",
+ org.eclipse.pde.core;bundle-version="3.6.0",
+ org.eclipse.papyrus.emf.facet.util.core;bundle-version="0.1.0",
+ com.ibm.icu;bundle-version="4.2.1",
+ org.eclipse.core.resources;bundle-version="3.6.0",
+ org.eclipse.jdt.core;bundle-version="3.6.0",
+ org.eclipse.jdt.launching;bundle-version="3.5.100"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.emf.facet.common.sdk.core.internal.exported;x-friends:="org.eclipse.emf.facet.common.sdk.ui,org.eclipse.emf.facet.custom.sdk.core",
+ org.eclipse.emf.facet.common.sdk.core.internal.exported.utils
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..962e0b2c97d
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2012 CEA LIST.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+###############################################################################
+#Properties file for org.eclipse.emf.facet.common.sdk.core
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = EMF Facet Common SDK Core (Incubation)
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/about.html b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/about.html
new file mode 100644
index 00000000000..3019b95b9cf
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>December 22, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/build.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/build.properties
new file mode 100644
index 00000000000..72f52df4e79
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/build.properties
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2012 CEA LIST.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ OSGI-INF/,\
+ plugin.xml,\
+ schema/,\
+ resources/
+src.includes = about.html
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/plugin.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/plugin.xml
new file mode 100644
index 00000000000..eab024d1645
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/plugin.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension-point id="builderRegistration" name="EMF Facet Builder registration" schema="schema/builderRegistration.exsd"/>
+ <extension
+ id="org.eclipse.emf.facet.common.sdk.core.projectBuilder"
+ name="EMF Facet project builder"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ callOnEmptyDelta="true"
+ hasNature="true"
+ isConfigurable="false">
+ <run
+ class="org.eclipse.emf.facet.common.sdk.core.internal.EmfFacetProjectBuilder">
+ </run>
+ </builder>
+ </extension>
+ <extension
+ id="org.eclipse.emf.facet.common.sdk.core.ProjectNature"
+ name="EMF Facet"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.eclipse.emf.facet.common.sdk.core.internal.EmfFacetProjectNature">
+ </run>
+ </runtime>
+ <builder id="org.eclipse.emf.facet.common.sdk.core.projectBuilder"/>
+ <requires-nature id="org.eclipse.jdt.core.javanature"/>
+ <requires-nature id="org.eclipse.pde.PluginNature"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/resources/Activator.java.template b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/resources/Activator.java.template
new file mode 100644
index 00000000000..59aa1af9ba6
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/resources/Activator.java.template
@@ -0,0 +1,32 @@
+package {0};
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/** The activator class controls the plug-in life cycle */
+public class Activator extends Plugin {
+
+ // The shared instance
+ private static Activator plugin;
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ Activator.plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ Activator.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return Activator.plugin;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/schema/builderRegistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/schema/builderRegistration.exsd
new file mode 100644
index 00000000000..667b6d6be63
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/schema/builderRegistration.exsd
@@ -0,0 +1,138 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.emf.facet.common.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.emf.facet.common.core" id="builderRegistration" name="EMF Facet Builder Registration"/>
+ </appinfo>
+ <documentation>
+ This extension point allows to register builders that will be run when the main EMF Facet builder is run.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <choice>
+ <element ref="builder"/>
+ </choice>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="builder">
+ <complexType>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="depends"/>
+ </choice>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ A class that implements org.eclipse.emf.facet.common.sdk.core.internal.exported.IEmfFacetProjectBuilder.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.facet.common.sdk.core.internal.exported.IEmfFacetProjectBuilder"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="depends">
+ <complexType>
+ <attribute name="builder" type="string" use="required">
+ <annotation>
+ <documentation>
+ ID of an EMF Facet builder on which this EMF Facet builder depends.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 0.2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.emf.facet.common.sdk.core.builderRegistration&quot;&gt;
+ &lt;builder class=&quot;org.eclipse.emf.facet.custom.sdk.core.internal.validation.CustomizationValidationBuilder&quot;/&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ The builder must implement org.eclipse.emf.facet.common.sdk.core.internal.exported.IEmfFacetProjectBuilder
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ For an example, see the customization validation builder in org.eclipse.emf.facet.custom.sdk.core:&lt;br/&gt;
+org.eclipse.emf.facet.custom.sdk.core.internal.validation.CustomizationValidationBuilder
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2009-2012 Mia-Software.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+&lt;a
+href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+Contributors:
+ Grégoire Dupé (Mia-Software)
+ Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Activator.java
new file mode 100644
index 00000000000..5b3303aad55
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Activator.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/** The activator class controls the plug-in life cycle */
+public class Activator extends Plugin {
+
+ // The shared instance
+ private static Activator plugin;
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ Activator.plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ Activator.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return Activator.plugin;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectBuilder.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectBuilder.java
new file mode 100644
index 00000000000..0674bd8a8e3
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectBuilder.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2012 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software)
+ * Nicolas Bros (Mia-Software)
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.facet.common.sdk.core.internal.exported.CommonConstants;
+import org.eclipse.emf.facet.common.sdk.core.internal.exported.IEmfFacetProjectBuilder;
+import org.eclipse.emf.facet.util.core.Logger;
+
+/**
+ * A builder for EMF Facet projects, that delegates to children builders provided by the extension point
+ * "builderRegistration".
+ *
+ * @author Gregoire Dupe (Mia-Software)
+ */
+public class EmfFacetProjectBuilder extends IncrementalProjectBuilder {
+
+ private static ArrayList<BuilderDescriptor> emffacetBuilders = null;
+
+ public EmfFacetProjectBuilder() {
+ super();
+ if (EmfFacetProjectBuilder.emffacetBuilders == null) {
+ EmfFacetProjectBuilder.emffacetBuilders = new ArrayList<BuilderDescriptor>();
+ synchronized (EmfFacetProjectBuilder.emffacetBuilders) {
+ final IConfigurationElement[] configs = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(CommonConstants.BUILDER_EXTENSION_POINT_ID);
+ for (final IConfigurationElement config : configs) {
+ try {
+ final String id = config.getDeclaringExtension().getUniqueIdentifier();
+ final IEmfFacetProjectBuilder builderInst = (IEmfFacetProjectBuilder) config
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ final BuilderDescriptor builderDescriptor = new BuilderDescriptor(
+ builderInst, id);
+ EmfFacetProjectBuilder.emffacetBuilders.add(builderDescriptor);
+ for (final IConfigurationElement depends : config.getChildren("depends")) { //$NON-NLS-1$
+ builderDescriptor.getDependsOn().add(depends.getAttribute("builder")); //$NON-NLS-1$
+ }
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+ EmfFacetProjectBuilder.emffacetBuilders = sortBuilders(EmfFacetProjectBuilder.emffacetBuilders);
+ }
+ }
+ validateBuilderDependencies();
+ }
+
+ /**
+ * Sort builders by dependencies : first those that depend on nothing, then those that depend on those already in
+ * the list, etc.
+ */
+ private static ArrayList<BuilderDescriptor> sortBuilders(final ArrayList<BuilderDescriptor> builders) {
+ final ArrayList<BuilderDescriptor> result = new ArrayList<EmfFacetProjectBuilder.BuilderDescriptor>();
+ final List<BuilderDescriptor> remaining = new LinkedList<EmfFacetProjectBuilder.BuilderDescriptor>();
+ remaining.addAll(builders);
+
+ while (!remaining.isEmpty()) {
+ boolean stuck = true;
+ final ListIterator<BuilderDescriptor> listIterator = remaining.listIterator();
+ while (listIterator.hasNext()) {
+ final BuilderDescriptor builder = listIterator.next();
+ // if it depends only on builders that are already in the list
+ // before it, then add it here
+ if (dependendsOnlyOn(builder, result)) {
+ result.add(builder);
+ listIterator.remove();
+ stuck = false;
+ }
+ }
+ if (stuck) {
+ throw new RuntimeException("Cannot order builders due to incoherent dependencies"); //$NON-NLS-1$
+ }
+ }
+
+ return result;
+ }
+
+ /** Whether the given builder only depends on those in the list. */
+ private static boolean dependendsOnlyOn(final BuilderDescriptor builder, final ArrayList<BuilderDescriptor> list) {
+ final List<String> dependsOn = builder.getDependsOn();
+ for (final String dep : dependsOn) {
+ boolean found = false;
+ for (final BuilderDescriptor prev : list) {
+ if (prev.getId().equals(dep)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static void validateBuilderDependencies() {
+ final List<String> idList = new ArrayList<String>();
+ for (final BuilderDescriptor descriptor : EmfFacetProjectBuilder.emffacetBuilders) {
+ idList.add(descriptor.getId());
+ }
+ for (final BuilderDescriptor descriptor : EmfFacetProjectBuilder.emffacetBuilders) {
+ for (final String dependsOn : descriptor.getDependsOn()) {
+ if (!idList.contains(dependsOn)) {
+ Logger.logWarning("The builder " + descriptor.getId() + " depends on " //$NON-NLS-1$//$NON-NLS-2$
+ + dependsOn + " which does not exist.", Activator //$NON-NLS-1$
+ .getDefault());
+ }
+ }
+ }
+
+ }
+
+ @Override
+ protected void clean(final IProgressMonitor monitor) throws CoreException {
+ synchronized (EmfFacetProjectBuilder.emffacetBuilders) {
+ final Iterator<BuilderDescriptor> builders = EmfFacetProjectBuilder.emffacetBuilders
+ .iterator();
+ while (builders.hasNext()) {
+ final BuilderDescriptor builder = builders.next();
+ builder.getBuilderInst().clean(this, monitor);
+ }
+ }
+ }
+
+ @Override
+ protected IProject[] build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor)
+ throws CoreException {
+ synchronized (EmfFacetProjectBuilder.emffacetBuilders) {
+ final Iterator<BuilderDescriptor> builders = EmfFacetProjectBuilder.emffacetBuilders
+ .iterator();
+ while (builders.hasNext()) {
+ final BuilderDescriptor builder = builders.next();
+ builder.getBuilderInst().build(this, kind, args, monitor);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This class is used to hold the builder id, the builder instance and the builder dependencies in a single
+ * structure.
+ */
+ private class BuilderDescriptor {
+ private final IEmfFacetProjectBuilder builderInst;
+
+ private final List<String> dependsOn = new ArrayList<String>();
+
+ private final String id;
+
+ /**
+ * @param builderInst
+ * an instance of the described builder
+ * @param id
+ * the id of the described builder
+ */
+ public BuilderDescriptor(final IEmfFacetProjectBuilder builderInst, final String id) {
+ this.builderInst = builderInst;
+ this.id = id;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ /** @return the list of dependencies on other EmfFacet builders. */
+ public List<String> getDependsOn() {
+ return this.dependsOn;
+ }
+
+ /** @return the instance of the described builder */
+ public IEmfFacetProjectBuilder getBuilderInst() {
+ return this.builderInst;
+ }
+
+ @Override
+ public String toString() {
+ return this.id + "(" + this.builderInst.getClass().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectNature.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectNature.java
new file mode 100644
index 00000000000..243560f9c46
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/EmfFacetProjectNature.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2012 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Fabien Giquel (Mia-Software)
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.facet.common.sdk.core.internal.exported.CommonConstants;
+
+/** The implementation of the EMF Facet project nature. */
+public class EmfFacetProjectNature implements IProjectNature {
+
+ /** The platform project this <code>IJavaProject</code> is based on */
+ private IProject project;
+
+ /** @see org.eclipse.core.resources.IProjectNature#configure() */
+ public void configure() throws CoreException {
+ // Add nature-specific information
+ // for the project, such as adding a builder
+ // to a project's build spec.
+ final IProjectDescription projectDescription = this.project.getDescription();
+ final ICommand[] oldBuildSpec = this.project.getDescription().getBuildSpec();
+ final ICommand[] newBuildSpec = new ICommand[oldBuildSpec.length + 1];
+ System.arraycopy(oldBuildSpec, 0, newBuildSpec, 0, oldBuildSpec.length);
+ final ICommand command = this.project.getDescription().newCommand();
+ command.setBuilderName(CommonConstants.BUILDER_NAME);
+ newBuildSpec[oldBuildSpec.length] = command;
+ projectDescription.setBuildSpec(newBuildSpec);
+ this.project.setDescription(projectDescription, new NullProgressMonitor());
+ }
+
+ /** @see org.eclipse.core.resources.IProjectNature#deconfigure() */
+ public void deconfigure() throws CoreException {
+ // Remove the nature-specific information here.
+ }
+
+ /** @see org.eclipse.core.resources.IProjectNature#getProject() */
+ public IProject getProject() {
+ return this.project;
+ }
+
+ /** @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) */
+ public void setProject(final IProject value) {
+ this.project = value;
+ }
+
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Messages.java
new file mode 100644
index 00000000000..19b45995abb
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/Messages.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.emf.facet.common.sdk.core.internal.messages"; //$NON-NLS-1$
+ public static String ProjectUtils_createEMFFacetProject;
+ public static String ProjectUtils_createPluginProject;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/CommonConstants.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/CommonConstants.java
new file mode 100644
index 00000000000..f2aca5e0a02
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/CommonConstants.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal.exported;
+
+public final class CommonConstants {
+ private CommonConstants() {
+ // not instantiable
+ }
+
+ public static final String BUILDER_EXTENSION_POINT_ID = "org.eclipse.emf.facet.common.sdk.core.builderRegistration"; //$NON-NLS-1$
+
+ /** The builder of EMF Facet projects */
+ public static final String BUILDER_NAME = "org.eclipse.emf.facet.common.sdk.core.projectBuilder"; //$NON-NLS-1$
+
+ /** The nature of EMF Facet projects */
+ public static final String NATURE_ID = "org.eclipse.emf.facet.common.sdk.core.ProjectNature"; //$NON-NLS-1$
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/IEmfFacetProjectBuilder.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/IEmfFacetProjectBuilder.java
new file mode 100644
index 00000000000..50a8947e488
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/IEmfFacetProjectBuilder.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2012 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Grégoire Dupé (Mia-Software) - Initial API
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal.exported;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * The EMF Facet project builder delegates its build behavior to a set of classes
+ * implementing this interface. This set of classes is defined through the use of
+ * the <tt>org.eclipse.emf.facet.common.sdk.core.builderRegistration</tt> extension
+ * point.
+ *
+ * @author Grégoire Dupé (Mia-Software)
+ *
+ */
+public interface IEmfFacetProjectBuilder {
+
+ /**
+ * @param builder
+ * The EMF Facet builder which delegates its build behavior to the
+ * classes that implement {@link IEmfFacetProjectBuilder}.
+ * @throws CoreException
+ */
+ IProject[] build(IncrementalProjectBuilder builder, int kind, Map<?, ?> args, IProgressMonitor monitor)
+ throws CoreException;
+
+ /**
+ * @see IncrementalProjectBuilder#clean(IProgressMonitor)
+ * @param builder
+ * The EmfFacet builder which delegates the build behavior to the
+ * classes that implement {@link IEmfFacetProjectBuilder}.
+ * @param monitor
+ * @throws CoreException
+ */
+ void clean(IncrementalProjectBuilder builder, IProgressMonitor monitor)
+ throws CoreException;
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/utils/ProjectUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/utils/ProjectUtils.java
new file mode 100644
index 00000000000..89dee115fcd
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/exported/utils/ProjectUtils.java
@@ -0,0 +1,355 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software)
+ * Fabien Giquel (Mia-Software)
+ * Nicolas Bros (Mia-Software)
+ * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+ *******************************************************************************/
+package org.eclipse.emf.facet.common.sdk.core.internal.exported.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.facet.common.sdk.core.internal.Activator;
+import org.eclipse.emf.facet.common.sdk.core.internal.Messages;
+import org.eclipse.emf.facet.common.sdk.core.internal.exported.CommonConstants;
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.core.internal.exported.FileUtils;
+import org.eclipse.emf.facet.util.core.internal.exported.FolderUtils;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.launching.JavaRuntime;
+
+import com.ibm.icu.lang.UCharacter;
+
+/**
+ * @author Gregoire Dupe (Mia-Software), Fabien Giquel (Mia-Software)
+ *
+ */
+public final class ProjectUtils {
+
+ private ProjectUtils() {
+ // Nothing
+ }
+
+ private static final String JAVA_VERSION = "J2SE-1.5"; //$NON-NLS-1$
+
+ public static void addPdeClassPath(final IProject project) throws JavaModelException {
+ final IJavaProject javaProject = JavaCore.create(project);
+ final IClasspathEntry[] oldClassPath = javaProject.getRawClasspath();
+ for (final IClasspathEntry classpathEntry : oldClassPath) {
+ if (classpathEntry.getPath().equals(new Path("org.eclipse.pde.core.requiredPlugins"))) { //$NON-NLS-1$
+ return;
+ }
+ }
+ final IClasspathEntry[] newClassPath = new IClasspathEntry[oldClassPath.length + 1];
+ System.arraycopy(oldClassPath, 0, newClassPath, 0, oldClassPath.length);
+ newClassPath[oldClassPath.length] = JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins")); //$NON-NLS-1$
+ javaProject.setRawClasspath(newClassPath, new NullProgressMonitor());
+ }
+
+ /**
+ * @author Gregoire Dupe (Mia-Software) - Removing "Require-Bundle" statement
+ */
+ public static void createManifest(final IProject project) throws CoreException {
+ final IFolder folder = project.getFolder("META-INF"); //$NON-NLS-1$
+ if (!folder.exists()) {
+ folder.create(true, true, new NullProgressMonitor());
+ }
+ final IFile manifestFile = folder.getFile("MANIFEST.MF"); //$NON-NLS-1$
+ if (!manifestFile.exists()) {
+ final StringBuffer manifestSB = new StringBuffer();
+ manifestSB.append("Manifest-Version: 1.0\n"); //$NON-NLS-1$
+ manifestSB.append("Bundle-ManifestVersion: 2\n"); //$NON-NLS-1$
+ manifestSB.append("Bundle-Name: " + project.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ final String packageName = ProjectUtils.packageName(project.getName());
+ manifestSB.append("Bundle-SymbolicName: " + packageName //$NON-NLS-1$
+ + ";singleton:=true\n"); //$NON-NLS-1$
+ manifestSB.append("Bundle-Version: 0.0.1.qualifier\n"); //$NON-NLS-1$
+ manifestSB
+ .append("Bundle-Activator: " + ProjectUtils.bundleActivatorQualifiedName(packageName) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ //manifestSB.append("Bundle-Vendor: bundle vendor\n"); //$NON-NLS-1$
+ manifestSB.append("Require-Bundle: org.eclipse.core.runtime,\n"); //$NON-NLS-1$
+ manifestSB.append(" org.eclipse.emf.facet.util.core\n"); //$NON-NLS-1$
+ manifestSB.append("Bundle-RequiredExecutionEnvironment: " //$NON-NLS-1$
+ + ProjectUtils.JAVA_VERSION + "\n"); //$NON-NLS-1$
+ manifestSB.append("Bundle-ActivationPolicy: lazy\n"); //$NON-NLS-1$
+ manifestSB.append("Bundle-ClassPath: .,bin\n"); //$NON-NLS-1$
+ final InputStream source = new ByteArrayInputStream(manifestSB.toString().getBytes());
+ manifestFile.create(source, true, new NullProgressMonitor());
+ }
+ }
+
+ private static String bundleActivatorQualifiedName(final String packageName) {
+ return packageName + ".Activator"; //$NON-NLS-1$
+ }
+
+ private static void createActivator(final IProject project) throws CoreException {
+ final String packageName = ProjectUtils.packageName(project.getName());
+ final String qualifiedName = ProjectUtils.bundleActivatorQualifiedName(packageName);
+ final String path = qualifiedName.replaceAll("\\.", "/"); //$NON-NLS-1$ //$NON-NLS-2$
+ final IFile activatorFile = project
+ .getFile(new Path("src").append(path).addFileExtension("java")); //$NON-NLS-1$ //$NON-NLS-2$
+ FolderUtils.createFolder((IFolder) activatorFile.getParent());
+ if (!activatorFile.exists()) {
+ try {
+ final String template = FileUtils.getFileContents(Activator.getDefault()
+ .getBundle(), "resources/Activator.java.template"); //$NON-NLS-1$
+ final String activatorContents = template.replace("{0}", packageName); //$NON-NLS-1$
+ final InputStream source = new ByteArrayInputStream(activatorContents.getBytes());
+ activatorFile.create(source, true, new NullProgressMonitor());
+ } catch (final IOException e) {
+ Logger.logError(e, "Couldn't create Activator", Activator //$NON-NLS-1$
+ .getDefault());
+ }
+ }
+ }
+
+ /** Transform the given name into a valid package and bundle name */
+ public static String packageName(final String name) {
+ final StringBuilder builder = new StringBuilder();
+ char prev = ' ';
+ for (int i = 0; i < name.length(); i++) {
+ final char c = name.charAt(i);
+ if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_') {
+ builder.append(c);
+ prev = c;
+ } else if (c >= '0' && c <= '9') {
+ if (builder.length() == 0 || prev == '.') {
+ builder.append("_"); //$NON-NLS-1$
+ }
+ builder.append(c);
+ prev = c;
+ } else if (c == '.') {
+ if (prev == '.') {
+ continue;
+ }
+ if (builder.length() == 0 || prev >= '0' && prev <= '9') {
+ builder.append("_"); //$NON-NLS-1$
+ }
+ builder.append(c);
+ prev = c;
+ } else {
+ builder.append("_"); //$NON-NLS-1$
+ }
+ }
+
+ String result = builder.toString();
+ // first letter to lowercase
+ if (result.length() > 0 && UCharacter.isUpperCase(result.charAt(0))) {
+ result = UCharacter.toLowerCase(result.charAt(0)) + result.substring(1);
+ }
+
+ final IStatus status = JavaConventions.validatePackageName(result, JavaCore.VERSION_1_5,
+ JavaCore.VERSION_1_5);
+ if (!status.isOK()) {
+ Logger.logWarning("Couldn't make valid package name from project name: " //$NON-NLS-1$
+ + status.getMessage(), Activator.getDefault());
+ return name;
+ }
+ return result;
+ }
+
+ public static void addPdeNature(final IProject project) throws CoreException {
+ final String pluginNature = "org.eclipse.pde.PluginNature"; //$NON-NLS-1$
+ final IProjectDescription description = project.getDescription();
+ final String[] natures = description.getNatureIds();
+ if (!Arrays.asList(natures).contains(pluginNature)) {
+ final String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = pluginNature;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, new NullProgressMonitor());
+ }
+ }
+
+ public static void addPdeBuilder(final IProject project) throws CoreException {
+ final IProjectDescription projectDescription = project.getDescription();
+ final ICommand[] oldBuildSpec = project.getDescription().getBuildSpec();
+ for (final ICommand command : oldBuildSpec) {
+ if ("org.eclipse.pde.ManifestBuilder".equals(command.getBuilderName())) { //$NON-NLS-1$
+ return;
+ }
+ }
+ final ICommand[] newBuildSpec = new ICommand[oldBuildSpec.length + 2];
+ System.arraycopy(oldBuildSpec, 0, newBuildSpec, 0, oldBuildSpec.length);
+ final ICommand command1 = project.getDescription().newCommand();
+ command1.setBuilderName("org.eclipse.pde.ManifestBuilder"); //$NON-NLS-1$
+ final ICommand command2 = project.getDescription().newCommand();
+ command2.setBuilderName("org.eclipse.pde.SchemaBuilder"); //$NON-NLS-1$
+ newBuildSpec[oldBuildSpec.length] = command1;
+ newBuildSpec[oldBuildSpec.length + 1] = command2;
+ projectDescription.setBuildSpec(newBuildSpec);
+ project.setDescription(projectDescription, new NullProgressMonitor());
+ }
+
+ /**
+ * @author Gregoire Dupe (Mia-Software) - classpath entries modification
+ */
+ public static void configureAsJavaProject(final IProject project, final IProgressMonitor monitor)
+ throws CoreException {
+ ProjectUtils.addNature(project, monitor, JavaCore.NATURE_ID);
+ final IJavaProject javaProject = JavaCore.create(project);
+ // Set output folder
+ final IPath path = project.getFullPath().append("bin"); //$NON-NLS-1$
+ javaProject.setOutputLocation(path, null);
+ final List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
+ // Set source folder
+ final IFolder sourceFolder = project.getFolder("src"); //$NON-NLS-1$
+ if (!sourceFolder.exists()) {
+ sourceFolder.create(false, true, monitor);
+ classpathEntries.add(JavaCore.newSourceEntry(javaProject.getPath().append(
+ new Path("src")))); //$NON-NLS-1$
+ }
+ final Path jrePath = new Path(JavaRuntime.JRE_CONTAINER
+ + "/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/" //$NON-NLS-1$
+ + ProjectUtils.JAVA_VERSION);
+ boolean hasJrePath = false;
+ final IClasspathEntry[] existingClassPath = javaProject.getRawClasspath();
+ for (final IClasspathEntry classpathEntry : existingClassPath) {
+ if (jrePath.equals(classpathEntry.getPath())) {
+ hasJrePath = true;
+ }
+ }
+ if (!hasJrePath) {
+ // add the jre api to the classpath
+ classpathEntries.add(JavaCore.newContainerEntry(jrePath));
+ javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[0]), monitor);
+ }
+ }
+
+ public static void configureAsPluginProject(final IProject project) throws CoreException {
+ // TODO PDE Operations would be useful here but they are internal in PDE
+ ProjectUtils.addPdeNature(project);
+ // PDE builders are automatically added when the PDE nature is added
+ // ProjectUtils.addPdeBuilder(project);
+ ProjectUtils.addPdeClassPath(project);
+ ProjectUtils.createManifest(project);
+ ProjectUtils.createActivator(project);
+ }
+
+ public static void addNature(final IProject project, final IProgressMonitor monitor,
+ final String natureId) throws CoreException {
+ final IProjectDescription description = project.getDescription();
+ final String[] natures = description.getNatureIds();
+ if (!Arrays.asList(natures).contains(natureId)) {
+ final String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 1, natures.length);
+ newNatures[0] = natureId;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, monitor);
+ }
+ }
+
+ /**
+ * @author Gregoire Dupe (Mia-Software) - initial implementation
+ */
+ public static void createBuildProperties(final IProject project) throws CoreException {
+ final IFile buildFile = project.getFile("build.properties"); //$NON-NLS-1$
+ if (!buildFile.exists()) {
+ final StringBuffer buildSB = new StringBuffer();
+ buildSB.append("source.. = src/\n"); //$NON-NLS-1$
+ buildSB.append("output.. = bin/\n"); //$NON-NLS-1$
+ buildSB.append("bin.includes = META-INF/,\\\n"); //$NON-NLS-1$
+ buildSB.append(" .\n"); //$NON-NLS-1$
+ final InputStream source = new ByteArrayInputStream(buildSB.toString().getBytes());
+ buildFile.create(source, true, new NullProgressMonitor());
+ }
+ }
+
+ /**
+ * Create an EMF Facet project
+ *
+ * @param project
+ * a reference to the project to create (it must not already exist)
+ * @param projectLocation
+ * @param monitor
+ * a progress monitor
+ * @throws CoreException
+ * in case of error
+ */
+ public static void createEmfFacetProject(final IProject project, final IPath projectLocation, final IProgressMonitor monitor)
+ throws CoreException {
+ ProjectUtils.createPluginProject(project, projectLocation, monitor, false);
+ ProjectUtils.addNature(project, monitor, CommonConstants.NATURE_ID);
+ monitor.done();
+ }
+
+ public static void createPluginProject(final IProject project, final IPath projectLocation, final IProgressMonitor monitor,
+ final boolean monitorDone) throws CoreException {
+ monitor.beginTask(Messages.ProjectUtils_createPluginProject, IProgressMonitor.UNKNOWN);
+ if (!project.exists()) {
+ final IProjectDescription description = project.getWorkspace().newProjectDescription(
+ project.getName());
+ if (!Platform.getLocation().equals(projectLocation)) {
+ description.setLocation(projectLocation);
+ }
+ project.create(description, monitor);
+ project.open(monitor);
+ ProjectUtils.configureAsJavaProject(project, monitor);
+ ProjectUtils.configureAsPluginProject(project);
+ ProjectUtils.createBuildProperties(project);
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "The project already exists")); //$NON-NLS-1$
+ }
+ if (monitorDone) {
+ monitor.done();
+ }
+ }
+
+ public static boolean isEmfFacetProject(final IProject project) {
+ try {
+ if (!project.isAccessible()) {
+ return false;
+ }
+ return project.getNature(CommonConstants.NATURE_ID) != null;
+ } catch (final CoreException e) {
+ Logger.logError(e, Activator.getDefault());
+ return false;
+ }
+ }
+
+ public static boolean isInEmfFacetProject(final IPath path) {
+ final IProject project = getProject(path);
+ return isEmfFacetProject(project);
+ }
+
+ public static IProject getProject(final IPath path) {
+ final IProject project;
+ if (path.segmentCount() == 1) {
+ project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(path.segment(0));
+ } else {
+ final IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+ project = folder.getProject();
+ }
+ return project;
+ }
+}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/messages.properties
new file mode 100644
index 00000000000..c96b421ec74
--- /dev/null
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.common.sdk.core/src/org/eclipse/emf/facet/common/sdk/core/internal/messages.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2012 CEA LIST.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
+###############################################################################
+ProjectUtils_createEMFFacetProject=Create EMF Facet project
+ProjectUtils_createPluginProject=Create Plug-in project

Back to the top