Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2018-07-03 08:23:48 +0000
committerVincent Lorenzo2018-09-05 08:30:33 +0000
commitc8bda1499131c103794418659698f9918c16dced (patch)
tree22530a97f0ba3bee7d12d03594ffd616bab894da /plugins
parent3c9f5a403c82f4aaa584341c9aa00602b1ebf2aa (diff)
downloadorg.eclipse.papyrus-c8bda1499131c103794418659698f9918c16dced.tar.gz
org.eclipse.papyrus-c8bda1499131c103794418659698f9918c16dced.tar.xz
org.eclipse.papyrus-c8bda1499131c103794418659698f9918c16dced.zip
Bug 536594: [Properties][OpaqueExpression][XText] the change of the
language to use doesn't work propertly with Xtext editor Change-Id: I05065a52f8182da46190d5d4c36d891c57e461fb Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr> Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.classpath2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF6
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/pom.xml2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java73
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/DynamicBodyEditor.java9
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LanguageBodyEditor.java43
9 files changed, 126 insertions, 19 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
index 64c5e31b7a2..eca7bdba8f0 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.classpath
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/.classpath
@@ -1,6 +1,6 @@
<?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.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="bin"/>
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
index 15d5f917b9c..74c6d08d7e4 100644
--- 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
@@ -1,16 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
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
index 0efd0e34c0a..a45c280433b 100644
--- 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
@@ -1,15 +1,15 @@
Manifest-Version: 1.0
-Require-Bundle: org.eclipse.papyrus.uml.properties;bundle-version="[3.0.0,4.0.0)",
+Require-Bundle: org.eclipse.papyrus.uml.properties;bundle-version="[3.2.0,4.0.0)",
org.eclipse.papyrus.infra.properties.ui;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui;bundle-version="[2.1.0,3.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.3.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.papyrus.uml.properties.xtext;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.papyrus.uml.properties.xtext,
org.eclipse.papyrus.uml.properties.xtext.sheet,
org.eclipse.papyrus.uml.properties.xtext.widget,
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/pom.xml
index 5fe6c7da4a3..cded9f34f25 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/pom.xml
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.properties.xtext</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java
index 29de4d5e5c9..d58e8d41630 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/XtextLanguageEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST.
+ * Copyright (c) 2014, 2016 - 2018 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -8,7 +8,8 @@
*
* SPDX-License-Identifier: EPL-2.0
*
- *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea. fr - Bug 536594
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.xtext;
@@ -29,7 +30,7 @@ import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
import org.eclipse.papyrus.infra.ui.emf.dialog.NestedEditingDialogContext;
import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement;
-import org.eclipse.papyrus.uml.properties.widgets.BodyEditor;
+import org.eclipse.papyrus.uml.properties.widgets.LanguageBodyEditor;
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;
@@ -48,7 +49,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Listener;
-public class XtextLanguageEditor implements BodyEditor, IContextElementProvider {
+public class XtextLanguageEditor implements LanguageBodyEditor, IContextElementProvider {
protected StyledText textControl;
@@ -66,8 +67,15 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter(this);
+ /**
+ * the language of the current editor
+ */
+ private String language = ""; //$NON-NLS-1$
+
+
+ @Override
public void createWidget(Composite parent, int style) {
- undoRedoStack = new UndoRedoStack<ExtendedModifyEvent>();
+ undoRedoStack = new UndoRedoStack<>();
createTextControl(parent);
}
@@ -77,6 +85,7 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
textControl.addFocusListener(new FocusListener() {
+ @Override
public void focusLost(FocusEvent e) {
IParser parser = getParser();
if (xtextAdapter == null) { // May happen under specific circumstances (See Bug 433647)
@@ -103,6 +112,7 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
}
}
+ @Override
public void focusGained(FocusEvent e) {
// Nothing
}
@@ -114,6 +124,7 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
// GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
textControl.addExtendedModifyListener(new ExtendedModifyListener() {
+ @Override
public void modifyText(ExtendedModifyEvent event) {
if (isUndo) {
undoRedoStack.pushRedo(event);
@@ -230,15 +241,27 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() {
EObject semanticElement = getEObject();
if (semanticElement != null) {
+ String languagePreferred = this.language;
+ // check if we found a configuration
+ if (!languagePreferred.isEmpty()) {
+ IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, semanticElement);
+ if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
+ DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration;
+ xtextConfiguration.preEditAction(semanticElement);
+ return xtextConfiguration;
+ }
+ return null; // no configuration found for the current language
+ }
+
+ // no language defined, so we use the preference store
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
String semanticClassName = semanticElement.eClass().getInstanceClassName();
String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT + semanticClassName;
- String languagePreferred = store.getString(key);
+ languagePreferred = store.getString(key);
if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, semanticElement);
if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
-
DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration;
xtextConfiguration.preEditAction(semanticElement);
return xtextConfiguration;
@@ -248,10 +271,12 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
return null;
}
+ @Override
public EObject getContextObject() {
return getEObject();
}
+ @Override
public void setInput(String value) {
if (value != null) {
textControl.setText(value);
@@ -262,6 +287,7 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
}
}
+ @Override
public void dispose() {
// dispose resources to avoid memory leaks
if (textControl != null) {
@@ -274,19 +300,24 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
}
}
+ @Override
public void addChangeListener(Listener listener) {
}
+ @Override
public void removeChangeListener(Listener listener) {
}
+ @Override
public String getValue() {
return null;
}
+ @Override
public void setReadOnly(boolean readOnly) {
}
+ @Override
public void setContext(ModelElement context) {
if (context instanceof UMLModelElement) {
currentEObj = ((UMLModelElement) context).getSource();
@@ -300,4 +331,32 @@ public class XtextLanguageEditor implements BodyEditor, IContextElementProvider
protected EObject getEObject() {
return currentEObj;
}
+
+ /**
+ * @see org.eclipse.papyrus.uml.properties.widgets.LanguageBodyEditor#setLanguage(java.lang.String)
+ *
+ * @param language
+ * @since 1.2.100
+ */
+ @Override
+ public void setLanguage(final String language) {
+ if (null == this.language) {
+ this.language = ""; //$NON-NLS-1$
+ } else {
+ this.language = language;
+ }
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.properties.widgets.LanguageBodyEditor#getLanguage()
+ *
+ * @return
+ *
+ * @since 1.2.100
+ *
+ */
+ @Override
+ public String getLanguage() {
+ return this.language != null ? this.language : ""; //$NON-NLS-1$
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
index 5cf393ae509..56b3093206d 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
@@ -39,7 +39,7 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v
org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.uml.properties.constraints"
-Bundle-Version: 3.1.100.qualifier
+Bundle-Version: 3.2.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.uml.properties.Activator
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
index 8364f33f743..5b944043e07 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.properties</artifactId>
- <version>3.1.100-SNAPSHOT</version>
+ <version>3.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/DynamicBodyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/DynamicBodyEditor.java
index f4e3e6fe1a5..ca71a1cac2e 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/DynamicBodyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/DynamicBodyEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2018 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Add binding implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea. fr - Bug 536594
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
@@ -132,7 +133,11 @@ public class DynamicBodyEditor extends AbstractValueEditor implements Listener {
}
private BodyEditor getEditor(String language) {
- return LanguageRegistry.instance.getEditorFor(language);
+ final BodyEditor editor = LanguageRegistry.instance.getEditorFor(language);
+ if (editor instanceof LanguageBodyEditor && null != language) {
+ ((LanguageBodyEditor) editor).setLanguage(language);
+ }
+ return editor;
}
private void disposeBodyEditor() {
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LanguageBodyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LanguageBodyEditor.java
new file mode 100644
index 00000000000..c37c139a610
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/LanguageBodyEditor.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright (c) 2018 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:
+ * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.widgets;
+
+/**
+ * This class allows to manage the change of the language to use in a body editor.
+ * This interface has been created to fix the Bug 536594: [Properties][OpaqueExpression][XText] the change of the language to use doesn't work propertly with Xtext editor
+ *
+ * @author Vincent LORENZO
+ * @since 3.2
+ */
+public interface LanguageBodyEditor extends BodyEditor {
+
+ /**
+ *
+ * @param language
+ * the language associated to the editor, it can't be <code>null</code>
+ */
+ public default void setLanguage(final String language) { // default to ensure implementation and avoid API break
+ // do nothing
+ }
+
+ /**
+ *
+ * @return
+ * the language associated to the editor, it can be an empty string if the language is not yet defined
+ * it can't return <code>null</code>
+ */
+ public default String getLanguage() {
+ return ""; //$NON-NLS-1$ //to ensure implementation and avoid API break
+ }
+}

Back to the top