Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible')
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/AbstractReversible.java9
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/Reversible.java15
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extension/AbstractExtension.java9
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/AbstractExtensionPoint.java7
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/WorkspaceExtensionPoint.java22
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/factory/ReversibleFactory.java259
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ExportPackage.java86
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ImportPackage.java86
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ReversiblePackage.java31
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/AbstractPlugin.java277
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/FragmentPlugin.java146
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/LoadedPlugin.java111
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleFeature.java245
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversiblePlugin.java37
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleProject.java17
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/StereotypeVersion.java212
-rw-r--r--extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/WorkspacePlugin.java247
17 files changed, 1463 insertions, 353 deletions
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/AbstractReversible.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/AbstractReversible.java
index ca5481c2e20..e886037e119 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/AbstractReversible.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/AbstractReversible.java
@@ -104,13 +104,8 @@ public abstract class AbstractReversible<T extends NamedElement> implements Reve
return false;
}
- /**
- * Ensures the stereotype is applied. If not, applies it. Returns true if
- * the stereotype is applied, false if the stereotype does not exist.
- *
- * @return
- */
- protected boolean applyStereotype() {
+ @Override
+ public boolean applyStereotype() {
// The getRepresentation() method instantiates the field and avoids null pointer
stereotype = getRepresentation().getAppliedStereotype(getStereotypeName());
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/Reversible.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/Reversible.java
index dcb1373e271..fecb192a974 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/Reversible.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/Reversible.java
@@ -21,8 +21,7 @@ import org.eclipse.uml2.uml.NamedElement;
* <ul>
* <li>an identifier that corresponds to the adapted class identifier,</li>
* <li>a UML representation that should extend the
- * {@link org.eclipse.uml2.uml.NamedElement NamedElement} interface,
- * </li>
+ * {@link org.eclipse.uml2.uml.NamedElement NamedElement} interface,</li>
* <li>a type,</li>
* <li>a stereotype name that will be applied to its representation,</li>
* <li>and a stereotype that will be applied to the dependency links to this
@@ -33,7 +32,7 @@ import org.eclipse.uml2.uml.NamedElement;
public interface Reversible<T extends NamedElement> {
enum Type {
- BUNDLE, FEATURE, PLUGIN, EXTENSION_POINT, EXTENSION
+ BUNDLE, FEATURE, PLUGIN, EXTENSION_POINT, EXTENSION, IMPORT_PACKAGE, EXPORT_PACKAGE
};
/**
@@ -84,7 +83,15 @@ public interface Reversible<T extends NamedElement> {
void setRepresentation(T representation);
/**
- * Applies the stereotype and fills its values.
+ * Applies the reversible's stereotype on its representation. Returns true
+ * if the stereotype is applied, false if not exist.
+ *
+ * @return true if the stereotype is applied, false if not
+ */
+ boolean applyStereotype();
+
+ /**
+ * Ensures the stereotype is applied and fills its values.
*/
void fillStereotype();
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extension/AbstractExtension.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extension/AbstractExtension.java
index 3123a3fae9d..8ce85ac4274 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extension/AbstractExtension.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extension/AbstractExtension.java
@@ -13,12 +13,11 @@ package org.eclipse.papyrus.adltool.reversible.extension;
import static org.eclipse.papyrus.adltool.Activator.log;
-import org.eclipse.papyrus.adl4eclipse.org.IADL4ECLIPSE_Stereotype;
+import org.eclipse.papyrus.adl4eclipse.org.ADL4Eclipse_Stereotypes;
import org.eclipse.papyrus.adltool.reversible.AbstractReversible;
import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtensionPoint;
import org.eclipse.papyrus.adltool.reversible.factory.ReversibleFactory;
import org.eclipse.papyrus.adltool.reversible.project.ReversibleProject;
-import org.eclipse.papyrus.osgi.profile.IOSGIStereotype;
import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.UMLFactory;
@@ -27,7 +26,7 @@ import org.eclipse.uml2.uml.UMLFactory;
* type, stereotype name to be applied) of the {@link ReversibleExtension}
* adapter.
*/
-public abstract class AbstractExtension extends AbstractReversible<InstanceSpecification>implements ReversibleExtension {
+public abstract class AbstractExtension extends AbstractReversible<InstanceSpecification> implements ReversibleExtension {
protected ReversibleProject parent;
@@ -43,12 +42,12 @@ public abstract class AbstractExtension extends AbstractReversible<InstanceSpeci
@Override
public String getStereotypeName() {
- return IADL4ECLIPSE_Stereotype.EXTENSION_STEREOTYPE;
+ return ADL4Eclipse_Stereotypes.EXTENSION_STEREOTYPE;
}
@Override
public String getDependencyStereotypeName() {
- return IOSGIStereotype.EXTENSION_REFERENCE;
+ return ADL4Eclipse_Stereotypes.EXTENSION_REFERENCE;
}
@Override
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/AbstractExtensionPoint.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/AbstractExtensionPoint.java
index d5284f06276..bfd5502879e 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/AbstractExtensionPoint.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/AbstractExtensionPoint.java
@@ -11,10 +11,9 @@
*****************************************************************************/
package org.eclipse.papyrus.adltool.reversible.extensionpoint;
-import org.eclipse.papyrus.adl4eclipse.org.IADL4ECLIPSE_Stereotype;
+import org.eclipse.papyrus.adl4eclipse.org.ADL4Eclipse_Stereotypes;
import org.eclipse.papyrus.adltool.reversible.AbstractReversible;
import org.eclipse.papyrus.adltool.reversible.project.ReversibleProject;
-import org.eclipse.papyrus.osgi.profile.IOSGIStereotype;
import org.eclipse.uml2.uml.Component;
import org.eclipse.uml2.uml.UMLFactory;
@@ -38,12 +37,12 @@ public abstract class AbstractExtensionPoint extends AbstractReversible<Componen
@Override
public String getStereotypeName() {
- return IADL4ECLIPSE_Stereotype.EXTENSION_POINT_STEREOTYPE;
+ return ADL4Eclipse_Stereotypes.EXTENSION_POINT_STEREOTYPE;
}
@Override
public String getDependencyStereotypeName() {
- return IOSGIStereotype.EXTENSION_POINT_REFERENCE;
+ return ADL4Eclipse_Stereotypes.EXTENSION_POINT_REFERENCE;
}
@Override
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/WorkspaceExtensionPoint.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/WorkspaceExtensionPoint.java
index 0692d5dd98f..f1f811a4b57 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/WorkspaceExtensionPoint.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/extensionpoint/WorkspaceExtensionPoint.java
@@ -60,19 +60,21 @@ public class WorkspaceExtensionPoint extends AbstractExtensionPoint {
List<SchemaElement> result = new ArrayList<>();
ISchema schema = ADL4EclipseUtils.getSchema(getId());
- for (ISchemaElement element : schema.getElements()) {
- String elementName = element.getName();
- SchemaElement schemaElement = new SchemaElement(elementName);
+ if (schema != null) {
+ for (ISchemaElement element : schema.getElements()) {
+ String elementName = element.getName();
+ SchemaElement schemaElement = new SchemaElement(elementName);
- schemaElement.setType(element.getType().getName());
- schemaElement.setMinOccurs(element.getMinOccurs());
- schemaElement.setMaxOccurs(element.getMaxOccurs());
+ schemaElement.setType(element.getType().getName());
+ schemaElement.setMinOccurs(element.getMinOccurs());
+ schemaElement.setMaxOccurs(element.getMaxOccurs());
- for (ISchemaAttribute attribute : element.getAttributes()) {
- schemaElement.addAttribute(new SchemaAttribute(attribute.getName()));
- }
+ for (ISchemaAttribute attribute : element.getAttributes()) {
+ schemaElement.addAttribute(new SchemaAttribute(attribute.getName()));
+ }
- result.add(schemaElement);
+ result.add(schemaElement);
+ }
}
return result;
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/factory/ReversibleFactory.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/factory/ReversibleFactory.java
index cb8a1868838..6e650a12e3e 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/factory/ReversibleFactory.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/factory/ReversibleFactory.java
@@ -18,6 +18,10 @@ import java.util.Map;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.papyrus.adltool.reversible.project.FragmentPlugin;
import org.eclipse.papyrus.adltool.reversible.project.LoadedPlugin;
import org.eclipse.papyrus.adltool.reversible.project.ReversibleFeature;
import org.eclipse.papyrus.adltool.reversible.project.ReversiblePlugin;
@@ -30,9 +34,14 @@ import org.eclipse.papyrus.adltool.reversible.extension.ReversibleExtension;
import org.eclipse.papyrus.adltool.reversible.extensionpoint.LoadedExtensionPoint;
import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtensionPoint;
import org.eclipse.papyrus.adltool.reversible.extensionpoint.WorkspaceExtensionPoint;
+import org.eclipse.papyrus.adltool.reversible.packages.ExportPackage;
+import org.eclipse.papyrus.adltool.reversible.packages.ImportPackage;
+import org.eclipse.papyrus.adltool.reversible.packages.ReversiblePackage;
import org.eclipse.pde.core.plugin.IPluginExtension;
import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
import org.eclipse.pde.core.project.IBundleProjectDescription;
+import org.eclipse.pde.core.project.IPackageExportDescription;
+import org.eclipse.pde.core.project.IPackageImportDescription;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.osgi.framework.Bundle;
@@ -43,6 +52,11 @@ import org.osgi.framework.Bundle;
public class ReversibleFactory {
/**
+ * The type of reversible package (either EXPORT or IMPORT).
+ */
+ public enum ReversiblePackageType { EXPORT, IMPORT };
+
+ /**
* Map containing all the reversible features.
*/
private Map<String, ReversibleProject> features;
@@ -53,14 +67,24 @@ public class ReversibleFactory {
private Map<String, ReversibleProject> plugins;
/**
+ * Map containing all the extensions.
+ */
+ private Map<String, ReversibleExtension> extensions;
+
+ /**
* Map containing all the extension points.
*/
private Map<String, ReversibleExtensionPoint> extensionPoints;
/**
- * Map containing all the extensions.
+ * Map containing all the imported packages.
*/
- private Map<String, ReversibleExtension> extensions;
+ private Map<String, ReversiblePackage> importedPackages;
+
+ /**
+ * Map containing all the exported packages.
+ */
+ private Map<String, ReversiblePackage> exportedPackages;
/**
* The singleton instance of the factory.
@@ -86,12 +110,14 @@ public class ReversibleFactory {
private ReversibleFactory() {
plugins = new HashMap<>();
features = new HashMap<>();
- extensionPoints = new HashMap<>();
extensions = new HashMap<>();
+ extensionPoints = new HashMap<>();
+ importedPackages = new HashMap<>();
+ exportedPackages = new HashMap<>();
}
/**
- * Gets a reversible project.
+ * Gets a reversible feature project.
*
* @param id the id of the reversible project to be returned
* @return the reversible project to which the specified id is mapped, or null if the project does not exist.
@@ -100,6 +126,12 @@ public class ReversibleFactory {
return features.get(id);
}
+ /**
+ * Gets a reversible plug-in project.
+ *
+ * @param id the id of the reversible project to be returned
+ * @return the reversible project to which the specified id is mapped, or null if the project does not exist.
+ */
public ReversibleProject getPlugin(String id) {
return plugins.get(id);
}
@@ -107,7 +139,7 @@ public class ReversibleFactory {
/**
* Gets a reversible extension point.
*
- * @param id
+ * @param id the id of the reversible extension point to be returned
* @return the reversible extension point with the corresponding id or null
* if the extension point does not exist.
*/
@@ -118,7 +150,7 @@ public class ReversibleFactory {
/**
* Gets a reversible extension.
*
- * @param id
+ * @param id the id of the reversible extension to be returned
* @return the reversible extension with the corresponding id or null if the
* extension point does not exist.
*/
@@ -126,12 +158,19 @@ public class ReversibleFactory {
return extensions.get(id);
}
+ /**
+ * Remove a plug-in from the map.
+ *
+ * @param id the id of the reversible plug-in to remove
+ */
public void removePlugin(String id) {
ReversibleProject reversible = getPlugin(id);
if (reversible instanceof ReversiblePlugin) {
ReversiblePlugin reversiblePlugin = (ReversiblePlugin) reversible;
+ // TODO: Remove project's package, but some package can have the same name.
+
for (ReversibleExtensionPoint extensionPoint : reversiblePlugin.getExtensionPoints()) {
removeExtensionPoint(extensionPoint.getId());
}
@@ -144,6 +183,11 @@ public class ReversibleFactory {
plugins.remove(id);
}
+ /**
+ * Removes a feature from the map.
+ *
+ * @param id the id of the reversible feature to remove
+ */
public void removeFeature(String id) {
features.remove(id);
}
@@ -151,7 +195,7 @@ public class ReversibleFactory {
/**
* Removes an extension point from the map.
*
- * @param id
+ * @param id the id of the reversible extension point to remove
*/
private void removeExtensionPoint(String id) {
extensionPoints.remove(id);
@@ -160,89 +204,37 @@ public class ReversibleFactory {
/**
* Removes an extension from the map.
*
- * @param id
+ * @param id the id of the reversible extension to remove
*/
private void removeExtension(String id) {
extensions.remove(id);
}
/**
- * Builds a reversible adapter from a plug-in project and stores it in a
- * map. The plug-in's extension points and extensions will also be adapted
- * and saved in other maps.
+ * Builds a reversible adapter from a workspace plug-in project and stores
+ * it in a map. The plug-in's extension points and extensions will also
+ * be adapted and saved in other maps.
*
- * @param pluginDescription
+ * @param pluginDescription the description of the OSGi bundle
* @return the reversible plug-in project
*/
public ReversiblePlugin makeReversible(IBundleProjectDescription pluginDescription) {
ReversiblePlugin project = new WorkspacePlugin(pluginDescription);
registerPlugin(project);
- // Save the extension points
- IPluginExtensionPoint[] pluginExtensionPoints = ADL4EclipseUtils.findExtensionPointsForPlugin(project.getId());
- List<ReversibleExtensionPoint> extensionPoints = new ArrayList<>();
-
- for (IPluginExtensionPoint pluginExtensionPoint : pluginExtensionPoints) {
- ReversibleExtensionPoint extensionPoint = makeReversible(pluginExtensionPoint);
-
- extensionPoint.setParent(project);
- extensionPoints.add(extensionPoint);
- }
-
- project.setExtensionPoints(extensionPoints);
-
- // Save the extensions
- IPluginExtension[] pluginExtensions = ADL4EclipseUtils.findExtensionsForPlugin(project.getId());
- List<ReversibleExtension> extensions = new ArrayList<>();
-
- for (IPluginExtension extension : pluginExtensions) {
- ReversibleExtension reversibleExtension = makeReversible(extension);
-
- reversibleExtension.setParent(project);
- extensions.add(reversibleExtension);
- }
-
- project.setExtensions(extensions);
-
return project;
}
/**
* Builds a reversible adapter from a bundle project and save it.
*
- * @param bundle
+ * @param bundle the OSGi bundle
* @return the reversible bundle project
*/
public ReversiblePlugin makeReversible(Bundle bundle) {
ReversiblePlugin project = new LoadedPlugin(bundle);
registerPlugin(project);
- // Save the extension points
- IExtensionPoint[] bundleExtensionPoints = ADL4EclipseUtils.findExtensionPointsForBundle(bundle.getBundleId(), project.getId());
- List<ReversibleExtensionPoint> extensionPoints = new ArrayList<>();
-
- for (IExtensionPoint bundleExtensionPoint : bundleExtensionPoints) {
- ReversibleExtensionPoint extensionPoint = makeReversible(bundleExtensionPoint);
-
- extensionPoint.setParent(project);
- extensionPoints.add(extensionPoint);
- }
-
- project.setExtensionPoints(extensionPoints);
-
- // Save the extensions
- IExtension[] bundleExtensions = ADL4EclipseUtils.findExtensionsForBundle(bundle.getBundleId(), project.getId());
- List<ReversibleExtension> extensions = new ArrayList<>();
-
- for (IExtension extension : bundleExtensions) {
- ReversibleExtension reversibleExtension = makeReversible(extension);
-
- reversibleExtension.setParent(project);
- extensions.add(reversibleExtension);
- }
-
- project.setExtensions(extensions);
-
return project;
}
@@ -312,6 +304,116 @@ public class ReversibleFactory {
}
/**
+ * Builds a reversible workspace imported package.
+ *
+ * @param importPackage
+ * @return
+ */
+ public ReversiblePackage makeReversible(IPackageImportDescription importPackage) {
+ ReversiblePackage importedPackage = new ImportPackage(importPackage);
+ registerImportedPackage(importedPackage);
+
+ return importedPackage;
+ }
+
+ /**
+ * Builds a reversible workspace exported package.
+ *
+ * @param exportPackage
+ * @return
+ */
+ public ReversiblePackage makeReversible(IPackageExportDescription exportPackage) {
+ ReversiblePackage exportedPackage = new ExportPackage(exportPackage);
+ registerExportedPackage(exportedPackage);
+
+ return exportedPackage;
+ }
+
+ /**
+ * Builds a reversible exported package.
+ *
+ * @param exportPackage
+ * @return
+ */
+ public ReversiblePackage makeReversible(ExportPackageDescription exportPackage) {
+ ReversiblePackage exportedPackage = new ExportPackage(exportPackage);
+ registerExportedPackage(exportedPackage);
+
+ return exportedPackage;
+ }
+
+ /**
+ *
+ * @param importPackage
+ * @return
+ */
+ public ReversiblePackage makeReversible(ImportPackageSpecification importPackage) {
+ ReversiblePackage importedPackage = new ImportPackage(importPackage);
+ registerImportedPackage(importedPackage);
+
+ return importedPackage;
+ }
+
+ /**
+ *
+ * @param bundleDescription
+ * @return
+ */
+ public ReversibleProject makeReversible(BundleDescription bundleDescription) {
+ ReversiblePlugin plugin = new FragmentPlugin(bundleDescription);
+ registerPlugin(plugin);
+
+ // Save the extension points
+ IPluginExtensionPoint[] pluginExtensionPoints = ADL4EclipseUtils.findExtensionPointsForPlugin(plugin.getId());
+ List<ReversibleExtensionPoint> extensionPoints = new ArrayList<>();
+
+ for (IPluginExtensionPoint pluginExtensionPoint : pluginExtensionPoints) {
+ ReversibleExtensionPoint extensionPoint = makeReversible(pluginExtensionPoint);
+
+ extensionPoint.setParent(plugin);
+ extensionPoints.add(extensionPoint);
+ }
+
+ plugin.setExtensionPoints(extensionPoints);
+
+ // Save the extensions
+ IPluginExtension[] pluginExtensions = ADL4EclipseUtils.findExtensionsForPlugin(plugin.getId());
+ List<ReversibleExtension> extensions = new ArrayList<>();
+
+ for (IPluginExtension extension : pluginExtensions) {
+ ReversibleExtension reversibleExtension = makeReversible(extension);
+
+ reversibleExtension.setParent(plugin);
+ extensions.add(reversibleExtension);
+ }
+
+ plugin.setExtensions(extensions);
+
+ return plugin;
+ }
+
+ /**
+ * Create a reversible package from a {@link ReversiblePackageType type}.
+ *
+ * @param id the name of the package
+ * @param type the type of the package
+ * @return
+ */
+ public ReversiblePackage makeReversible(String id, ReversiblePackageType type) {
+ ReversiblePackage reversiblePackage;
+
+ if (ReversiblePackageType.EXPORT == type) {
+ reversiblePackage = new ExportPackage(id);
+ registerExportedPackage(reversiblePackage);
+ } else {
+ reversiblePackage = new ImportPackage(id);
+ registerImportedPackage(reversiblePackage);
+ }
+
+ return reversiblePackage;
+ }
+
+ /**
* Saves a reversible plug-in in a map.
*
* @param plugin
@@ -335,6 +437,7 @@ public class ReversibleFactory {
if (savedFeature == null || savedFeature.equals(feature)) {
features.put(feature.getId(), feature);
}
+ // else: name & type conflict
}
/**
@@ -363,4 +466,30 @@ public class ReversibleFactory {
}
}
+ /**
+ * Saves an imported package in a map.
+ *
+ * @param importedPackage
+ */
+ private void registerImportedPackage(ReversiblePackage importedPackage) {
+ ReversiblePackage savedPackage = importedPackages.get(importedPackage.getId());
+
+ if (savedPackage == null || savedPackage.equals(importedPackage)) {
+ importedPackages.put(importedPackage.getId(), importedPackage);
+ }
+ }
+
+ /**
+ * Saves an exported package in a map.
+ *
+ * @param exportedPackage
+ */
+ private void registerExportedPackage(ReversiblePackage exportedPackage) {
+ ReversiblePackage savedPackage = exportedPackages.get(exportedPackage.getId());
+
+ if (savedPackage == null || savedPackage.equals(exportedPackage)) {
+ exportedPackages.put(exportedPackage.getId(), exportedPackage);
+ }
+ }
+
}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ExportPackage.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ExportPackage.java
new file mode 100644
index 00000000000..23c2f34162e
--- /dev/null
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ExportPackage.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Thomas Daniellou (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.adltool.reversible.packages;
+
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.papyrus.adltool.reversible.AbstractReversible;
+import org.eclipse.papyrus.adltool.reversible.project.ReversibleProject;
+import org.eclipse.papyrus.osgi.profile.OSGIStereotypes;
+import org.eclipse.pde.core.project.IPackageExportDescription;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+
+public class ExportPackage extends AbstractReversible<Package> implements ReversiblePackage {
+
+ private String id;
+ private ReversibleProject parent;
+
+ public ExportPackage(String id) {
+ this.id = id;
+ }
+
+ public ExportPackage(ExportPackageDescription exportPackage) {
+ id = exportPackage.getName();
+ /*
+ Version version = exportPackage.getVersion();
+
+ if (version != null) {
+ dependencyVersion = new DependencyVersion(version);
+ }
+ */
+ }
+
+ public ExportPackage(IPackageExportDescription exportPackage) {
+ id = exportPackage.getName();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getStereotypeName() {
+ return OSGIStereotypes.EXPORTED_PACKAGE_STEREOTYPE;
+ }
+
+ @Override
+ public Type getType() {
+ return Type.EXPORT_PACKAGE;
+ }
+
+ @Override
+ public String getDependencyStereotypeName() {
+ return OSGIStereotypes.PACKAGE_REFERENCE;
+ }
+
+ @Override
+ protected Package createRepresentation() {
+ return UMLFactory.eINSTANCE.createPackage();
+ }
+
+ @Override
+ public void fillStereotype() {
+ // Empty: no stereotypes values to set
+ }
+
+ @Override
+ public ReversibleProject getParent() {
+ return parent;
+ }
+
+ @Override
+ public void setParent(ReversibleProject parent) {
+ this.parent = parent;
+ }
+
+}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ImportPackage.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ImportPackage.java
new file mode 100644
index 00000000000..69d0fdd7f1a
--- /dev/null
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ImportPackage.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Thomas Daniellou (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.adltool.reversible.packages;
+
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.papyrus.adltool.reversible.AbstractReversible;
+import org.eclipse.papyrus.adltool.reversible.project.ReversibleProject;
+import org.eclipse.papyrus.osgi.profile.OSGIStereotypes;
+import org.eclipse.pde.core.project.IPackageImportDescription;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.UMLFactory;
+
+public class ImportPackage extends AbstractReversible<Package> implements ReversiblePackage {
+
+ private String id;
+ private ReversibleProject parent;
+
+ public ImportPackage(String id) {
+ this.id = id;
+ }
+
+ public ImportPackage(ImportPackageSpecification importPackage) {
+ id = importPackage.getName();
+ /*
+ VersionRange versionRange = importPackage.getVersionRange();
+
+ if (versionRange != null) {
+ dependencyVersion = new DependencyVersion(versionRange);
+ }
+ */
+ }
+
+ public ImportPackage(IPackageImportDescription importPackage) {
+ id = importPackage.getName();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getStereotypeName() {
+ return OSGIStereotypes.IMPORTED_PACKAGE_STEREOTYPE;
+ }
+
+ @Override
+ public Type getType() {
+ return Type.IMPORT_PACKAGE;
+ }
+
+ @Override
+ public String getDependencyStereotypeName() {
+ return OSGIStereotypes.PACKAGE_REFERENCE;
+ }
+
+ @Override
+ protected Package createRepresentation() {
+ return UMLFactory.eINSTANCE.createPackage();
+ }
+
+ @Override
+ public void fillStereotype() {
+ // Empty: no stereotypes values to set
+ }
+
+ @Override
+ public ReversibleProject getParent() {
+ return parent;
+ }
+
+ @Override
+ public void setParent(ReversibleProject parent) {
+ this.parent = parent;
+ }
+
+}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ReversiblePackage.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ReversiblePackage.java
new file mode 100644
index 00000000000..1692a8da595
--- /dev/null
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/packages/ReversiblePackage.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Thomas Daniellou (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.adltool.reversible.packages;
+
+import org.eclipse.papyrus.adltool.reversible.Reversible;
+import org.eclipse.papyrus.adltool.reversible.project.ReversibleProject;
+import org.eclipse.uml2.uml.Package;
+
+public interface ReversiblePackage extends Reversible<Package> {
+
+ /**
+ * Gets the ReversibleProject parent of this package.
+ * @return
+ */
+ ReversibleProject getParent();
+
+ /**
+ * Sets the ReversibleProject parent of this package.
+ * @param parent
+ */
+ void setParent(ReversibleProject parent);
+}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/AbstractPlugin.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/AbstractPlugin.java
new file mode 100644
index 00000000000..24f0c7ae356
--- /dev/null
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/AbstractPlugin.java
@@ -0,0 +1,277 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Thomas Daniellou (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.adltool.reversible.project;
+
+import static org.eclipse.papyrus.adltool.Activator.log;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.papyrus.adltool.reversible.AbstractReversible;
+import org.eclipse.papyrus.adltool.reversible.Reversible;
+import org.eclipse.papyrus.adltool.reversible.extension.ReversibleExtension;
+import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtensionPoint;
+import org.eclipse.papyrus.adltool.reversible.packages.ReversiblePackage;
+import org.eclipse.papyrus.osgi.profile.OSGIStereotypes;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * This abstract class provides the default implementation of the
+ * {@link ReversiblePlugin} adapter.
+ */
+public abstract class AbstractPlugin extends AbstractReversible<Component> implements ReversiblePlugin {
+
+ /**
+ * Map containing all the versions of reversible project or package.
+ */
+ protected Map<Reversible<?>, StereotypeVersion> reversibleVersion;
+
+ /**
+ * The list of packages exported by this plug-in.
+ */
+ protected List<ReversiblePackage> exportedPackages;
+
+ /**
+ * The list of packages imported by this plug-in.
+ */
+ protected List<ReversiblePackage> importedPackages;
+
+ /**
+ * The list of extension points defined by this plug-in.
+ */
+ protected List<ReversibleExtensionPoint> extensionPoints;
+
+ /**
+ * The list of extensions defined by this plug-in.
+ */
+ protected List<ReversibleExtension> extensions;
+
+ /**
+ * Gets a value in the plug-in manifest.
+ *
+ * @param key the key of the value to retrieve.
+ * @return the corresponding value in the plug-in manifest
+ */
+ protected abstract String getBundleValue(String key);
+
+ public AbstractPlugin() {
+ reversibleVersion = new HashMap<>();
+ }
+
+ @Override
+ public List<ReversiblePackage> getExportedPackages() {
+ return exportedPackages;
+ }
+
+ @Override
+ public void setExportedPackages(List<ReversiblePackage> exportedPackages) {
+ this.exportedPackages = exportedPackages;
+ }
+
+ @Override
+ public List<ReversiblePackage> getImportedPackages() {
+ return importedPackages;
+ }
+
+ @Override
+ public void setImportedPackages(List<ReversiblePackage> importedPackages) {
+ this.importedPackages = importedPackages;
+ }
+
+ @Override
+ public List<ReversibleExtensionPoint> getExtensionPoints() {
+ return extensionPoints;
+ }
+
+ @Override
+ public void setExtensionPoints(List<ReversibleExtensionPoint> extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+
+ @Override
+ public List<ReversibleExtension> getExtensions() {
+ return extensions;
+ }
+
+ @Override
+ public void setExtensions(List<ReversibleExtension> extensions) {
+ this.extensions = extensions;
+ }
+
+ @Override
+ public String getDescription() {
+ String bundleDescription = getBundleValue(Constants.BUNDLE_DESCRIPTION);
+
+ return bundleDescription != null ? bundleDescription : "";
+ }
+
+ @Override
+ public String getDependencyStereotypeName() {
+ return OSGIStereotypes.BUNDLE_REFERENCE;
+ }
+
+ @Override
+ public Component createRepresentation() {
+ return UMLFactory.eINSTANCE.createComponent();
+ }
+
+ public List<ManifestElement> extractManifestHeader(String header) {
+ List<ManifestElement> result = new ArrayList<>();
+ String value = getBundleValue(header);
+
+ try {
+ ManifestElement[] manifests = ManifestElement.parseHeader(header, value);
+
+ if (manifests != null) {
+ for (ManifestElement manifest : manifests) {
+ result.add(manifest);
+ }
+ }
+ } catch (BundleException e) {
+ log.error(e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Retrieves a list of stereotyped applications from a list of bundleId and
+ * store it in the representation's stereotype at the propertyName value.
+ *
+ * @param propertyName the name of the property to set the value.
+ * @param requireBundleIds the array of identifiable to set
+ * @param stereotypeIdentifier the stereotype qualified name of the EObject to save
+ */
+ protected void setStereotypeValues(String propertyName, List<ManifestElement> requireBundleIds, String stereotypeIdentifier) {
+ List<EObject> pluginReferences = new ArrayList<>();
+
+ for (ManifestElement bundle : requireBundleIds) {
+ // The stereotype takes stereotyped dependencies that are inside the representation
+ Dependency dependency = getElement(bundle.getValue(), Dependency.class);
+
+ if (dependency != null) {
+ Stereotype dependencyStereotype = dependency.getAppliedStereotype(stereotypeIdentifier);
+
+ if (dependencyStereotype != null) {
+ EObject stereotypeApplication = dependency.getStereotypeApplication(dependencyStereotype);
+
+ if (stereotypeApplication != null) {
+ pluginReferences.add(stereotypeApplication);
+ }
+ }
+ }
+ }
+
+ representation.setValue(stereotype, propertyName, pluginReferences);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void fillStereotype() {
+ if (!applyStereotype()) {
+ log.warn("(" + getType() +") " + getId() + " cannot fill the stereotype properties");
+ return;
+ }
+
+ Map<String, String> stereotypeKeyValues = new HashMap<>();
+
+ // ActivationPolicy
+ stereotypeKeyValues.put(Constants.BUNDLE_ACTIVATIONPOLICY, OSGIStereotypes.BUNDLE_ACTIVATION_POLICY_ATT);
+ // Activator
+ stereotypeKeyValues.put(Constants.BUNDLE_ACTIVATOR, OSGIStereotypes.BUNDLE_ACTIVATOR_ATT);
+ // Category
+ stereotypeKeyValues.put(Constants.BUNDLE_CATEGORY, OSGIStereotypes.BUNDLE_CATEGORY_ATT);
+ // Classpath
+ stereotypeKeyValues.put(Constants.BUNDLE_CLASSPATH, OSGIStereotypes.BUNDLE_CLASSPATH_ATT);
+ // Contact address
+ stereotypeKeyValues.put(Constants.BUNDLE_CONTACTADDRESS, OSGIStereotypes.BUNDLE_CONTACTADDRESS_ATT);
+ // Copyright
+ stereotypeKeyValues.put(Constants.BUNDLE_COPYRIGHT, OSGIStereotypes.BUNDLE_COPYRIGHT_ATT);
+ // Description
+ stereotypeKeyValues.put(Constants.BUNDLE_DESCRIPTION, OSGIStereotypes.BUNDLE_DESCRIPTION_ATT);
+ // DocURL
+ stereotypeKeyValues.put(Constants.BUNDLE_DOCURL, OSGIStereotypes.BUNDLE_DOCURL_ATT);
+ // Icon
+ stereotypeKeyValues.put(Constants.BUNDLE_ICON, OSGIStereotypes.BUNDLE_ICON_ATT);
+ // License
+ stereotypeKeyValues.put(Constants.BUNDLE_LICENSE, OSGIStereotypes.BUNDLE_LICENSE_ATT);
+ // Localization
+ stereotypeKeyValues.put(Constants.BUNDLE_LOCALIZATION, OSGIStereotypes.BUNDLE_LOCALIZATION_ATT);
+ // Manifest version
+ stereotypeKeyValues.put(Constants.BUNDLE_MANIFESTVERSION, OSGIStereotypes.BUNDLE_MANIFESTVERSION_ATT);
+ // Name
+ stereotypeKeyValues.put(Constants.BUNDLE_NAME, OSGIStereotypes.BUNDLE_NAME_ATT);
+ // NativeCode
+ stereotypeKeyValues.put(Constants.BUNDLE_NATIVECODE, OSGIStereotypes.BUNDLE_NATIVECODE_ATT);
+ // ProvideCapability
+ stereotypeKeyValues.put(Constants.PROVIDE_CAPABILITY, OSGIStereotypes.BUNDLE_PROVIDE_CAPABILITY_ATT);
+ // RequireCapability
+ stereotypeKeyValues.put(Constants.REQUIRE_CAPABILITY, OSGIStereotypes.BUNDLE_REQUIRE_CAPABILITY_ATT);
+ // RequiredExecutionEnvironment
+ stereotypeKeyValues.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, OSGIStereotypes.BUNDLE_REQUIREDEXECUTIONENVIRONMENT_ATT);
+ // SymbolicName
+ representation.setValue(stereotype, OSGIStereotypes.BUNDLE_SYMBOLICNAME_ATT, getId());
+ // Update location
+ stereotypeKeyValues.put(Constants.BUNDLE_UPDATELOCATION, OSGIStereotypes.BUNDLE_UPDATELOCATION_ATT);
+ // Vendor
+ stereotypeKeyValues.put(Constants.BUNDLE_VENDOR, OSGIStereotypes.BUNDLE_VENDOR_ATT);
+ // Version
+ stereotypeKeyValues.put(Constants.BUNDLE_VERSION, OSGIStereotypes.BUNDLE_VERSION_ATT);
+
+ for (Map.Entry<String, String> entry : stereotypeKeyValues.entrySet()) {
+ String value = getBundleValue(entry.getKey());
+ if (value != null && value.length() > 0) {
+ representation.setValue(stereotype, entry.getValue(), value);
+ }
+ }
+
+ // Singleton
+ representation.setValue(stereotype, OSGIStereotypes.BUNDLE_ISSINGLETON_ATT, isSingleton());
+ // ExportPackage
+ List<ManifestElement> exportedPackages = extractManifestHeader(Constants.EXPORT_PACKAGE);
+ setStereotypeValues(OSGIStereotypes.BUNDLE_EXPORTPACKAGE_ATT, exportedPackages, OSGIStereotypes.PACKAGE_REFERENCE);
+
+ // ImportPackage
+ List<ManifestElement> importedPackages = extractManifestHeader(Constants.IMPORT_PACKAGE);
+ setStereotypeValues(OSGIStereotypes.BUNDLE_IMPORTPACKAGE_ATT, importedPackages, OSGIStereotypes.PACKAGE_REFERENCE);
+
+ // RequireBundle
+ List<ManifestElement> requireBundleIds = extractManifestHeader(Constants.REQUIRE_BUNDLE);
+ setStereotypeValues(OSGIStereotypes.BUNDLE_REQUIREBUNDLE_ATT, requireBundleIds, OSGIStereotypes.BUNDLE_REFERENCE);
+
+ // DynamicImportPackage
+ // TODO
+
+ // FragmentHost
+ // TODO
+ }
+
+ @Override
+ public StereotypeVersion getReversibleVersion(Reversible<?> reversible) {
+ return reversibleVersion.get(reversible);
+ }
+
+ @Override
+ public void setReversibleVersion(Reversible<?> reversible, StereotypeVersion version) {
+ reversibleVersion.put(reversible, version);
+ }
+
+}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/FragmentPlugin.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/FragmentPlugin.java
new file mode 100644
index 00000000000..8a0ecb4f273
--- /dev/null
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/FragmentPlugin.java
@@ -0,0 +1,146 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Thomas Daniellou (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.adltool.reversible.project;
+
+import static org.eclipse.papyrus.adltool.Activator.log;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.papyrus.adltool.ADL4EclipseUtils;
+import org.eclipse.papyrus.adltool.reversible.factory.ReversibleFactory;
+import org.eclipse.papyrus.adltool.reversible.packages.ReversiblePackage;
+import org.eclipse.papyrus.osgi.profile.OSGIStereotypes;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Version;
+
+/**
+ * <p>This class is an adapter of the BundleDescription that represents a bundle in
+ * the system. (Loaded, workspace, fragment plug-ins)</p>
+ * <p>
+ * Since the workspace and loaded plug-ins are already adapted with the LoadedPlugin
+ * and WorkspacePlugin, this adapter can be used for Fragment plug-ins.</p>
+ * <p>
+ * For now, a reversed Fragment plug-in will be the same as a reversed
+ * LoadedPlugin.</p>
+ */
+public class FragmentPlugin extends AbstractPlugin {
+
+ /**
+ * The adaptee.
+ */
+ private BundleDescription bundleDescription;
+
+ public FragmentPlugin(BundleDescription bundleDescription) {
+ super();
+ this.bundleDescription = bundleDescription;
+ }
+
+ @Override
+ public String getId() {
+ return bundleDescription.getSymbolicName();
+ }
+
+ @Override
+ public String getStereotypeName() {
+ return OSGIStereotypes.BUNDLE;
+ }
+
+ @Override
+ public Type getType() {
+ return Type.BUNDLE;
+ }
+
+ @Override
+ public Image getImage() {
+ return ADL4EclipseUtils.getImage("img/bundle_obj.gif");
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return bundleDescription.isSingleton();
+ }
+
+ @Override
+ public List<ReversibleProject> getDependencies() {
+ List<ReversibleProject> dependencies = new ArrayList<>();
+ BundleSpecification[] requiredBundles = bundleDescription.getRequiredBundles();
+
+ if (requiredBundles != null) {
+ for (BundleSpecification requireBundle : requiredBundles) {
+ ReversibleProject plugin = ReversibleFactory.getInstance().getPlugin(requireBundle.getName());
+ if (plugin != null) {
+ dependencies.add(plugin);
+
+ VersionRange version = requireBundle.getVersionRange();
+ if (version != null) {
+ reversibleVersion.put(plugin, new StereotypeVersion(version));
+ }
+ } else {
+ log.warn(getType() + " \"" + getId() + "\": cannot find child " + requireBundle.getName());
+ }
+ }
+ }
+
+ return dependencies;
+ }
+
+ @Override
+ public List<ReversiblePackage> getExportedPackages() {
+ List<ReversiblePackage> exportedPackages = new ArrayList<>();
+ ExportPackageDescription[] exportPackages = bundleDescription.getExportPackages();
+
+ if (exportPackages != null) {
+ for (ExportPackageDescription exportPackage : exportPackages) {
+ ReversiblePackage reversibleExportPackage = ReversibleFactory.getInstance().makeReversible(exportPackage);
+ exportedPackages.add(reversibleExportPackage);
+
+ Version version = exportPackage.getVersion();
+ if (version != null) {
+ reversibleVersion.put(reversibleExportPackage, new StereotypeVersion(version));
+ }
+ }
+ }
+
+ return exportedPackages;
+ }
+
+ @Override
+ public List<ReversiblePackage> getImportedPackages() {
+ List<ReversiblePackage> importedPackages = new ArrayList<>();
+ ImportPackageSpecification[] importPackages = bundleDescription.getImportPackages();
+
+ if (importPackages != null) {
+ for (ImportPackageSpecification importPackage : importPackages) {
+ ReversiblePackage reversibleImportPackage = ReversibleFactory.getInstance().makeReversible(importPackage);
+ importedPackages.add(reversibleImportPackage);
+
+ VersionRange version = importPackage.getVersionRange();
+ if (version != null) {
+ reversibleVersion.put(reversibleImportPackage, new StereotypeVersion(version));
+ }
+ }
+ }
+
+ return importedPackages;
+ }
+
+ @Override
+ protected String getBundleValue(String key) {
+ // Unused
+ return null;
+ }
+}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/LoadedPlugin.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/LoadedPlugin.java
index a937445a19a..794da534e75 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/LoadedPlugin.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/LoadedPlugin.java
@@ -16,9 +16,17 @@ import static org.eclipse.papyrus.adltool.Activator.log;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.papyrus.adl4eclipse.org.IADL4ECLIPSE_Stereotype;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.papyrus.adltool.ADL4EclipseUtils;
+import org.eclipse.papyrus.adltool.reversible.extension.ReversibleExtension;
+import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtensionPoint;
import org.eclipse.papyrus.adltool.reversible.factory.ReversibleFactory;
+import org.eclipse.papyrus.adltool.reversible.factory.ReversibleFactory.ReversiblePackageType;
+import org.eclipse.papyrus.adltool.reversible.packages.ReversiblePackage;
+import org.eclipse.papyrus.osgi.profile.OSGIStereotypes;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
@@ -26,7 +34,7 @@ import org.osgi.framework.Constants;
/**
* This class is a reversible adapter of a loaded plug-in.
*/
-public class LoadedPlugin extends AbstractReversiblePlugin {
+public class LoadedPlugin extends AbstractPlugin {
private Bundle bundle;
@@ -36,7 +44,55 @@ public class LoadedPlugin extends AbstractReversiblePlugin {
* @param bundle
*/
public LoadedPlugin(Bundle bundle) {
+ super();
this.bundle = bundle;
+
+ List<ReversiblePackage> exportedPackages = new ArrayList<>();
+ List<ManifestElement> manifestExportedPackages = extractManifestHeader(Constants.EXPORT_PACKAGE);
+
+ for (ManifestElement exportedPackage : manifestExportedPackages) {
+ ReversiblePackage exportPackage = ReversibleFactory.getInstance().makeReversible(exportedPackage.getValue(), ReversiblePackageType.EXPORT);
+
+ exportPackage.setParent(this);
+ exportedPackages.add(exportPackage);
+ }
+
+ List<ManifestElement> manifestImportedPackages = extractManifestHeader(Constants.IMPORT_PACKAGE);
+ List<ReversiblePackage> importedPackages = new ArrayList<>();
+
+ for (ManifestElement importedPackage : manifestImportedPackages) {
+ ReversiblePackage importPackage = ReversibleFactory.getInstance().makeReversible(importedPackage.getValue(), ReversiblePackageType.IMPORT);
+
+ importPackage.setParent(this);
+ importedPackages.add(importPackage);
+ }
+
+ // Save the extension points
+ IExtensionPoint[] bundleExtensionPoints = ADL4EclipseUtils.findExtensionPointsForBundle(bundle.getBundleId(), getId());
+ List<ReversibleExtensionPoint> extensionPoints = new ArrayList<>();
+
+ for (IExtensionPoint bundleExtensionPoint : bundleExtensionPoints) {
+ ReversibleExtensionPoint extensionPoint = ReversibleFactory.getInstance().makeReversible(bundleExtensionPoint);
+
+ extensionPoint.setParent(this);
+ extensionPoints.add(extensionPoint);
+ }
+
+ // Save the extensions
+ IExtension[] bundleExtensions = ADL4EclipseUtils.findExtensionsForBundle(bundle.getBundleId(), getId());
+ List<ReversibleExtension> extensions = new ArrayList<>();
+
+ for (IExtension extension : bundleExtensions) {
+ ReversibleExtension reversibleExtension = ReversibleFactory.getInstance().makeReversible(extension);
+
+ reversibleExtension.setParent(this);
+ extensions.add(reversibleExtension);
+ }
+
+ setExportedPackages(exportedPackages);
+ setImportedPackages(importedPackages);
+ setExtensionPoints(extensionPoints);
+ setExtensions(extensions);
}
@Override
@@ -46,7 +102,7 @@ public class LoadedPlugin extends AbstractReversiblePlugin {
@Override
public String getStereotypeName() {
- return IADL4ECLIPSE_Stereotype.PLUGIN_STEREOTYPE;
+ return OSGIStereotypes.BUNDLE;
}
@Override
@@ -60,32 +116,41 @@ public class LoadedPlugin extends AbstractReversiblePlugin {
}
@Override
+ public boolean isSingleton() {
+ String isSingleton = getBundleValue(Constants.SINGLETON_DIRECTIVE);
+
+ return Boolean.valueOf(isSingleton);
+ }
+
+ @Override
public List<ReversibleProject> getDependencies() {
- List<ReversibleProject> children = new ArrayList<>();
- String requireBundles = getBundleValue(Constants.REQUIRE_BUNDLE);
+ List<ReversibleProject> dependencies = new ArrayList<>();
+ List<ManifestElement> requiredBundles = extractManifestHeader(Constants.REQUIRE_BUNDLE);
- if (requireBundles != null) {
- List<String> childrenIds = extractManifestHeader(Constants.REQUIRE_BUNDLE);
+ if (!requiredBundles.isEmpty()) {
+ for (ManifestElement requiredBundle : requiredBundles) {
+ String bundleId = requiredBundle.getValue();
- if (!childrenIds.isEmpty()) {
- for (String childId : childrenIds) {
- ReversibleProject reversibleChild = ReversibleFactory.getInstance().getPlugin(childId);
+ if (!Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(bundleId)) {
+ ReversibleProject reversibleChild = ReversibleFactory.getInstance().getPlugin(bundleId);
if (reversibleChild != null) {
- children.add(reversibleChild);
+ dependencies.add(reversibleChild);
+
+ // Version
+ String version = requiredBundle.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
+ if (version != null) {
+ VersionRange versionRange = new VersionRange(version);
+ reversibleVersion.put(reversibleChild, new StereotypeVersion(versionRange));
+ }
} else {
- log.warn("Bundle \"" + getId() + "\" : cannot find child " + childId);
+ log.warn(getType() + " \"" + getId() + "\": cannot find child " + bundleId);
}
}
}
}
- return children;
- }
-
- @Override
- public List<String> getExportedPackages() {
- return extractManifestHeader(Constants.EXPORT_PACKAGE);
+ return dependencies;
}
@Override
@@ -93,14 +158,4 @@ public class LoadedPlugin extends AbstractReversiblePlugin {
return bundle.getHeaders().get(key);
}
- @Override
- public void fillStereotype() {
- if (!applyStereotype()) {
- log.warn("(" + getType() +") " + getId() + " cannot fill the stereotype properties");
- return;
- }
-
- // TODO
- }
-
}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleFeature.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleFeature.java
index e2d239f1c7b..11f572b6eb2 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleFeature.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleFeature.java
@@ -13,20 +13,32 @@ package org.eclipse.papyrus.adltool.reversible.project;
import static org.eclipse.papyrus.adltool.Activator.log;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.adl4eclipse.org.IADL4ECLIPSE_Stereotype;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.papyrus.adl4eclipse.org.ADL4Eclipse_Stereotypes;
import org.eclipse.papyrus.adltool.ADL4EclipseUtils;
import org.eclipse.papyrus.adltool.reversible.AbstractReversible;
+import org.eclipse.papyrus.adltool.reversible.Reversible;
import org.eclipse.papyrus.adltool.reversible.factory.ReversibleFactory;
-import org.eclipse.papyrus.osgi.profile.IOSGIStereotype;
+import org.eclipse.papyrus.osgi.profile.OSGIStereotypes;
import org.eclipse.pde.core.IIdentifiable;
import org.eclipse.pde.internal.core.ifeature.IFeature;
+import org.eclipse.pde.internal.core.ifeature.IFeatureChild;
+import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
+import org.eclipse.pde.internal.core.ifeature.IFeatureInfo;
+import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
import org.eclipse.pde.internal.core.ifeature.IFeatureURL;
+import org.eclipse.pde.internal.core.ifeature.IFeatureURLElement;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.Dependency;
+import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
/**
@@ -35,6 +47,8 @@ import org.eclipse.uml2.uml.UMLFactory;
@SuppressWarnings("restriction")
public class ReversibleFeature extends AbstractReversible<Component> implements ReversibleProject {
+ private Map<Reversible<?>, StereotypeVersion> dependencyVersions;
+
private IFeature feature;
/**
@@ -44,6 +58,8 @@ public class ReversibleFeature extends AbstractReversible<Component> implements
*/
public ReversibleFeature(IFeature feature) {
this.feature = feature;
+
+ dependencyVersions = new HashMap<>();
}
@Override
@@ -53,12 +69,12 @@ public class ReversibleFeature extends AbstractReversible<Component> implements
@Override
public String getStereotypeName() {
- return IADL4ECLIPSE_Stereotype.FEATURE_STEREOTYPE;
+ return ADL4Eclipse_Stereotypes.FEATURE_STEREOTYPE;
}
@Override
public String getDependencyStereotypeName() {
- return IOSGIStereotype.FEATURE_REFERENCE;
+ return ADL4Eclipse_Stereotypes.FEATURE_REFERENCE;
}
@Override
@@ -73,71 +89,58 @@ public class ReversibleFeature extends AbstractReversible<Component> implements
@Override
public List<ReversibleProject> getDependencies() {
- List<ReversibleProject> children = new ArrayList<>();
-
- for (String featureId : getFeatureDependencies()) {
- ReversibleProject reversibleFeature = ReversibleFactory.getInstance().getFeature(featureId);
- if (reversibleFeature != null) {
- children.add(reversibleFeature);
- } else {
- log.warn(getType() + "\"" + getId() + "\": cannot find child " + featureId);
- }
- }
+ List<ReversibleProject> dependencies = new ArrayList<>();
- for (String pluginId : getPluginDependencies()) {
- ReversibleProject reversibleChild = ReversibleFactory.getInstance().getPlugin(pluginId);
+ for (IFeatureChild include : feature.getIncludedFeatures()) {
+ ReversibleProject reversibleFeature = ReversibleFactory.getInstance().getFeature(include.getId());
- if (reversibleChild != null) {
- children.add(reversibleChild);
+ if (reversibleFeature != null) {
+ dependencies.add(reversibleFeature);
+ VersionRange versionRange = new VersionRange(include.getVersion());
+ dependencyVersions.put(reversibleFeature, new StereotypeVersion(versionRange));
} else {
- log.warn(getType() + "\"" + getId() + "\" : cannot find child " + pluginId);
+ log.warn(getType() + " \"" + getId() + "\": cannot find child " + include.getId());
}
}
- return children;
- }
-
- public List<String> getFeatureDependencies() {
- List<String> features = new ArrayList<>();
+ for (IFeatureImport require : feature.getImports()) {
+ ReversibleProject reversibleProject = ReversibleFactory.getInstance().getFeature(require.getId());
- IIdentifiable[] includes = feature.getIncludedFeatures();
- IIdentifiable[] requires = feature.getImports();
-
- // Includes
- if (includes != null) {
- for (IIdentifiable include : includes) {
- features.add(include.getId());
+ if (reversibleProject == null) {
+ reversibleProject = ReversibleFactory.getInstance().getPlugin(require.getId());
}
- }
- // Requires
- if (requires != null) {
- for (IIdentifiable require : requires) {
- features.add(require.getId());
+ if (reversibleProject != null) {
+ dependencies.add(reversibleProject);
+ dependencyVersions.put(reversibleProject, new StereotypeVersion(require.getVersion()));
+ } else {
+ log.warn(getType() + " \"" + getId() + "\": cannot find child " + require.getId());
}
}
- return features;
- }
-
- public List<String> getPluginDependencies() {
- List<String> result = new ArrayList<>();
-
- IIdentifiable[] plugins = feature.getPlugins();
+ for (IFeaturePlugin plugin : feature.getPlugins()) {
+ ReversibleProject reversiblePlugin = ReversibleFactory.getInstance().getPlugin(plugin.getId());
- // Plug-ins
- if (plugins != null) {
- for (IIdentifiable plugin : plugins) {
- result.add(plugin.getId());
+ if (reversiblePlugin != null) {
+ dependencies.add(reversiblePlugin);
+ dependencyVersions.put(reversiblePlugin, new StereotypeVersion(plugin.getVersion()));
+ } else {
+ log.warn(getType() + " \"" + getId() + "\": cannot find child " + plugin.getId());
}
}
- return result;
+ return dependencies;
}
@Override
public String getDescription() {
- return feature.getFeatureInfo(IFeature.INFO_DESCRIPTION).getDescription();
+ IFeatureInfo featureInfo = feature.getFeatureInfo(IFeature.INFO_DESCRIPTION);
+
+ if (featureInfo != null) {
+ return featureInfo.getDescription();
+ }
+
+ return null;
}
@Override
@@ -152,55 +155,137 @@ public class ReversibleFeature extends AbstractReversible<Component> implements
return;
}
- // Description
- String description = feature.getFeatureInfo(IFeature.INFO_DESCRIPTION).getDescription();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_DESCRIPTION_ATT, description);
+ // Id
+ String id = feature.getId();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_ID_ATT, id);
- // Copyright
- String copyright = feature.getFeatureInfo(IFeature.INFO_COPYRIGHT).getDescription();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_COPYRIGHT_ATT, copyright);
+ // Label
+ String label = feature.getLabel();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_LABEL_ATT, label);
- // License
- String license = feature.getFeatureInfo(IFeature.INFO_LICENSE).getDescription();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_LICENSE_ATT, license);
+ // Version
+ String version = feature.getVersion();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_VERSION_ATT, version);
// Provider
String provider = feature.getProviderName();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_PROVIDER_ATT, provider);
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_PROVIDER_ATT, provider);
+
+ IFeatureInfo featureInfoDescription = feature.getFeatureInfo(IFeature.INFO_DESCRIPTION);
+ if (featureInfoDescription != null) {
+ // Description
+ String description = getDescription();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_DESCRIPTION_ATT, description);
- // Image
- String image = feature.getImageName();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_IMAGE_ATT, image);
+ // Description URL
+ String descriptionURL = featureInfoDescription.getURL();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_DESCRIPTION_URL_ATT, descriptionURL);
+ }
+
+ IFeatureInfo featureInfoCopyright = feature.getFeatureInfo(IFeature.INFO_COPYRIGHT);
+ if (featureInfoCopyright != null) {
+ // Copyright
+ String copyright = feature.getFeatureInfo(IFeature.INFO_COPYRIGHT).getDescription();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_COPYRIGHT_ATT, copyright);
+
+ // Copyright URL
+ String copyrightURL = feature.getFeatureInfo(IFeature.INFO_COPYRIGHT).getURL();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_COPYRIGHT_URL_ATT, copyrightURL);
+ }
+
+ IFeatureInfo featureInfoLicense = feature.getFeatureInfo(IFeature.INFO_LICENSE);
+ if (featureInfoLicense != null) {
+ // License
+ String license = featureInfoLicense.getDescription();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_LICENSE_ATT, license);
+
+ // License URL
+ String licenseURL = feature.getFeatureInfo(IFeature.INFO_LICENSE).getURL();
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_LICENSE_URL_ATT, licenseURL);
+ }
// URL
- IFeatureURL url = feature.getURL();
- if (url != null) {
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_URL_ATT, url.toString());
+ IFeatureURL featureUrl = feature.getURL();
+ if (featureUrl != null) {
+
+ IFeatureURLElement updateUrl = featureUrl.getUpdate();
+ if (updateUrl != null) {
+ // URL label
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_URL_LABEL_ATT, updateUrl.getLabel());
+
+ URL url = updateUrl.getURL();
+ if (url != null) {
+ // URL address
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_URL_ATT, url.toString());
+ }
+ }
}
- // Label
- String label = feature.getLabel();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_LABEL_ATT, label);
+ // Operating system
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_OS_ATT, feature.getOS());
- // Id
- String id = feature.getId();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_ID_ATT, id);
+ // Window system
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_WS_ATT, feature.getWS());
- // Version
- String version = feature.getVersion();
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_VERSION_ATT, version);
+ // Language
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_LANGUAGES_ATT, feature.getNL());
+
+ // Architecture
+ representation.setValue(stereotype, ADL4Eclipse_Stereotypes.FEATURE_ARCHITECTURE_ATT, feature.getArch());
// Plug-ins
- List<EObject> packagedPlugins = ADL4EclipseUtils.getPluginStereotypeApplications(feature.getPlugins());
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_PLUGINS_ATT, packagedPlugins);
+ setStereotypeValues(ADL4Eclipse_Stereotypes.FEATURE_PLUGINS_ATT, feature.getPlugins(), OSGIStereotypes.BUNDLE_REFERENCE);
// Included Features
- List<EObject> packagedFeatures = ADL4EclipseUtils.getFeatureStereotypeApplication(feature.getIncludedFeatures());
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_INCLUDEDFEATURES_ATT, packagedFeatures);
+ setStereotypeValues(ADL4Eclipse_Stereotypes.FEATURE_INCLUDED_FEATURES_ATT, feature.getIncludedFeatures(), ADL4Eclipse_Stereotypes.FEATURE_REFERENCE);
// Imported Features
- List<EObject> importedFeatures = ADL4EclipseUtils.getFeatureStereotypeApplication(feature.getImports());
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.FEATURE_IMPORTEDFEATURES_ATT, importedFeatures);
+ setStereotypeValues(ADL4Eclipse_Stereotypes.FEATURE_FEATURE_DEPENDENCIES_ATT, feature.getImports(), ADL4Eclipse_Stereotypes.FEATURE_REFERENCE);
+
+ // Imported Plug-ins
+ setStereotypeValues(ADL4Eclipse_Stereotypes.FEATURE_PLUGIN_DEPENDENCIES_ATT, feature.getImports(), OSGIStereotypes.BUNDLE_REFERENCE);
+ }
+
+ /**
+ * Retrieves a list of stereotyped applications from an array of identifiable and
+ * store it in the feature's stereotype at the propertyName value.
+ *
+ * @param propertyName the name of the property to set the value.
+ * @param identifiables the array of identifiable to set
+ * @param stereotypeIdentifier the stereotype qualified name of the EObject to save
+ */
+ private void setStereotypeValues(String propertyName, IIdentifiable[] identifiables, String stereotypeIdentifier) {
+ List<EObject> pluginReferences = new ArrayList<>();
+
+ for (IIdentifiable identifiable : identifiables) {
+ // The stereotype takes stereotyped dependencies that are inside the representation
+ Dependency dependency = getElement(identifiable.getId(), Dependency.class);
+
+ if (dependency != null) {
+ Stereotype dependencyStereotype = dependency.getAppliedStereotype(stereotypeIdentifier);
+
+ if (dependencyStereotype != null) {
+ EObject stereotypeApplication = dependency.getStereotypeApplication(dependencyStereotype);
+
+ if (stereotypeApplication != null) {
+ pluginReferences.add(stereotypeApplication);
+ }
+ }
+ }
+ }
+
+ representation.setValue(stereotype, propertyName, pluginReferences);
+ }
+
+ @Override
+ public StereotypeVersion getReversibleVersion(Reversible<?> reversibleProject) {
+ return dependencyVersions.get(reversibleProject);
+ }
+
+ @Override
+ public void setReversibleVersion(Reversible<?> reversible, StereotypeVersion version) {
+ dependencyVersions.put(reversible, version);
+
}
}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversiblePlugin.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversiblePlugin.java
index 9864dc896de..e1e63926efd 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversiblePlugin.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversiblePlugin.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.papyrus.adltool.reversible.extension.ReversibleExtension;
import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtensionPoint;
+import org.eclipse.papyrus.adltool.reversible.packages.ReversiblePackage;
/**
* Projects that implements that interface are reversible plug-ins that
@@ -23,17 +24,45 @@ import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtension
public interface ReversiblePlugin extends ReversibleProject {
/**
+ * Returns whether the plug-in is a singleton or not.
+ *
+ * @return true if the plug-in is a singleton, false of not
+ */
+ boolean isSingleton();
+
+ /**
* Returns a list containing all the exported packages names.
*
- * @return
+ * @return the list of reversible exported packages
+ */
+ List<ReversiblePackage> getExportedPackages();
+
+ /**
+ * Sets the list of exported package.
+ *
+ * @param exportedPackages
+ */
+ void setExportedPackages(List<ReversiblePackage> exportedPackages);
+
+ /**
+ * Returns a list containing all the imported packages names.
+ *
+ * @return the list of reversible imported packages
+ */
+ List<ReversiblePackage> getImportedPackages();
+
+ /**
+ * Sets the list of imported package.
+ *
+ * @param exportedPackages
*/
- List<String> getExportedPackages();
+ void setImportedPackages(List<ReversiblePackage> importedPackages);
/**
* Returns a list of reversible corresponding to the project's extension
* points.
*
- * @return
+ * @return the list of reversible extension points
*/
List<ReversibleExtensionPoint> getExtensionPoints();
@@ -47,7 +76,7 @@ public interface ReversiblePlugin extends ReversibleProject {
/**
* Returns a list of extensions.
*
- * @return
+ * @return the list of reversible extensions
*/
List<ReversibleExtension> getExtensions();
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleProject.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleProject.java
index 01497f928e8..40e9b4fdba8 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleProject.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/ReversibleProject.java
@@ -31,9 +31,24 @@ public interface ReversibleProject extends Reversible<Component> {
List<ReversibleProject> getDependencies();
/**
+ * Returns the version range of a dependency.
+ *
+ * @return
+ */
+ StereotypeVersion getReversibleVersion(Reversible<?> reversible);
+
+ /**
+ * Sets the version range of a reversible.
+ *
+ * @param reversible
+ * @param version
+ */
+ void setReversibleVersion(Reversible<?> reversible, StereotypeVersion version);
+
+ /**
* Gets the description.
*
- * @return the description
+ * @return the description or null.
*/
String getDescription();
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/StereotypeVersion.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/StereotypeVersion.java
new file mode 100644
index 00000000000..09d7f28f592
--- /dev/null
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/StereotypeVersion.java
@@ -0,0 +1,212 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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:
+ * Thomas Daniellou (CEA LIST) - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.adltool.reversible.project;
+
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.papyrus.adltool.ADL4EclipseUtils;
+import org.osgi.framework.Version;
+
+/**
+ * This class represents a stereotyped dependency version. It wraps simple OSGi
+ * {@link org.osgi.framework.Version Version} identifier and
+ * {@link org.osgi.framework.Version VersionRange}
+ */
+public class StereotypeVersion {
+
+ /**
+ * The floor of the version.
+ */
+ private String floor;
+
+ /**
+ * The ceiling of the version.
+ */
+ private String ceiling;
+
+ /**
+ * Whether the floor should be included or not.
+ */
+ private boolean includeFloor;
+
+ /**
+ * Whether the ceiling should be included or not.
+ */
+ private boolean includeCeiling;
+
+ /**
+ * VersionRange flag used to generate the readable version.
+ */
+ private boolean versionRange = false;
+
+ /**
+ * Constructor.
+ *
+ * @param floor the readable version
+ */
+ public StereotypeVersion(String floor) {
+ setFloor(floor);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param version the OSGi version
+ */
+ public StereotypeVersion(Version version) {
+ floor = ADL4EclipseUtils.formatVersion(version);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param version the OSGi version range
+ */
+ public StereotypeVersion(VersionRange version) {
+ Version left = version.getLeft();
+ Version right = version.getRight();
+
+ setFloor(ADL4EclipseUtils.formatVersion(left));
+ setIncludeFloor(version.getIncludeMinimum());
+
+ if (right != null) {
+ setCeiling(ADL4EclipseUtils.formatVersion(right));
+ setIncludeCeiling(version.getIncludeMaximum());
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param floor
+ * @param ceiling
+ * @param includeFloor
+ * @param includeCeiling
+ */
+ public StereotypeVersion(String floor, String ceiling, boolean includeFloor, boolean includeCeiling) {
+ setFloor(floor);
+ setCeiling(ceiling);
+ setIncludeFloor(includeFloor);
+ setIncludeCeiling(includeCeiling);
+ }
+
+ /**
+ * Returns the floor of the version.<br />
+ * If the version is not flagged as version range, the floor corresponds to
+ * the version.
+ *
+ * @return the floor of the version
+ */
+ public String getFloor() {
+ return floor;
+ }
+
+ /**
+ * Sets the floor of the version.
+ *
+ * @param floor the floor of the version
+ */
+ public void setFloor(String floor) {
+ this.floor = floor;
+ }
+
+ /**
+ * Gets the ceiling of the version.
+ *
+ * @return the ceiling of the version
+ */
+ public String getCeiling() {
+ return ceiling;
+ }
+
+ /**
+ * Sets the ceiling of the version. <br />
+ * If the ceiling is not null, the version is flagged as version range.
+ *
+ * @param ceiling the ceiling of the version
+ */
+ public void setCeiling(String ceiling) {
+ this.ceiling = ceiling;
+ versionRange = ceiling != null;
+ }
+
+ /**
+ * Returns whether the floor should be included or not.
+ *
+ * @return true if the floor should be included, false if not
+ */
+ public boolean includeFloor() {
+ return includeFloor;
+ }
+
+ /**
+ * Sets whether the floor should be included or not.
+ *
+ * @param includeFloor the new value
+ */
+ public void setIncludeFloor(boolean includeFloor) {
+ this.includeFloor = includeFloor;
+ }
+
+ /**
+ * Returns whether the ceiling should be included or not.
+ *
+ * @return true if the ceiling should be included, false if not
+ */
+ public boolean includeCeiling() {
+ return includeCeiling;
+ }
+
+ /**
+ * Sets whether the ceiling should be included or not.
+ *
+ * @param includeCeiling the new value
+ */
+ public void setIncludeCeiling(boolean includeCeiling) {
+ this.includeCeiling = includeCeiling;
+ }
+
+ /**
+ * Returns the OSGi version range in an interval notation.<br />
+ * If the version is not flagged as version range, the generated output will
+ * be the version.<br />
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ if (versionRange) {
+ if (includeFloor) {
+ sb.append("[");
+ } else {
+ sb.append("(");
+ }
+ }
+
+ sb.append(floor);
+
+ if (versionRange) {
+ if (ceiling != null) {
+ sb.append(",");
+ sb.append(ceiling);
+
+ if (includeCeiling) {
+ sb.append("]");
+ } else {
+ sb.append(")");
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+
+}
diff --git a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/WorkspacePlugin.java b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/WorkspacePlugin.java
index 6930ce1242d..dfe9b9a95ed 100644
--- a/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/WorkspacePlugin.java
+++ b/extraplugins/adl4eclipse/org.eclipse.papyrus.adl4eclipsetool/src/org/eclipse/papyrus/adltool/reversible/project/WorkspacePlugin.java
@@ -14,28 +14,30 @@ package org.eclipse.papyrus.adltool.reversible.project;
import static org.eclipse.papyrus.adltool.Activator.log;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.PropertyResourceBundle;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.adl4eclipse.org.IADL4ECLIPSE_Stereotype;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.papyrus.adl4eclipse.org.ADL4Eclipse_Stereotypes;
import org.eclipse.papyrus.adltool.ADL4EclipseUtils;
-import org.eclipse.papyrus.adltool.ADLConstants;
+import org.eclipse.papyrus.adltool.reversible.extension.ReversibleExtension;
+import org.eclipse.papyrus.adltool.reversible.extensionpoint.ReversibleExtensionPoint;
import org.eclipse.papyrus.adltool.reversible.factory.ReversibleFactory;
-import org.eclipse.papyrus.osgi.profile.IOSGIStereotype;
+import org.eclipse.papyrus.adltool.reversible.packages.ReversiblePackage;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
import org.eclipse.pde.core.project.IBundleProjectDescription;
import org.eclipse.pde.core.project.IPackageExportDescription;
+import org.eclipse.pde.core.project.IPackageImportDescription;
import org.eclipse.pde.core.project.IRequiredBundleDescription;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
/**
* This class is a reversible adapter of a workspace plug-in.
*/
-public class WorkspacePlugin extends AbstractReversiblePlugin {
+public class WorkspacePlugin extends AbstractPlugin {
private IBundleProjectDescription plugin;
@@ -45,7 +47,74 @@ public class WorkspacePlugin extends AbstractReversiblePlugin {
* @param plugin
*/
public WorkspacePlugin(IBundleProjectDescription plugin) {
+ super();
this.plugin = plugin;
+
+ // Save the exported packages
+ List<ReversiblePackage> reversiblePackageExports = new ArrayList<>();
+ IPackageExportDescription[] packageExports = plugin.getPackageExports();
+
+ if (packageExports != null) {
+ for (IPackageExportDescription packageExport : packageExports) {
+ if (packageExport != null) {
+ ReversiblePackage reversiblePackageExport = ReversibleFactory.getInstance().makeReversible(packageExport);
+
+ reversiblePackageExports.add(reversiblePackageExport);
+
+ Version version = packageExport.getVersion();
+
+ if (version != null) {
+ setReversibleVersion(reversiblePackageExport, new StereotypeVersion(version));
+ }
+ }
+ }
+ }
+
+ // Save the imported packages
+ List<ReversiblePackage> reversiblePackageImports = new ArrayList<>();
+ IPackageImportDescription[] packageImports = plugin.getPackageImports();
+
+ if (packageImports != null) {
+ for (IPackageImportDescription packageImport : packageImports) {
+ if (packageImport != null) {
+ ReversiblePackage reversiblePackageImport = ReversibleFactory.getInstance().makeReversible(packageImport);
+
+ reversiblePackageImports.add(reversiblePackageImport);
+
+ VersionRange versionRange = packageImport.getVersionRange();
+ if (versionRange != null) {
+ setReversibleVersion(reversiblePackageImport, new StereotypeVersion(versionRange));
+ }
+ }
+ }
+ }
+
+ // Save the extension points
+ IPluginExtensionPoint[] pluginExtensionPoints = ADL4EclipseUtils.findExtensionPointsForPlugin(getId());
+ List<ReversibleExtensionPoint> extensionPoints = new ArrayList<>();
+
+ for (IPluginExtensionPoint pluginExtensionPoint : pluginExtensionPoints) {
+ ReversibleExtensionPoint extensionPoint = ReversibleFactory.getInstance().makeReversible(pluginExtensionPoint);
+
+ extensionPoint.setParent(this);
+ extensionPoints.add(extensionPoint);
+ }
+
+ // Save the extensions
+ IPluginExtension[] pluginExtensions = ADL4EclipseUtils.findExtensionsForPlugin(getId());
+ List<ReversibleExtension> extensions = new ArrayList<>();
+
+ for (IPluginExtension extension : pluginExtensions) {
+ ReversibleExtension reversibleExtension = ReversibleFactory.getInstance().makeReversible(extension);
+
+ reversibleExtension.setParent(this);
+ extensions.add(reversibleExtension);
+ }
+
+ setExportedPackages(reversiblePackageExports);
+ setImportedPackages(reversiblePackageImports);
+ setExtensionPoints(extensionPoints);
+ setExtensions(extensions);
}
@Override
@@ -55,7 +124,7 @@ public class WorkspacePlugin extends AbstractReversiblePlugin {
@Override
public String getStereotypeName() {
- return IADL4ECLIPSE_Stereotype.PLUGIN_STEREOTYPE;
+ return ADL4Eclipse_Stereotypes.PLUGIN_STEREOTYPE;
}
@Override
@@ -68,32 +137,36 @@ public class WorkspacePlugin extends AbstractReversiblePlugin {
return ADL4EclipseUtils.getImage("img/bundle_pj.gif");
}
- private List<String> getDependenciesIds() {
- List<String> children = new ArrayList<>();
- IRequiredBundleDescription[] requiredBundles = plugin.getRequiredBundles();
-
- if (requiredBundles != null) {
- for (IRequiredBundleDescription child : requiredBundles) {
- children.add(child.getName());
- }
- }
-
- return children;
+ @Override
+ public boolean isSingleton() {
+ return plugin.isSingleton();
}
@Override
public List<ReversibleProject> getDependencies() {
List<ReversibleProject> dependencies = new ArrayList<>();
- List<String> dependenciesIds = getDependenciesIds();
-
- if (!dependenciesIds.isEmpty()) {
- for (String pluginId : dependenciesIds) {
- ReversibleProject reversiblePlugin = ReversibleFactory.getInstance().getPlugin(pluginId);
+ IRequiredBundleDescription[] requiredBundles = plugin.getRequiredBundles();
- if (reversiblePlugin != null) {
- dependencies.add(reversiblePlugin);
- } else {
- log.warn("Plug-in " + getId() + " : cannot find child " + pluginId);
+ if (requiredBundles != null) {
+ for (IRequiredBundleDescription requiredBundle : requiredBundles) {
+ if (requiredBundle != null) {
+ String pluginId = requiredBundle.getName();
+
+ if (!Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(pluginId)) {
+ ReversibleProject reversiblePlugin = ReversibleFactory.getInstance().getPlugin(pluginId);
+
+ if (reversiblePlugin != null) {
+ dependencies.add(reversiblePlugin);
+ // Save the version range of the dependency
+ VersionRange versionRange = requiredBundle.getVersionRange();
+
+ if (versionRange != null) {
+ reversibleVersion.put(reversiblePlugin, new StereotypeVersion(versionRange));
+ }
+ } else {
+ log.warn(getType() + " \"" + getId() + "\": cannot find child " + pluginId);
+ }
+ }
}
}
}
@@ -102,20 +175,6 @@ public class WorkspacePlugin extends AbstractReversiblePlugin {
}
@Override
- public List<String> getExportedPackages() {
- List<String> packageExports = new ArrayList<>();
- IPackageExportDescription[] packageExportDescriptions = plugin.getPackageExports();
-
- if (packageExportDescriptions != null) {
- for (IPackageExportDescription packageExport : packageExportDescriptions) {
- packageExports.add(packageExport.getName());
- }
- }
-
- return packageExports;
- }
-
- @Override
protected String getBundleValue(String key) {
String valueFromDescription = plugin.getHeader(key);
PropertyResourceBundle propertyResourceBundle = ADL4EclipseUtils.getNLSFilesFor(plugin);
@@ -130,106 +189,4 @@ public class WorkspacePlugin extends AbstractReversiblePlugin {
return valueFromDescription;
}
- @SuppressWarnings("deprecation")
- @Override
- public void fillStereotype() {
- if (!applyStereotype()) {
- log.warn("(" + getType() + ") " + getId() + " cannot fill the stereotype properties");
- return;
- }
-
- Map<String, String> stereotypeKeyValues = new HashMap<>();
-
- // Activator
- stereotypeKeyValues.put(Constants.BUNDLE_ACTIVATOR, IOSGIStereotype.BUNDLE_ACTIVATOR_ATT);
- // Category
- stereotypeKeyValues.put(Constants.BUNDLE_CATEGORY, IOSGIStereotype.BUNDLE_CATEGORY_ATT);
- // Classpath
- stereotypeKeyValues.put(Constants.BUNDLE_CLASSPATH, IOSGIStereotype.BUNDLE_CLASSPATH_ATT);
- // Contact address
- stereotypeKeyValues.put(Constants.BUNDLE_CONTACTADDRESS, IOSGIStereotype.BUNDLE_CONTACTADDRESS_ATT);
- // Copyright
- stereotypeKeyValues.put(Constants.BUNDLE_COPYRIGHT, IOSGIStereotype.BUNDLE_COPYRIGHT_ATT);
- // Description
- stereotypeKeyValues.put(Constants.BUNDLE_DESCRIPTION, IOSGIStereotype.BUNDLE_DESCRIPTION_ATT);
- // DocURL
- stereotypeKeyValues.put(Constants.BUNDLE_DOCURL, IOSGIStereotype.BUNDLE_DOCURL_ATT);
- // Localization
- stereotypeKeyValues.put(Constants.BUNDLE_LOCALIZATION, IOSGIStereotype.BUNDLE_LOCALIZATION_ATT);
- // Manifest version
- stereotypeKeyValues.put(Constants.BUNDLE_MANIFESTVERSION, IOSGIStereotype.BUNDLE_MANIFESTVERSION_ATT);
- // NativeCode
- stereotypeKeyValues.put(Constants.BUNDLE_NATIVECODE, IOSGIStereotype.BUNDLE_NATIVECODE_ATT);
- // RequiredExecutionEnvironment
- stereotypeKeyValues.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, IOSGIStereotype.BUNDLE_REQUIREDEXECUTIONENVIRONMENT_ATT);
- // Update location
- stereotypeKeyValues.put(Constants.BUNDLE_UPDATELOCATION, IOSGIStereotype.BUNDLE_UPDATELOCATION_ATT);
- // Vendor
- stereotypeKeyValues.put(Constants.BUNDLE_VENDOR, IOSGIStereotype.BUNDLE_VENDOR_ATT);
- // Version
- stereotypeKeyValues.put(Constants.BUNDLE_VERSION, IOSGIStereotype.BUNDLE_VERSION_ATT);
- // Platform filter
- stereotypeKeyValues.put(ADLConstants.ECLIPSE_PLATFORMFILTER, IADL4ECLIPSE_Stereotype.PLUGIN_PLATFORMFILTER_ATT);
-
- for (Map.Entry<String, String> entry : stereotypeKeyValues.entrySet()) {
- String value = getBundleValue(entry.getKey());
- representation.setValue(stereotype, entry.getValue(), value);
- }
-
- // Lazy start
- String activationPolicy = getBundleValue(Constants.BUNDLE_ACTIVATIONPOLICY);
- boolean hasLazyActivationPolicy = "lazy".equals(activationPolicy);
-
- representation.setValue(stereotype, IOSGIStereotype.BUNDLE_HASLAZYACTIVATIONPOLICY_ATT, hasLazyActivationPolicy);
-
- // BUNDLE_SYMBOLICNAME
- representation.setValue(stereotype, IOSGIStereotype.BUNDLE_SYMBOLICNAME_ATT, getId());
-
- // BUNDLE_NAME
- String name = getBundleValue(Constants.BUNDLE_NAME);
- if (name != null) {
- if (name.toLowerCase().contains("incubation")) {
-
- name = name.replace("(Incubation)", "");
- name = name.replace("(incubation)", "");
- name = name.replace("Incubation", "");
- name = name.replace("incubation", "");
-
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_ISINCUBATION_ATT, true);
- } else {
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_ISINCUBATION_ATT, false);
- }
-
- representation.setValue(stereotype, IOSGIStereotype.BUNDLE_NAME_ATT, name.trim());
- }
-
- String lazystartExpression = getBundleValue(ADLConstants.ECLIPSE_LAZYSTART);
- if (lazystartExpression != null) {
- boolean lazyStartValue;
- if (lazystartExpression.contains(";")) {
- String lazyStartString = lazystartExpression.substring(0, lazystartExpression.indexOf(";"));
- lazyStartValue = Boolean.valueOf(lazyStartString);
- // String lazyStartException=
- // lazystartExpression.substring(lazystartExpression.indexOf(";"));
- // TODO: lazystartExpression
- // bundleComponent.setValue(pluginStereotype,
- // IADL4ECLIPSE_Stereotype.PLUGIN_LAZYSTARTEXCEPTION_ATT,lazyStartException
- // );
- } else {
- lazyStartValue = Boolean.valueOf(lazystartExpression);
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_LAZYSTART_ATT, lazyStartValue);
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_LAZYSTARTEXCEPTION_ATT, Collections.EMPTY_LIST);
- }
- } else {
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_LAZYSTART_ATT, null);
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_LAZYSTARTEXCEPTION_ATT, Collections.EMPTY_LIST);
- }
-
- List<String> requireBundleIds = extractManifestHeader(Constants.REQUIRE_BUNDLE);
-
- List<EObject> requireBundles = ADL4EclipseUtils.getBundleStereotypeApplications(requireBundleIds);
-
- representation.setValue(stereotype, IADL4ECLIPSE_Stereotype.PLUGIN_REQUIRE_BUNDLE_ATT, requireBundles);
- }
-
}

Back to the top