Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremie Tatibouet2015-03-24 09:15:15 -0400
committerCamille Letavernier2015-03-24 09:19:29 -0400
commit246b5ad5b70a9d974448ec9c2dfd8fdfe10553e2 (patch)
tree3fafa30290597619ed71bc13fafad1eb8d5f5bb1 /extraplugins/alf/ui
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/ui')
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.classpath7
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.project28
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF35
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/about.html28
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/build.properties9
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml98
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/pom.xml14
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/resources/icons/incom_stat.gifbin0 -> 93 bytes
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/ActivatorALFProperties.java50
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/UndoRedoStack.java64
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java114
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java75
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java62
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java109
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java330
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java64
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java46
-rw-r--r--extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java52
19 files changed, 1192 insertions, 0 deletions
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.classpath b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.classpath
new file mode 100644
index 00000000000..b1dabee3829
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.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.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.project b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.project
new file mode 100644
index 00000000000..ab93d1f965a
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.alf.properties.xtext</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>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.settings/org.eclipse.jdt.core.prefs b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..11f6e462df7
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/.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.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..3696d1b0b7b
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/META-INF/MANIFEST.MF
@@ -0,0 +1,35 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui;bundle-version="3.105.0",
+ org.eclipse.ui.forms;bundle-version="3.6.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.6.0",
+ org.eclipse.emf.ecore;bundle-version="2.9.0",
+ org.eclipse.gmf.runtime.common.core;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.common.ui.services;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.1.0",
+ org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.1.0",
+ org.eclipse.xtext;bundle-version="2.4.2",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.1.0",
+ org.eclipse.papyrus.uml.properties;bundle-version="1.1.0",
+ org.eclipse.papyrus.views.properties;bundle-version="1.1.0",
+ org.eclipse.core.jobs,
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.uml.alf,
+ org.eclipse.swt,
+ org.eclipse.papyrus.uml.alf.ui;bundle-version="1.1.0",
+ org.eclipse.papyrus.uml.alf.libraries;bundle-version="1.1.0",
+ org.eclipse.papyrus.uml.alf.transaction;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.alf.text,
+ org.eclipse.compare
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.1.0.qualifier
+Bundle-Name: %pluginName
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.uml.alf.properties.xtext;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-Activator: org.eclipse.papyrus.uml.alf.properties.xtext.ActivatorALFProperties
+
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/about.html b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/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 (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/build.properties b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/build.properties
new file mode 100644
index 00000000000..34513f24e58
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/build.properties
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html,\
+ build.properties,\
+ resources/
+src.includes = about.html
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml
new file mode 100644
index 00000000000..302c5d51946
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/plugin.xml
@@ -0,0 +1,98 @@
+<?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.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySection"
+ filter="org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySectionFilter"
+ id="alf.property.section.AdvancedEditingPropertySection"
+ tab="alf_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="alf_editing"
+ indented="true"
+ label="ALF">
+ </propertyTab>
+ </propertyTabs>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.extensionpoints.editors.DirectEditor">
+ <DirectEditor
+ language="Alf"
+ objectToEdit="org.eclipse.uml2.uml.Class">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Highest">
+ </Priority>
+ </DirectEditor>
+ <DirectEditor
+ language="Alf"
+ objectToEdit="org.eclipse.uml2.uml.Enumeration">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Highest">
+ </Priority>
+ </DirectEditor>
+ <DirectEditor
+ language="Alf"
+ objectToEdit="org.eclipse.uml2.uml.Signal">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Highest">
+ </Priority>
+ </DirectEditor>
+ <DirectEditor
+ language="Alf"
+ objectToEdit="org.eclipse.uml2.uml.DataType">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Highest">
+ </Priority>
+ </DirectEditor>
+ <DirectEditor
+ language="Alf"
+ objectToEdit="org.eclipse.uml2.uml.Package">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Highest">
+ </Priority>
+ </DirectEditor>
+ <DirectEditor
+ language="Alf"
+ objectToEdit="org.eclipse.uml2.uml.Association">
+ <popupeditor
+ editorConfiguration="org.eclipse.papyrus.uml.alf.properties.xtext.configuration.DefaultAlfXtextEditorConfiguration">
+ </popupeditor>
+ <Priority
+ name="Highest">
+ </Priority>
+ </DirectEditor>
+ </extension>
+</plugin>
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/pom.xml b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/pom.xml
new file mode 100644
index 00000000000..b332dcf4494
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/pom.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../../../releng/top-pom-extras.xml</relativePath>
+ </parent>
+ <artifactId>org.eclipse.papyrus.uml.alf.properties.xtext</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/resources/icons/incom_stat.gif b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/resources/icons/incom_stat.gif
new file mode 100644
index 00000000000..4f419106dc4
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/resources/icons/incom_stat.gif
Binary files differ
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/ActivatorALFProperties.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/ActivatorALFProperties.java
new file mode 100644
index 00000000000..b8fa0b95bde
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/ActivatorALFProperties.java
@@ -0,0 +1,50 @@
+package org.eclipse.papyrus.uml.alf.properties.xtext;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ActivatorALFProperties extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.alf.properties.xtext"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ActivatorALFProperties plugin;
+
+ /**
+ * The constructor
+ */
+ public ActivatorALFProperties() {
+ }
+
+ /*
+ * (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 ActivatorALFProperties getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/UndoRedoStack.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/UndoRedoStack.java
new file mode 100644
index 00000000000..5ef65f2634f
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/UndoRedoStack.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * 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:
+ * Petr Bodnar
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.properties.xtext;
+
+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/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java
new file mode 100644
index 00000000000..f700bdb05f2
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/AbstractAlfXtextEditorConfiguration.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jeremie Tatibouet
+ * Arnaud Cuccuru
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.properties.xtext.configuration;
+
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.uml.alf.impl.ModelNamespaceImpl;
+import org.eclipse.papyrus.uml.alf.libraries.helper.AlfUtil;
+import org.eclipse.papyrus.uml.alf.libraries.helper.BackupUtil;
+import org.eclipse.papyrus.uml.alf.parser.antlr.MutableAlfParser;
+import org.eclipse.papyrus.uml.alf.ui.internal.AlfActivator;
+import org.eclipse.papyrus.uml.alf.properties.xtext.parser.GMFAlfParser;
+import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+
+import com.google.inject.Injector;
+
+public abstract class AbstractAlfXtextEditorConfiguration extends DefaultXtextDirectEditorConfiguration {
+
+ private void loadProfiles(Element context) {
+ AlfUtil alfProfileHelper = AlfUtil.getInstance();
+ BackupUtil backupProfileHelper = BackupUtil.getInstance();
+ if (!alfProfileHelper.isActionLanguageProfileApplied(context)) {
+ alfProfileHelper.applyActionLanguageProfile(context);
+ }
+ if (!backupProfileHelper.isBackupProfileApplied(context)) {
+ backupProfileHelper.applyBackupProfile(context);
+ }
+ }
+
+ /**
+ * Update the context in which the Alf representation will be validated.
+ * The context is the namespace of the editedObject if any
+ *
+ * @param editedObject
+ */
+ protected void updateAlfModelContext(EObject editedObject) {
+ if (editedObject instanceof NamedElement) {
+ NamedElement element = (NamedElement) editedObject;
+ ModelNamespaceImpl.setContext(element.getNamespace());
+ this.loadProfiles(element);
+ }
+ }
+
+ /**
+ * Provide the injector with the location of the implementation of the Alf Language
+ */
+ @Override
+ public Injector getInjector() {
+ return AlfActivator.getInstance().getInjector(AlfActivator.ORG_ECLIPSE_PAPYRUS_UML_ALF_ALF);
+ }
+
+ /**
+ * Provide a GMF wrapped parser
+ */
+ public IParser createParser(final EObject semanticObject) {
+ return new GMFAlfParser(semanticObject, this);
+ }
+
+ /**
+ * Not used - see GMFCompatibleAlfParser
+ */
+ public String getEditString(IAdaptable element, int flags) {
+ return null;
+ }
+
+ /**
+ * Not used - see GMFCompatibleAlfParser
+ */
+ @Override
+ protected ICommand getParseCommand(EObject umlObject, EObject xtextObject) {
+ return null;
+ }
+
+ /**
+ * Executed before the editor opens
+ */
+ public Object preEditAction(Object objectToEdit) {
+ /* 1. Save a reference to the object to edit */
+ this.setObjectToEdit(objectToEdit);
+ /* 2. Change the compilation context */
+ this.updateAlfModelContext((EObject) objectToEdit);
+ /* 3. Let the parser access to the semantic element for which a textual representation is parsed */
+ MutableAlfParser.SEMANTIC_ELEMENT = (EObject) objectToEdit; /* FIXME */
+ return null;
+ }
+
+
+ /**
+ * Not used
+ */
+ public ICommand createInvalidStringCommand(final String newString, EObject semanticElement) {
+ return null;
+ }
+
+ public abstract String getEditString(EObject semanticObject);
+
+ public abstract ICommand getParseCommand(String textualRepresentation, EObject umlObject, EObject xtextObject);
+}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java
new file mode 100644
index 00000000000..0daf2a21f2e
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/configuration/DefaultAlfXtextEditorConfiguration.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jérémie Tatibouet
+ * Arnaud Cuccuru
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.properties.xtext.configuration;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
+import org.eclipse.papyrus.uml.alf.text.generation.DefaultEditStringRetrievalStrategy;
+import org.eclipse.papyrus.uml.alf.text.representation.AlfTextualRepresentation;
+import org.eclipse.papyrus.uml.alf.transaction.commands.AlfCommandFactory;
+import org.eclipse.papyrus.uml.xtext.integration.XtextFakeResourceContext;
+import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter;
+import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProvider;
+import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProviderWithInit;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.util.StringInputStream;
+
+/**
+ * Configuration used by the DirectEditor for Alf
+ */
+public class DefaultAlfXtextEditorConfiguration extends
+ AbstractAlfXtextEditorConfiguration {
+
+ /**
+ * Called each time the editor using the configuration is refreshed
+ *
+ * @param semanticObject
+ * @return the textual representation of a specific semantic object
+ */
+ @Override
+ public String getEditString(EObject semanticObject) {
+ this.updateAlfModelContext(semanticObject);
+ return new DefaultEditStringRetrievalStrategy().getEditString((NamedElement) semanticObject);
+ }
+
+ /**
+ * Build the parse command required to launch the compilation of the textual representation (only if it has no syntax errors).
+ *
+ */
+ @Override
+ public ICommand getParseCommand(String textualRepresentation,
+ EObject semanticObject, EObject xtextObject) {
+ AlfTextualRepresentation representation = new AlfTextualRepresentation((NamedElement) semanticObject);
+ IContextElementProvider provider = this.getContextProvider();
+ XtextFakeResourceContext context = new XtextFakeResourceContext(this.getInjector());
+ context.getFakeResource().eAdapters().add(new ContextElementAdapter(provider));
+ try {
+ context.getFakeResource().load(new StringInputStream(textualRepresentation), Collections.EMPTY_MAP);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ if (provider instanceof IContextElementProviderWithInit) {
+ ((IContextElementProviderWithInit) provider).initResource(context.getFakeResource());
+ }
+ EcoreUtil2.resolveLazyCrossReferences(context.getFakeResource(), CancelIndicator.NullImpl);
+ return new EMFtoGMFCommandWrapper(AlfCommandFactory.getInstance().createCompilationCommand(representation));
+ }
+} \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java
new file mode 100644
index 00000000000..2f7ca130029
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/constraints/ALFFilterConstraint.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Jeremie Tatibouet (CEA LIST)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.alf.properties.xtext.constraints;
+
+import org.eclipse.uml2.uml.Association;
+import org.eclipse.uml2.uml.AssociationClass;
+import org.eclipse.uml2.uml.CommunicationPath;
+import org.eclipse.uml2.uml.Extension;
+
+/**
+ * This class implements the opening constraints for the ALF editor
+ */
+public class ALFFilterConstraint {
+
+ private ALFFilterConstraint() {
+ }
+
+ /**
+ * Checks if an association can edited using ALF
+ *
+ * @param association
+ * the association evaluated against the constraints
+ *
+ * @return conforms
+ * true if the association respects the constraints
+ */
+ public static boolean conforms(Association association) {
+ boolean conforms = true;
+ /* The editor can only be opened for associations owning all of their ends */
+ if (association != null && isStrictAssociation(association)) {
+ conforms = association.getOwnedEnds().size() == association.getMemberEnds().size();
+ }
+ return conforms;
+ }
+
+ /**
+ * Checks if a given association is strictly an Association and not an instance of one of the sub-classes
+ *
+ * @param association
+ * the association for which we verifies that it is not a sub-class instance
+ *
+ * @return true if the association is only an instance of Association, false otherwise
+ */
+ private static boolean isStrictAssociation(Association association) {
+ return !(association instanceof AssociationClass) &&
+ !(association instanceof CommunicationPath) &&
+ !(association instanceof Extension);
+ }
+
+}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java
new file mode 100644
index 00000000000..72e19f7caea
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/parser/GMFAlfParser.java
@@ -0,0 +1,109 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jérémie Tatibouet
+ * Arnaud Cuccuru
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.properties.xtext.parser;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.alf.properties.xtext.configuration.AbstractAlfXtextEditorConfiguration;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Provide the possibility to use the ALF parser directly in the context of GMF.
+ */
+public class GMFAlfParser implements IParser {
+
+ protected final static String TEXTUAL_REPRESENTATION_ERROR = "/*String representation could not be computed*/";
+
+ protected final EObject semanticObject;
+
+ protected AbstractAlfXtextEditorConfiguration configuration;
+
+ /**
+ * Retrieve the NamedElement hidden behind the adapter
+ *
+ * @param adaptable
+ * @return the adapted element
+ */
+ protected NamedElement adapt(IAdaptable adaptable) {
+ Object o = EMFHelper.getEObject(adaptable);
+ if (o != null && o instanceof NamedElement) {
+ return (NamedElement) o;
+ }
+ return null;
+ }
+
+ /**
+ * Initializes the context in which type names are going to be resolved
+ */
+
+ public GMFAlfParser(final EObject semanticObject, final AbstractAlfXtextEditorConfiguration configuration) {
+ this.semanticObject = semanticObject;
+ this.configuration = configuration;
+ }
+
+ /***
+ * Delegate computation of the textual representation to the configuration
+ */
+ public String getEditString(IAdaptable element, int flags) {
+ NamedElement target = this.adapt(element);
+ if (target != null) {
+ return this.configuration.getEditString(target);
+ } else if (this.semanticObject != null) {
+ return this.configuration.getEditString(this.semanticObject);
+ } else {
+ return TEXTUAL_REPRESENTATION_ERROR;
+ }
+ }
+
+ public IParserEditStatus isValidEditString(IAdaptable element, String editString) {
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ /**
+ * Delegate creation of the parse command to the configuration
+ */
+ public ICommand getParseCommand(IAdaptable element, String newString, int flags) {
+ NamedElement target = this.adapt(element);
+ if (target != null) {
+ return this.configuration.getParseCommand(newString, target, null);
+ } else if (this.semanticObject != null) {
+ return this.configuration.getParseCommand(newString, this.semanticObject, null);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * No differences between results returned by getPrintString or getEditString
+ */
+ public String getPrintString(IAdaptable element, int flags) {
+ return this.getEditString(element, flags);
+ }
+
+ public boolean isAffectingEvent(Object event, int flags) {
+ return false;
+ }
+
+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
+ return null;
+ }
+
+}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java
new file mode 100644
index 00000000000..154dce39d28
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySection.java
@@ -0,0 +1,330 @@
+/*****************************************************************************
+ * Copyright (c) 2013, 2014 Itemis AG, 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:
+ * Itemis - Initial API and implementation
+ * Ansgar Radermacher - added undo/redo support (inspired by code from Petr Bodnar)
+ * Christian W. Damus (CEA) - bug 323802
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.alf.properties.xtext.sheet;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AbstractModelerPropertySection;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.uml.alf.transaction.job.AlfJobObserver;
+import org.eclipse.papyrus.uml.alf.properties.xtext.UndoRedoStack;
+import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners.CommitButtonSelectionListener;
+import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners.EditorFocusListener;
+import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
+import org.eclipse.papyrus.uml.xtext.integration.StyledTextXtextAdapter;
+import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter;
+import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProvider;
+import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProviderWithInit;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ExtendedModifyEvent;
+import org.eclipse.swt.custom.ExtendedModifyListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * Attention: class has been deactivated, since the additional tab is redundant with the
+ * body editor in the standard UML property tab.
+ */
+public class AdvancedEditingPropertySection extends
+ AbstractModelerPropertySection implements IContextElementProvider {
+
+ private FormToolkit toolkit;
+
+ private Form form;
+
+ private StyledText textControl;
+
+ private Button commitButton;
+
+ private DefaultXtextDirectEditorConfiguration configuration;
+
+ private StyledTextXtextAdapter xtextAdapter;
+
+ final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter(
+ this);
+
+ UndoRedoStack<ExtendedModifyEvent> undoRedoStack;
+
+ protected boolean isUndo;
+
+ protected boolean isRedo;
+
+ protected EObject currentEObj;
+
+ public AdvancedEditingPropertySection() {
+ undoRedoStack = new UndoRedoStack<ExtendedModifyEvent>();
+ }
+
+ public StyledText getEditor() {
+ return this.textControl;
+ }
+
+ @Override
+ public void refresh() {
+ updateXtextAdapters(this.textControl);
+ IParser parser = getParser();
+ if (parser != null) {
+ this.textControl.setText(parser.getEditString(new EObjectAdapter(eObject), 0));
+ }
+
+ if (textControl != null) {
+ textControl.setEnabled(!isReadOnly());
+ }
+ }
+
+ @Override
+ public void aboutToBeHidden() {
+ super.aboutToBeHidden();
+ if (xtextAdapter != null) {
+ xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
+ .remove(contextElementAdapter);
+ }
+ }
+
+ @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());
+ this.createPushButton(form.getBody());
+ }
+
+
+ protected void createPushButton(final Composite parent) {
+ final AlfJobObserver observer = new AlfJobObserver(this.commitButton);
+ this.commitButton = new Button(parent, SWT.PUSH);
+ this.commitButton.setText("Commit");
+ this.commitButton.setToolTipText("Commit the modifications in your model");
+ this.commitButton.setImage(new Image(Display.getDefault(), getClass().getResourceAsStream("/resources/icons/incom_stat.gif")));
+ this.commitButton.addSelectionListener(new CommitButtonSelectionListener(this));
+ this.commitButton.addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ Job.getJobManager().removeJobChangeListener(observer);
+ }
+ });
+ Job.getJobManager().addJobChangeListener(new AlfJobObserver(this.commitButton));
+ }
+
+ protected void createTextControl(final Composite parent) {
+
+ textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER
+ | SWT.V_SCROLL | SWT.WRAP);
+
+ textControl.setAlwaysShowScrollBars(false);
+ GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize())
+ .applyTo(textControl);
+ textControl.addExtendedModifyListener(new ExtendedModifyListener() {
+
+ public void modifyText(ExtendedModifyEvent event) {
+ if (isUndo) {
+ undoRedoStack.pushRedo(event);
+ } else { // is Redo or a normal user action
+ undoRedoStack.pushUndo(event);
+ if (!isRedo) {
+ undoRedoStack.clearRedo();
+ // TODO Switch to treat consecutive characters as one event?
+ }
+ }
+ }
+ });
+
+ textControl.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ 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 (e.keyCode == 'z') {
+ if (isShift) {
+ redo();
+ }
+ else {
+ undo();
+ }
+ }
+ }
+ }
+ });
+
+ textControl.addFocusListener(new EditorFocusListener(this));
+ }
+
+ protected void undo() {
+ if (undoRedoStack.hasUndo()) {
+ isUndo = true;
+ revertEvent(undoRedoStack.popUndo());
+ isUndo = false;
+ }
+ }
+
+ protected void redo() {
+ if (undoRedoStack.hasRedo()) {
+ isRedo = true;
+ revertEvent(undoRedoStack.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) {
+ textControl.replaceTextRange(event.start, event.length, event.replacedText);
+ // (causes the modifyText() listener method to be called)
+
+ textControl.setSelectionRange(event.start, event.replacedText.length());
+ }
+
+
+ protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() {
+ EObject semanticElement = getSemanticObjectFromSelection();
+ if (semanticElement != null) {
+ IPreferenceStore store = Activator.getDefault()
+ .getPreferenceStore();
+ String semanticClassName = semanticElement.eClass()
+ .getInstanceClassName();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + semanticClassName;
+ String languagePreferred = store.getString(key);
+
+ if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
+ IDirectEditorConfiguration configuration = DirectEditorsUtil
+ .findEditorConfiguration(languagePreferred,
+ semanticClassName);
+ if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
+
+ DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration;
+ xtextConfiguration.preEditAction(semanticElement);
+ return xtextConfiguration;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected EObject getSemanticObjectFromSelection() {
+ Object selection = getPrimarySelection();
+ if (selection instanceof IGraphicalEditPart) {
+ return ((IGraphicalEditPart) selection).resolveSemanticElement();
+ }
+ else if (selection instanceof IAdaptable) {
+ return (EObject) ((IAdaptable) selection).getAdapter(EObject.class);
+ }
+ return null;
+ }
+
+ public IParser getParser() {
+ final EObject semanticElement = getSemanticObjectFromSelection();
+ if (configuration != null && semanticElement != null) {
+ return configuration.createParser(semanticElement);
+ }
+ return null;
+ }
+
+ protected void updateXtextAdapters(Control styledText) {
+ final Object oldObjectToEdit = configuration != null ? configuration.getObjectToEdit() : null;
+
+ final DefaultXtextDirectEditorConfiguration newConfiguration = getConfigurationFromSelection();
+ // Check if configuration has changed and update adapters
+ if (newConfiguration != null && newConfiguration != configuration) {
+ if (xtextAdapter != null) {
+ xtextAdapter.getFakeResourceContext().getFakeResource()
+ .eAdapters().remove(contextElementAdapter);
+ }
+ configuration = newConfiguration;
+ xtextAdapter = new StyledTextXtextAdapter(
+ configuration.getInjector());
+
+ EObject semanticElement = getSemanticObjectFromSelection();
+ if (semanticElement != null) {
+ newConfiguration.preEditAction(semanticElement);
+ }
+
+ xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters()
+ .add(contextElementAdapter);
+ xtextAdapter.adapt((StyledText) styledText);
+ }
+
+ if (configuration.getObjectToEdit() != oldObjectToEdit) {
+ IContextElementProvider provider = configuration.getContextProvider();
+ if (provider instanceof IContextElementProviderWithInit) {
+ // update resource, if required by text editor
+ if (xtextAdapter != null) {
+ ((IContextElementProviderWithInit) provider).initResource(
+ xtextAdapter.getFakeResourceContext().getFakeResource());
+ }
+ }
+ Object semanticObject = configuration.getObjectToEdit();
+ if (semanticObject instanceof EObject) {
+ currentEObj = (EObject) semanticObject;
+ }
+ }
+ }
+
+ public EObject getContextObject() {
+ return getEObject();
+ }
+
+ @Override
+ protected boolean isReadOnly() {
+ EObject context = getContextObject();
+ return (context == null) || EMFHelper.isReadOnly(context) || super.isReadOnly();
+ }
+} \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
new file mode 100644
index 00000000000..9ccf1c8fefa
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.alf.properties.xtext.sheet;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IFilter;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
+import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
+import org.eclipse.papyrus.uml.alf.properties.xtext.constraints.ALFFilterConstraint;
+import org.eclipse.uml2.uml.Association;
+
+public class AdvancedEditingPropertySectionFilter implements IFilter {
+
+ public boolean select(Object toTest) {
+ EObject semanticElement = null;
+ if (toTest instanceof IAdaptable) {
+ semanticElement = (EObject) ((IAdaptable) toTest).getAdapter(EObject.class);
+ }
+ else if (toTest instanceof GraphicalEditPart) {
+ GraphicalEditPart part = (GraphicalEditPart) toTest;
+ semanticElement = part.resolveSemanticElement();
+ }
+ if (semanticElement != null) {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + semanticElement.eClass().getInstanceClassName();
+
+ String languagePreferred = store.getString(key);
+
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ IDirectEditorConfiguration configuration = null;
+ if (languagePreferred.equals("Alf") && semanticElement instanceof Association) {
+ if (ALFFilterConstraint.conforms((Association) semanticElement)) {
+ configuration = DirectEditorsUtil.findEditorConfiguration(
+ languagePreferred, semanticElement.eClass()
+ .getInstanceClassName());
+ }
+ } else {
+ configuration = DirectEditorsUtil.findEditorConfiguration(
+ languagePreferred, semanticElement.eClass()
+ .getInstanceClassName());
+ }
+ return configuration instanceof ICustomDirectEditorConfiguration;
+ }
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java
new file mode 100644
index 00000000000..537a5adc47c
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/CommitButtonSelectionListener.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * 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
+ * Jrmie Tatibouet (CEA LIST)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners;
+
+import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory;
+import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySection;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.uml2.uml.NamedElement;
+
+public class CommitButtonSelectionListener extends SelectionAdapter {
+
+
+ private AdvancedEditingPropertySection propertySection;
+
+ public CommitButtonSelectionListener(AdvancedEditingPropertySection propertySection) {
+ this.propertySection = propertySection;
+ }
+
+ /**
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent event) {
+ /* 1. Retrieved the current model element */
+ NamedElement semanticObject = (NamedElement) this.propertySection.getContextObject();
+ /* 2. Retrieved its currently edited representation */
+ StyledText editor = this.propertySection.getEditor();
+ /* 3. Compile without blocking URI */
+ if (semanticObject != null && editor != null) {
+ ScenarioFactory.getInstance().createCommitScenario().execute(semanticObject, editor.getText());
+ }
+ }
+}
diff --git a/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java
new file mode 100644
index 00000000000..fe0f9715813
--- /dev/null
+++ b/extraplugins/alf/ui/org.eclipse.papyrus.uml.alf.properties.xtext/src/org/eclipse/papyrus/uml/alf/properties/xtext/sheet/ui/listeners/EditorFocusListener.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * 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
+ * Jrmie Tatibouet (CEA LIST)
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.alf.properties.xtext.sheet.ui.listeners;
+
+import org.eclipse.papyrus.uml.alf.transaction.commit.ScenarioFactory;
+import org.eclipse.papyrus.uml.alf.properties.xtext.sheet.AdvancedEditingPropertySection;
+import org.eclipse.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 AdvancedEditingPropertySection section;
+
+ public EditorFocusListener(AdvancedEditingPropertySection 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 alfEditor = null;
+ if (event.getSource() instanceof StyledText) {
+ alfEditor = (StyledText) event.getSource();
+ }
+ /* 2. Save the textual representation */
+ if (alfEditor != null) {
+ ScenarioFactory.getInstance().createSaveScenario().
+ execute((NamedElement) this.section.getContextObject(), alfEditor.getText());
+ }
+
+ }
+}

Back to the top