Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremie.tatibouet2015-04-29 08:45:33 -0400
committerArnaud Cuccuru2015-04-30 07:48:09 -0400
commit066606ffdddf3da55330b9b987fdbf3ea46c5d8b (patch)
treed4b100027546e3461302707f3db6c918f8df34af /extraplugins/alf
parentbbdda04530c5901c986da88c550db65a146aede7 (diff)
downloadorg.eclipse.papyrus-066606ffdddf3da55330b9b987fdbf3ea46c5d8b.tar.gz
org.eclipse.papyrus-066606ffdddf3da55330b9b987fdbf3ea46c5d8b.tar.xz
org.eclipse.papyrus-066606ffdddf3da55330b9b987fdbf3ea46c5d8b.zip
Cleans up the property view integration.
- Delete direct editors contribution - Rewrite filter making the property section available Change-Id: Ib14347e3ad3cf95495991536fa4964d0bceb0444 Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr> Reviewed-on: https://git.eclipse.org/r/46800 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/META-INF/MANIFEST.MF3
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java232
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java224
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml70
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java114
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java75
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java62
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java109
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java64
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java (renamed from extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java)149
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java98
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java6
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java6
13 files changed, 382 insertions, 830 deletions
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF
index 1f5439aabb5..b6e879c0978 100644
--- a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/META-INF/MANIFEST.MF
@@ -24,5 +24,6 @@ Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.uml.alf.transaction,
org.eclipse.papyrus.uml.alf.transaction.commands,
org.eclipse.papyrus.uml.alf.transaction.commit,
- org.eclipse.papyrus.uml.alf.transaction.job
+ org.eclipse.papyrus.uml.alf.transaction.job,
+ org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter
Bundle-Vendor: %providerName
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java
index 073b5eea365..f4b64d662e1 100644
--- a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java
@@ -16,32 +16,7 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.transaction.NotificationFilter;
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.AssociationClass;
-import org.eclipse.uml2.uml.Behavior;
-import org.eclipse.uml2.uml.CommunicationPath;
-import org.eclipse.uml2.uml.Component;
-import org.eclipse.uml2.uml.DataType;
import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.ElementImport;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-import org.eclipse.uml2.uml.Extension;
-import org.eclipse.uml2.uml.ExtensionEnd;
-import org.eclipse.uml2.uml.Generalization;
-import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
-import org.eclipse.uml2.uml.Model;
-import org.eclipse.uml2.uml.Node;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Reception;
-import org.eclipse.uml2.uml.Signal;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.resource.UMLResource;
@@ -60,33 +35,33 @@ public class FUMLFilter extends NotificationFilter.Custom {
}
Object feature = notification.getFeature();
if (notifier != null && feature != null) {
- if (this.isEnumeration(notifier)) {
+ if (FUMLScopeUtil.isEnumeration(notifier)) {
return this.isEnumerationFeatureListened((EStructuralFeature) feature);
- } else if (this.isDataType(notifier)) {
+ } else if (FUMLScopeUtil.isDataType(notifier)) {
return this.isDatatypeFeatureListened((EStructuralFeature) feature);
- } else if (this.isPackage(notifier)) {
+ } else if (FUMLScopeUtil.isPackage(notifier)) {
return this.isPackageFeatureListened((EStructuralFeature) feature);
}/* else if (this.isAssociation(notifier)) {
return this.isAssociationFeatureListener((EStructuralFeature) feature);
- }*/ else if (this.isSignal(notifier)) {
+ }*/ else if (FUMLScopeUtil.isSignal(notifier)) {
return this.isSignalFeatureListened((EStructuralFeature) feature);
- } else if (this.isClass(notifier)) {
+ } else if (FUMLScopeUtil.isClass(notifier)) {
return this.isClassFeatureListened((EStructuralFeature) feature);
- } else if (this.isGeneralization(notifier)) {
+ } else if (FUMLScopeUtil.isGeneralization(notifier)) {
return this.isGeneralizationtFeatureListened((EStructuralFeature) feature);
- }else if(this.isProperty(notifier)){
+ }else if(FUMLScopeUtil.isProperty(notifier)){
return this.isPropertyFeatureListened((EStructuralFeature)feature);
- }else if(this.isOperation(notifier)){
+ }else if(FUMLScopeUtil.isOperation(notifier)){
return this.isOperationFeatureListened((EStructuralFeature)feature);
- }else if(this.isReception(notifier)){
+ }else if(FUMLScopeUtil.isReception(notifier)){
return this.isReceptionFeatureListened((EStructuralFeature)feature);
- }else if(this.isLiteralUnlimitedNatural(notifier)){
+ }else if(FUMLScopeUtil.isLiteralUnlimitedNatural(notifier)){
return this.isLiteralUnlimitedNaturalFeatureListened((EStructuralFeature)feature);
- }else if(this.isEnumerationLiteral(notifier)){
+ }else if(FUMLScopeUtil.isEnumerationLiteral(notifier)){
return this.isEnumerationLiteralFeatureListened((EStructuralFeature)feature);
- }else if(this.isPackageImport(notifier)){
+ }else if(FUMLScopeUtil.isPackageImport(notifier)){
return this.isPackageImportFeatureListened((EStructuralFeature)feature);
- }else if(this.isElementImport(notifier)){
+ }else if(FUMLScopeUtil.isElementImport(notifier)){
return this.isElementImportFeatureListened((EStructuralFeature)feature);
}
}
@@ -103,188 +78,7 @@ public class FUMLFilter extends NotificationFilter.Custom {
}
return allowed;
}
-
- /*----------------------------------------------------------------------------*/
- /* Enforce the filter to respect the fUML subset */
- /*----------------------------------------------------------------------------*/
- /**
- * Check if the given notifier is strictly a Class
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isClass(Object notifier) {
- if (notifier instanceof Class &&
- (!(notifier instanceof AssociationClass) &&
- !(notifier instanceof Component) &&
- !(notifier instanceof Node) &&
- !(notifier instanceof Stereotype) &&
- !(notifier instanceof Behavior))) {
- return true;
- }
- return false;
- }
-
- /**
- * Check if the given notifier is strictly a Signal
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isSignal(Object notifier) {
- return notifier instanceof Signal;
- }
-
- /**
- * Check if the given notifier is strictly a DataType
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isDataType(Object notifier) {
- if (notifier instanceof DataType
- && !(notifier instanceof Enumeration)) {
- return true;
- }
- return false;
- }
-
- /**
- * Check if the given notifier is strictly a Package
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isPackage(Object notifier) {
- if (notifier != null
- && notifier instanceof Package
- && !(notifier instanceof Model)
- && !(notifier instanceof Profile)) {
- return true;
- }
- return false;
- }
-
- /**
- * Check if the given notifier is strictly an Enumeration
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isEnumeration(Object notifier) {
- return notifier instanceof Enumeration;
- }
-
- /**
- * Check if the given notifier is strictly an Association
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- @SuppressWarnings("unused")
- private boolean isAssociation(Object notifier) {
- if (notifier instanceof Association
- && !(notifier instanceof AssociationClass)
- && !(notifier instanceof Extension)
- && !(notifier instanceof CommunicationPath)) {
- return true;
- }
- return false;
- }
-
- /**
- * Check if the given notifier is strictly a Generalization
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isGeneralization(Object notifier) {
- return notifier instanceof Generalization;
- }
-
- /**
- * Check if the given notifier is strictly a property
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isProperty(Object notifier){
- if(notifier instanceof Property
- && !(notifier instanceof Port)
- && !(notifier instanceof ExtensionEnd) ){
- return true;
- }
- return false;
- }
-
- private boolean isLiteralUnlimitedNatural(Object notifier){
- return notifier instanceof LiteralUnlimitedNatural;
- }
-
- /**
- * Check if the given notifier is strictly an Operation
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isOperation(Object notifier){
- return notifier instanceof Operation;
- }
-
-
- /**
- * Check if the given notifier is strictly a Reception
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isReception(Object notifier){
- return notifier instanceof Reception;
- }
-
- /**
- * Check if the given notifier is strictly an Enumeration literal
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isEnumerationLiteral(Object notifier){
- return notifier instanceof EnumerationLiteral;
- }
-
- /**
- * Check if the given notifier is strictly a PackageImport
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isPackageImport(Object notifier){
- return notifier instanceof PackageImport;
- }
- /**
- * Check if the given notifier is strictly an ElementImport
- *
- * @param notifier
- *
- * @return true if constraint is verified false otherwise
- */
- private boolean isElementImport(Object notifier){
- return notifier instanceof ElementImport;
- }
-
/*----------------------------------------------------------------------------*/
/* Low level checks encoding the UML meta-model hierarchy */
/*----------------------------------------------------------------------------*/
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
new file mode 100644
index 00000000000..f2631bde785
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLScopeUtil.java
@@ -0,0 +1,224 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Jeremie Tatibouet (CEA LIST)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter;
+
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.AssociationClass;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.CommunicationPath;
+import org.eclipse.uml2.uml.Component;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.ElementImport;
+import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.ExtensionEnd;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.LiteralUnlimitedNatural;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Node;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Reception;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * Provides utility to check if an object is part of the fUML scope
+ */
+public class FUMLScopeUtil {
+
+ /**
+ * Check if the given notifier is strictly a Class
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isClass(Object notifier) {
+ if (notifier instanceof Class &&
+ (!(notifier instanceof AssociationClass) &&
+ !(notifier instanceof Component) &&
+ !(notifier instanceof Node) &&
+ !(notifier instanceof Stereotype) &&
+ !(notifier instanceof Behavior))) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the given notifier is strictly a Signal
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isSignal(Object notifier) {
+ return notifier instanceof Signal;
+ }
+
+ /**
+ * Check if the given notifier is strictly a DataType
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isDataType(Object notifier) {
+ if (notifier instanceof DataType
+ && !(notifier instanceof Enumeration)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the given notifier is strictly a Package
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isPackage(Object notifier) {
+ if (notifier != null
+ && notifier instanceof Package
+ && !(notifier instanceof Model)
+ && !(notifier instanceof Profile)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if the given notifier is strictly an Enumeration
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isEnumeration(Object notifier) {
+ return notifier instanceof Enumeration;
+ }
+
+ /**
+ * Check if the given notifier is strictly an Association
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isAssociation(Object notifier) {
+ if (notifier instanceof Association
+ && !(notifier instanceof AssociationClass)
+ && !(notifier instanceof Extension)
+ && !(notifier instanceof CommunicationPath)) {
+ Association association = (Association)notifier;
+ return association.getOwnedEnds().size() == association.getMemberEnds().size();
+ }
+ return false;
+ }
+
+ /**
+ * Check if the given notifier is strictly a Generalization
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isGeneralization(Object notifier) {
+ return notifier instanceof Generalization;
+ }
+
+ /**
+ * Check if the given notifier is strictly a property
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isProperty(Object notifier){
+ if(notifier instanceof Property
+ && !(notifier instanceof Port)
+ && !(notifier instanceof ExtensionEnd) ){
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isLiteralUnlimitedNatural(Object notifier){
+ return notifier instanceof LiteralUnlimitedNatural;
+ }
+
+ /**
+ * Check if the given notifier is strictly an Operation
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isOperation(Object notifier){
+ return notifier instanceof Operation;
+ }
+
+
+ /**
+ * Check if the given notifier is strictly a Reception
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isReception(Object notifier){
+ return notifier instanceof Reception;
+ }
+
+ /**
+ * Check if the given notifier is strictly an Enumeration literal
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isEnumerationLiteral(Object notifier){
+ return notifier instanceof EnumerationLiteral;
+ }
+
+ /**
+ * Check if the given notifier is strictly a PackageImport
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isPackageImport(Object notifier){
+ return notifier instanceof PackageImport;
+ }
+
+ /**
+ * Check if the given notifier is strictly an ElementImport
+ *
+ * @param notifier
+ *
+ * @return true if constraint is verified false otherwise
+ */
+ public static boolean isElementImport(Object notifier){
+ return notifier instanceof ElementImport;
+ }
+
+}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml
index 302c5d51946..4769bb6b5af 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml
@@ -6,8 +6,9 @@
<propertySections
contributorId="TreeOutlinePage">
<propertySection
- class="org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySection"
- filter="org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySectionFilter"
+ class="org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AlfEditionPropertySection"
+ enablesFor="1"
+ filter="org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AlfEditorPropertySectionFilter"
id="alf.property.section.AdvancedEditingPropertySection"
tab="alf_editing">
<input
@@ -31,68 +32,5 @@
label="ALF">
</propertyTab>
</propertyTabs>
- </extension>
- <extension
- point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
- <DirectEditor
- language="Alf"
- objectToEdit="org.eclipse.uml2.uml.Class">
- <popupeditor
- editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
- </popupeditor>
- <Priority
- name="Highest">
- </Priority>
- </DirectEditor>
- <DirectEditor
- language="Alf"
- objectToEdit="org.eclipse.uml2.uml.Enumeration">
- <popupeditor
- editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
- </popupeditor>
- <Priority
- name="Highest">
- </Priority>
- </DirectEditor>
- <DirectEditor
- language="Alf"
- objectToEdit="org.eclipse.uml2.uml.Signal">
- <popupeditor
- editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
- </popupeditor>
- <Priority
- name="Highest">
- </Priority>
- </DirectEditor>
- <DirectEditor
- language="Alf"
- objectToEdit="org.eclipse.uml2.uml.DataType">
- <popupeditor
- editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
- </popupeditor>
- <Priority
- name="Highest">
- </Priority>
- </DirectEditor>
- <DirectEditor
- language="Alf"
- objectToEdit="org.eclipse.uml2.uml.Package">
- <popupeditor
- editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
- </popupeditor>
- <Priority
- name="Highest">
- </Priority>
- </DirectEditor>
- <DirectEditor
- language="Alf"
- objectToEdit="org.eclipse.uml2.uml.Association">
- <popupeditor
- editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
- </popupeditor>
- <Priority
- name="Highest">
- </Priority>
- </DirectEditor>
- </extension>
+ </extension>
</plugin>
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java
deleted file mode 100644
index f700bdb05f2..00000000000
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * Jeremie Tatibouet
- * Arnaud Cuccuru
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.alf.properties.xtext.configuration;
-
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.uml.alf.impl.ModelNamespaceImpl;
-import org.eclipse.papyrus.uml.alf.libraries.helper.AlfUtil;
-import org.eclipse.papyrus.uml.alf.libraries.helper.BackupUtil;
-import org.eclipse.papyrus.uml.alf.parser.antlr.MutableAlfParser;
-import org.eclipse.papyrus.uml.alf.ui.internal.AlfActivator;
-import org.eclipse.papyrus.uml.alf.properties.xtext.parser.GMFAlfParser;
-import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.NamedElement;
-
-import com.google.inject.Injector;
-
-public abstract class AbstractAlfXtextEditorConfiguration extends DefaultXtextDirectEditorConfiguration {
-
- private void loadProfiles(Element context) {
- AlfUtil alfProfileHelper = AlfUtil.getInstance();
- BackupUtil backupProfileHelper = BackupUtil.getInstance();
- if (!alfProfileHelper.isActionLanguageProfileApplied(context)) {
- alfProfileHelper.applyActionLanguageProfile(context);
- }
- if (!backupProfileHelper.isBackupProfileApplied(context)) {
- backupProfileHelper.applyBackupProfile(context);
- }
- }
-
- /**
- * Update the context in which the Alf representation will be validated.
- * The context is the namespace of the editedObject if any
- *
- * @param editedObject
- */
- protected void updateAlfModelContext(EObject editedObject) {
- if (editedObject instanceof NamedElement) {
- NamedElement element = (NamedElement) editedObject;
- ModelNamespaceImpl.setContext(element.getNamespace());
- this.loadProfiles(element);
- }
- }
-
- /**
- * Provide the injector with the location of the implementation of the Alf Language
- */
- @Override
- public Injector getInjector() {
- return AlfActivator.getInstance().getInjector(AlfActivator.ORG_ECLIPSE_PAPYRUS_UML_ALF_ALF);
- }
-
- /**
- * Provide a GMF wrapped parser
- */
- public IParser createParser(final EObject semanticObject) {
- return new GMFAlfParser(semanticObject, this);
- }
-
- /**
- * Not used - see GMFCompatibleAlfParser
- */
- public String getEditString(IAdaptable element, int flags) {
- return null;
- }
-
- /**
- * Not used - see GMFCompatibleAlfParser
- */
- @Override
- protected ICommand getParseCommand(EObject umlObject, EObject xtextObject) {
- return null;
- }
-
- /**
- * Executed before the editor opens
- */
- public Object preEditAction(Object objectToEdit) {
- /* 1. Save a reference to the object to edit */
- this.setObjectToEdit(objectToEdit);
- /* 2. Change the compilation context */
- this.updateAlfModelContext((EObject) objectToEdit);
- /* 3. Let the parser access to the semantic element for which a textual representation is parsed */
- MutableAlfParser.SEMANTIC_ELEMENT = (EObject) objectToEdit; /* FIXME */
- return null;
- }
-
-
- /**
- * Not used
- */
- public ICommand createInvalidStringCommand(final String newString, EObject semanticElement) {
- return null;
- }
-
- public abstract String getEditString(EObject semanticObject);
-
- public abstract ICommand getParseCommand(String textualRepresentation, EObject umlObject, EObject xtextObject);
-}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java
deleted file mode 100644
index 0daf2a21f2e..00000000000
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * Jérémie Tatibouet
- * Arnaud Cuccuru
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.alf.properties.xtext.configuration;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
-import org.eclipse.papyrus.uml.alf.text.generation.DefaultEditStringRetrievalStrategy;
-import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
-import org.eclipse.papyrus.uml.alf.transaction.commands.AlfCommandFactory;
-import org.eclipse.papyrus.uml.xtext.integration.XtextFakeResourceContext;
-import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter;
-import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProvider;
-import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProviderWithInit;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.xtext.EcoreUtil2;
-import org.eclipse.xtext.util.CancelIndicator;
-import org.eclipse.xtext.util.StringInputStream;
-
-/**
- * Configuration used by the DirectEditor for Alf
- */
-public class DefaultAlfXtextEditorConfiguration extends
- AbstractAlfXtextEditorConfiguration {
-
- /**
- * Called each time the editor using the configuration is refreshed
- *
- * @param semanticObject
- * @return the textual representation of a specific semantic object
- */
- @Override
- public String getEditString(EObject semanticObject) {
- this.updateAlfModelContext(semanticObject);
- return new DefaultEditStringRetrievalStrategy().getEditString((NamedElement) semanticObject);
- }
-
- /**
- * Build the parse command required to launch the compilation of the textual representation (only if it has no syntax errors).
- *
- */
- @Override
- public ICommand getParseCommand(String textualRepresentation,
- EObject semanticObject, EObject xtextObject) {
- AlfTextualRepresentation representation = new AlfTextualRepresentation((NamedElement) semanticObject);
- IContextElementProvider provider = this.getContextProvider();
- XtextFakeResourceContext context = new XtextFakeResourceContext(this.getInjector());
- context.getFakeResource().eAdapters().add(new ContextElementAdapter(provider));
- try {
- context.getFakeResource().load(new StringInputStream(textualRepresentation), Collections.EMPTY_MAP);
- } catch (IOException e) {
- e.printStackTrace();
- }
- if (provider instanceof IContextElementProviderWithInit) {
- ((IContextElementProviderWithInit) provider).initResource(context.getFakeResource());
- }
- EcoreUtil2.resolveLazyCrossReferences(context.getFakeResource(), CancelIndicator.NullImpl);
- return new EMFtoGMFCommandWrapper(AlfCommandFactory.getInstance().createCompilationCommand(representation));
- }
-} \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java
deleted file mode 100644
index 2f7ca130029..00000000000
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * 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:
- * CEA LIST - Initial API and implementation
- * Jeremie Tatibouet (CEA LIST)
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.alf.properties.xtext.constraints;
-
-import org.eclipse.uml2.uml.Association;
-import org.eclipse.uml2.uml.AssociationClass;
-import org.eclipse.uml2.uml.CommunicationPath;
-import org.eclipse.uml2.uml.Extension;
-
-/**
- * This class implements the opening constraints for the ALF editor
- */
-public class ALFFilterConstraint {
-
- private ALFFilterConstraint() {
- }
-
- /**
- * Checks if an association can edited using ALF
- *
- * @param association
- * the association evaluated against the constraints
- *
- * @return conforms
- * true if the association respects the constraints
- */
- public static boolean conforms(Association association) {
- boolean conforms = true;
- /* The editor can only be opened for associations owning all of their ends */
- if (association != null && isStrictAssociation(association)) {
- conforms = association.getOwnedEnds().size() == association.getMemberEnds().size();
- }
- return conforms;
- }
-
- /**
- * Checks if a given association is strictly an Association and not an instance of one of the sub-classes
- *
- * @param association
- * the association for which we verifies that it is not a sub-class instance
- *
- * @return true if the association is only an instance of Association, false otherwise
- */
- private static boolean isStrictAssociation(Association association) {
- return !(association instanceof AssociationClass) &&
- !(association instanceof CommunicationPath) &&
- !(association instanceof Extension);
- }
-
-}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java
deleted file mode 100644
index 72e19f7caea..00000000000
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * Jérémie Tatibouet
- * Arnaud Cuccuru
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.alf.properties.xtext.parser;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.uml.alf.properties.xtext.configuration.AbstractAlfXtextEditorConfiguration;
-import org.eclipse.uml2.uml.NamedElement;
-
-/**
- * Provide the possibility to use the ALF parser directly in the context of GMF.
- */
-public class GMFAlfParser implements IParser {
-
- protected final static String TEXTUAL_REPRESENTATION_ERROR = "/*String representation could not be computed*/";
-
- protected final EObject semanticObject;
-
- protected AbstractAlfXtextEditorConfiguration configuration;
-
- /**
- * Retrieve the NamedElement hidden behind the adapter
- *
- * @param adaptable
- * @return the adapted element
- */
- protected NamedElement adapt(IAdaptable adaptable) {
- Object o = EMFHelper.getEObject(adaptable);
- if (o != null && o instanceof NamedElement) {
- return (NamedElement) o;
- }
- return null;
- }
-
- /**
- * Initializes the context in which type names are going to be resolved
- */
-
- public GMFAlfParser(final EObject semanticObject, final AbstractAlfXtextEditorConfiguration configuration) {
- this.semanticObject = semanticObject;
- this.configuration = configuration;
- }
-
- /***
- * Delegate computation of the textual representation to the configuration
- */
- public String getEditString(IAdaptable element, int flags) {
- NamedElement target = this.adapt(element);
- if (target != null) {
- return this.configuration.getEditString(target);
- } else if (this.semanticObject != null) {
- return this.configuration.getEditString(this.semanticObject);
- } else {
- return TEXTUAL_REPRESENTATION_ERROR;
- }
- }
-
- public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
- return ParserEditStatus.EDITABLE_STATUS;
- }
-
- /**
- * Delegate creation of the parse command to the configuration
- */
- public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
- NamedElement target = this.adapt(element);
- if (target != null) {
- return this.configuration.getParseCommand(newString, target, null);
- } else if (this.semanticObject != null) {
- return this.configuration.getParseCommand(newString, this.semanticObject, null);
- } else {
- return null;
- }
- }
-
- /**
- * No differences between results returned by getPrintString or getEditString
- */
- public String getPrintString(IAdaptable element, int flags) {
- return this.getEditString(element, flags);
- }
-
- public boolean isAffectingEvent(Object event, int flags) {
- return false;
- }
-
- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
- return null;
- }
-
-}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
deleted file mode 100644
index 9ccf1c8fefa..00000000000
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.alf.properties.xtext.sheet;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.IFilter;
-import org.eclipse.papyrus.extensionpoints.editors.Activator;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
-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.uml.alf.properties.xtext.constraints.ALFFilterConstraint;
-import org.eclipse.uml2.uml.Association;
-
-public class AdvancedEditingPropertySectionFilter implements IFilter {
-
- public boolean select(Object toTest) {
- EObject semanticElement = null;
- if (toTest instanceof IAdaptable) {
- semanticElement = (EObject) ((IAdaptable) toTest).getAdapter(EObject.class);
- }
- else if (toTest instanceof GraphicalEditPart) {
- GraphicalEditPart part = (GraphicalEditPart) toTest;
- semanticElement = part.resolveSemanticElement();
- }
- if (semanticElement != null) {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
- + semanticElement.eClass().getInstanceClassName();
-
- String languagePreferred = store.getString(key);
-
- if (languagePreferred != null && !languagePreferred.equals("")) {
- IDirectEditorConfiguration configuration = null;
- if (languagePreferred.equals("Alf") && semanticElement instanceof Association) {
- if (ALFFilterConstraint.conforms((Association) semanticElement)) {
- configuration = DirectEditorsUtil.findEditorConfiguration(
- languagePreferred, semanticElement.eClass()
- .getInstanceClassName());
- }
- } else {
- configuration = DirectEditorsUtil.findEditorConfiguration(
- languagePreferred, semanticElement.eClass()
- .getInstanceClassName());
- }
- return configuration instanceof ICustomDirectEditorConfiguration;
- }
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java
index 154dce39d28..18322897b0a 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditionPropertySection.java
@@ -15,29 +15,20 @@
package org.eclipse.papyrus.uml.alf.properties.xtext.sheet;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AbstractModelerPropertySection;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.preference.IPreferenceStore;
-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.utils.EMFHelper;
-import org.eclipse.papyrus.uml.alf.transaction.job.AlfJobObserver;
import org.eclipse.papyrus.uml.alf.properties.xtext.UndoRedoStack;
import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners.CommitButtonSelectionListener;
import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners.EditorFocusListener;
-import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
+import org.eclipse.papyrus.uml.alf.text.generation.DefaultEditStringRetrievalStrategy;
+import org.eclipse.papyrus.uml.alf.transaction.job.AlfJobObserver;
+import org.eclipse.papyrus.uml.alf.ui.internal.AlfActivator;
import org.eclipse.papyrus.uml.xtext.integration.StyledTextXtextAdapter;
import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter;
import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProvider;
-import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProviderWithInit;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ExtendedModifyEvent;
import org.eclipse.swt.custom.ExtendedModifyListener;
@@ -55,12 +46,15 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.uml2.uml.Element;
+
+import com.google.inject.Injector;
/**
* Attention: class has been deactivated, since the additional tab is redundant with the
* body editor in the standard UML property tab.
*/
-public class AdvancedEditingPropertySection extends
+public class AlfEditionPropertySection extends
AbstractModelerPropertySection implements IContextElementProvider {
private FormToolkit toolkit;
@@ -71,23 +65,24 @@ public class AdvancedEditingPropertySection extends
private Button commitButton;
- private DefaultXtextDirectEditorConfiguration configuration;
-
- private StyledTextXtextAdapter xtextAdapter;
+ private StyledTextXtextAdapter styledTextAdapter;
- final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter(
- this);
+ final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter(this);
- UndoRedoStack<ExtendedModifyEvent> undoRedoStack;
+ private UndoRedoStack<ExtendedModifyEvent> undoRedoStack;
protected boolean isUndo;
protected boolean isRedo;
- protected EObject currentEObj;
-
- public AdvancedEditingPropertySection() {
- undoRedoStack = new UndoRedoStack<ExtendedModifyEvent>();
+ private DefaultEditStringRetrievalStrategy alfSerialization;
+
+ private Injector alfToolingInjector;
+
+ public AlfEditionPropertySection() {
+ this.undoRedoStack = new UndoRedoStack<ExtendedModifyEvent>();
+ this.alfSerialization = new DefaultEditStringRetrievalStrategy();
+ this.alfToolingInjector = AlfActivator.getInstance().getInjector(AlfActivator.ORG_ECLIPSE_PAPYRUS_UML_ALF_ALF);
}
public StyledText getEditor() {
@@ -96,22 +91,25 @@ public class AdvancedEditingPropertySection extends
@Override
public void refresh() {
- updateXtextAdapters(this.textControl);
- IParser parser = getParser();
- if (parser != null) {
- this.textControl.setText(parser.getEditString(new EObjectAdapter(eObject), 0));
+ /*1. Update adapters placed over the xtext resource*/
+ this.updateXtextAdapters(this.textControl);
+ /*2. Compute edit string*/
+ String serialization = "/*Error: serialization could not be computed*/";
+ if(this.eObject!=null){
+ serialization = this.alfSerialization.getEditString((Element)this.eObject);
}
-
- if (textControl != null) {
- textControl.setEnabled(!isReadOnly());
+ /*3. Set up editor content (textControl)*/
+ this.textControl.setText(serialization);
+ if (this.textControl != null) {
+ this.textControl.setEnabled(!isReadOnly());
}
}
@Override
public void aboutToBeHidden() {
super.aboutToBeHidden();
- if (xtextAdapter != null) {
- xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
+ if (styledTextAdapter != null) {
+ styledTextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
.remove(contextElementAdapter);
}
}
@@ -232,90 +230,13 @@ public class AdvancedEditingPropertySection extends
textControl.setSelectionRange(event.start, event.replacedText.length());
}
-
- protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() {
- EObject semanticElement = getSemanticObjectFromSelection();
- if (semanticElement != null) {
- IPreferenceStore store = Activator.getDefault()
- .getPreferenceStore();
- String semanticClassName = semanticElement.eClass()
- .getInstanceClassName();
- String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
- + semanticClassName;
- String languagePreferred = store.getString(key);
-
- if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
- IDirectEditorConfiguration configuration = DirectEditorsUtil
- .findEditorConfiguration(languagePreferred,
- semanticClassName);
- if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
-
- DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration;
- xtextConfiguration.preEditAction(semanticElement);
- return xtextConfiguration;
- }
- }
- }
- return null;
- }
-
- protected EObject getSemanticObjectFromSelection() {
- Object selection = getPrimarySelection();
- if (selection instanceof IGraphicalEditPart) {
- return ((IGraphicalEditPart) selection).resolveSemanticElement();
- }
- else if (selection instanceof IAdaptable) {
- return (EObject) ((IAdaptable) selection).getAdapter(EObject.class);
- }
- return null;
- }
-
- public IParser getParser() {
- final EObject semanticElement = getSemanticObjectFromSelection();
- if (configuration != null && semanticElement != null) {
- return configuration.createParser(semanticElement);
- }
- return null;
- }
-
protected void updateXtextAdapters(Control styledText) {
- final Object oldObjectToEdit = configuration != null ? configuration.getObjectToEdit() : null;
-
- final DefaultXtextDirectEditorConfiguration newConfiguration = getConfigurationFromSelection();
- // Check if configuration has changed and update adapters
- if (newConfiguration != null && newConfiguration != configuration) {
- if (xtextAdapter != null) {
- xtextAdapter.getFakeResourceContext().getFakeResource()
- .eAdapters().remove(contextElementAdapter);
- }
- configuration = newConfiguration;
- xtextAdapter = new StyledTextXtextAdapter(
- configuration.getInjector());
-
- EObject semanticElement = getSemanticObjectFromSelection();
- if (semanticElement != null) {
- newConfiguration.preEditAction(semanticElement);
- }
-
- xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
- .add(contextElementAdapter);
- xtextAdapter.adapt((StyledText) styledText);
- }
-
- if (configuration.getObjectToEdit() != oldObjectToEdit) {
- IContextElementProvider provider = configuration.getContextProvider();
- if (provider instanceof IContextElementProviderWithInit) {
- // update resource, if required by text editor
- if (xtextAdapter != null) {
- ((IContextElementProviderWithInit) provider).initResource(
- xtextAdapter.getFakeResourceContext().getFakeResource());
- }
- }
- Object semanticObject = configuration.getObjectToEdit();
- if (semanticObject instanceof EObject) {
- currentEObj = (EObject) semanticObject;
- }
+ if (styledTextAdapter != null) {
+ styledTextAdapter.getFakeResourceContext().getFakeResource().eAdapters().remove(contextElementAdapter);
}
+ styledTextAdapter = new StyledTextXtextAdapter(this.alfToolingInjector);
+ styledTextAdapter.getFakeResourceContext().getFakeResource().eAdapters().add(contextElementAdapter);
+ styledTextAdapter.adapt((StyledText) styledText);
}
public EObject getContextObject() {
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
new file mode 100644
index 00000000000..151c3b47c31
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AlfEditorPropertySectionFilter.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.properties.xtext.sheet;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.jface.viewers.IFilter;
+import org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter.FUMLScopeUtil;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * This class constrains the availability of the embedded ALF editor.
+ *
+ * The ALF editor must only be available when:
+ * 1. The selection is a Class (not composite)
+ * 2. The selection is an Association
+ * 3. The selection is a Signal
+ * 4. The selection is a Datatype
+ * 5. The selection is an Enumeration
+ * 6. The selection is a Package
+ * 7. The selection is an Activity
+ */
+public class AlfEditorPropertySectionFilter implements IFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object)
+ *
+ * @param toTest
+ *
+ * @return accepted
+ */
+ public boolean select(Object toTest) {
+ Element element = this.resolveSemanticElement(toTest);
+ boolean accepted = false;
+ if(element!=null){
+ accepted = this.isValidInput(element);
+ }
+ return accepted;
+ }
+
+ /**
+ * Check the given input and returns true if it is a valid input for the embedded ALF editor
+ * false otherwise
+ *
+ * @param element
+ * an input element for ALF embedded editor
+ *
+ * @return true if element is accepted as an input false otherwise
+ */
+ private boolean isValidInput(Element element){
+ if(FUMLScopeUtil.isClass(element)){
+ return true;
+ }else if(FUMLScopeUtil.isPackage(element)){
+ return true;
+ }else if(FUMLScopeUtil.isSignal(element)){
+ return true;
+ }else if(FUMLScopeUtil.isEnumeration(element)){
+ return true;
+ }else if(FUMLScopeUtil.isDataType(element)){
+ return true;
+ }else if(FUMLScopeUtil.isAssociation(element)){
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * From a selection this methods tries to extract the underlying model element
+ *
+ * @param selectedElement
+ * an object selected in the view (e.g., a class in a diagram)
+ *
+ * @return semanticElement
+ * the model element that is under the graphical element (may be null)
+ */
+ private Element resolveSemanticElement(Object selectedElement){
+ Element semanticElement = null;
+ if (selectedElement instanceof IAdaptable) {
+ semanticElement = (Element) ((IAdaptable) selectedElement).getAdapter(EObject.class);
+ }
+ else if (selectedElement instanceof GraphicalEditPart) {
+ GraphicalEditPart part = (GraphicalEditPart) selectedElement;
+ semanticElement = (Element)part.resolveSemanticElement();
+ }
+ return semanticElement;
+ }
+} \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java
index 537a5adc47c..68036f95e6a 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java
@@ -15,7 +15,7 @@
package org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners;
import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory;
-import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySection;
+import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AlfEditionPropertySection;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -24,9 +24,9 @@ import org.eclipse.uml2.uml.NamedElement;
public class CommitButtonSelectionListener extends SelectionAdapter {
- private AdvancedEditingPropertySection propertySection;
+ private AlfEditionPropertySection propertySection;
- public CommitButtonSelectionListener(AdvancedEditingPropertySection propertySection) {
+ public CommitButtonSelectionListener(AlfEditionPropertySection propertySection) {
this.propertySection = propertySection;
}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java
index fe0f9715813..f6a0a1d09d7 100644
--- a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java
@@ -15,7 +15,7 @@
package org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners;
import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory;
-import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySection;
+import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AlfEditionPropertySection;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -24,9 +24,9 @@ import org.eclipse.uml2.uml.NamedElement;
public class EditorFocusListener extends FocusAdapter {
- private AdvancedEditingPropertySection section;
+ private AlfEditionPropertySection section;
- public EditorFocusListener(AdvancedEditingPropertySection section) {
+ public EditorFocusListener(AlfEditionPropertySection section) {
this.section = section;
}

Back to the top