Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2017-11-29 08:44:24 -0500
committerAnsgar Radermacher2017-12-14 07:17:35 -0500
commitef349fa5b7a8eff25748a7cc8c8371c4bf86b525 (patch)
tree6a4923bfa95a07512da6a89795dbd631a2d3aff0 /examples
parent9d12e4c91251948f82150d6ac57577405279abcc (diff)
downloadorg.eclipse.papyrus-ef349fa5b7a8eff25748a7cc8c8371c4bf86b525.tar.gz
org.eclipse.papyrus-ef349fa5b7a8eff25748a7cc8c8371c4bf86b525.tar.xz
org.eclipse.papyrus-ef349fa5b7a8eff25748a7cc8c8371c4bf86b525.zip
Bug 527876 - [Property View] Facilitate the use of xtext editors in property view
- Export elements of oep.uml.properties.xtext plugin - Add missing copyright messages in some classes of the oep.uml.properties.xtext plugin - Add "getter" method for accessing the text-control in XtextLanguageEditor - Add new abstract class that specific xtext-editors should subclass. - Provide the editing of state-machine transitions via xtext as an example. - Add LANGUAGE string constant to TransitionEditorConfigurationContribution Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr> Change-Id: Ied704ae35277d324595ee8e3b874206bbb989313
Diffstat (limited to 'examples')
-rw-r--r--examples/uml/org.eclipse.papyrus.uml.textual.editors.example/META-INF/MANIFEST.MF3
-rw-r--r--examples/uml/org.eclipse.papyrus.uml.textual.editors.example/plugin.xml6
-rw-r--r--examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/ui/SingleTransition.xwt17
-rw-r--r--examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/xtext.ctx19
-rw-r--r--examples/uml/org.eclipse.papyrus.uml.textual.editors.example/src/org/eclipse/papyrus/uml/textual/editors/example/widgets/TransitionEditor.java60
5 files changed, 104 insertions, 1 deletions
diff --git a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/META-INF/MANIFEST.MF b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/META-INF/MANIFEST.MF
index 29ffcd5efd6..e6e06cc5203 100644
--- a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/META-INF/MANIFEST.MF
+++ b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/META-INF/MANIFEST.MF
@@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.emf.nattable;bundle-version="[4.0.0,5.0.0)",
org.eclipse.papyrus.infra.tools;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.uml.nattable.xtext.valuespecification;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.papyrus.uml.properties.xtext;bundle-version="[1.2.0,2.0.0)"
+ org.eclipse.papyrus.uml.properties.xtext;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.uml.textedit.transition.xtext.ui;bundle-version="2.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-Description: %Bundle-Description
diff --git a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/plugin.xml b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/plugin.xml
index dad31a0a2bd..348d1a92978 100644
--- a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/plugin.xml
+++ b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/plugin.xml
@@ -30,4 +30,10 @@
order="20">
</configuration>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.properties.contexts">
+ <context
+ contextModel="properties/xtext.ctx">
+ </context>
+ </extension>
</plugin>
diff --git a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/ui/SingleTransition.xwt b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/ui/SingleTransition.xwt
new file mode 100644
index 00000000000..a0425ba42c1
--- /dev/null
+++ b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/ui/SingleTransition.xwt
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Composite xmlns="http://www.eclipse.org/xwt/presentation"
+ xmlns:j="clr-namespace:java.lang" xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets"
+ xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout"
+ xmlns:xtext="clr-namespace:org.eclipse.papyrus.uml.textual.editors.example.widgets"
+ xmlns:x="http://www.eclipse.org/xwt">
+ <Composite.layout>
+ <ppel:PropertiesLayout></ppel:PropertiesLayout>
+ </Composite.layout>
+ <Composite>
+ <Composite.layout>
+ <ppel:PropertiesLayout numColumns="1"></ppel:PropertiesLayout>
+ </Composite.layout>
+ <xtext:TransitionEditor input="{Binding}"
+ property="UML:Transition"></xtext:TransitionEditor>
+ </Composite>
+</Composite> \ No newline at end of file
diff --git a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/xtext.ctx b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/xtext.ctx
new file mode 100644
index 00000000000..323672be822
--- /dev/null
+++ b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/properties/xtext.ctx
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ASCII"?>
+<contexts:Context xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:constraints="http://www.eclipse.org/papyrus/constraints/0.9" xmlns:contexts="http://www.eclipse.org/papyrus/properties/contexts/0.9" xmi:id="_iM9CcM33Eee3Tq5d85ujcg" name="xtext">
+ <dependencies href="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_69QJkKDJEeSZxfCXzZz3-w"/>
+ <tabs xmi:id="_kWGgQM33Eee3Tq5d85ujcg" label="Xtext-example" id="xtext" priority="100">
+ <afterTab href="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_69QJkaDJEeSZxfCXzZz3-w"/>
+ <sections xmi:id="_kWOcEc33Eee3Tq5d85ujcg" name="Single Transition" sectionFile="ui/SingleTransition.xwt">
+ <widget href="ui/SingleTransition.xwt#/"/>
+ </sections>
+ </tabs>
+ <views xmi:id="_iM9pjM33Eee3Tq5d85ujcg" name="Single Transition" sections="_kWOcEc33Eee3Tq5d85ujcg" automaticContext="true" datacontexts="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_690yiKDJEeSZxfCXzZz3-w">
+ <constraints xsi:type="constraints:SimpleConstraint" xmi:id="_iM9pjc33Eee3Tq5d85ujcg" name="isSingleTransition">
+ <constraintType href="ppe:/environment/org.eclipse.papyrus.uml.properties/Model/Environment.xmi#//@constraintTypes.0"/>
+ <properties xsi:type="constraints:ValueProperty" xmi:id="_iM9pjs33Eee3Tq5d85ujcg" name="umlClassName" value="Transition"/>
+ </constraints>
+ </views>
+ <dataContexts xmi:id="_iM9ppM33Eee3Tq5d85ujcg" name="xtext">
+ <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.uml.properties/Model/Environment.xmi#//@modelElementFactories.2"/>
+ </dataContexts>
+</contexts:Context>
diff --git a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/src/org/eclipse/papyrus/uml/textual/editors/example/widgets/TransitionEditor.java b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/src/org/eclipse/papyrus/uml/textual/editors/example/widgets/TransitionEditor.java
new file mode 100644
index 00000000000..604cc616736
--- /dev/null
+++ b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/src/org/eclipse/papyrus/uml/textual/editors/example/widgets/TransitionEditor.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * 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:
+ * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.textual.editors.example.widgets;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
+import org.eclipse.papyrus.uml.properties.xtext.widget.property.AbstractXtextPropertyEditor;
+import org.eclipse.papyrus.uml.textedit.transition.xtext.ui.contributions.TransitionEditorConfigurationContribution;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * An xtext transition editor within the property view
+ *
+ * @see AbstractXtextPropertyEditor
+ */
+@SuppressWarnings("nls")
+public class TransitionEditor extends AbstractXtextPropertyEditor {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * The composite in which the widget is created
+ * @param style
+ * The style for the {@link XtextValueEditor}
+ */
+ public TransitionEditor(Composite parent, int style) {
+ // 1st parameter is name of language associated with xtext editor (see language
+ // attribute in extension point org.eclipse.papyrus.extensionpoints.editors.DirectEditor).
+ // In this case, we added the language constant to the editor contribution, but this is
+ // not the case for all Papyrus xtext editors
+ super(TransitionEditorConfigurationContribution.LANGUAGE, parent, style);
+
+ // add a small label above the editor
+ Label editorLabel = new Label(parent, SWT.NONE);
+ editorLabel.setText("Edit transition:");
+ editorLabel.moveAbove(null);
+ GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 150).applyTo(xtextEditor.getTextControl());
+ }
+
+ @Override
+ protected void registerChangeListeners(ModelElement element) {
+ registerObservable(element, "name");
+ registerObservable(element, "guard");
+ registerObservable(element, "kind");
+ registerObservable(element, "effect");
+ }
+}

Back to the top