Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremie Tatibouet2015-03-24 13:15:15 +0000
committerCamille Letavernier2015-03-24 13:19:29 +0000
commit246b5ad5b70a9d974448ec9c2dfd8fdfe10553e2 (patch)
tree3fafa30290597619ed71bc13fafad1eb8d5f5bb1 /extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org
parentdef2c21b7ea8a1529fa6b06a96dd1a30ddc4f6da (diff)
downloadorg.eclipse.papyrus-246b5ad5b70a9d974448ec9c2dfd8fdfe10553e2.tar.gz
org.eclipse.papyrus-246b5ad5b70a9d974448ec9c2dfd8fdfe10553e2.tar.xz
org.eclipse.papyrus-246b5ad5b70a9d974448ec9c2dfd8fdfe10553e2.zip
462954: [ALF] Integrate the new ALF grammar & tooling
https://bugs.eclipse.org/bugs/show_bug.cgi?id=462954 - Squash the committers/cletavernie/alf-integration branch Also-by: Ed Seidewitz <ed-s@modeldriven.com> Also-by: Arnaud Cuccuru <arnaud.cuccuru@cea.fr> Signed-off-by: Jeremie Tatibouet <jeremie.tatibouet@cea.fr>
Diffstat (limited to 'extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org')
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/ActivatorTransaction.java56
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommand.java51
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandFactory.java70
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandLabels.java25
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/CompileCommand.java62
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/SaveCommand.java54
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/VersioningSaveCommand.java35
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ChangeScenario.java46
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/CommitScenario.java96
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IChangeScenario.java17
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IScenario.java28
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ISyncScenario.java30
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SaveScenario.java100
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/Scenario.java53
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ScenarioFactory.java41
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SyncScenario.java163
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfAbstractJob.java50
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfCompilationJob.java69
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfJobObserver.java63
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/SaveTextualRepresentationJob.java49
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/FUMLElementService.java56
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java77
-rw-r--r--extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java289
23 files changed, 1580 insertions, 0 deletions
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/ActivatorTransaction.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/ActivatorTransaction.java
new file mode 100644
index 00000000000..fd7eff3f384
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/ActivatorTransaction.java
@@ -0,0 +1,56 @@
+package org.eclipse.papyrus.uml.alf.transaction;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ActivatorTransaction extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.alf.transaction"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ActivatorTransaction plugin;
+
+ public static LogHelper logger;
+
+ /**
+ * The constructor
+ */
+ public ActivatorTransaction() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ logger = new LogHelper(plugin);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ logger = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ActivatorTransaction getDefault() {
+ return plugin;
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommand.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommand.java
new file mode 100644
index 00000000000..37109581d15
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommand.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * 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.transaction.commands;
+
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Transaction used by the ALF framework to persist modification of UML model
+ */
+public abstract class AlfCommand extends RecordingCommand {
+
+ /**
+ * The state of a particular model element given as text
+ */
+ protected AlfTextualRepresentation modelElementState;
+
+
+ public AlfCommand(String commandLabel, AlfTextualRepresentation state) {
+ super(TransactionUtil.getEditingDomain(state.getOwner()));
+ this.modelElementState = state;
+ }
+
+ /**
+ * Returns the UML named element target by the command execution
+ */
+ public NamedElement getCommandTarget() {
+ return this.modelElementState.getOwner();
+ }
+
+ /**
+ * Returns the modification that need to be applied to a particular model element
+ */
+ public AlfTextualRepresentation getModelElementState() {
+ return this.modelElementState;
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandFactory.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandFactory.java
new file mode 100644
index 00000000000..9c1f484dd61
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandFactory.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * 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.transaction.commands;
+
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+
+/**
+ * Factory providing facilities to instantiate ALF commands.
+ */
+public class AlfCommandFactory {
+
+ /** The factory. */
+ private static AlfCommandFactory factory;
+
+ /**
+ * Instantiates a new alf command factory.
+ */
+ private AlfCommandFactory() {
+ }
+
+ /**
+ * Gets the single instance of AlfCommandFactory.
+ *
+ * @return single instance of AlfCommandFactory
+ */
+ public static AlfCommandFactory getInstance() {
+ if (factory == null) {
+ factory = new AlfCommandFactory();
+ }
+ return factory;
+ }
+
+ /**
+ * Creates a new AlfCommand object.
+ *
+ * @param element
+ * the element
+ * @param textualRepresentation
+ * the textual representation
+ * @return the abstract transactional command
+ */
+ public AlfCommand createCompilationCommand(AlfTextualRepresentation representation) {
+ return new CompileCommand(representation);
+ }
+
+ /**
+ * Creates a new AlfCommand object.
+ *
+ * @param element
+ * the element
+ * @param textualRepresentation
+ * the textual representation
+ * @return the abstract transactional command
+ */
+ public AlfCommand creatSaveCommand(AlfTextualRepresentation representation) {
+ return new VersioningSaveCommand(representation);
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandLabels.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandLabels.java
new file mode 100644
index 00000000000..727c1a02ee8
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/AlfCommandLabels.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * 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.transaction.commands;
+
+/**
+ * Provides ALF commands labels.
+ */
+public class AlfCommandLabels {
+
+ public static final String COMPILATION = "Compilation";
+
+ public static final String CREATE_OR_UPDATE_TEXTUAL_REPRESENTATION = "Create Or Update Textual Representation";
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/CompileCommand.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/CompileCommand.java
new file mode 100644
index 00000000000..d9455109ec7
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/CompileCommand.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * 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.transaction.commands;
+
+import org.eclipse.core.runtime.AssertionFailedException;
+import org.eclipse.emf.common.util.WrappedException;
+import org.eclipse.papyrus.uml.alf.AlfCompiler;
+import org.eclipse.papyrus.uml.alf.MappingError;
+import org.eclipse.papyrus.uml.alf.ParsingError;
+import org.eclipse.papyrus.uml.alf.libraries.helper.AlfUtil;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * This command enables the compilation (ALF->fUML) of the given textual representation
+ */
+public class CompileCommand extends AlfCommand {
+
+ protected CompileCommand(AlfTextualRepresentation modelElementState) {
+ super(AlfCommandLabels.COMPILATION, modelElementState);
+ }
+
+ /**
+ * Compile the description provided by the textual representation and merge
+ * them within the current model element
+ */
+ protected void doExecute() {
+ NamedElement context = this.modelElementState.getOwner();
+ Model root = context.getModel();
+ if (root != null) {
+ AlfCompiler alfCompiler = new AlfCompiler(
+ (NamedElement) this.modelElementState.getOwner(),
+ AlfUtil.getInstance().getStandardProfile(root),
+ AlfUtil.getInstance().getActionLanguageProfile(root));
+ try {
+ alfCompiler.compile(this.modelElementState.getContent());
+ } catch (ParsingError e) {
+ e.printStackTrace();
+ throw new WrappedException(e);
+ } catch (MappingError e) {
+ e.printStackTrace();
+ throw new WrappedException(e);
+ } catch (AssertionFailedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/SaveCommand.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/SaveCommand.java
new file mode 100644
index 00000000000..af4fe98714d
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/SaveCommand.java
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * 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.transaction.commands;
+
+import org.eclipse.papyrus.uml.alf.libraries.helper.AlfUtil;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ * This command enables the backup of the specification of particular model element
+ * in a comment owned by this latter
+ */
+public class SaveCommand extends AlfCommand {
+
+ protected SaveCommand(AlfTextualRepresentation representation) {
+ super(AlfCommandLabels.CREATE_OR_UPDATE_TEXTUAL_REPRESENTATION, representation);
+ }
+
+ /**
+ * Saves the specification in a comment stereotyped TextualRepresentation
+ */
+ protected void doExecute() {
+ AlfUtil helper = AlfUtil.getInstance();
+ /* 1. Make sure it exists a comment to save the model element description */
+ Comment comment = this.modelElementState.getSource();
+ if (comment == null) {
+ comment = UMLFactory.eINSTANCE.createComment();
+ this.modelElementState.setSource(comment);
+ }
+ /* 2. Make sure the comment used to save the model element description has a owner */
+ if (comment.getOwner() == null) {
+ this.modelElementState.getOwner().getOwnedComments().add(comment);
+ }
+ /* 3. Set the body of the comment with the model element description */
+ comment.setBody(this.modelElementState.getContent());
+ /* 4. Make sure the TextualRepresentation stereotype is applied onto the comment */
+ if (!helper.isATextualRepresentationComment(comment)) {
+ helper.applyTextualRepresentation(comment);
+ }
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/VersioningSaveCommand.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/VersioningSaveCommand.java
new file mode 100644
index 00000000000..5d67da750ee
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commands/VersioningSaveCommand.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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 (CEA LIST)
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commands;
+
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupUtil;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+
+public class VersioningSaveCommand extends SaveCommand {
+
+ protected VersioningSaveCommand(AlfTextualRepresentation representation) {
+ super(representation);
+ }
+
+ /**
+ * In addition to save the specification of a model element, this command
+ * also serialization about edition time and status (i.e. is the specification
+ * merged into the model or is it just saved in the comment waiting to be propagated).
+ */
+ protected void doExecute() {
+ /* 1. Saves the stereotyped comment in the model */
+ super.doExecute();
+ /* 2. Save time and edition status */
+ BackupUtil.getInstance().applyBackup(this.modelElementState.getSource(), this.modelElementState.getEditionState());
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ChangeScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ChangeScenario.java
new file mode 100644
index 00000000000..406951252e7
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ChangeScenario.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+import org.eclipse.papyrus.uml.alf.libraries.helper.AlfUtil;
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupUtil;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+
+public abstract class ChangeScenario extends Scenario implements IChangeScenario {
+
+ /**
+ * The model state that is taken as reference to perform a change
+ */
+ protected AlfTextualRepresentation modelStateToBeCommitted;
+
+ public ChangeScenario() {
+ super();
+ this.modelStateToBeCommitted = null;
+ }
+
+ public void before() {
+ /* 1. Apply action language profile if it is not already applied */
+ if (!AlfUtil.getInstance().isActionLanguageProfileApplied(this.currentModelState.getOwner())) {
+ AlfUtil.getInstance().applyActionLanguageProfile(this.currentModelState.getOwner());
+ }
+ /* 2. Apply standard profile if it is not already applied */
+ if (!AlfUtil.getInstance().isStandardProfileApplied(this.currentModelState.getOwner())) {
+ AlfUtil.getInstance().applyStandardProfile(this.currentModelState.getOwner());
+ }
+ /* 3. Apply backup profile if it is not already applied */
+ if (!BackupUtil.getInstance().isBackupProfileApplied(this.currentModelState.getOwner())) {
+ BackupUtil.getInstance().applyBackupProfile(this.currentModelState.getOwner());
+ }
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/CommitScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/CommitScenario.java
new file mode 100644
index 00000000000..b3017c20764
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/CommitScenario.java
@@ -0,0 +1,96 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+import static org.eclipse.papyrus.uml.alf.transaction.ActivatorTransaction.logger;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupState;
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupState.EditionStatus;
+import org.eclipse.papyrus.uml.alf.transaction.job.AlfCompilationJob;
+import org.eclipse.uml2.uml.NamedElement;
+
+
+/**
+ * This class describes the process of propagating the state of a particular
+ * model element in a given UML model
+ */
+public class CommitScenario extends ChangeScenario {
+
+ /**
+ * Flag use to know if the commit is required. it may change in the before method
+ */
+ private boolean isCommitRequired;
+
+ public CommitScenario() {
+ super();
+ this.isCommitRequired = true;
+ }
+
+ /**
+ * Update the user model state edition status
+ */
+ public void before() {
+ /* 1. Check parent constraints */
+ super.before();
+ /* 2. Update user model state meta-data */
+ BackupState editionState = new BackupState();
+ editionState.status = EditionStatus.MERGED;
+ editionState.timestamp = new Timestamp(Calendar.getInstance().getTimeInMillis());
+ this.userModelState.setEditionState(editionState);
+ this.modelStateToBeCommitted = this.userModelState;
+ }
+
+ /**
+ * Propagate the model state specified in text within the model
+ *
+ * @param - the model element to update with the specified changes
+ */
+ public void execute(NamedElement target, final String lastEditedVersion) {
+ /* 1. Load the states of the target */
+ this.init(target);
+ if (!this.userModelState.getContent().equals(lastEditedVersion)) {
+ this.userModelState.setText(lastEditedVersion);
+ }
+ /* 2. Realize before actions */
+ this.before();
+ if (this.isCommitRequired) {
+ /* 3.1. Schedule a job in charge of propagated the changes in the model */
+ Job job = new AlfCompilationJob(this.modelStateToBeCommitted);
+ job.setPriority(Job.SHORT);
+ job.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void done(IJobChangeEvent event) {
+ CommitScenario.this.after();
+ }
+ });
+ job.schedule();
+ } else {
+ this.isCommitRequired = true;
+ }
+ }
+
+ /**
+ * This method is automatically called after the job scheduled by this scenario terminates.
+ */
+ public void after() {
+ logger.info("Compilation Job Done");
+ }
+
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IChangeScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IChangeScenario.java
new file mode 100644
index 00000000000..bedb1638a9a
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IChangeScenario.java
@@ -0,0 +1,17 @@
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+import org.eclipse.uml2.uml.NamedElement;
+
+public interface IChangeScenario {
+
+ /**
+ * The core method of a scenario
+ *
+ * @param target
+ * - the element for which the scenario is executed
+ * @param lastEditedVersion
+ * - the last version of the textual representation (usually in an editor)
+ */
+ public void execute(NamedElement target, final String lastEditedVersion);
+
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IScenario.java
new file mode 100644
index 00000000000..55f4b014bc3
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/IScenario.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+public abstract interface IScenario {
+
+ /**
+ * Computations that need to be realized before the main method of the scenario
+ */
+ public void before();
+
+ /**
+ * Computations that need to be realized after the main method of the scenario
+ */
+ public void after();
+
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ISyncScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ISyncScenario.java
new file mode 100644
index 00000000000..188833c40b5
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ISyncScenario.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * 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.commit;
+
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.uml2.uml.Element;
+
+public interface ISyncScenario {
+ /**
+ * The core method of a scenario
+ *
+ * @param target
+ * - the element for which the scenario is executed
+ * @return command - a command (that may be compound) to be executed in order to perform the synchronization
+ */
+ public Command synchronize(Element target, List<Notification> changes);
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SaveScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SaveScenario.java
new file mode 100644
index 00000000000..f877869e1fa
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SaveScenario.java
@@ -0,0 +1,100 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+import static org.eclipse.papyrus.uml.alf.transaction.ActivatorTransaction.logger;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupState;
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupState.EditionStatus;
+import org.eclipse.papyrus.uml.alf.transaction.job.SaveTextualRepresentationJob;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * This class describes the process of persisting the state description
+ * attached to a particular model element.
+ */
+public class SaveScenario extends ChangeScenario {
+
+ /**
+ * Flag use to know if the backup is required. It may change in the before method
+ */
+ private boolean isBackupRequired;
+
+ public SaveScenario() {
+ super();
+ this.isBackupRequired = true;
+ }
+
+ /**
+ * If the <code>userModelState<code> and the <code>currentModelState<code> are not different
+ * then consider the textual specification was MERGED. Otherwise, the user model stand point
+ * is considered as SAVED. Typically it diverges from state of the current model.
+ */
+ public void before() {
+ super.before();
+ if (!this.userModelState.isDifferent(this.currentModelState)) {
+ this.userModelState.rebase(this.currentModelState);
+ } else {
+ BackupState editionState = new BackupState();
+ editionState.status = EditionStatus.SAVED;
+ editionState.timestamp = new Timestamp(Calendar.getInstance().getTimeInMillis());
+ this.userModelState.setEditionState(editionState);
+ }
+ this.modelStateToBeCommitted = this.userModelState;
+ }
+
+ /**
+ * Persist in the model the state of the target as a comment
+ *
+ * @param target
+ * - the model element state to persist
+ */
+ public void execute(NamedElement target, final String lastEditedVersion) {
+ /* 1. Load the states of the target */
+ this.init(target);
+ if (!this.userModelState.getContent().equals(lastEditedVersion)) {
+ this.userModelState.setText(lastEditedVersion);
+ }
+ /* 2. Realize before actions */
+ this.before();
+ /* 3. Is a backup required */
+ if (this.isBackupRequired) {
+ /* 3.1. Schedule a job in charge of saving target state */
+ Job job = new SaveTextualRepresentationJob(this.modelStateToBeCommitted);
+ job.setPriority(Job.SHORT);
+ job.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void done(IJobChangeEvent event) {
+ SaveScenario.this.after();
+ }
+ });
+ job.schedule();
+ } else {
+ this.isBackupRequired = true;
+ }
+ }
+
+ /**
+ * This method is automatically called after the job scheduled by this scenario terminates.
+ */
+ public void after() {
+ logger.info("Save Job Done");
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/Scenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/Scenario.java
new file mode 100644
index 00000000000..bcc79b83562
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/Scenario.java
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.papyrus.uml.alf.text.representation.util.RepresentationParser;
+import org.eclipse.papyrus.uml.alf.text.representation.util.RepresentationParsingError;
+import org.eclipse.uml2.uml.NamedElement;
+
+public abstract class Scenario implements IScenario {
+
+ /**
+ * The textual representation of a model element from the user stand point
+ */
+ protected AlfTextualRepresentation userModelState;
+
+ /**
+ * The textual representation of a model element from the semantic model stand point
+ */
+ protected AlfTextualRepresentation currentModelState;
+
+ public Scenario() {
+ this.userModelState = null;
+ this.currentModelState = null;
+ }
+
+ protected void init(NamedElement target) throws IllegalArgumentException {
+ if (target == null) {
+ throw new IllegalArgumentException("The model element provided to the scenario cannot be null");
+ }
+ try {
+ this.userModelState = RepresentationParser.getInstance().parse(target);
+ } catch (RepresentationParsingError e) {
+ e.printStackTrace();
+ }
+ try {
+ this.currentModelState = RepresentationParser.getInstance().getSnapshot(target);
+ } catch (RepresentationParsingError e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ScenarioFactory.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ScenarioFactory.java
new file mode 100644
index 00000000000..ced2cf605ed
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/ScenarioFactory.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+public class ScenarioFactory {
+
+ private static ScenarioFactory INSTANCE;
+
+ private ScenarioFactory() {
+ }
+
+ public static ScenarioFactory getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ScenarioFactory();
+ }
+ return INSTANCE;
+ }
+
+ public IChangeScenario createSaveScenario() {
+ return new SaveScenario();
+ }
+
+ public IChangeScenario createCommitScenario() {
+ return new CommitScenario();
+ }
+
+ public ISyncScenario createSyncScenario() {
+ return new SyncScenario();
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SyncScenario.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SyncScenario.java
new file mode 100644
index 00000000000..370ca87a7ab
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/commit/SyncScenario.java
@@ -0,0 +1,163 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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 (CEA LIST)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.commit;
+
+import static org.eclipse.papyrus.uml.alf.transaction.ActivatorTransaction.logger;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.compare.CompareUI;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.uml.alf.text.merge.manual.AlfCompareEditor;
+import org.eclipse.papyrus.uml.alf.text.merge.manual.MergeActionDialog;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.papyrus.uml.alf.transaction.commands.AlfCommandFactory;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.Package;
+
+public class SyncScenario extends Scenario implements ISyncScenario {
+
+ /**
+ * The model state that is taken as reference to perform the synchronization
+ */
+ protected AlfTextualRepresentation modelStateToBeCommitted;
+
+ public SyncScenario() {
+ super();
+ this.modelStateToBeCommitted = null;
+ }
+
+ /**
+ * Checks required before to perform a synchronization
+ */
+ public void before() {
+ /* 1. It means the user model has not been saved in the current model */
+ if (this.userModelState.isSaved()) {
+ /* 1.1. The two models diverge */
+ if (this.userModelState.isDifferent(this.currentModelState)) {
+ MergeActionDialog mergeActionDialog = new MergeActionDialog(Display.getCurrent().getActiveShell(), this.currentModelState.getOwner());
+ /* 1.1.1. The user has to choose what to do */
+ if (mergeActionDialog.open() == Window.OK) {
+ if (mergeActionDialog.getReturnCode() == MergeActionDialog.REBASE) {
+ this.userModelState.rebase(this.currentModelState);
+ this.modelStateToBeCommitted = this.userModelState;
+ } else if (mergeActionDialog.getReturnCode() == MergeActionDialog.MERGE) {
+ CompareUI.openCompareDialog(new AlfCompareEditor(this.userModelState, this.currentModelState));
+ } else {
+ this.currentModelState.reconcile(this.userModelState);
+ this.currentModelState.setSource(this.userModelState.getSource());
+ this.modelStateToBeCommitted = this.currentModelState;
+ }
+ }
+ }
+ } else {
+ this.modelStateToBeCommitted = this.userModelState.rebase(this.currentModelState);
+ }
+ }
+
+ protected Set<NamedElement> getRealTargets(Element target, List<Notification> changes) {
+ Set<NamedElement> realTargets = new HashSet<NamedElement>();
+ Iterator<Notification> changesIterator = changes.iterator();
+ /* 1. Handle model modifications implied by Generalization */
+ if (target instanceof Generalization) {
+ while (changesIterator.hasNext()) {
+ Notification notification = changesIterator.next();
+ switch (notification.getEventType()) {
+ /* Handle the case where Class::superClass derived feature changed but no notification was emitted */
+ case Notification.SET: {
+ /* The specific feature has changed (deletion / update) */
+ if (notification.getFeature() == UMLPackage.eINSTANCE.getGeneralization_Specific()
+ && notification.getOldValue() != null) {
+ realTargets.add((NamedElement) notification.getOldValue());
+ }
+ /* The general feature has changed (deletion / update) */
+ else if (notification.getFeature() == UMLPackage.eINSTANCE.getGeneralization_General()
+ && ((Generalization) target).getSpecific() != null) {
+ realTargets.add(((Generalization) target).getSpecific());
+ }
+ }
+ break;
+ }
+ }
+ }
+ /* 2. Handle model modifications implied by Packages */
+ else if (target instanceof Package) {
+ while (changesIterator.hasNext()) {
+ Notification notification = changesIterator.next();
+ switch (notification.getEventType()) {
+ case Notification.ADD: {
+ if (notification.getFeature() == UMLPackage.eINSTANCE.getPackage_PackagedElement()) {
+ realTargets.add((NamedElement) notification.getNewValue());
+ }
+ }
+ break;
+ case Notification.REMOVE: {
+ if (notification.getFeature() == UMLPackage.eINSTANCE.getPackage_PackagedElement()) {
+ NamedElement oldValue = (NamedElement) notification.getOldValue();
+ /* In case a element is deleted from the package */
+ if (oldValue.getModel() != null) {
+ realTargets.add((NamedElement) notification.getOldValue());
+ }
+ }
+ }
+ break;
+ }
+ }
+ realTargets.add((Package) target);
+ }
+ /* 3. */
+ else {
+ realTargets.add((NamedElement) target);
+ }
+ return realTargets;
+ }
+
+ public Command synchronize(Element target, List<Notification> changes) {
+ CompoundCommand compoundCommand = new CompoundCommand("synchronize");
+ for (NamedElement affectedElement : this.getRealTargets(target, changes)) {
+ compoundCommand.append(this._synchronize(affectedElement));
+ }
+ return compoundCommand;
+ }
+
+ /**
+ * Provide a synchronization command for the given target
+ *
+ * @param target
+ * - the model element on which textual specification must be aligned
+ * @return command - a command to synchronize the model element and the text
+ */
+ protected Command _synchronize(NamedElement target) {
+ /* 1. Load the target states */
+ this.init(target);
+ /* 2. Do before checks */
+ this.before();
+ /* 3. Provide save command */
+ return AlfCommandFactory.getInstance().creatSaveCommand(this.modelStateToBeCommitted);
+ }
+
+ public void after() {
+ logger.info("Synchronization Done");
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfAbstractJob.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfAbstractJob.java
new file mode 100644
index 00000000000..29e91c3e593
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfAbstractJob.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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 (CEA LIST)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.job;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+
+public abstract class AlfAbstractJob extends Job {
+
+ protected AlfTextualRepresentation modelElementState;
+
+ protected TransactionalEditingDomain getEditingDomain() {
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForResource.getInstance().getServiceRegistry(this.modelElementState.getOwner().eResource());
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+ TransactionalEditingDomain domain = null;
+ if (registry != null) {
+ try {
+ domain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ }
+ }
+ return domain;
+ }
+
+ public AlfAbstractJob(String name, AlfTextualRepresentation modelElemtState) {
+ super(name);
+ this.modelElementState = modelElemtState;
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfCompilationJob.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfCompilationJob.java
new file mode 100644
index 00000000000..cf87db6d3e1
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfCompilationJob.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * 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.transaction.job;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+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;
+
+public class AlfCompilationJob extends AlfAbstractJob {
+
+ public static final String NAME = "Compile";
+
+ public AlfCompilationJob(AlfTextualRepresentation representation) {
+ super(NAME, representation);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus jobStatus = Status.OK_STATUS;
+ TransactionalEditingDomain domain = this.getEditingDomain();
+ if (domain != null) {
+ /* Protect the resource in case of concurrent jobs */
+ Resource resource = this.modelElementState.getOwner().eResource();
+ synchronized (resource) {
+ /* 1. Do not listen to modifications that occur on the resource during compilation */
+ resource.setTrackingModification(false);
+ /* 2. Do compilation phase */
+ try {
+ domain.getCommandStack().execute(AlfCommandFactory.getInstance().createCompilationCommand(this.modelElementState));
+ } catch (Exception e) {
+ e.printStackTrace();
+ jobStatus = Status.CANCEL_STATUS;
+ }
+ /* 3. Save the textual representation within the model */
+ if (jobStatus.equals(Status.OK_STATUS)) {
+ this.modelElementState.setText(new DefaultEditStringRetrievalStrategy().getGeneratedEditString(this.modelElementState.getOwner()));
+ /* 3. Execute the commands */
+ try {
+ domain.getCommandStack().execute(AlfCommandFactory.getInstance().creatSaveCommand(this.modelElementState));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /* 4. Restore the modification tracking */
+ resource.setTrackingModification(true);
+ }
+ } else {
+ jobStatus = Status.CANCEL_STATUS;
+ }
+ return jobStatus;
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfJobObserver.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfJobObserver.java
new file mode 100644
index 00000000000..f686076de20
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/AlfJobObserver.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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 (CEA LIST)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.job;
+
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.papyrus.uml.xtext.integration.job.XtextValidationJob;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Display;
+
+public class AlfJobObserver extends JobChangeAdapter {
+
+ private Button commitButtton;
+
+ public AlfJobObserver(Button commitButton) {
+ this.commitButtton = commitButton;
+ }
+
+ public void done(IJobChangeEvent event) {
+ if (event.getJob() instanceof XtextValidationJob) {
+ XtextValidationJob job = (XtextValidationJob) event.getJob();
+ this.setCommitButtonState(job.hasValidationIssues());
+ }
+ }
+
+ protected void setCommitButtonState(boolean validationIssues) {
+ Display ui = Display.getDefault();
+ if (ui != null) {
+ if (!validationIssues) {
+ ui.syncExec(new Runnable() {
+ public void run() {
+ if (!AlfJobObserver.this.commitButtton.isDisposed() &&
+ !AlfJobObserver.this.commitButtton.isEnabled()) {
+ AlfJobObserver.this.commitButtton.setEnabled(true);
+ }
+ }
+ });
+ }
+ else {
+ ui.syncExec(new Runnable() {
+ public void run() {
+ if (!AlfJobObserver.this.commitButtton.isDisposed() &&
+ AlfJobObserver.this.commitButtton.isEnabled()) {
+ AlfJobObserver.this.commitButtton.setEnabled(false);
+ }
+ }
+ });
+ }
+ }
+ }
+
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/SaveTextualRepresentationJob.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/SaveTextualRepresentationJob.java
new file mode 100644
index 00000000000..5f90f77671f
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/job/SaveTextualRepresentationJob.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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 (CEA LIST)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.job;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.papyrus.uml.alf.transaction.commands.AlfCommandFactory;
+
+public class SaveTextualRepresentationJob extends AlfAbstractJob {
+
+ public static final String NAME = "Save";
+
+ public SaveTextualRepresentationJob(AlfTextualRepresentation representation) {
+ super(NAME, representation);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ /* 1. Retrieve the editing domain */
+ TransactionalEditingDomain domain = this.getEditingDomain();
+ /* 3. Ask for the execution of the command */
+ if (domain != null) {
+ /* Protect the resource in case of concurrent jobs */
+ Resource resource = this.modelElementState.getOwner().eResource();
+ synchronized (resource) {
+ domain.getCommandStack().execute(AlfCommandFactory.getInstance().creatSaveCommand(this.modelElementState));
+ }
+ } else {
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/FUMLElementService.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/FUMLElementService.java
new file mode 100644
index 00000000000..7a1ac24fc4b
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/FUMLElementService.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.observation;
+
+import org.eclipse.emf.transaction.ResourceSetListenerImpl;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.services.IService;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.uml.alf.transaction.observation.listener.FUMLElementListener;
+
+public class FUMLElementService implements IService {
+
+ protected TransactionalEditingDomain editingDomain;
+
+ protected ResourceSetListenerImpl listener;
+
+ public FUMLElementService() {
+ this.editingDomain = null;
+ this.listener = null;
+ }
+
+ public void init(ServicesRegistry servicesRegistry) throws ServiceException {
+ this.editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(servicesRegistry);
+ this.listener = new FUMLElementListener(this.editingDomain);
+ }
+
+ public TransactionalEditingDomain getEditingDomain() {
+ return this.editingDomain;
+ }
+
+ public void startService() throws ServiceException {
+ this.editingDomain.addResourceSetListener(this.listener);
+ }
+
+ public void disposeService() throws ServiceException {
+ this.editingDomain.removeResourceSetListener(this.listener);
+ this.listener = null;
+ }
+
+ public ResourceSetListenerImpl getListener() {
+ return this.listener;
+ }
+}
diff --git a/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java
new file mode 100644
index 00000000000..99091e7d039
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/FUMLElementListener.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.transaction.observation.listener;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.NotificationFilter;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListenerImpl;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.uml.alf.transaction.commit.ISyncScenario;
+import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory;
+import org.eclipse.papyrus.uml.alf.transaction.observation.listener.filter.FUMLFilter;
+import org.eclipse.uml2.uml.Element;
+
+public class FUMLElementListener extends ResourceSetListenerImpl {
+
+ public FUMLElementListener(TransactionalEditingDomain editingDomain) {
+ this(editingDomain.getResourceSet());
+ }
+
+ protected FUMLElementListener(ResourceSet resourceSet) {
+ super();
+ }
+
+ public NotificationFilter getFilter() {
+ return new FUMLFilter();
+ }
+
+ /**
+ * If a changes occurs on a model element supported by fUML then
+ * 1. If this change is implied by the ALF framework then we do nothing
+ * 2. If this change is not implied by the ALF framework then we try to automatically
+ * align the textual representation onto the current state of the edited model element.
+ * Note this is not always possible (e.g. the user has ongoing changes in the text)
+ */
+ public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
+ /* 1. Initialization */
+ CompoundCommand subCommands = new CompoundCommand("Synchronization");
+ HashMap<Element, List<Notification>> modifications = new HashMap<Element, List<Notification>>();
+ /* 2. Notification handling */
+ if (!event.getNotifications().isEmpty()) {
+ /* 2.1. Notification registration phase */
+ for (Notification notification : event.getNotifications()) {
+ Element target = (Element) notification.getNotifier();
+ if (modifications.get(target) == null) {
+ modifications.put(target, new ArrayList<Notification>());
+ }
+ modifications.get(target).add(notification);
+ }
+ /* 2.2. Calculate synchronization actions through a synchronization scenario */
+ ISyncScenario scenario = ScenarioFactory.getInstance().createSyncScenario();
+ for (Element key : modifications.keySet()) {
+ subCommands.append(scenario.synchronize(key, modifications.get(key)));
+ }
+ }
+ return subCommands;
+ }
+}
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
new file mode 100644
index 00000000000..6f0a6dbca83
--- /dev/null
+++ b/extraplugins/alf/core/org.eclipse.papyrus.uml.alf.transaction/src/org/eclipse/papyrus/uml/alf/transaction/observation/listener/filter/FUMLFilter.java
@@ -0,0 +1,289 @@
+/*****************************************************************************
+ * 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.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.Enumeration;
+import org.eclipse.uml2.uml.Extension;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Node;
+import org.eclipse.uml2.uml.Profile;
+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.UMLPackage;
+import org.eclipse.uml2.uml.resource.UMLResource;
+
+public class FUMLFilter extends NotificationFilter.Custom {
+
+ public FUMLFilter() {
+ }
+
+ /**
+ * Filter starting point
+ */
+ public boolean matches(Notification notification) {
+ Object notifier = notification.getNotifier();
+ if (!this.isNotifierAllowed(notifier)) {
+ return false;
+ }
+ Object feature = notification.getFeature();
+ if (notifier != null && feature != null) {
+ if (this.isEnumeration(notifier)) {
+ return this.isEnumerationFeatureListened((EStructuralFeature) feature);
+ } else if (this.isDataType(notifier)) {
+ return this.isDatatypeFeatureListened((EStructuralFeature) feature);
+ } else if (this.isPackage(notifier)) {
+ return this.isPackageFeatureListened((EStructuralFeature) feature);
+ } else if (this.isAssociation(notifier)) {
+ return this.isAssociationFeatureListener((EStructuralFeature) feature);
+ } else if (this.isSignal(notifier)) {
+ return this.isSignalFeatureListened((EStructuralFeature) feature);
+ } else if (this.isClass(notifier)) {
+ return this.isClassFeatureListened((EStructuralFeature) feature);
+ } else if (this.isGeneralization(notifier)) {
+ return this.isGeneralizationtFeatureListened((EStructuralFeature) feature);
+ }
+ }
+ return false;
+ }
+
+ private boolean isNotifierAllowed(Object notifier) {
+ boolean allowed = false;
+ if (notifier instanceof Element) {
+ EObject target = (EObject) notifier;
+ if (target.eResource() != null && target.eResource() instanceof UMLResource) {
+ allowed = target.eResource().isTrackingModification();
+ }
+ }
+ return allowed;
+ }
+
+ /*----------------------------------------------------------------------------*/
+ /* Enforce the filter to respect the fUML subset */
+ /*----------------------------------------------------------------------------*/
+
+ private boolean isGeneralization(Object notifier) {
+ return notifier instanceof Generalization;
+ }
+
+ /**
+ *
+ * @param notifier
+ * @return
+ */
+ 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;
+ }
+
+ /**
+ *
+ * @param notifier
+ * @return
+ */
+ private boolean isSignal(Object notifier) {
+ return notifier instanceof Signal;
+ }
+
+ /**
+ *
+ * @param notifier
+ * @return
+ */
+ private boolean isDataType(Object notifier) {
+ if (notifier instanceof DataType
+ && !(notifier instanceof Enumeration)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param notifier
+ * @return
+ */
+ private boolean isPackage(Object notifier) {
+ if (notifier != null
+ && notifier instanceof Package
+ && !(notifier instanceof Model)
+ && !(notifier instanceof Profile)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param notifier
+ * @return
+ */
+ private boolean isEnumeration(Object notifier) {
+ return notifier instanceof Enumeration;
+ }
+
+ /**
+ *
+ * @param notifier
+ * @return
+ */
+ private boolean isAssociation(Object notifier) {
+ if (notifier instanceof Association
+ && !(notifier instanceof AssociationClass)
+ && !(notifier instanceof Extension)
+ && !(notifier instanceof CommunicationPath)) {
+ return true;
+ }
+ return false;
+ }
+
+ /*----------------------------------------------------------------------------*/
+ /* Low level checks encoding the UML meta-model hierarchy */
+ /*----------------------------------------------------------------------------*/
+
+ private boolean isGeneralizationtFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getGeneralization_General() == feature
+ || UMLPackage.eINSTANCE.getGeneralization_Specific() == feature) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isNamedElementFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getNamedElement_Name() == feature
+ || UMLPackage.eINSTANCE.getNamedElement_QualifiedName() == feature
+ || UMLPackage.eINSTANCE.getNamedElement_Namespace() == feature
+ || UMLPackage.eINSTANCE.getNamedElement_Visibility() == feature
+ || UMLPackage.eINSTANCE.getNamedElement_Namespace() == feature) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isTypeFeatureListened(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getType_Package() == feature || this.isPackageableElementFeatureListened(feature);
+ }
+
+ private boolean isNamespaceFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getNamespace_ElementImport() == feature
+ || UMLPackage.eINSTANCE.getNamespace_ImportedMember() == feature
+ || UMLPackage.eINSTANCE.getNamespace_Member() == feature
+ || UMLPackage.eINSTANCE.getNamespace_OwnedMember() == feature
+ || UMLPackage.eINSTANCE.getNamespace_PackageImport() == feature
+ || this.isNamedElementFeatureListened(feature)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isPackageableElementFeatureListened(EStructuralFeature feature) {
+ return this.isNamedElementFeatureListened(feature);
+ }
+
+ private boolean isPackageFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getPackage_URI() == feature
+ || UMLPackage.eINSTANCE.getPackage_NestedPackage() == feature
+ || UMLPackage.eINSTANCE.getPackage_NestingPackage() == feature
+ || UMLPackage.eINSTANCE.getPackage_OwnedType() == feature
+ || UMLPackage.eINSTANCE.getPackage_PackagedElement() == feature
+ || this.isPackageableElementFeatureListened(feature)
+ || this.isNamespaceFeatureListened(feature)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isClassifierFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getClassifier_IsFinalSpecialization() == feature
+ || UMLPackage.eINSTANCE.getClassifier_IsAbstract() == feature
+ || UMLPackage.eINSTANCE.getClassifier_Attribute() == feature
+ || UMLPackage.eINSTANCE.getClassifier_Feature() == feature
+ || UMLPackage.eINSTANCE.getClassifier_General() == feature
+ || UMLPackage.eINSTANCE.getClassifier_Generalization() == feature
+ || this.isNamespaceFeatureListened(feature)
+ || this.isTypeFeatureListened(feature)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isStructuredClassifierFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute() == feature
+ || this.isClassifierFeatureListened(feature)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isEncapsulatedClassifierFeatureListened(EStructuralFeature feature) {
+ return this.isStructuredClassifierFeatureListened(feature);
+ }
+
+ private boolean isBehavioredClassifierListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getBehavioredClassifier_ClassifierBehavior() == feature
+ || UMLPackage.eINSTANCE.getBehavioredClassifier_OwnedBehavior() == feature
+ || this.isClassifierFeatureListened(feature)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isClassFeatureListened(EStructuralFeature feature) {
+ if (UMLPackage.eINSTANCE.getClass_IsActive() == feature
+ || UMLPackage.eINSTANCE.getClass_NestedClassifier() == feature
+ || UMLPackage.eINSTANCE.getClass_OwnedOperation() == feature
+ || UMLPackage.eINSTANCE.getClass_OwnedReception() == feature
+ || UMLPackage.eINSTANCE.getClass_SuperClass() == feature
+ || this.isEncapsulatedClassifierFeatureListened(feature)
+ || this.isBehavioredClassifierListened(feature)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isAssociationFeatureListener(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getAssociation_OwnedEnd() == feature || this.isClassifierFeatureListened(feature);
+ }
+
+ private boolean isSignalFeatureListened(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getSignal_OwnedAttribute() == feature || this.isClassifierFeatureListened(feature);
+ }
+
+ private boolean isDatatypeFeatureListened(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getDataType_OwnedAttribute() == feature || this.isClassifierFeatureListened(feature);
+ }
+
+ private boolean isEnumerationFeatureListened(EStructuralFeature feature) {
+ return UMLPackage.eINSTANCE.getEnumeration_OwnedLiteral() == feature || this.isDatatypeFeatureListened(feature);
+ }
+}

Back to the top