Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2015-02-03 04:22:02 -0500
committervincent lorenzo2015-02-05 09:08:36 -0500
commit87b808196c0e11008d74370a9c5c886c81889f08 (patch)
tree52f2eb88820fe732307ce4fa97f8a2d0940e313a
parent273603b70e1ef5770fe85336b3dd4ec9446c0eee (diff)
downloadorg.eclipse.papyrus-87b808196c0e11008d74370a9c5c886c81889f08.tar.gz
org.eclipse.papyrus-87b808196c0e11008d74370a9c5c886c81889f08.tar.xz
org.eclipse.papyrus-87b808196c0e11008d74370a9c5c886c81889f08.zip
453445: [Customization] Greyed out fields when stereotype attributes
contain whitespaces https://bugs.eclipse.org/bugs/show_bug.cgi?id=453445 Change-Id: I2dcb14fa431a677bb7ee96fc239703910bf3a2c0 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/tree/objects/AppliedStereotypePropertyTreeObject.java10
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java244
2 files changed, 151 insertions, 103 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/tree/objects/AppliedStereotypePropertyTreeObject.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/tree/objects/AppliedStereotypePropertyTreeObject.java
index 80c2db64384..ee2f34cddcc 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/tree/objects/AppliedStereotypePropertyTreeObject.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/tree/objects/AppliedStereotypePropertyTreeObject.java
@@ -11,6 +11,7 @@
* Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
* Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
* Christian W. Damus (CEA) - bug 448139
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - bug 453445
*
*****************************************************************************/
package org.eclipse.papyrus.uml.profile.tree.objects;
@@ -28,6 +29,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.uml.profile.Activator;
import org.eclipse.papyrus.uml.profile.utils.Util;
+import org.eclipse.uml2.common.util.UML2Util;
import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Enumeration;
@@ -119,7 +121,8 @@ public class AppliedStereotypePropertyTreeObject extends ParentTreeObject {
Stereotype st = sTO.getStereotype();
Element elt = rTO.getElement();
- return elt.getValue(st, property.getName());
+ // Bug 453445 : Manage the special character for the property name
+ return elt.getValue(st, UML2Util.getValidJavaIdentifier(property.getName()));
}
public Element getElement() {
@@ -130,7 +133,8 @@ public class AppliedStereotypePropertyTreeObject extends ParentTreeObject {
}
public EStructuralFeature getFeature() {
- return getStereotypeApplication().eClass().getEStructuralFeature(property.getName());
+ // Bug 453445 : Manage the special character for the property name
+ return getStereotypeApplication().eClass().getEStructuralFeature(UML2Util.getValidJavaIdentifier(property.getName()));
}
public EObject getStereotypeApplication() {
@@ -296,4 +300,4 @@ public class AppliedStereotypePropertyTreeObject extends ParentTreeObject {
}
-}
+} \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java
index 3ab846fdaf6..8e4fb40ec4e 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java
@@ -1,100 +1,144 @@
-/*****************************************************************************
- * Copyright (c) 2010 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.properties.modelelement;
-
-import org.eclipse.core.databinding.observable.IObservable;
-import org.eclipse.emf.databinding.EMFProperties;
-import org.eclipse.emf.databinding.FeaturePath;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.uml.properties.datatype.DataTypeProvider;
-import org.eclipse.papyrus.uml.properties.datatype.StructuredDataTypeObservableValue;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
-import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
-import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
-import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * A Model Element for manipulating Stereotype properties
- *
- * @author Camille Letavernier
- */
-public class StereotypeModelElement extends EMFModelElement {
-
- /**
- * The stereotype handled by this ModelElement
- */
- protected Stereotype stereotype;
-
- /**
- * Constructor.
- *
- * @param stereotypeApplication
- * The StereotypeApplication being edited
- * @param stereotype
- * The Stereotype element
- * @param domain
- * The Editing domain on which the commands will be called
- *
- */
- public StereotypeModelElement(EObject stereotypeApplication, Stereotype stereotype, EditingDomain domain) {
- super(stereotypeApplication, domain);
- this.stereotype = stereotype;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IObservable doGetObservable(String propertyPath) {
- FeaturePath featurePath = getFeaturePath(propertyPath);
- EStructuralFeature feature = getFeature(featurePath);
- if (feature == null) {
- return super.doGetObservable(propertyPath);
- }
-
- if (feature.getEType() instanceof EDataType && !(feature.getEType() instanceof EEnum)) {
- if (feature.getUpperBound() == 1) {
- // Single-valued DataType
- if (DataTypeProvider.instance.canHandle((EDataType) feature.getEType())) {
- return new StructuredDataTypeObservableValue(source, feature, domain, (EDataType) feature.getEType());
- }
- // TODO : Multi-valued DataTypes
- }
- }
-
- if (feature.getUpperBound() != 1) {
- return new PapyrusObservableList(EMFProperties.list(featurePath).observe(source), domain, getSource(featurePath), feature);
- }
-
- return new PapyrusObservableValue(getSource(featurePath), feature, domain);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IStaticContentProvider getContentProvider(String propertyPath) {
- EStructuralFeature feature = getFeature(propertyPath);
-
- if (feature == null) {
- return super.getContentProvider(propertyPath);
- }
-
- return new UMLContentProvider(source, feature, stereotype);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - bug 453445
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.modelelement;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.databinding.FeaturePath;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.uml.properties.datatype.DataTypeProvider;
+import org.eclipse.papyrus.uml.properties.datatype.StructuredDataTypeObservableValue;
+import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList;
+import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.views.properties.Activator;
+import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * A Model Element for manipulating Stereotype properties
+ *
+ * @author Camille Letavernier
+ */
+public class StereotypeModelElement extends EMFModelElement {
+
+ /**
+ * The stereotype handled by this ModelElement
+ */
+ protected Stereotype stereotype;
+
+ /**
+ * Constructor.
+ *
+ * @param stereotypeApplication
+ * The StereotypeApplication being edited
+ * @param stereotype
+ * The Stereotype element
+ * @param domain
+ * The Editing domain on which the commands will be called
+ *
+ */
+ public StereotypeModelElement(EObject stereotypeApplication, Stereotype stereotype, EditingDomain domain) {
+ super(stereotypeApplication, domain);
+ this.stereotype = stereotype;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IObservable doGetObservable(String propertyPath) {
+ FeaturePath featurePath = getFeaturePath(propertyPath);
+ EStructuralFeature feature = getFeature(featurePath);
+ if (feature == null) {
+ return super.doGetObservable(propertyPath);
+ }
+
+ if (feature.getEType() instanceof EDataType && !(feature.getEType() instanceof EEnum)) {
+ if (feature.getUpperBound() == 1) {
+ // Single-valued DataType
+ if (DataTypeProvider.instance.canHandle((EDataType) feature.getEType())) {
+ return new StructuredDataTypeObservableValue(source, feature, domain, (EDataType) feature.getEType());
+ }
+ // TODO : Multi-valued DataTypes
+ }
+ }
+
+ if (feature.getUpperBound() != 1) {
+ return new PapyrusObservableList(EMFProperties.list(featurePath).observe(source), domain, getSource(featurePath), feature);
+ }
+
+ return new PapyrusObservableValue(getSource(featurePath), feature, domain);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public FeaturePath getFeaturePath(String propertyPath) {
+ String[] featureNames = propertyPath.split("\\."); //$NON-NLS-1$
+ EStructuralFeature[] features = new EStructuralFeature[featureNames.length];
+
+ int i = 0;
+ EClass currentClass = source.eClass();
+ for (String featureName : featureNames) {
+ // Bug 453445 : Manage the special character for the property path
+ featureName = UML2Util.getValidJavaIdentifier(featureName);
+ EStructuralFeature feature = currentClass.getEStructuralFeature(featureName);
+ features[i++] = feature;
+ if (i < featureNames.length) {
+ if (feature instanceof EReference) {
+ EReference reference = (EReference) feature;
+ EClassifier type = reference.getEType();
+ if (type instanceof EClass) {
+ currentClass = (EClass) type;
+ continue;
+ }
+ }
+
+ final StringBuilder warningMessage = new StringBuilder("Cannot find feature path "); //$NON-NLS-1$
+ warningMessage.append(propertyPath);
+ warningMessage.append(" for EClass "); //$NON-NLS-1$
+ warningMessage.append(source.eClass());
+ Activator.log.warn(warningMessage.toString());
+ return null;
+ }
+ }
+
+ return FeaturePath.fromList(features);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IStaticContentProvider getContentProvider(String propertyPath) {
+ EStructuralFeature feature = getFeature(propertyPath);
+
+ if (feature == null) {
+ return super.getContentProvider(propertyPath);
+ }
+
+ return new UMLContentProvider(source, feature, stereotype);
+ }
+} \ No newline at end of file

Back to the top