Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2015-12-18 14:08:55 +0000
committerAnsgar Radermacher2015-12-18 14:08:55 +0000
commit05e99c8bdfa2d44588e9e4ea19a24c69e7146469 (patch)
tree90e3da48f63a318dfd2136fdc27fb757e75edf82 /extraplugins
parent842607427e697734ef1a73f5a0a1005223302cf7 (diff)
downloadorg.eclipse.papyrus-05e99c8bdfa2d44588e9e4ea19a24c69e7146469.tar.gz
org.eclipse.papyrus-05e99c8bdfa2d44588e9e4ea19a24c69e7146469.tar.xz
org.eclipse.papyrus-05e99c8bdfa2d44588e9e4ea19a24c69e7146469.zip
Bug 484464 - [Papyrus DSML Validation] nsURI is taken from definition in case of static profile
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java13
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java48
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java4
3 files changed, 25 insertions, 40 deletions
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java
index a1194510a3b..768232e0df4 100644
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java
+++ b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java
@@ -19,6 +19,8 @@ import java.util.Map;
import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category;
import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintProvider;
import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsManager;
+import org.eclipse.papyrus.dsml.validation.model.profilenames.Utils;
+import org.eclipse.papyrus.uml.tools.utils.StaticProfileUtil;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
@@ -100,8 +102,8 @@ public class ConstraintManagerImpl implements IConstraintsManager {
*/
private void relateCategoriesWithConstraints(Element element, Category category) {
-
if (element instanceof Profile) {
+ Profile profile = (Profile) element;
// creation of a category
ConstraintCategoryImpl subCategory = new ConstraintCategoryImpl(((Profile) element).getName(), category);
@@ -113,8 +115,13 @@ public class ConstraintManagerImpl implements IConstraintsManager {
// associate validation to category to provider
constraintProvider.getConstraintsCategories().add(subCategory);
constraintsProviders.add(constraintProvider);
- if (((Profile) element).getDefinition() != null) {
- constraintProvider.setEPackage(((Profile) element).getDefinition());
+ StaticProfileUtil staticProfile = new StaticProfileUtil(profile);
+ Utils.setStaticProfile(staticProfile);
+ if (staticProfile.getDefinition() != null) {
+ constraintProvider.setEPackage(staticProfile.getDefinition());
+ }
+ else if (profile.getDefinition() != null) {
+ constraintProvider.setEPackage(profile.getDefinition());
}
// iterate on all direct element of the profile
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java
index 88d2047ac68..d1018c3fd5d 100644
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java
+++ b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java
@@ -15,12 +15,10 @@ package org.eclipse.papyrus.dsml.validation.model.profilenames;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
+import org.eclipse.papyrus.uml.tools.utils.StaticProfileUtil;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Namespace;
import org.eclipse.uml2.uml.OpaqueExpression;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.ValueSpecification;
@@ -34,18 +32,7 @@ public class Utils {
private static final String DOT = "."; //$NON-NLS-1$
private static final String JAVA_LANGUAGE = "JAVA"; //$NON-NLS-1$
private static final String OCL_LANGUAGE = "OCL"; //$NON-NLS-1$
-
- /**
- * qualified name of EPackage stereotype (used for static profile detection)
- */
- public static final String EPackage_QNAME = "Ecore::EPackage"; //$NON-NLS-1$
- /**
- * Attributes of EPackage stereotype
- */
- private static final String EPKG_BASE_PACKAGE = "basePackage"; //$NON-NLS-1$
- private static final String EPKG_PACKAGE_NAME = "packageName"; //$NON-NLS-1$
-
-
+
/*
* Map holding relations between String representing the qualified name of a
* constraint and name of a package to which it belongs. Package name in
@@ -120,22 +107,17 @@ public class Utils {
Namespace nameSpace = constraint.getContext();
if (nameSpace instanceof Stereotype) {
- Package profilePkg = PackageUtil.getRootPackage(constraint.getContext());
- if (profilePkg instanceof Profile) {
- Profile profile = (Profile) profilePkg;
- Stereotype ePkg = profile.getAppliedStereotype(EPackage_QNAME);
- String base = (String) profile.getValue(ePkg, EPKG_BASE_PACKAGE);
- if (base != null) {
- String pkgName = (String) profile.getValue(ePkg, EPKG_PACKAGE_NAME);
- if (pkgName != null) {
- return base + DOT + pkgName + DOT + nameSpace.getName();
- }
- else {
- return base + DOT + nameSpace.getQualifiedName();
+ if (staticProfile != null) {
+ String basePackage = staticProfile.getBasePackage();
+ if (basePackage != null) {
+ String packageName = staticProfile.getPackageName();
+ if (packageName != null) {
+ return basePackage + DOT + packageName + DOT + nameSpace.getName();
+ } else {
+ return basePackage + DOT + nameSpace.getQualifiedName();
}
}
}
- // Stereotype ePackage = umlProfile.getAppliedStereotype(EPackage_QNAME);
return nameSpace.getQualifiedName();
}
return ""; //$NON-NLS-1$
@@ -254,20 +236,20 @@ public class Utils {
public static String getTopPkg() {
return pluginID.toLowerCase();
}
-
+
public static void setPluginID(String ID) {
pluginID = ID;
}
public static boolean isStaticProfile() {
- return staticProfile;
+ return staticProfile.getDefinition() != null;
}
- public static void setStaticProfile(boolean staticProfile) {
+ public static void setStaticProfile(StaticProfileUtil staticProfile) {
Utils.staticProfile = staticProfile;
}
private static String pluginID;
-
- private static boolean staticProfile;
+
+ private static StaticProfileUtil staticProfile;
}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java
index fc492ea21f4..3af86eb7933 100644
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java
+++ b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.wizard/src/org/eclipse/papyrus/dsml/validation/wizard/JavaContentGenerator.java
@@ -25,7 +25,6 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.papyrus.dsml.validation.model.profilenames.Utils;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Stereotype;
/**
* this class generate java classes in the project
@@ -66,9 +65,6 @@ public class JavaContentGenerator {
public void run(IProgressMonitor monitor) {
try {
- // static profile apply the EPackage stereotype
- Stereotype ePackage = umlProfile.getAppliedStereotype(Utils.EPackage_QNAME);
- Utils.setStaticProfile(ePackage != null);
Utils.setPluginID(project.getName());
ClassesGenerator generator = new ClassesGenerator(umlProfile.eResource(), project);
generator.doGenerate(monitor);

Back to the top