diff options
author | Ansgar Radermacher | 2017-12-08 13:19:27 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2018-03-19 22:26:13 +0000 |
commit | d1a9f4c59e9582b8d28045d3ef9924e77b5e9457 (patch) | |
tree | 151043fb2002e1f301326e2780a93d45024c2eb8 /plugins | |
parent | 3e7f4342e10ec1c4b42f741882e694a18a27919a (diff) | |
download | org.eclipse.papyrus-d1a9f4c59e9582b8d28045d3ef9924e77b5e9457.tar.gz org.eclipse.papyrus-d1a9f4c59e9582b8d28045d3ef9924e77b5e9457.tar.xz org.eclipse.papyrus-d1a9f4c59e9582b8d28045d3ef9924e77b5e9457.zip |
Bug 528252 - [Properties] Language field does not refresh when switching between opaque expressions of different language
- Refresh language editor
- Assure that constraint checking OCL editor eligibility is not only applied to constraints
but also to opaque expressions
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
Diffstat (limited to 'plugins')
3 files changed, 26 insertions, 15 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ExpressionEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ExpressionEditor.java index 9625edaf62f..942f69f29a9 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ExpressionEditor.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/ExpressionEditor.java @@ -61,9 +61,9 @@ public class ExpressionEditor extends AbstractPropertyEditor implements Listener public void handleChange(ChangeEvent event) { if (event.getSource() == currentExpression) { bodyEditor.display(currentExpression); + languageEditor.refreshValue(); } } - } ExpressionListChangeHandler expressionListChangeHandler; diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/plugin.xml b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/plugin.xml index 948abd15e15..d61a7aa013b 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/plugin.xml +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/plugin.xml @@ -17,6 +17,7 @@ </Priority> </DirectEditor> <DirectEditor + additionalConstraint="org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext.OCLDirectEditorConstraint" contributor="Eclipse Modeling Project" icon="icons/OCLModelFile.gif" language="Essential OCL constraint editor" diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/OCLDirectEditorConstraint.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/OCLDirectEditorConstraint.java index 502a428e712..44caadb6dc1 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/OCLDirectEditorConstraint.java +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/OCLDirectEditorConstraint.java @@ -30,10 +30,10 @@ import org.eclipse.uml2.uml.ValueSpecification; public class OCLDirectEditorConstraint implements IDirectEditorConstraint { /** The Constant OCL_LANGAGE_CONSTRAINT. */ - private static final String OCL_LANGAGE_CONSTRAINT = "OCL Langage Constraint"; + private static final String OCL_LANGUAGE_CONSTRAINT = "OCL Language Constraint"; //$NON-NLS-1$ /** The Constant OCL_LANGAGE_BODY. */ - private static final String OCL_LANGAGE_BODY = "OCL"; + private static final String OCL_LANGUAGE_BODY = "OCL"; //$NON-NLS-1$ /** * Constructor. @@ -48,7 +48,7 @@ public class OCLDirectEditorConstraint implements IDirectEditorConstraint { * @return */ public String getLabel() { - return OCL_LANGAGE_CONSTRAINT; + return OCL_LANGUAGE_CONSTRAINT; } /** @@ -59,18 +59,28 @@ public class OCLDirectEditorConstraint implements IDirectEditorConstraint { */ public boolean appliesTo(Object selection) { boolean appliedConstraint = false; - EObject resolveEobject = EMFHelper.getEObject(selection); - if (resolveEobject instanceof Constraint) { - Constraint selectedConstraint = (Constraint) resolveEobject; - ValueSpecification constraintSpecification = selectedConstraint.getSpecification(); - if (constraintSpecification instanceof OpaqueExpression) { - appliedConstraint = ((OpaqueExpression) constraintSpecification).getBodies().isEmpty() || ((OpaqueExpression) constraintSpecification).getLanguages().contains(OCL_LANGAGE_BODY); - } else { - appliedConstraint = constraintSpecification instanceof LiteralString; - } - + EObject resolvedEObject = EMFHelper.getEObject(selection); + if (resolvedEObject instanceof Constraint) { + Constraint selectedConstraint = (Constraint) resolvedEObject; + appliedConstraint = checkValueSpecification(selectedConstraint.getSpecification()); + } + else if (resolvedEObject instanceof ValueSpecification) { + appliedConstraint = checkValueSpecification((ValueSpecification) resolvedEObject); } - return appliedConstraint; } + + /** + * check whether a value specification complies with OCL editor + * @param specification + * @return true, if either opaque-expression (empty or OCL as language) or a literal string + */ + public boolean checkValueSpecification(ValueSpecification specification) { + if (specification instanceof OpaqueExpression) { + return ((OpaqueExpression) specification).getBodies().isEmpty() || ((OpaqueExpression) specification).getLanguages().contains(OCL_LANGUAGE_BODY); + } + else { + return specification instanceof LiteralString; + } + } } |