Bug 514634 Spring cleaning
Projects & packages name normalization
Adding Execution folder & refactoring some gui project
Amend: adding Copyright in build.properties
Amend: adding newWizardShortcut for Examples in Modeling & Editing
perspective
Change-Id: I20ae04ac446bac31f9611e90b408e9c606676d71
Signed-off-by: Arnault Lapitre <arnault.lapitre@cea.fr>
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.classpath b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.classpath
new file mode 100644
index 0000000..cf36b56
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.gitignore b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.gitignore
new file mode 100644
index 0000000..bbdfc34
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.gitignore
@@ -0,0 +1,2 @@
+/bin/
+*.md.html
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.project b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.project
new file mode 100644
index 0000000..42e1d75
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.efm.modeling.ui.views.property.tab.xlia</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.core.resources.prefs b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.jdt.core.prefs b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..295926d
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.m2e.core.prefs b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/META-INF/MANIFEST.MF b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..04f9b97
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.eclipse.efm.papyrus.view.property.concretesyntax.sheet
+Bundle-SymbolicName: org.eclipse.efm.modeling.ui.views.property.tab.xlia;singleton:=true
+Bundle-Version: 0.0.1.qualifier
+Bundle-Name: Diversity XLIA XText Properties (Incubation)
+Require-Bundle: org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.1.3",
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.uml.tools.utils,
+ org.eclipse.xtext.ui;bundle-version="2.9.0",
+ org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.1.3",
+ org.eclipse.papyrus.infra.core.log,
+ org.eclipse.efm.formalml.xtext.ui;bundle-version="[0.0.1,1.0.0)",
+ org.eclipse.efm.modeling.codegen.xlia;bundle-version="[0.0.1,1.0.0)",
+ org.eclipse.efm.formalml;bundle-version="[0.0.1,1.0.0)",
+ org.eclipse.efm.ui;bundle-version="0.0.1"
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.eclipse.efm.papyrus.view.property.concretesyntax.ActivatorXLIAProperties
+Bundle-ManifestVersion: 2
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-Vendor: Eclipse Modeling Project
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/about.html b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/about.html
new file mode 100644
index 0000000..d35d5ae
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/build.properties b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/build.properties
new file mode 100644
index 0000000..5f84f22
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/build.properties
@@ -0,0 +1,17 @@
+###############################################################################
+# Copyright (c) 2017 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:
+# Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
+# - Initial API and Implementation
+###############################################################################
+source.. = src/
+output.. = target/classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/plugin.xml b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/plugin.xml
new file mode 100644
index 0000000..ec903e8
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/plugin.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections
+ contributorId="TreeOutlinePage">
+ <propertySection
+ class="org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.EditingPropertySection"
+ enablesFor="1"
+ filter="org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.EditingPropertySectionFilter"
+ id="fml.property.section.AdvancedEditingPropertySection"
+ tab="fml_editing">
+ <input
+ type="org.eclipse.gmf.runtime.notation.View">
+ </input>
+ <input
+ type="org.eclipse.gef.EditPart">
+ </input>
+ </propertySection>
+ </propertySections>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs
+ contributorId="TreeOutlinePage">
+ <propertyTab
+ afterTab="uml"
+ category="org.eclipse.papyrus"
+ id="fml_editing"
+ image="platform:/plugin/org.eclipse.efm.ui/resources/icons/diversity_icon.png"
+ indented="true"
+ label="xLIA">
+ </propertyTab>
+ </propertyTabs>
+ </extension>
+</plugin>
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/pom.xml b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/pom.xml
new file mode 100644
index 0000000..82d4a0e
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/pom.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.eclipse.efm</groupId>
+ <artifactId>org.eclipse.efm.modeling.gui</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.efm.modeling.ui.views.property.tab.xlia</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>org.eclipse.efm.modeling.ui.views.property.tab.xlia</name>
+ <description>This plug-in contains the XXXXXXXXX.</description>
+</project>
\ No newline at end of file
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/ActivatorXLIAProperties.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/ActivatorXLIAProperties.java
new file mode 100644
index 0000000..febcb64
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/ActivatorXLIAProperties.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax;
+
+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 ActivatorXLIAProperties extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.efm.papyrus.view.property.concretesyntax"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ActivatorXLIAProperties plugin;
+
+ /**
+ * The constructor
+ */
+ public ActivatorXLIAProperties() {
+ }
+
+ /*
+ * (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;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ActivatorXLIAProperties getDefault() {
+ return plugin;
+ }
+
+
+ /**
+ * The plug-in's logger
+ */
+ public static LogHelper log;
+
+
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/UndoRedoStack.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/UndoRedoStack.java
new file mode 100644
index 0000000..466ab0e
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/UndoRedoStack.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2014, 2016 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:
+ * Petr Bodnar
+ *****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax;
+
+import java.util.Stack;
+
+/**
+ * Encapsulation of the Undo and Redo stack(s)
+ *
+ */
+public class UndoRedoStack<T> {
+
+ private Stack<T> undo;
+ private Stack<T> redo;
+
+ public UndoRedoStack() {
+ undo = new Stack<T>();
+ redo = new Stack<T>();
+ }
+
+ public void pushUndo(T delta) {
+ undo.add(delta);
+ }
+
+ public void pushRedo(T delta) {
+ redo.add(delta);
+ }
+
+ public T popUndo() {
+ T res = undo.pop();
+ return res;
+ }
+
+ public T popRedo() {
+ T res = redo.pop();
+ return res;
+ }
+
+ public void clearUndo() {
+ undo.clear();
+ }
+
+ public void clearRedo() {
+ redo.clear();
+ }
+
+ public boolean hasUndo() {
+ return !undo.isEmpty();
+ }
+
+ public boolean hasRedo() {
+ return !redo.isEmpty();
+ }
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/AbstractUpdateCommand.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/AbstractUpdateCommand.java
new file mode 100644
index 0000000..cc1f2d2
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/AbstractUpdateCommand.java
@@ -0,0 +1,160 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax.internal.command;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.uml2.uml.Element;
+
+public abstract class AbstractUpdateCommand extends RecordingCommand {
+
+ protected static final String EMPTY = ""; //$NON-NLS-1$
+
+ protected static final String ANY = "any"; //$NON-NLS-1$
+
+
+ protected final String fNewEditedText;
+ protected final String fOldEditedText;
+
+ public AbstractUpdateCommand(Element context,
+ String newEditedText, String oldEditedText) {
+ super(TransactionUtil.getEditingDomain(context));
+
+ fNewEditedText = newEditedText;
+ fOldEditedText = oldEditedText;
+ }
+
+
+ /**
+ * Compile the description provided by the textual representation and merge
+ * them within the current model element
+ */
+ @Override
+ protected void doExecute() {
+ try {
+ if( compile() ) {
+ if( merge() ) {
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected abstract boolean compile();
+
+ protected abstract boolean merge();
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ // xLIA TEXT EXTRACTION UTILS
+ ////////////////////////////////////////////////////////////////////////////
+
+ protected String extractXliaCode(String editedText,
+ int fromIndex, String[] beginMarks, String[] endMarks) {
+ int beginIndex = beginIndexOf(editedText, fromIndex, beginMarks);
+ if( beginIndex >= fromIndex ) {
+ int endIndex = endIndexOf(editedText, beginIndex, endMarks );
+
+ if( endIndex > beginIndex ) {
+ editedText = editedText.substring(beginIndex, endIndex);
+
+ return( formatString( editedText ) );
+ }
+ else if( endIndex == beginIndex ) {
+ return( null );
+ }
+ else
+ {
+ endIndex = editedText.lastIndexOf('}');
+ if( endIndex > beginIndex ) {
+ editedText = editedText.substring(beginIndex, endIndex);
+
+ return( formatString( editedText ) );
+ }
+ }
+ }
+
+ return( null );
+ }
+
+ protected int beginIndexOf(
+ String editedText, int fromIndex, String[] beginMarks) {
+ int endIndex = -1;
+
+ for (String beginMark : beginMarks) {
+ endIndex = editedText.indexOf(beginMark, fromIndex);
+ if( endIndex >= fromIndex ) {
+ int mark = endIndex + beginMark.length();
+ if( beginMark.startsWith("//") ) {
+// Character.LINE_SEPARATOR;
+ return( editedText.indexOf(
+ '\n' /*System.lineSeparator()*/, mark) );
+ }
+ return( mark );
+ }
+ }
+
+ return( -1 );
+ }
+
+ protected int endIndexOf(
+ String editedText, int fromIndex, String[] endMarks) {
+ int endIndex = -1;
+
+ for (String endMark : endMarks) {
+ endIndex = editedText.indexOf(endMark, fromIndex);
+ if( endIndex >= fromIndex ) {
+ return( endIndex );
+ }
+ }
+
+ return( -1 );
+ }
+
+
+ protected String formatString(String editedText) {
+// editedText = editedText.trim();
+// return( editedText.isEmpty() ? null : editedText );
+
+ final int textLength = editedText.length();
+
+ int pos = 0;
+
+ while( (pos < textLength) && (editedText.charAt(pos) != '\n') &&
+ Character.isWhitespace( editedText.charAt(pos) ) ) {
+ pos++;
+ }
+
+ if( pos == textLength ) {
+ return( null );
+ }
+
+ int beginTab = pos;
+ while( (pos < textLength) &&
+ Character.isWhitespace( editedText.charAt(pos) ) ) {
+ pos++;
+ }
+
+ if( pos == textLength ) {
+ return( null );
+ }
+ else if( pos == beginTab ) {
+ return( editedText.trim() );
+ }
+
+ String strTab = editedText.substring(beginTab, pos);
+ editedText = editedText.trim();
+
+ editedText = editedText.replaceAll(strTab, "\n");
+
+ return( editedText );
+ }
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateOperationCommand.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateOperationCommand.java
new file mode 100644
index 0000000..8186e02
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateOperationCommand.java
@@ -0,0 +1,111 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax.internal.command;
+
+import org.eclipse.efm.modeling.formalml.helpers.StereotypeUtil;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.OpaqueBehavior;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.UMLPackage;
+
+public class UpdateOperationCommand extends AbstractUpdateCommand {
+
+ protected Operation fOperationContext;
+
+ public UpdateOperationCommand(Operation operationContext,
+ String newEditedText, String oldEditedText) {
+ super(operationContext, newEditedText, oldEditedText);
+
+ fOperationContext = operationContext;
+ }
+
+
+ protected boolean compile() {
+ if( this.fNewEditedText != null ) {
+// Model root = fOperationContext.getModel();
+// if( root != null ) {
+// return true;
+// }
+
+ return true;
+ }
+
+ return false ;
+ }
+
+ protected boolean merge() {
+ System.out.println("Begin doExecuteWithResult Operation !!!");
+
+ // METHOD as BEHAVIOR
+ String xliaBehavior = extractMethod(this.fNewEditedText);
+ String oldBehavior = extractMethod(this.fOldEditedText);
+ if( (oldBehavior != xliaBehavior) && ( (oldBehavior == null) ||
+ (! oldBehavior.equals(xliaBehavior))) ) {
+ // remove/destroy old effect.
+
+ if( ! fOperationContext.getMethods().isEmpty() ) {
+ Behavior method = fOperationContext.getMethods().get(0);
+ if( method instanceof OpaqueBehavior ) {
+ OpaqueBehavior oBehavior = (OpaqueBehavior) method;
+
+ oBehavior.getBodies().clear();
+
+ oBehavior.getLanguages().add(
+ StereotypeUtil.XLIA_LANGUAGE);
+
+ if( xliaBehavior != null ) {
+ oBehavior.getBodies().add( xliaBehavior );
+ }
+ }
+ }
+ else if( xliaBehavior != null ) {
+ // Create the new behavior !
+ org.eclipse.uml2.uml.Class behaviorContainer =
+ fOperationContext.getClass_();
+
+ if( behaviorContainer != null ) {
+ OpaqueBehavior newMethodBehavior = (OpaqueBehavior)
+ behaviorContainer.createOwnedBehavior(
+ fOperationContext.getName() + "_xliaBehavior",
+ UMLPackage.eINSTANCE.getOpaqueBehavior());
+
+ newMethodBehavior.getLanguages().add(
+ StereotypeUtil.XLIA_LANGUAGE);
+
+ newMethodBehavior.getBodies().add( xliaBehavior );
+
+ fOperationContext.getMethods().add( newMethodBehavior );
+ }
+ }
+ }
+
+ System.out.println("End Commit Operation !!!");
+
+ return true;
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ // xLIA TEXT EXTRACTION UTILS
+ ////////////////////////////////////////////////////////////////////////////
+
+ private final String[] METHOD_BEGIN_MARK = { "//begin xlia::behavior method" , "{" };
+ private final String[] METHOD_END_MARKS = { "//end xlia::behavior method" };
+
+ private String extractMethod(String editedText) {
+ String xliaBehavior = "commit< effect xLIA textual behavior >";
+
+ xliaBehavior = extractXliaCode(
+ editedText, 0, METHOD_BEGIN_MARK, METHOD_END_MARKS);
+
+ return( xliaBehavior );
+ }
+
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateTransitionCommand.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateTransitionCommand.java
new file mode 100644
index 0000000..ac7b54e
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateTransitionCommand.java
@@ -0,0 +1,240 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax.internal.command;
+
+import org.eclipse.efm.modeling.formalml.TimedTransition;
+import org.eclipse.efm.modeling.formalml.helpers.StereotypeUtil;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Event;
+import org.eclipse.uml2.uml.OpaqueBehavior;
+import org.eclipse.uml2.uml.OpaqueExpression;
+import org.eclipse.uml2.uml.Transition;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.UMLFactory;
+
+public class UpdateTransitionCommand extends AbstractUpdateCommand {
+
+ private static final String CONSTRAINT_XLIA_GUARD = "xLIA guard";
+
+
+ protected Transition fTransitionContext;
+
+ public UpdateTransitionCommand(Transition transitionContext,
+ String newTransitionText, String oldTransitionText) {
+ super(transitionContext, newTransitionText, oldTransitionText);
+
+ fTransitionContext = transitionContext;
+ }
+
+
+ protected boolean compile() {
+ if( this.fNewEditedText != null ) {
+// Model root = fTransitionContext.getModel();
+// if( root != null ) {
+// return true;
+// }
+
+ return true;
+ }
+
+ return false ;
+ }
+
+ protected boolean merge() {
+ System.out.println("Begin doExecuteWithResult Transition !!!");
+
+ // TRIGGER
+ String xliaTrigger = extractTrigger(this.fNewEditedText);
+ String oldTrigger = extractTrigger(this.fOldEditedText);
+ if( (oldTrigger != xliaTrigger) && ( (oldTrigger == null) ||
+ (! oldTrigger.equals(xliaTrigger))) ) {
+ // remove/destroy old effect.
+ // - Events associated with triggers of this fTransitionContext
+ for (Trigger t : fTransitionContext.getTriggers()) {
+ Event e = t.getEvent();
+ t.setEvent(null);
+ if (UML2Util.getNonNavigableInverseReferences(e).size() == 0) {
+ // no trigger is referencing the event any more, delete call event
+ e.destroy();
+ }
+ }
+ // - Triggers owned by this fTransitionContext
+ fTransitionContext.getTriggers()
+ .removeAll(fTransitionContext.getTriggers());
+
+ // Create the new triggers
+// if (transitionRuleObject.getTriggers() != null) {
+// List<Trigger> newTriggers = new ArrayList<Trigger>();
+// for (EventRule eventRule : transitionRuleObject.getTriggers()) {
+// Trigger newTrigger = UMLFactory.eINSTANCE.createTrigger();
+// newTriggers.add(newTrigger);
+// newTrigger.setEvent(createUMLEvent(eventRule));
+// }
+// fTransitionContext.getTriggers().addAll(newTriggers);
+// }
+ }
+
+ // GUARD
+ // - Guard associated with the fTransitionContext
+ String xliaConstraint = extractGuard(this.fNewEditedText);
+ String oldConstraint = extractGuard(this.fOldEditedText);
+ if( (oldConstraint != xliaConstraint) && ( (oldConstraint == null) ||
+ (! oldConstraint.equals(xliaConstraint))) ) {
+ // remove/destroy old guard.
+ Constraint guard = fTransitionContext.getGuard();
+ fTransitionContext.setGuard(null);
+ if (guard != null) {
+ guard.destroy();
+ }
+
+ // Create the new constraint
+// if( (transitionRuleObject.getGuard() != null) &&
+// (transitionRuleObject.getGuard().getConstraint() != null) ) {
+ if( xliaConstraint != null ) {
+ Constraint newConstraint =
+ fTransitionContext.createGuard(CONSTRAINT_XLIA_GUARD);
+ OpaqueExpression guardSpecification =
+ UMLFactory.eINSTANCE.createOpaqueExpression();
+ guardSpecification.getLanguages().add(
+ StereotypeUtil.XLIA_LANGUAGE);
+
+ guardSpecification.getBodies().add( xliaConstraint );
+
+ newConstraint.setSpecification(guardSpecification);
+ }
+ }
+
+ // TGUARD
+ // - Timed Guard associated with the fTransitionContext stereotype
+ xliaConstraint = extractTimedGuard(this.fNewEditedText);
+ oldConstraint = extractTimedGuard(this.fOldEditedText);
+ if( (oldConstraint != xliaConstraint) && ( (oldConstraint == null) ||
+ (! oldConstraint.equals(xliaConstraint))) ) {
+ // remove/destroy old tguard.
+ TimedTransition timedTransition =
+ StereotypeUtil.getTimedTransition(fTransitionContext);
+ if( timedTransition != null ) {
+ timedTransition.setTguard(null);
+
+ xliaConstraint = extractTimedGuard(this.fNewEditedText);
+ if( xliaConstraint != null ) {
+ Constraint constraint =
+ UMLFactory.eINSTANCE.createConstraint();
+ constraint.setName("xLIA tguard");
+
+ OpaqueExpression tguardSpecification =
+ UMLFactory.eINSTANCE.createOpaqueExpression();
+ tguardSpecification.getLanguages().add(
+ StereotypeUtil.XLIA_LANGUAGE);
+
+ tguardSpecification.getBodies().add( xliaConstraint );
+
+ constraint.setSpecification(tguardSpecification);
+
+ timedTransition.setTguard(constraint);
+ }
+ }
+ }
+
+ // EFFECT
+ String xliaBehavior = extractEffect(this.fNewEditedText);
+ String oldBehavior = extractEffect(this.fOldEditedText);
+ if( (oldBehavior != xliaBehavior) && ( (oldBehavior == null) ||
+ (! oldBehavior.equals(xliaBehavior))) ) {
+ // remove/destroy old effect.
+ Behavior effect = fTransitionContext.getEffect();
+ fTransitionContext.setEffect(null);
+ if (effect != null) {
+ effect.destroy();
+ }
+
+ // Create the new behavior ?
+ if( xliaBehavior != null ) {
+ // behavior does exist yet => create
+ OpaqueBehavior newEffectBehavior =
+ UMLFactory.eINSTANCE.createOpaqueBehavior();
+ newEffectBehavior.setName("xLIA effect");
+
+ newEffectBehavior.getLanguages().add(
+ StereotypeUtil.XLIA_LANGUAGE);
+
+ newEffectBehavior.getBodies().add( xliaBehavior );
+
+ fTransitionContext.setEffect(newEffectBehavior);
+ }
+ }
+
+ System.out.println("End Commit Transition !!!");
+
+ return true;
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ // xLIA TEXT EXTRACTION UTILS
+ ////////////////////////////////////////////////////////////////////////////
+
+ protected final String[] TRIGGER_BEGIN_MARK = { "@trigger:" };
+ protected final String[] TRIGGER_END_MARKS =
+ { "@guard:" , "@tguard:" , "@effect:" ,
+ "} -->" , "} // end transition" };
+
+ protected String extractTrigger(String editedText) {
+ String xliaConstraint = "commit< guard xLIA textual constraint >";
+
+ xliaConstraint = extractXliaCode(
+ editedText, 0, TRIGGER_BEGIN_MARK, TRIGGER_END_MARKS);
+
+ return( xliaConstraint );
+ }
+
+ protected final String[] GUARD_BEGIN_MARK = { "@guard:" };
+ protected final String[] GUARD_END_MARKS =
+ { "@tguard:" , "@effect:" , "} -->" , "} // end transition" };
+
+ protected String extractGuard(String editedText) {
+ String xliaConstraint = "commit< guard xLIA textual constraint >";
+
+ xliaConstraint = extractXliaCode(
+ editedText, 0, GUARD_BEGIN_MARK, GUARD_END_MARKS);
+
+ return( xliaConstraint );
+ }
+
+
+ protected final String[] TGUARD_BEGIN_MARK = { "@tguard:" };
+ protected final String[] TGUARD_END_MARKS =
+ { "@effect:" , "} -->" , "} // end transition" };
+
+ protected String extractTimedGuard(String editedText) {
+ String xliaConstraint = "commit< tguard xLIA textual constraint >";
+
+ xliaConstraint = extractXliaCode(
+ editedText, 0, TGUARD_BEGIN_MARK, TGUARD_END_MARKS);
+
+ return( xliaConstraint );
+ }
+
+
+ protected final String[] EFFECT_BEGIN_MARK = { "@effect:" };
+ protected final String[] EFFECT_END_MARKS = { "} -->" , "} // end transition" };
+
+ protected String extractEffect(String editedText) {
+ String xliaBehavior = "commit< effect xLIA textual behavior >";
+
+ xliaBehavior = extractXliaCode(
+ editedText, 0, EFFECT_BEGIN_MARK, EFFECT_END_MARKS);
+
+ return( xliaBehavior );
+ }
+
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateTransitionTransactionalCommand.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateTransitionTransactionalCommand.java
new file mode 100644
index 0000000..f50367d
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/command/UpdateTransitionTransactionalCommand.java
@@ -0,0 +1,242 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax.internal.command;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.ActivatorXLIAProperties;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.uml2.common.util.UML2Util;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Event;
+import org.eclipse.uml2.uml.Transition;
+import org.eclipse.uml2.uml.Trigger;
+
+public class UpdateTransitionTransactionalCommand extends AbstractTransactionalCommand implements Command {
+
+ protected static final String EMPTY = ""; //$NON-NLS-1$
+ protected final static String EVENTS = "events"; //$NON-NLS-1$
+
+ protected static final String TGUARD = "tguard";
+
+
+ protected static final String ANY = "any"; //$NON-NLS-1$
+
+ protected static final String NATURAL_LANGUAGE = "Natural language"; //$NON-NLS-1$
+
+ protected final Transition transition;
+
+ protected List<Trigger> newTriggers = new ArrayList<Trigger>();
+
+ protected Constraint newConstraint = null;
+
+
+ public UpdateTransitionTransactionalCommand(TransactionalEditingDomain domain, Transition transition) {
+ super(domain, "Transition Update", getWorkspaceFiles(transition));
+ this.transition = transition;
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(
+ IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+
+ System.out.println("Begin doExecuteWithResult Transition !!!");
+
+ // - Events associated with triggers of this transition
+ for (Trigger t : transition.getTriggers()) {
+ Event e = t.getEvent();
+ t.setEvent(null);
+ if (UML2Util.getNonNavigableInverseReferences(e).size() == 0) {
+ // no trigger is referencing the event any more, delete call event
+ e.destroy();
+ }
+ }
+ // - Triggers owned by this transition
+ transition.getTriggers().removeAll(transition.getTriggers());
+ // - Guard associated with the transition
+ Constraint guard = transition.getGuard();
+ transition.setGuard(null);
+ if (guard != null) {
+ guard.destroy();
+ }
+
+ // ////////////////////////////////////////////////////////////////////////////////////////////////
+ // Then extract any relevant information from the TransitionRuleObject, and update the Transition
+ // ////////////////////////////////////////////////////////////////////////////////////////////////
+
+ // Create the new triggers
+// if (transitionRuleObject != null) {
+// if (transitionRuleObject.getTriggers() != null) {
+// for (EventRule eventRule : transitionRuleObject.getTriggers()) {
+// Trigger newTrigger = UMLFactory.eINSTANCE.createTrigger();
+// this.newTriggers.add(newTrigger);
+// newTrigger.setEvent(createUMLEvent(eventRule));
+// }
+// transition.getTriggers().addAll(this.newTriggers);
+// }
+// // Create the new constraint
+// if (transitionRuleObject.getGuard() != null && transitionRuleObject.getGuard().getConstraint() != null) {
+// this.newConstraint = transition.createGuard(EMPTY);
+// OpaqueExpression guardSpecification = UMLFactory.eINSTANCE.createOpaqueExpression();
+// guardSpecification.getLanguages().add(XLIA_LANGUAGE);
+// guardSpecification.getBodies().add(EMPTY + transitionRuleObject.getGuard().getConstraint());
+// this.newConstraint.setSpecification(guardSpecification);
+// }
+//
+//
+// // - Timed Guard associated with the transition stereotype
+// org.eclipse.diversity.Transition diversityTransition =
+// DiversityStereotype.getTransition(transition);
+// if( diversityTransition != null ) {
+// Constraint constraint = UMLFactory.eINSTANCE.createConstraint();
+// constraint.setName("tguardConstraint");
+//
+// OpaqueExpression tguardSpecification = UMLFactory.eINSTANCE.createOpaqueExpression();
+// tguardSpecification.getLanguages().add(XLIA_LANGUAGE);
+//
+//// tguardSpecification.getBodies().add(EMPTY + transitionRuleObject.getTguard().getConstraint());
+//
+//
+// /*Expression*/ String tguard = transitionRuleObject.getTguard().getConstraint();
+//
+//
+//// Injector injector = Guice.createInjector(new XLIARuntimeModule());
+//// ISerializer serializer = injector.getInstance(ISerializer.class);
+////
+//// String s = serializer.serialize(tguard);
+//// tguardSpecification.getBodies().add(EMPTY + s);
+//
+// tguardSpecification.getBodies().add(EMPTY +
+// "\"" + tguard + "\"" );
+//
+//// tguardSpecification.getBodies().add(EMPTY +
+//// "\"" + ((LiteralStringExpression)tguard.getLeftOperand()).getValue() + "\" < " +
+//// "\"" + ((LiteralStringExpression)tguard.getRigthOperand()).getValue() + "\"" );
+//
+//
+// constraint.setSpecification(tguardSpecification);
+//
+// diversityTransition.setTguard(constraint);
+// }
+//
+//
+//
+// boolean hasEffect = transitionRuleObject.getEffect() != null && transitionRuleObject.getEffect().getKind() != null && transitionRuleObject.getEffect().getBehaviorName() != null;
+// BehaviorKind oldKind = getBehaviorKind(transition.getEffect());
+//
+// if ((!hasEffect) || (transitionRuleObject.getEffect().getKind() != oldKind)) {
+// // delete owned effect behavior
+// Behavior effect = transition.getEffect();
+// transition.setEffect(null);
+// if (effect != null) {
+// effect.destroy();
+// }
+// }
+//
+// // Create the new behavior
+// if (hasEffect) {
+// String behaviorName = transitionRuleObject.getEffect().getBehaviorName();
+// if (transition.getEffect() == null) {
+// // behavior does exist yet => create
+// Behavior newEffectBehavior = createUMLBehavior(transitionRuleObject.getEffect().getKind(), behaviorName);
+// transition.setEffect(newEffectBehavior);
+// } else {
+// transition.getEffect().setName(behaviorName);
+// }
+// }
+// }
+// else {
+// // no effect, remove it.
+// Behavior effect = transition.getEffect();
+// transition.setEffect(null);
+// if (effect != null) {
+// effect.destroy();
+// }
+// }
+
+ System.out.println("End doExecuteWithResult Transition !!!");
+
+ return CommandResult.newOKCommandResult(transition);
+ }
+
+
+ public static ICommand getCommand(Transition transition) {
+ // Creates and executes the update command
+ try {
+ TransactionalEditingDomain dom = ServiceUtilsForEObject.
+ getInstance().getTransactionalEditingDomain(transition);
+
+ UpdateTransitionTransactionalCommand updateCommand =
+ new UpdateTransitionTransactionalCommand(dom, transition);
+
+ return updateCommand;
+ }
+ catch (ServiceException ex) {
+ ActivatorXLIAProperties.log.error(ex);
+
+ return null;
+ }
+ }
+
+ @Override
+ public void execute() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void undo() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void redo() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Collection<?> getResult() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<?> getAffectedObjects() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Command chain(Command command) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/job/ExecuteCommandJob.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/job/ExecuteCommandJob.java
new file mode 100644
index 0000000..2ed2012
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/internal/job/ExecuteCommandJob.java
@@ -0,0 +1,141 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax.internal.job;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.ActivatorXLIAProperties;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.EditingPropertySection;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.resource.Resource;
+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;
+
+public class ExecuteCommandJob extends Job {
+
+ protected EditingPropertySection fPropertySection;
+
+ protected ArrayList< Command > fTransactionalCommands;
+
+ protected ArrayList< Command > fExecutedCommands;
+
+ public ExecuteCommandJob(EditingPropertySection propertySection,
+ Command command) {
+ super("name");
+
+ fPropertySection = propertySection;
+
+ fTransactionalCommands = new ArrayList<Command>();
+ fTransactionalCommands.add(command);
+
+ fExecutedCommands = new ArrayList<Command>();
+ }
+
+ protected TransactionalEditingDomain getEditingDomain() {
+ ServicesRegistry registry = null;
+ try {
+ registry = ServiceUtilsForResource.getInstance().getServiceRegistry(
+ fPropertySection.getContextObject().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;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Propagate xLIA specification into the model", 4);
+
+ this.fExecutedCommands.clear();
+
+ IStatus jobStatus = Status.OK_STATUS;
+
+ TransactionalEditingDomain domain = this.getEditingDomain();
+// if (domain != null) {
+// domain = fPropertySection.getTransactionalEditingDomain();
+// }
+
+ if (domain != null) {
+ /* Protect the resource in case of concurrent jobs */
+ monitor.subTask("Prepare compilation");
+ Resource resource = fPropertySection.getContextObject().eResource();
+ monitor.worked(1);
+ synchronized (resource) {
+ /* 1. Do not listen to modifications that occur on the resource during compilation */
+ resource.setTrackingModification(false);
+
+ /* 2. Do compilation phase */
+// jobStatus = this.doCompilation(domain, monitor);
+
+ /* 3. Save the textual representation within the model */
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ } else if (jobStatus.equals(Status.OK_STATUS)) {
+ jobStatus = this.doExecuteCommand(domain, monitor);
+ } else {
+ return jobStatus;
+ }
+
+ /* 4. Restore the modification tracking */
+ resource.setTrackingModification(true);
+ }
+ }
+ monitor.done();
+ return jobStatus;
+ }
+
+ /**
+ * Execute the save procedure
+ *
+ * @param domain
+ * - the editing domain in which the modifications are done
+ * @param monitor
+ * - the monitor used to report progress
+ * @return a status reporting the state of the job
+ */
+ protected IStatus doExecuteCommand(
+ TransactionalEditingDomain domain, IProgressMonitor monitor) {
+
+ monitor.subTask("Merge specification");
+
+ try {
+ for(Command command : fTransactionalCommands) {
+ domain.getCommandStack().execute(command);
+
+ fExecutedCommands.add(command);
+
+ monitor.worked(1);
+ }
+ }
+ catch (Exception e) {
+ return new Status(Status.ERROR, ActivatorXLIAProperties.PLUGIN_ID,
+ "An unexpected error stopped the merging phase");
+ }
+
+ return Status.OK_STATUS;
+ }
+
+
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertyCodeGenerator.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertyCodeGenerator.java
new file mode 100644
index 0000000..8e73af5
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertyCodeGenerator.java
@@ -0,0 +1,346 @@
+/*****************************************************************************
+* Copyright (c) 2016 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
+*****************************************************************************/
+package org.eclipse.efm.papyrus.view.property.concretesyntax.sheet;
+
+import java.io.StringWriter;
+
+import org.eclipse.efm.modeling.codegen.xlia.core.MainCodeGenerator;
+import org.eclipse.efm.modeling.codegen.xlia.util.PrettyPrintWriter;
+import org.eclipse.efm.modeling.formalml.TimedTransition;
+import org.eclipse.efm.modeling.formalml.helpers.StereotypeUtil;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.FinalState;
+import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.OpaqueBehavior;
+import org.eclipse.uml2.uml.OpaqueExpression;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Pseudostate;
+import org.eclipse.uml2.uml.Region;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.StateMachine;
+import org.eclipse.uml2.uml.Transition;
+import org.eclipse.uml2.uml.Trigger;
+import org.eclipse.uml2.uml.ValueSpecification;
+import org.eclipse.uml2.uml.Vertex;
+
+public class EditingPropertyCodeGenerator extends MainCodeGenerator {
+
+ /**
+ * Constructor
+ */
+ public EditingPropertyCodeGenerator() {
+ super();
+ }
+
+ public String performTransform(EObject element) {
+ if( element instanceof Element ) {
+ StringWriter buffer = new StringWriter();
+ PrettyPrintWriter writer = new PrettyPrintWriter(buffer);
+
+ if( element instanceof Transition ){
+ transformTransition((Transition) element, writer);
+ }
+ else if( element instanceof Operation ){
+ transformOperation((Operation) element, writer);
+ }
+ else {
+ super.performTransform((Element)element, writer);
+ }
+
+ return( buffer.toString() );
+ }
+
+ else if( element != null ) {
+ return( element.toString() );
+ }
+ else {
+ return null;
+ }
+ }
+
+
+ public void transformOperation(Operation element, PrettyPrintWriter writer) {
+ writer.appendTab("macro routine ");
+ if( element.getName() != null ) {
+ writer.append( element.getName() );
+ }
+ else {
+ writer.append( "null<name>" );
+ }
+
+ super.transformOperationParameters(
+ element.getOwnedParameters(), writer);
+
+ writer.appendEol(" {");
+
+ // A writer indenting with TAB + iTAB -> TAB2
+ PrettyPrintWriter writer2 = writer.itab2();
+
+ for( Behavior method : element.getMethods() ) {
+ if( method instanceof OpaqueBehavior ) {
+ writer.appendTab2("//begin xlia::behavior method ")
+ .appendEol( method.getName() );
+
+ transformOpaqueBehavior((OpaqueBehavior)method, writer2);
+
+ writer.appendTab2("//end xlia::behavior method ")
+ .appendEol( method.getName() );
+ }
+ else if( method instanceof Activity ) {
+ writer.appendTab2("uml::activity ")
+ .appendEol(method.getName());
+ }
+ else if( method instanceof Interaction ) {
+ writer.appendTab2("uml::interaction ")
+ .appendEol(method.getName());
+ }
+ else if( method instanceof StateMachine ) {
+ writer.appendTab2("uml::statemachine ")
+ .appendEol(method.getName());
+ }
+ else if( method != null ) {
+ writer.appendTab2("uml::")
+ .append(method.getClass().getSimpleName())
+ .append(" ")
+ .appendEol(method.getName());
+ }
+ }
+
+ writer.appendTabEol("}");
+ }
+
+
+ public void transformStateMachine(StateMachine element, PrettyPrintWriter writer) {
+ writer.appendTab("model statemachine< or > ")
+ .append(element.getName())
+ .appendEol(" {");
+
+ for(Region itRegion : element.getRegions() ) {
+ writer.appendEol();
+ transformRegion(itRegion, writer);
+ }
+
+ writer.appendTab("} // end statemachine ")
+ .appendEol2(element.getName());
+ }
+
+
+ public void transformRegion(Region element, PrettyPrintWriter writer) {
+ writer.appendTabEol("@region:");
+
+ // A writer indenting with TAB + iTAB -> TAB2
+ super.fStatemachineFactory.transformRegionBody(element, writer.itab2());
+}
+
+
+ public void transformPseudostate(Pseudostate element, PrettyPrintWriter writer) {
+ writer.appendTab("state< ")
+ .append(element.getKind().toString())
+ .append(" > ")
+ .append(element.getName())
+ .appendEol(" {");
+
+ transformVertexContent(element, writer);
+
+ writer.appendTab("} // end pseudo-state ")
+ .appendEol2(element.getName());
+ }
+
+ public void transformFinalState(FinalState element, PrettyPrintWriter writer) {
+ writer.appendTab("state< final > ")
+ .append(element.getName())
+ .appendEol(" {");
+
+ transformVertexContent(element, writer);
+
+ writer.appendTab("} // end final-state ")
+ .appendEol2(element.getName());
+ }
+
+ public void transformState(State element, PrettyPrintWriter writer) {
+ writer.appendTab("state");
+ if( element.isOrthogonal() ) {
+ writer.append("< and >");
+ }
+ else if( element.isComposite() ) {
+ writer.append("< or >");
+ }
+ writer.append(" ")
+ .append(element.getName())
+ .appendEol(" {");
+
+ super.fStatemachineFactory.transformStateActivity(element, writer);
+
+ transformVertexContent(element, writer);
+
+ super.fStatemachineFactory.transformConnectionPoint(element, writer);
+
+ for(Region itRegion : element.getRegions() ) {
+ writer.appendEol();
+ transformRegion(itRegion, writer);
+ }
+
+ writer.appendTab("} // end state ")
+ .appendEol2(element.getName());
+ }
+
+ public void transformVertex(Vertex element, PrettyPrintWriter writer) {
+ writer.appendTab("vertex ")
+ .append(element.getName())
+ .appendEol(" {");
+
+ transformVertexContent(element, writer);
+
+ writer.appendTab("} // end vertex ")
+ .appendEol2(element.getName());
+ }
+
+ public void transformVertexContent(Vertex element, PrettyPrintWriter writer) {
+ // A writer indenting with TAB + iTAB -> TAB2
+ PrettyPrintWriter writer2 = writer.itab2();
+
+ for(Transition itTransition : element.getOutgoings() ) {
+ transformTransition(itTransition, writer2);
+ // Si ce n'est pas la dernière transition sortante,
+ // Ajout d'un saut de ligne supplémentaire
+ if( element.getOutgoings().indexOf(itTransition) !=
+ element.getOutgoings().size()-1) {
+ writer.appendEol();
+ }
+ }
+ }
+
+
+ public void transformTransition(Transition element, PrettyPrintWriter writer) {
+ TimedTransition timedTransition =
+ StereotypeUtil.getTimedTransition(element);
+
+ boolean isElseGuard =
+ super.isConstraintSymbol(element.getGuard(), "else");
+
+ boolean isElseTransition = isElseGuard && (timedTransition == null);
+
+ writer.appendTab("transition");
+ if( isElseTransition ) {
+ writer.append("< else >");
+ }
+
+ if( element.getName() != null ) {
+ writer.append(" ")
+ .append(element.getName());
+ }
+ writer.appendEol(" {");
+
+ // Triggers
+ //
+ writer.appendTabEol("@trigger:");
+ for(Trigger itTrigger : element.getTriggers() ) {
+ super.fStatemachineFactory.transformTrigger(itTrigger, writer);
+ }
+
+ // Guard
+ //
+ writer.appendTabEol("@guard:");
+ if( ! isElseGuard ) {
+ Constraint guard = element.getGuard();
+ if ( guard != null) {
+ ValueSpecification vsGuard = guard.getSpecification();
+ if( vsGuard instanceof OpaqueExpression ) {
+ OpaqueExpression exprGuard = (OpaqueExpression) vsGuard;
+ for( String body : exprGuard.getBodies() ) {
+// writer.appendTab2Eol("guard( " + body + " );");
+ writer.appendTab2Eol( body );
+ }
+ }
+ else {
+ writer.appendTab2();
+ super.transformValueSpecification(vsGuard, writer);
+ writer.appendEol();
+ }
+ }
+ }
+
+ // Timed Guard
+ //
+ writer.appendTabEol("@tguard:");
+ if( timedTransition != null ) {
+ Constraint constraint = timedTransition.getTguard();
+
+ if( constraint != null ) {
+ ValueSpecification vsTGuard = constraint.getSpecification();
+ if( vsTGuard instanceof OpaqueExpression ) {
+ OpaqueExpression exprTGuard = (OpaqueExpression) vsTGuard;
+ for( String body : exprTGuard.getBodies() ) {
+// writer.appendTab2Eol("tguard( " + body + " );");
+ writer.appendTab2Eol( body );
+ }
+ }
+ else {
+ writer.appendTab2();
+ super.transformValueSpecification(vsTGuard, writer);
+ writer.appendEol();
+ }
+ }
+ }
+
+ // Behavior
+ //
+ writer.appendTabEol("@effect:");
+ Behavior behavior = element.getEffect();
+ if( behavior instanceof OpaqueBehavior ) {
+ transformOpaqueBehavior((OpaqueBehavior)behavior, writer.itab2());
+ }
+ else if( behavior instanceof Activity ) {
+ writer.appendTab2("// exec uml::activity ")
+ .appendEol(behavior.getName());
+ }
+ else if( behavior instanceof Interaction ) {
+ writer.appendTab2("// exec uml::interaction ")
+ .appendEol(behavior.getName());
+ }
+ else if( behavior instanceof StateMachine ) {
+ writer.appendTab2("// exec uml::statemachine ")
+ .appendEol(behavior.getName());
+ }
+ else if( behavior != null ) {
+ writer.appendTab2("// exec uml::")
+ .append(behavior.getClass().getSimpleName())
+ .append(" ")
+ .appendEol(behavior.getName());
+ }
+
+ writer.appendTab("} --> ")
+ .append(element.getTarget().getName())
+ .appendEol(";");
+ }
+
+
+ public void transformOpaqueBehavior(
+ OpaqueBehavior behavior, PrettyPrintWriter writer) {
+ for( String body : behavior.getBodies() ) {
+ if( body.startsWith(writer.iTAB) ) {
+ body = body.trim().replaceAll(
+ "\n" /*System.lineSeparator()*/ + writer.iTAB,
+ writer.EOL + writer.TAB1);
+ writer.appendTab2Eol(body);
+ }
+ else {
+ body = body.replaceAll(
+ "\n" /*System.lineSeparator()*/,
+ writer.EOL + writer.TAB1);
+ writer.appendTabEol(body);
+ }
+ }
+ }
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertySection.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertySection.java
new file mode 100644
index 0000000..11f8852
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertySection.java
@@ -0,0 +1,448 @@
+/*****************************************************************************
+* Copyright (c) 2012, 2017 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:
+* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
+* - Initial API and implementation
+*****************************************************************************/
+
+package org.eclipse.efm.papyrus.view.property.concretesyntax.sheet;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.efm.formalml.xtext.ui.internal.XtextActivator;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.internal.command.UpdateOperationCommand;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.internal.command.UpdateTransitionCommand;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.internal.job.ExecuteCommandJob;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.tooling.StyledTextWithUndoRedo;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.tooling.UndoStyledTextManager;
+import org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.tooling.listeners.EditorFocusListener;
+import org.eclipse.efm.ui.utils.ImageResources;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AbstractModelerPropertySection;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+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.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.SubActionBars;
+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 org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Transition;
+import org.eclipse.xtext.resource.XtextResource;
+
+import com.google.inject.Injector;
+
+/**
+ * Property view contribution for the ALF editor
+ */
+public class EditingPropertySection extends
+ AbstractModelerPropertySection implements IContextElementProvider {
+
+ private FormToolkit toolkit;
+
+ private Form form;
+
+ String fRefreshEditedTextBakup;
+
+ private StyledTextWithUndoRedo fStyledText;
+ UndoStyledTextManager fUndoManager;
+
+
+ SubActionBars fSubActionBars;
+ Action fRevertAction;
+ Action fCommitAction;
+
+ public final String COMMIT_ACTION_DEFAULT_TEXT = "Commit";
+ public final String COMMIT_ACTION_DEFAULT_DESCRIPTION = "Commit and Push to Model";
+
+// private Button commitButton;
+
+ private StyledTextXtextAdapter styledTextAdapter;
+
+ final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter(this);
+
+ protected boolean isUndo;
+
+ protected boolean isRedo;
+
+ private Injector xliaToolingInjector;
+
+ private EObject previousEObject;
+
+ private EditingPropertyCodeGenerator fCodeGenerator;
+
+ public EditingPropertySection() {
+ this.previousEObject = null;
+
+ this.xliaToolingInjector = XtextActivator.getInstance().getInjector(
+ XtextActivator.ORG_ECLIPSE_EFM_FORMALML_XTEXT_FORMALML);
+
+ this.fCodeGenerator = new EditingPropertyCodeGenerator();
+ }
+
+ public StyledText getEditor() {
+ return this.fStyledText;
+ }
+
+
+ protected boolean isEditableElement(EObject eObject) {
+ return( (this.eObject instanceof Transition) ||
+ (this.eObject instanceof Operation ) );
+ }
+
+
+ @Override
+ public void refresh() {
+ /* 1. Compute edit string */
+ fRefreshEditedTextBakup = "/*Error: serialization could not be computed*/";
+
+ if( this.eObject != null ) {
+ this.fCodeGenerator.reset();
+
+ fRefreshEditedTextBakup =
+ this.fCodeGenerator.performTransform( this.eObject );
+ }
+
+ /* 2. Update adapters placed over the xtext resource */
+ if( this.previousEObject != this.eObject ) {
+ this.updateXtextAdapters(this.fStyledText);
+ this.previousEObject = this.eObject;
+
+ if( isEditableElement(this.eObject) ){
+// aboutToBeShown();
+ String commitText = COMMIT_ACTION_DEFAULT_TEXT;
+ String commitDescription = COMMIT_ACTION_DEFAULT_DESCRIPTION;
+ if( this.eObject instanceof Transition ) {
+ commitText ="Commit Transition";
+ commitDescription ="Commit Transition(guard, tguard, effect)";
+ }
+ else if( this.eObject instanceof Operation ) {
+ commitText = "Commit Operation";
+ commitDescription = "Commit Operation Opaque xLIA behavior method";
+ }
+ fCommitAction.setText(commitText);
+ fCommitAction.setToolTipText(commitDescription);
+
+ fCommitAction.setEnabled(true);
+ fRevertAction.setEnabled(true);
+ }
+ else {
+// aboutToBeHidden();
+ fCommitAction.setText(COMMIT_ACTION_DEFAULT_TEXT);
+ fCommitAction.setToolTipText(COMMIT_ACTION_DEFAULT_DESCRIPTION);
+
+ fCommitAction.setEnabled(false);
+ fRevertAction.setEnabled(false);
+ }
+ fSubActionBars.updateActionBars();
+ }
+
+ /* 3. Set up editor content (fStyledText) */
+ this.fStyledText.setText(fRefreshEditedTextBakup);
+ if (this.fStyledText != null) {
+ this.fStyledText.setEditable(! isReadOnly());
+ }
+ }
+
+ /**
+ * Provide the object that will be edited through the editor.
+ * The particular case is for an edited that is an operation.
+ * In this situation we return the implementation
+ * (i.e. an activity) of this operation.
+ * This way it is transparent for the user that when editing an
+ * operation it can modify both the signature and its implementation.
+ *
+ * @param edited
+ * the object that is currently edited
+ *
+ * @return the real object that will be edited
+ */
+ private Element getEditableObject(EObject edited){
+ if( edited instanceof Transition ) {
+ return (Transition)edited;
+ }
+ else if( edited instanceof Operation ) {
+// return ((Operation)edited).getMethods().get(0);
+ return (Operation)edited;
+ }
+ return (Element)edited;
+ }
+
+ /**
+ * Provide the namespace of the element that is given as parameter
+ *
+ * @param element
+ * the element currently edited
+ *
+ * @return a namespace
+ */
+// private Namespace getNamespace(Element element){
+// if(element!=null && element instanceof NamedElement){
+// Element edited = this.getEditableObject(element);
+// return ((NamedElement)edited).getNamespace();
+// }
+// return null;
+// }
+
+ /**
+ * Associate a context in which the xtext resource containing an ALF model will be validated
+ *
+ * @param element
+ * the element currently edited
+ */
+ private void installValidationContextFor(Element element) {
+ if (this.styledTextAdapter != null) {
+ XtextResource resource = this.styledTextAdapter.
+ getFakeResourceContext().getFakeResource();
+ if (resource != null) {
+// ModelNamespaceFacade.getInstance().createValidationContext(
+// resource, this.getNamespace(element));
+ }
+ }
+ }
+
+ @Override
+ public void aboutToBeHidden() {
+ super.aboutToBeHidden();
+ if (styledTextAdapter != null) {
+ styledTextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
+ .remove(contextElementAdapter);
+ }
+
+ fSubActionBars.deactivate();
+ fSubActionBars.updateActionBars();
+ }
+
+
+
+ @Override
+ public void aboutToBeShown() {
+ super.aboutToBeShown();
+
+ fSubActionBars.activate();
+ fSubActionBars.updateActionBars();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (toolkit != null) {
+ toolkit.dispose();
+ }
+ }
+
+ @Override
+ public final void createControls(Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ toolkit = new FormToolkit(parent.getDisplay());
+ toolkit.setBorderStyle(SWT.BORDER);
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
+ parent.setLayout(new GridLayout(1, true));
+ form = toolkit.createForm(parent);
+ toolkit.decorateFormHeading(form);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(form);
+ form.getBody().setLayout(new GridLayout(1, false));
+
+ createTextControl(form.getBody());
+
+ createSubActionBars(parent, aTabbedPropertySheetPage);
+ }
+
+ protected void createSubActionBars(final Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ fSubActionBars = new SubActionBars(
+ aTabbedPropertySheetPage.getSite().getActionBars() );
+
+ createCommitAction(parent, aTabbedPropertySheetPage);
+
+ createRevertAction(parent, aTabbedPropertySheetPage);
+ }
+
+
+ protected void createRevertAction(final Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ fRevertAction = new Action("Revert") {
+ @Override
+ public void run() {
+ super.run();
+
+ revertFromModel();
+ }
+ };
+
+ fRevertAction.setToolTipText("Reset edited element text");
+
+ fRevertAction.setImageDescriptor(ImageResources.getImageDescriptor(ImageResources.IMAGE__REVERT_ICON));
+
+
+ ActionContributionItem aci = new ActionContributionItem(fRevertAction);
+ aci.setMode(ActionContributionItem.MODE_FORCE_TEXT);
+
+ fSubActionBars.getToolBarManager().add( aci );
+ fSubActionBars.getMenuManager().add( fRevertAction );
+ }
+
+ protected void revertFromModel() {
+ refresh();
+ }
+
+
+ protected void createCommitAction(final Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ fCommitAction = new Action( COMMIT_ACTION_DEFAULT_TEXT ) {
+ @Override
+ public void run() {
+ super.run();
+
+ commitAndPushToModel();
+ }
+ };
+
+ fCommitAction.setToolTipText(COMMIT_ACTION_DEFAULT_DESCRIPTION);
+
+ fCommitAction.setImageDescriptor(ImageResources.getImageDescriptor(ImageResources.IMAGE__PUSH_ICON));
+
+
+ ActionContributionItem aci = new ActionContributionItem(fCommitAction);
+ aci.setMode(ActionContributionItem.MODE_FORCE_TEXT);
+
+ fSubActionBars.getToolBarManager().add( aci );
+ fSubActionBars.getMenuManager().add( fCommitAction );
+ }
+
+ protected void commitAndPushToModel() {
+ if( isEditableElement(this.eObject) ) {
+ if( this.eObject instanceof Transition ) {
+ commitAndPushTransitionToModel((Transition) this.eObject);
+ }
+ if( this.eObject instanceof Operation ) {
+ commitAndPushOperationToModel((Operation) this.eObject);
+ }
+ else if( this.eObject instanceof NamedElement ) {
+ System.out.println("TODO:> Commit and Push to Model: element " +
+ ((NamedElement) this.eObject).getName());
+ }
+ else {
+ System.out.println("Unknown Commit and Push to Model ?");
+ }
+ }
+ }
+
+ public TransactionalEditingDomain getTransactionalEditingDomain() {
+ return getEditingDomain();
+ }
+
+ protected void commitAndPushTransitionToModel(Transition transitionContext) {
+ System.out.println("Commit and Push to Model: transition " +
+ transitionContext.getName());
+
+ final String editedtext = getEditor().getText();
+
+ if( (editedtext != null) && (! editedtext.equals(fRefreshEditedTextBakup)) ) {
+
+ UpdateTransitionCommand command = new UpdateTransitionCommand(
+ transitionContext, editedtext, fRefreshEditedTextBakup);
+
+ Job job = new ExecuteCommandJob(this, command);
+
+// job.addJobChangeListener(new JobChangeAdapter() {
+// @Override
+// public void done(IJobChangeEvent event) {
+// this.after();
+// }
+// });
+
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
+ else {
+ System.out.println("End Commit Transition without change !!!");
+ }
+ }
+
+
+ protected void commitAndPushOperationToModel(Operation operationContext) {
+ System.out.println("Commit and Push to Model: operation " +
+ operationContext.getName());
+
+ final String editedtext = getEditor().getText();
+
+ if( (editedtext != null) && (! editedtext.equals(fRefreshEditedTextBakup)) ) {
+
+ UpdateOperationCommand command = new UpdateOperationCommand(
+ operationContext, editedtext, fRefreshEditedTextBakup);
+
+ Job job = new ExecuteCommandJob(this, command);
+
+// job.addJobChangeListener(new JobChangeAdapter() {
+// @Override
+// public void done(IJobChangeEvent event) {
+// this.after();
+// }
+// });
+
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
+ else {
+ System.out.println("End Commit Operation without change !!!");
+ }
+ }
+
+ protected void createTextControl(final Composite parent) {
+ fStyledText = new StyledTextWithUndoRedo(parent,
+ SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+
+ fStyledText.setAlwaysShowScrollBars(false);
+ GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize())
+ .applyTo(fStyledText);
+
+ fUndoManager = new UndoStyledTextManager(fStyledText);
+
+ fStyledText.addFocusListener(new EditorFocusListener(this));
+ }
+
+ protected void updateXtextAdapters(Control styledText) {
+ if (styledTextAdapter != null) {
+ styledTextAdapter.getFakeResourceContext().
+ getFakeResource().eAdapters().remove(contextElementAdapter);
+ }
+
+ styledTextAdapter = new StyledTextXtextAdapter(this.xliaToolingInjector);
+ styledTextAdapter.getFakeResourceContext().
+ getFakeResource().eAdapters().add(contextElementAdapter);
+
+ this.installValidationContextFor((Element)this.eObject);
+ styledTextAdapter.adapt((StyledText) styledText);
+ }
+
+ public EObject getContextObject() {
+ return this.getEditableObject(this.eObject);
+ }
+
+ @Override
+ protected boolean isReadOnly() {
+ EObject context = getContextObject();
+ return (context == null) || EMFHelper.isReadOnly(context) ||
+ super.isReadOnly() || (! isEditableElement(this.eObject));
+ }
+}
\ No newline at end of file
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertySectionFilter.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertySectionFilter.java
new file mode 100644
index 0000000..6a410c5
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/EditingPropertySectionFilter.java
@@ -0,0 +1,122 @@
+/*****************************************************************************
+ * Copyright (c) 2014, 2016 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.efm.papyrus.view.property.concretesyntax.sheet;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.jface.viewers.IFilter;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Connector;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.EnumerationLiteral;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Region;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.StateMachine;
+import org.eclipse.uml2.uml.Transition;
+import org.eclipse.uml2.uml.Vertex;
+
+/**
+ * This class constrains the availability of the embedded XLIA 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 EditingPropertySectionFilter implements IFilter {
+
+ /**
+ * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object)
+ *
+ * @param toTest
+ *
+ * @return accepted
+ */
+ @Override
+ public boolean select(Object toTest) {
+ Element element = this.resolveSemanticElement(toTest);
+ boolean accepted = false;
+ if( (element != null) /*&&
+ XliaIntegrationPreferencesUtil.isXliaSupportEnabled()*/ ) {
+ 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) {
+ /* 1. First constraint: the element must be modifiable (i.e. not read only) */
+ if (! this.isModifiable(element)) {
+ return false;
+ }
+ /* 2. It should be in the scope supported by the XLIA editor */
+ if( (element instanceof StateMachine) ||
+ (element instanceof Region ) ||
+ (element instanceof Vertex ) ||
+ (element instanceof Transition ) ){
+ return( true );
+ }
+ else if( (element instanceof Model ) ||
+ (element instanceof Class ) ||
+ (element instanceof Property ) ||
+ (element instanceof Parameter) ||
+ (element instanceof Operation) ||
+ (element instanceof Signal ) ||
+ (element instanceof Connector) ||
+ (element instanceof DataType ) ||
+ (element instanceof EnumerationLiteral ) ){
+ return( true );
+ }
+
+ return false;
+ }
+
+ private boolean isModifiable(Element element) {
+ Resource resource = element.eResource();
+ if (resource != null) {
+ return( ! EMFHelper.isReadOnly(element) );
+ }
+ 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) {
+ return UMLUtil.resolveUMLElement(selectedElement);
+ }
+}
\ No newline at end of file
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/StyledTextWithUndoRedo.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/StyledTextWithUndoRedo.java
new file mode 100644
index 0000000..7ee0ee3
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/StyledTextWithUndoRedo.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2015, 2016 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:
+ * J�r�mie Tatibouet (CEA LIST)
+ *
+ *****************************************************************************/
+
+package org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.tooling;
+
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+
+public class StyledTextWithUndoRedo extends StyledText {
+
+ public StyledTextWithUndoRedo(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ @Override
+ public void replaceTextRange(int start, int length, String text) {
+ int contentLength = getCharCount();
+ int end = start + length;
+ if( (start <= end) && (start >= 0) && (end <= contentLength) ) {
+ super.replaceTextRange(start, length, text);
+ }
+ }
+
+ @Override
+ public void redrawRange(int start, int length, boolean clearBackground) {
+ int end = start + length;
+ int contentLength = getContent().getCharCount();
+ if( (start <= end) && (start >= 0) && (end <= contentLength) ) {
+ super.redrawRange(start, length, clearBackground);
+ }
+ }
+
+ @Override
+ public Rectangle getTextBounds(int start, int end) {
+ int contentLength = getCharCount();
+ if( (start < 0) || (start >= contentLength) ||
+ (end < 0) || (end >= contentLength) || (start > end) ) {
+ return new Rectangle(0, 0, 0, 0);
+ }
+ else {
+ return super.getTextBounds(start, end);
+ }
+ }
+
+ @Override
+ public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
+ try{
+ super.replaceStyleRanges(start, length, ranges);
+ }
+ catch( IllegalArgumentException e ){
+ //!! NOTHING
+ }
+ }
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/UndoStyledTextManager.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/UndoStyledTextManager.java
new file mode 100644
index 0000000..7c58a26
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/UndoStyledTextManager.java
@@ -0,0 +1,202 @@
+/*****************************************************************************
+* Copyright (c) 2012, 2016 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:
+* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
+* - Initial API and implementation
+*****************************************************************************/
+
+package org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.tooling;
+
+import java.util.Stack;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ExtendedModifyEvent;
+import org.eclipse.swt.custom.ExtendedModifyListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+
+/**
+ * Adds the Undo-Redo functionality (working Ctrl+Z and Ctrl+Y) to an instance
+ * of {@link StyledText}.
+ *
+ * @author Petr Bodnar
+ * @see {@linkplain http
+ * ://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWTUndoRedo.htm} -
+ * inspiration for this code, though not really functioning - it mainly
+ * shows which listeners to use...
+ * @see {@linkplain http
+ * ://stackoverflow.com/questions/7179464/swt-how-to-recreate
+ * -a-default-context-menu-for-text-fields} -
+ * "SWT's StyledText doesn't support Undo-Redo out-of-the-box"
+ */
+public class UndoStyledTextManager implements KeyListener, ExtendedModifyListener {
+
+ /**
+ * Encapsulation of the Undo and Redo stack(s).
+ */
+ private static class UndoRedoStack<T> {
+
+ private Stack<T> undo;
+ private Stack<T> redo;
+
+ public UndoRedoStack() {
+ undo = new Stack<T>();
+ redo = new Stack<T>();
+ }
+
+ public void pushUndo(T delta) {
+ undo.add(delta);
+ }
+
+ public void pushRedo(T delta) {
+ redo.add(delta);
+ }
+
+ public T popUndo() {
+ T res = undo.pop();
+ return res;
+ }
+
+ public T popRedo() {
+ T res = redo.pop();
+ return res;
+ }
+
+ public void clearRedo() {
+ redo.clear();
+ }
+
+ public boolean hasUndo() {
+ return !undo.isEmpty();
+ }
+
+ public boolean hasRedo() {
+ return !redo.isEmpty();
+ }
+
+ }
+
+ private StyledText editor;
+
+ private UndoRedoStack<ExtendedModifyEvent> stack;
+
+ private boolean isUndo;
+
+ private boolean isRedo;
+
+ /**
+ * Creates a new instance of this class. Automatically starts listening to
+ * corresponding key and modify events coming from the given
+ * <var>editor</var>.
+ *
+ * @param editor
+ * the text field to which the Undo-Redo functionality should be
+ * added
+ */
+ public UndoStyledTextManager(StyledText editor) {
+ editor.addExtendedModifyListener(this);
+ editor.addKeyListener(this);
+
+ this.editor = editor;
+ stack = new UndoRedoStack<ExtendedModifyEvent>();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.
+ * KeyEvent)
+ */
+ public void keyPressed(KeyEvent e) {
+ // Listen to CTRL+Z for Undo, to CTRL+Y or CTRL+SHIFT+Z for Redo
+ boolean isCtrl = (e.stateMask & SWT.CTRL) > 0;
+ boolean isAlt = (e.stateMask & SWT.ALT) > 0;
+ if (isCtrl && !isAlt) {
+ boolean isShift = (e.stateMask & SWT.SHIFT) > 0;
+ if (!isShift && e.keyCode == 'z') {
+ undo();
+ } else if (!isShift && e.keyCode == 'y' || isShift
+ && e.keyCode == 'z') {
+ redo();
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events
+ * .KeyEvent)
+ */
+ public void keyReleased(KeyEvent e) {
+ // ignore
+ }
+
+ /**
+ * Creates a corresponding Undo or Redo step from the given event and pushes
+ * it to the stack. The Redo stack is, logically, emptied if the event comes
+ * from a normal user action.
+ *
+ * @param event
+ * @see org.eclipse.swt.custom.ExtendedModifyListener#modifyText(org.eclipse.
+ * swt.custom.ExtendedModifyEvent)
+ */
+ public void modifyText(ExtendedModifyEvent event) {
+ if (isUndo) {
+ stack.pushRedo(event);
+ } else { // is Redo or a normal user action
+ stack.pushUndo(event);
+ if (!isRedo) {
+ stack.clearRedo();
+ // TODO Switch to treat consecutive characters as one event?
+ }
+ }
+ }
+
+ /**
+ * Performs the Undo action. A new corresponding Redo step is automatically
+ * pushed to the stack.
+ */
+ private void undo() {
+ if (stack.hasUndo()) {
+ isUndo = true;
+ revertEvent(stack.popUndo());
+ isUndo = false;
+ }
+ }
+
+ /**
+ * Performs the Redo action. A new corresponding Undo step is automatically
+ * pushed to the stack.
+ */
+ private void redo() {
+ if (stack.hasRedo()) {
+ isRedo = true;
+ revertEvent(stack.popRedo());
+ isRedo = false;
+ }
+ }
+
+ /**
+ * Reverts the given modify event, in the way as the Eclipse text editor
+ * does it.
+ *
+ * @param event
+ */
+ private void revertEvent(ExtendedModifyEvent event) {
+ editor.replaceTextRange(event.start, event.length, event.replacedText);
+ // (causes the modifyText() listener method to be called)
+
+ editor.setSelectionRange(event.start, event.replacedText.length());
+ }
+
+}
diff --git a/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/listeners/EditorFocusListener.java b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/listeners/EditorFocusListener.java
new file mode 100644
index 0000000..829a938
--- /dev/null
+++ b/gui/org.eclipse.efm.modeling.ui.views.property.tab.xlia/src/org/eclipse/efm/papyrus/view/property/concretesyntax/sheet/tooling/listeners/EditorFocusListener.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2015, 2016 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
+ * J�r�mie Tatibouet (CEA LIST)
+ *
+ *****************************************************************************/
+
+package org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.tooling.listeners;
+
+import org.eclipse.efm.papyrus.view.property.concretesyntax.sheet.EditingPropertySection;
+//import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+//import org.eclipse.uml2.uml.NamedElement;
+
+public class EditorFocusListener extends FocusAdapter {
+
+
+// private XliaEditionPropertySection section;
+
+ public EditorFocusListener(EditingPropertySection section) {
+// this.section = section;
+ }
+
+ /**
+ * When the ALF editor looses the focus, this triggers the execution of a backup sequence.
+ * This backup sequence saves the current state of the textual definition of the current model element.
+ * Modifications introduced in text are not propagated in the current model element.
+ */
+ @Override
+ public void focusLost(FocusEvent event) {
+ /* 1. Retrieve the alf editor */
+ StyledText xliaEditor = null;
+ if (event.getSource() instanceof StyledText) {
+ xliaEditor = (StyledText) event.getSource();
+ }
+ /* 2. Save the textual representation */
+ if (xliaEditor != null) {
+// ScenarioFactory.getInstance().createSaveScenario().
+// execute((NamedElement) this.section.getContextObject(), xliaEditor.getText());
+ }
+
+ }
+}