Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremie.tatibouet2015-05-04 09:24:49 -0400
committerArnaud Cuccuru2015-05-05 12:47:26 -0400
commit67d24a73dcbbe539c906905c1f7788b1265ff11c (patch)
tree8ac3747985e5c0251ae8bb8f918fdf0f2636964b /extraplugins/alf
parentb8e467cba2b0fb654c7d8c10e43de9c5f526c6b1 (diff)
downloadorg.eclipse.papyrus-67d24a73dcbbe539c906905c1f7788b1265ff11c.tar.gz
org.eclipse.papyrus-67d24a73dcbbe539c906905c1f7788b1265ff11c.tar.xz
org.eclipse.papyrus-67d24a73dcbbe539c906905c1f7788b1265ff11c.zip
Enables the ALF editor when an operation is selected. Still some merge
problem at this step (e.g. the implementation of an operation not referenced in the "method" list after a compilation). Change-Id: I6cd85e10180d9b113fd5a77d23ac572c9426000c Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr> Reviewed-on: https://git.eclipse.org/r/47155 Tested-by: Hudson CI Reviewed-by: Arnaud Cuccuru <arnaud.cuccuru@cea.fr> Tested-by: Arnaud Cuccuru <arnaud.cuccuru@cea.fr>
Diffstat (limited to 'extraplugins/alf')
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java17
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java25
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java2
3 files changed, 41 insertions, 3 deletions
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java
index 6426cf6a2a8..d80116956a0 100644
--- a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java
@@ -181,6 +181,23 @@ public class FUMLScopeUtil {
return notifier instanceof Operation;
}
+ /**
+ * This predictate is only valid if:
+ * 1 - the notified is an Operation
+ * 2 - the operation is not abstract
+ * 3 - there is only one implementation for the operation
+ * 4 - the implementation is given as an activity
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isOperationWithImplementation(Object notifier){
+ return isOperation(notifier)
+ && !((Operation)notifier).isAbstract()
+ && ((Operation)notifier).getMethods().size()==1
+ && ((Operation)notifier).getMethods().get(0) instanceof Activity;
+ }
/**
* Check if the given notifier is strictly a Reception
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java
index 57020118566..49f85098fb5 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java
@@ -50,6 +50,7 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Namespace;
+import org.eclipse.uml2.uml.Operation;
import org.eclipse.xtext.resource.XtextResource;
import com.google.inject.Injector;
@@ -100,7 +101,7 @@ public class AlfEditionPropertySection extends
/* 2. Compute edit string */
String serialization = "/*Error: serialization could not be computed*/";
if (this.eObject != null) {
- serialization = this.alfSerialization.getEditString((Element) this.eObject);
+ serialization = this.alfSerialization.getEditString(this.getEditableObject(this.eObject));
}
/* 3. Set up editor content (textControl) */
this.textControl.setText(serialization);
@@ -109,6 +110,23 @@ public class AlfEditionPropertySection extends
}
}
+ /**
+ * Provide the object that will be edited through the editor. The particular case is for an edited
+ * that is an operation. In this situation we return the implementation (i.e. an activity) of this operation.
+ * This way it is transparent for the user that when editing an operation it can modify both the signature and
+ * its implementation.
+ *
+ * @param edited
+ * the object that is currently edited
+ *
+ * @return the real object that will be edited
+ */
+ private Element getEditableObject(EObject edited){
+ if(edited instanceof Operation){
+ return ((Operation)edited).getMethods().get(0);
+ }
+ return (Element)edited;
+ }
/**
* Provide the namespace of the element that is given as parameter
@@ -120,7 +138,8 @@ public class AlfEditionPropertySection extends
*/
private Namespace getNamespace(Element element){
if(element!=null && element instanceof NamedElement){
- return ((NamedElement)element).getNamespace();
+ Element edited = this.getEditableObject(element);
+ return ((NamedElement)edited).getNamespace();
}
return null;
}
@@ -275,7 +294,7 @@ public class AlfEditionPropertySection extends
}
public EObject getContextObject() {
- return getEObject();
+ return this.getEditableObject(this.eObject);
}
@Override
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
index c704aa1e25b..4da0952f1a4 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
@@ -73,6 +73,8 @@ public class AlfEditorPropertySectionFilter implements IFilter {
return true;
}else if(FUMLScopeUtil.isActivity(element)){
return true;
+ }else if(FUMLScopeUtil.isOperationWithImplementation(element)){
+ return true;
}
return false;
}

Back to the top