Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracuccuru2013-08-28 13:04:05 +0000
committerArnaud Cuccuru2013-09-02 09:40:48 +0000
commit710cde428dee51f208d36ff0deacef954c6fdb5c (patch)
tree0e94b84481880dcb06b7728f845a6141f43816db /plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext
parent0ddf2331d864f3d0d6f9ea15a19a73c38320f43a (diff)
downloadorg.eclipse.papyrus-710cde428dee51f208d36ff0deacef954c6fdb5c.tar.gz
org.eclipse.papyrus-710cde428dee51f208d36ff0deacef954c6fdb5c.tar.xz
org.eclipse.papyrus-710cde428dee51f208d36ff0deacef954c6fdb5c.zip
Bug 315231 - Improvement of xtext integration.
Applies patch produced by ITEMIS.
Diffstat (limited to 'plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.classpath7
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.project28
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF20
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/build.properties5
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.properties8
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml28
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java160
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java32
9 files changed, 295 insertions, 0 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.classpath b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.project b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.project
new file mode 100644
index 00000000000..1d798513068
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.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/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..44217f8c068
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.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.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..9b4f477a220
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.uml.properties.xtext;singleton:=true
+Bundle-Version: 0.10.1.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+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.gmfdiag.commands;bundle-version="0.10.0",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="0.10.1",
+ org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.0.0",
+ org.eclipse.xtext;bundle-version="2.4.2"
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/build.properties b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/build.properties
new file mode 100644
index 00000000000..6f20375d6c7
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.properties b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.properties
new file mode 100644
index 00000000000..69c2377c5e6
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.properties
@@ -0,0 +1,8 @@
+
+# <copyright>
+# </copyright>
+#
+# $Id$
+
+pluginName = Papyrus xtext properties UML (Incubation)
+providerName = Eclipse Modeling Project
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml
new file mode 100644
index 00000000000..ed9df447719
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml
@@ -0,0 +1,28 @@
+<?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.properties.xtext.sheet.AdvancedEditingPropertySection"
+ filter="org.eclipse.papyrus.uml.properties.xtext.sheet.AdvancedEditingPropertySectionFilter"
+ id="property.section.AdvancedEditingPropertySection"
+ tab="advanced_editing">
+ <input type="org.eclipse.gmf.runtime.notation.View"/>
+ <input type="org.eclipse.gef.EditPart"/>
+ </propertySection>
+ </propertySections>
+</extension>
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs
+ contributorId="TreeOutlinePage">
+ <propertyTab
+ afterTab="advanced"
+ category="org.eclipse.papyrus"
+ id="advanced_editing"
+ label="Advanced Editing">
+ </propertyTab>
+ </propertyTabs>
+ </extension>
+</plugin>
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java
new file mode 100644
index 00000000000..6bf57407894
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySection.java
@@ -0,0 +1,160 @@
+package org.eclipse.papyrus.uml.properties.xtext.sheet;
+
+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.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.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.extensionpoints.editors.Activator;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.DefaultXtextDirectEditorConfiguration;
+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.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.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+public class AdvancedEditingPropertySection extends AbstractModelerPropertySection implements IContextElementProvider {
+
+ private FormToolkit toolkit;
+
+ private Form form;
+
+ private StyledText textControl;
+
+ private DefaultXtextDirectEditorConfiguration configuration;
+
+ private StyledTextXtextAdapter xtextAdapter;
+
+ final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter(this);
+
+ @Override
+ public void refresh() {
+ updateXtextAdapters(textControl);
+
+ IParser parser = getParser();
+ if (parser != null) {
+ textControl.setText(parser.getPrintString(null, 0));
+ }
+
+ }
+
+ @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());
+ }
+
+ protected void createTextControl(final Composite parent) {
+
+ textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+ textControl.addFocusListener(new FocusListener() {
+
+ public void focusLost(FocusEvent e) {
+ IParser parser = getParser();
+ if (parser != null) {
+ ICommand command = parser.getParseCommand(new EObjectAdapter(getEObject()), textControl.getText(),
+ 0);
+
+ getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(command));
+ }
+ }
+
+ public void focusGained(FocusEvent e) {
+ }
+ });
+ ((StyledText) textControl).setAlwaysShowScrollBars(false);
+ GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
+
+ }
+
+ protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() {
+ IGraphicalEditPart part = getEditPartFromSelection();
+ if (part != null) {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String semanticClassName = part.resolveSemanticElement().eClass().getInstanceClassName();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT + semanticClassName;
+ String languagePreferred = store.getString(key);
+
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred,
+ semanticClassName);
+ if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
+ return (DefaultXtextDirectEditorConfiguration) configuration;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected IGraphicalEditPart getEditPartFromSelection() {
+ Object selection = getPrimarySelection();
+ if (selection instanceof IGraphicalEditPart) {
+ return (IGraphicalEditPart) selection;
+ }
+ return null;
+ }
+
+ protected IParser getParser() {
+ final IGraphicalEditPart part = getEditPartFromSelection();
+ if (configuration != null && part != null) {
+ return configuration.createParser(part.resolveSemanticElement());
+ }
+ return null;
+ }
+
+ protected void updateXtextAdapters(Control styledText) {
+ 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());
+ xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters().add(contextElementAdapter);
+ xtextAdapter.adapt((StyledText) styledText);
+ }
+ }
+
+ public EObject getContextObject() {
+ return getEObject();
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
new file mode 100644
index 00000000000..014c4edda46
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/sheet/AdvancedEditingPropertySectionFilter.java
@@ -0,0 +1,32 @@
+package org.eclipse.papyrus.uml.properties.xtext.sheet;
+
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+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;
+
+public class AdvancedEditingPropertySectionFilter implements IFilter {
+
+ public boolean select(Object toTest) {
+ if (toTest instanceof IGraphicalEditPart) {
+ IGraphicalEditPart part = (IGraphicalEditPart) toTest;
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + part.resolveSemanticElement().eClass().getInstanceClassName();
+ String languagePreferred = store.getString(key);
+
+ if (languagePreferred != null && !languagePreferred.equals("")) {
+ IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(
+ languagePreferred, part.resolveSemanticElement().eClass()
+ .getInstanceClassName());
+ return configuration instanceof ICustomDirectEditorConfiguration;
+ }
+
+ }
+ return false;
+ }
+} \ No newline at end of file

Back to the top