Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-03-13 14:40:00 +0000
committerAnsgar Radermacher2014-03-13 14:41:41 +0000
commitee83380462941881a5d2b4fcc1c82155e2c1c446 (patch)
tree44801150aaeb51fd297ce91fb4e6c20bcd00728d /plugins/uml
parent1a08f4c9af22318f711e5b9e8121f1d9bdd978b8 (diff)
downloadorg.eclipse.papyrus-ee83380462941881a5d2b4fcc1c82155e2c1c446.tar.gz
org.eclipse.papyrus-ee83380462941881a5d2b4fcc1c82155e2c1c446.tar.xz
org.eclipse.papyrus-ee83380462941881a5d2b4fcc1c82155e2c1c446.zip
Bug 427025 - [OCL For Papyrus] Cannot create OCL constraints in Luna: handle editing of newly created opaque expressions
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java19
-rw-r--r--plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/EssentialOCLEditorConfiguration.java31
2 files changed, 40 insertions, 10 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java
index b6e8e0bb746..2251a534bf3 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java
@@ -1,6 +1,8 @@
package org.eclipse.papyrus.uml.properties.xtext;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
@@ -11,6 +13,7 @@ import org.eclipse.papyrus.extensionpoints.editors.Activator;
import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.emf.dialog.NestedEditingDialogContext;
import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement;
import org.eclipse.papyrus.uml.properties.widgets.BodyEditor;
import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
@@ -74,8 +77,16 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
new EObjectAdapter(getEObject()),
textControl.getText(), 0);
- TransactionUtil.getEditingDomain(getEObject()).getCommandStack().execute(
- new GMFtoEMFCommandWrapper(command));
+ TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(getEObject());
+ if (domain == null) {
+ // can be null for opaque expression that have been created but have not been added to parent
+ // try to get resource set from nested dialog context
+ ResourceSet rs = NestedEditingDialogContext.getInstance().getResourceSet();
+ domain = TransactionUtil.getEditingDomain(rs);
+ }
+ if (domain != null) {
+ domain.getCommandStack().execute(new GMFtoEMFCommandWrapper(command));
+ }
}
}
@@ -229,7 +240,9 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
}
public void setInput(String value) {
- textControl.setText(value);
+ if (value != null) {
+ textControl.setText(value);
+ }
}
public void dispose() {
diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/EssentialOCLEditorConfiguration.java b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/EssentialOCLEditorConfiguration.java
index 078769ddcac..00727f33303 100644
--- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/EssentialOCLEditorConfiguration.java
+++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.constraintwithessentialocl.xtext/src/org/eclipse/papyrus/uml/textedit/constraintwithessentialocl/xtext/EssentialOCLEditorConfiguration.java
@@ -20,6 +20,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
@@ -35,6 +36,7 @@ import org.eclipse.ocl.examples.pivot.ParserException;
import org.eclipse.ocl.examples.pivot.utilities.BaseResource;
import org.eclipse.ocl.examples.pivot.utilities.PivotUtil;
import org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLRuntimeModule;
+import org.eclipse.papyrus.infra.emf.dialog.NestedEditingDialogContext;
import org.eclipse.papyrus.infra.services.validation.commands.AbstractValidateCommand;
import org.eclipse.papyrus.infra.services.validation.commands.AsyncValidateSubtreeCommand;
import org.eclipse.papyrus.uml.service.validation.UMLDiagnostician;
@@ -159,8 +161,10 @@ public class EssentialOCLEditorConfiguration extends DefaultXtextDirectEditorCon
if(indexOfOCLBody == -1) {
opaqueExpression.getLanguages().add(OCL);
opaqueExpression.getBodies().add(newTextualRepresentation);
- } else {
+ } else if (indexOfOCLBody < opaqueExpression.getBodies().size()) { // might not be true, if body list is not synchronized with language list
opaqueExpression.getBodies().set(indexOfOCLBody, newTextualRepresentation);
+ } else {
+ opaqueExpression.getBodies().add(newTextualRepresentation);
}
return CommandResult.newOKCommandResult(opaqueExpression);
}
@@ -186,7 +190,9 @@ public class EssentialOCLEditorConfiguration extends DefaultXtextDirectEditorCon
org.eclipse.uml2.uml.OpaqueExpression opaqueExpression = (org.eclipse.uml2.uml.OpaqueExpression)specification;
for(int i = 0; i < opaqueExpression.getLanguages().size() && indexOfOCLBody == -1; i++) {
if(opaqueExpression.getLanguages().get(i).equals(OCL)) {
- value += opaqueExpression.getBodies().get(i);
+ if (i < opaqueExpression.getBodies().size()) {
+ value += opaqueExpression.getBodies().get(i);
+ }
indexOfOCLBody = i;
}
}
@@ -205,8 +211,9 @@ public class EssentialOCLEditorConfiguration extends DefaultXtextDirectEditorCon
}
else if(objectToEdit instanceof OpaqueExpression) {
Element owner = ((OpaqueExpression) objectToEdit).getOwner();
- if (owner instanceof Constraint);
- return ((Constraint)owner).getContext();
+ if (owner instanceof Constraint) {
+ return ((Constraint)owner).getContext();
+ }
}
return null;
}
@@ -245,15 +252,25 @@ public class EssentialOCLEditorConfiguration extends DefaultXtextDirectEditorCon
// since the OCL expression is already stored in opaque form within the constraint.
CompositeCommand result = new CompositeCommand("validation"); //$NON-NLS-1$
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(semanticObject);
+ boolean doValidation = editingDomain != null;
+ if (editingDomain == null) {
+ // can be null for opaque expression that have been created but have not been added to parent
+ // try to get resource set from nested dialog context
+ ResourceSet rs = NestedEditingDialogContext.getInstance().getResourceSet();
+ editingDomain = TransactionUtil.getEditingDomain(rs);
+
+ }
if (semanticObject instanceof Constraint) {
result.add(new UpdateConstraintCommand(editingDomain, (Constraint) semanticObject, newString));
}
else if (semanticObject instanceof OpaqueExpression) {
result.add(new UpdateOpaqueExpressionCommand(editingDomain, (OpaqueExpression) semanticObject, newString));
}
- final AbstractValidateCommand validationCommand = new AsyncValidateSubtreeCommand(semanticObject, new UMLDiagnostician());
- validationCommand.disableUIFeedback();
- result.add(validationCommand);
+ if (doValidation) {
+ final AbstractValidateCommand validationCommand = new AsyncValidateSubtreeCommand(semanticObject, new UMLDiagnostician());
+ validationCommand.disableUIFeedback();
+ result.add(validationCommand);
+ }
return result;
}

Back to the top