diff options
author | Nicolas FAUVERGUE | 2015-03-10 15:22:37 +0000 |
---|---|---|
committer | Nicolas FAUVERGUE | 2015-03-11 13:07:10 +0000 |
commit | 46f7f82ed71747d812aad9facaccedfd04afd845 (patch) | |
tree | 10aa52eab1dc37271530d0f7add338391b45bb80 | |
parent | b0cb161e451eb4ea4e016c9bac68c259a9b68962 (diff) | |
download | org.eclipse.papyrus-46f7f82ed71747d812aad9facaccedfd04afd845.tar.gz org.eclipse.papyrus-46f7f82ed71747d812aad9facaccedfd04afd845.tar.xz org.eclipse.papyrus-46f7f82ed71747d812aad9facaccedfd04afd845.zip |
Bug 459747: [XText] Papyrus must provides a XText editor for the
ValueSpecification
https://bugs.eclipse.org/bugs/show_bug.cgi?id=459747
- Modify dependencies identifier and Bundle-vendor
- Manage the handles method of the cell manager
- Move the properties dialog for the xtext editor in the
"oep.uml.properties.xtext" plugin
- Manage the priority for the direct editor configuration
Change-Id: I70041d5325b6bdbb001aaf6aa747ab597703b46c
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
17 files changed, 597 insertions, 195 deletions
diff --git a/examples/uml/org.eclipse.papyrus.textual.editors.example/META-INF/MANIFEST.MF b/examples/uml/org.eclipse.papyrus.textual.editors.example/META-INF/MANIFEST.MF index 31a288e3b71..9426cb08dff 100644 --- a/examples/uml/org.eclipse.papyrus.textual.editors.example/META-INF/MANIFEST.MF +++ b/examples/uml/org.eclipse.papyrus.textual.editors.example/META-INF/MANIFEST.MF @@ -12,21 +12,16 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.uml.nattable;bundle-version="1.0.2", org.eclipse.papyrus.infra.nattable.model;bundle-version="1.0.2", org.eclipse.nebula.widgets.nattable.core;bundle-version="1.1.0", - org.eclipse.papyrus.infra.widgets;bundle-version="1.0.2", - org.eclipse.core.databinding.observable, - org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.2", - org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.0.2", org.eclipse.gmf.runtime.common.core, org.eclipse.gmf.runtime.common.ui.services, org.eclipse.gmf.runtime.emf.core, org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2", org.eclipse.papyrus.infra.emf;bundle-version="1.0.2", org.eclipse.xtext, - org.eclipse.papyrus.uml.xtext.integration.core;bundle-version="1.0.2", - org.eclipse.core.databinding, org.eclipse.papyrus.infra.emf.nattable;bundle-version="1.0.2", org.eclipse.papyrus.infra.tools;bundle-version="1.0.2", - org.eclipse.papyrus.uml.nattable.xtext.valuespecification;bundle-version="1.0.2" + org.eclipse.papyrus.uml.nattable.xtext.valuespecification;bundle-version="1.0.2", + org.eclipse.papyrus.uml.properties.xtext;bundle-version="1.0.2" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Bundle-Description: %Bundle-Description diff --git a/examples/uml/org.eclipse.papyrus.textual.editors.example/model/UML/ui/PropertyViewEditorsExample.xwt b/examples/uml/org.eclipse.papyrus.textual.editors.example/model/UML/ui/PropertyViewEditorsExample.xwt index 4cd9c987a99..342afdaf55a 100644 --- a/examples/uml/org.eclipse.papyrus.textual.editors.example/model/UML/ui/PropertyViewEditorsExample.xwt +++ b/examples/uml/org.eclipse.papyrus.textual.editors.example/model/UML/ui/PropertyViewEditorsExample.xwt @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <Composite xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets" xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout" - xmlns:xtexteditor="clr-namespace:org.eclipse.papyrus.textual.editors.example.widget.property" + xmlns:xtexteditor="clr-namespace:org.eclipse.papyrus.uml.properties.xtext.widget.property" xmlns:x="http://www.eclipse.org/xwt" xmlns="http://www.eclipse.org/xwt/presentation"> <Composite.layout> <ppel:PropertiesLayout></ppel:PropertiesLayout> diff --git a/examples/uml/org.eclipse.papyrus.textual.editors.example/plugin.xml b/examples/uml/org.eclipse.papyrus.textual.editors.example/plugin.xml index c0c66239fff..65cee2a42d6 100644 --- a/examples/uml/org.eclipse.papyrus.textual.editors.example/plugin.xml +++ b/examples/uml/org.eclipse.papyrus.textual.editors.example/plugin.xml @@ -15,12 +15,6 @@ isCustomizable="true"> </context> </extension> - <extension - point="org.eclipse.papyrus.views.properties.environment"> - <environment - environmentModel="model/environment.xmi"> - </environment> - </extension> <extension point="org.eclipse.papyrus.infra.nattable.cellmanager"> <cellManager diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java index e2659c4bfd4..14115d1c77d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java @@ -1,113 +1,147 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Remi Schnekenburger (CEA LIST) Remi.Schnekenburger@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.extensionpoints.editors.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.papyrus.extensionpoints.editors.configuration.DefaultDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.definition.DirectEditorExtensionPoint;
-
-/**
- *
- */
-public class DirectEditorsUtil {
-
- /**
- * Finds a editor for specific language and object to edit type
- *
- * @param language
- * the language to edit
- * @param objectToEdit
- * the type of object to edit
- * @return the extension point proxy that manages this kind of editor
- */
- public static IDirectEditorConfiguration findEditorConfiguration(String language, String objectToEdit) {
- DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations();
- for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (lang.equals(language) && oToEdit.equals(objectToEdit)) {
- // extension point found!
- return directEditorExtensionPoint.getDirectEditorConfiguration();
- }
- }
- return new DefaultDirectEditorConfiguration();
- }
-
- /**
- * finds if an editor for specific language and object is available to edit type
- *
- * @param language
- * the language to edit
- * @param objectToEdit
- * the type of object to edit
- * @return <code>true</code> if an editor exists
- */
- public static boolean hasSpecificEditorConfiguration(String language, String objectToEdit) {
- DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations();
- for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String lang = directEditorExtensionPoint.getLanguage();
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (lang.equals(language) && oToEdit.equals(objectToEdit)) {
- // extension point found!
- return true;
- }
- }
- return false;
- }
-
- /**
- * finds if an editor for specific object is available to edit type
- *
- * @param language
- * the language to edit
- * @param objectToEdit
- * the type of object to edit
- * @return <code>true</code> if an editor exists
- */
- public static boolean hasSpecificEditorConfiguration(String objectToEdit) {
- DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations();
- for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- final String oToEdit = directEditorExtensionPoint.getObjectToEdit();
- if (oToEdit.equals(objectToEdit)) {
- // extension point found!
- return true;
- }
- }
- return false;
- }
-
- /**
- * returns the list of languages that are available from extension points
- *
- * @return the list of languages that have an extended editor
- */
- // @unused
- public static List<String> getLanguages(String objectToEdit) {
- List<String> languages = new ArrayList<String>();
- DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations();
- for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) {
- if (objectToEdit == null || directEditorExtensionPoint.getObjectToEdit().equals(objectToEdit)) {
- String lang = directEditorExtensionPoint.getLanguage();
- if (!languages.contains(lang)) {
- languages.add(lang);
- }
- }
- }
- return languages;
- }
-}
+/***************************************************************************** + * Copyright (c) 2008 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: + * Remi Schnekenburger (CEA LIST) Remi.Schnekenburger@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 459747 + * + *****************************************************************************/ + +package org.eclipse.papyrus.extensionpoints.editors.utils; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.extensionpoints.editors.configuration.DefaultDirectEditorConfiguration; +import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; +import org.eclipse.papyrus.extensionpoints.editors.definition.DirectEditorExtensionPoint; + +/** + * + */ +public class DirectEditorsUtil { + + /** + * Define the default priority constant (equals to LOW priority). + */ + public static final int DEFAULT_PRORITY = 3; + + /** + * Finds a editor for specific language and object to edit type + * + * @param language + * the language to edit + * @param objectToEdit + * the type of object to edit + * @return the extension point proxy that manages this kind of editor + */ + public static IDirectEditorConfiguration findEditorConfiguration(String language, String objectToEdit) { + DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations(); + for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) { + final String lang = directEditorExtensionPoint.getLanguage(); + final String oToEdit = directEditorExtensionPoint.getObjectToEdit(); + if (lang.equals(language) && oToEdit.equals(objectToEdit)) { + // extension point found! + return directEditorExtensionPoint.getDirectEditorConfiguration(); + } + } + return new DefaultDirectEditorConfiguration(); + } + + /** + * Finds a editor for specific language and object to edit type with the higher priority. + * + * @param language + * the language to edit + * @param objectToEdit + * the type of object to edit + * @return the extension point proxy that manages this kind of editor + */ + public static IDirectEditorConfiguration findEditorConfigurationWithPriority(String language, String objectToEdit) { + IDirectEditorConfiguration result = null; + int currentPrority = DEFAULT_PRORITY; + DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations(); + for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) { + final String lang = directEditorExtensionPoint.getLanguage(); + final String oToEdit = directEditorExtensionPoint.getObjectToEdit(); + if (lang.equals(language) && oToEdit.equals(objectToEdit)) { + // extension point found! + int directEditorExtensionPointPriority = directEditorExtensionPoint.getPriority() != null ? directEditorExtensionPoint.getPriority() : DEFAULT_PRORITY; + if (result == null || (directEditorExtensionPointPriority < currentPrority)) { + result = directEditorExtensionPoint.getDirectEditorConfiguration(); + currentPrority = directEditorExtensionPointPriority; + } + } + } + return result != null ? result : new DefaultDirectEditorConfiguration(); + } + + /** + * finds if an editor for specific language and object is available to edit type + * + * @param language + * the language to edit + * @param objectToEdit + * the type of object to edit + * @return <code>true</code> if an editor exists + */ + public static boolean hasSpecificEditorConfiguration(String language, String objectToEdit) { + DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations(); + for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) { + final String lang = directEditorExtensionPoint.getLanguage(); + final String oToEdit = directEditorExtensionPoint.getObjectToEdit(); + if (lang.equals(language) && oToEdit.equals(objectToEdit)) { + // extension point found! + return true; + } + } + return false; + } + + /** + * finds if an editor for specific object is available to edit type + * + * @param language + * the language to edit + * @param objectToEdit + * the type of object to edit + * @return <code>true</code> if an editor exists + */ + public static boolean hasSpecificEditorConfiguration(String objectToEdit) { + DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations(); + for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) { + final String oToEdit = directEditorExtensionPoint.getObjectToEdit(); + if (oToEdit.equals(objectToEdit)) { + // extension point found! + return true; + } + } + return false; + } + + /** + * returns the list of languages that are available from extension points + * + * @return the list of languages that have an extended editor + */ + // @unused + public static List<String> getLanguages(String objectToEdit) { + List<String> languages = new ArrayList<String>(); + DirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations(); + for (DirectEditorExtensionPoint directEditorExtensionPoint : extensionPoints) { + if (objectToEdit == null || directEditorExtensionPoint.getObjectToEdit().equals(objectToEdit)) { + String lang = directEditorExtensionPoint.getLanguage(); + if (!languages.contains(lang)) { + languages.add(lang); + } + } + } + return languages; + } +} diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/celleditor/ValueSpecificationCellEditor.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/celleditor/ValueSpecificationCellEditor.java index 14e69e4dc10..a8db522a61e 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/celleditor/ValueSpecificationCellEditor.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/celleditor/ValueSpecificationCellEditor.java @@ -105,7 +105,7 @@ public class ValueSpecificationCellEditor extends AbstractXtextCellEditor { if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$ IDirectEditorConfiguration configuration = DirectEditorsUtil - .findEditorConfiguration(languagePreferred, + .findEditorConfigurationWithPriority(languagePreferred, semanticClassName); if (configuration instanceof DefaultXtextDirectEditorConfiguration) { diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/manager/cell/ValueSpecificationCellManager.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/manager/cell/ValueSpecificationCellManager.java index 54bd2c72c33..381d2157642 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/manager/cell/ValueSpecificationCellManager.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/manager/cell/ValueSpecificationCellManager.java @@ -26,12 +26,15 @@ import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; import org.eclipse.papyrus.infra.emf.nattable.manager.cell.EMFFeatureValueCellManager; import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis; import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EStructuralFeatureAxis; +import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter; import org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.internal.UmlValueSpecificationActivator; import org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils.commands.ValueSpecificationSetCommand; import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.ValueSpecification; import com.google.inject.Injector; @@ -134,4 +137,24 @@ public class ValueSpecificationCellManager extends EMFFeatureValueCellManager { UmlValueSpecificationActivator.ORG_ECLIPSE_PAPYRUS_UML_TEXTEDIT_VALUESPECIFICATION_XTEXT_UMLVALUESPECIFICATION); } + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.emf.nattable.manager.cell.EMFFeatureValueCellManager#handles(java.lang.Object, java.lang.Object) + */ + @Override + public boolean handles(final Object columnElement, final Object rowElement) { + boolean result = false; + Object row = AxisUtils.getRepresentedElement(rowElement); + Object column = AxisUtils.getRepresentedElement(columnElement); + if (column instanceof EStructuralFeature) { + result = UMLPackage.Literals.VALUE_SPECIFICATION == ((EStructuralFeature) column) + .getEType(); + } else if (row instanceof EStructuralFeature) { + result = UMLPackage.Literals.VALUE_SPECIFICATION == ((EStructuralFeature) row) + .getEType(); + } + return result; + } + } 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 1cdba3c9afc..7d39d358496 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,25 +1,28 @@ -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.0.2",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2",
- org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.2",
- org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.0.2",
- org.eclipse.xtext;bundle-version="2.4.2",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.2",
- org.eclipse.papyrus.uml.properties;bundle-version="1.0.2",
- org.eclipse.papyrus.views.properties;bundle-version="1.0.2"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.2.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.uml.properties.xtext;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+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.0.2", + org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2", + org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.2", + org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="1.0.2", + org.eclipse.xtext;bundle-version="2.4.2", + org.eclipse.papyrus.infra.emf;bundle-version="1.0.2", + org.eclipse.papyrus.uml.properties;bundle-version="1.0.2", + org.eclipse.papyrus.views.properties;bundle-version="1.0.2", + org.eclipse.papyrus.infra.widgets;bundle-version="1.0.2", + org.eclipse.core.databinding.observable, + org.eclipse.core.databinding +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.0.2.qualifier +Bundle-Name: %pluginName +Bundle-Localization: plugin +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.uml.properties.xtext;singleton:=true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/examples/uml/org.eclipse.papyrus.textual.editors.example/src/org/eclipse/papyrus/textual/editors/example/widget/UMLXtextReferenceValueEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/UMLXtextReferenceValueEditor.java index a990905d246..a990905d246 100644 --- a/examples/uml/org.eclipse.papyrus.textual.editors.example/src/org/eclipse/papyrus/textual/editors/example/widget/UMLXtextReferenceValueEditor.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/UMLXtextReferenceValueEditor.java diff --git a/examples/uml/org.eclipse.papyrus.textual.editors.example/model/environment.xmi b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/model/environment.xmi index 54664633f15..0addaed8040 100644 --- a/examples/uml/org.eclipse.papyrus.textual.editors.example/model/environment.xmi +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/model/environment.xmi @@ -9,5 +9,5 @@ namespace="//@namespaces.0"/> <namespaces name="xtexteditor" - value="org.eclipse.papyrus.textual.editors.example.widget.property"/> + value="org.eclipse.papyrus.uml.properties.xtext.widget.property"/> </environment:Environment> 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 index d3f366ccdb7..73b22f1d0bf 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/plugin.xml @@ -1,11 +1,17 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.papyrus.uml.properties.languageEditor">
- <editor
- editor="org.eclipse.papyrus.uml.properties.xtext.XtextLanguageEditor"
- language="OCL">
- </editor>
- </extension>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.papyrus.uml.properties.languageEditor"> + <editor + editor="org.eclipse.papyrus.uml.properties.xtext.XtextLanguageEditor" + language="OCL"> + </editor> + </extension> + <extension + point="org.eclipse.papyrus.views.properties.environment"> + <environment + environmentModel="model/environment.xmi"> + </environment> + </extension> +</plugin> diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java new file mode 100644 index 00000000000..182ff901e2b --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java @@ -0,0 +1,346 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.xtext.widget; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +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.IDirectEditorConfiguration; +import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; +import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; +import org.eclipse.papyrus.infra.emf.dialog.NestedEditingDialogContext; +import org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog; +import org.eclipse.papyrus.infra.widgets.editors.StyledTextStringEditor; +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.StyledText; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * This class provides a ReferenceValueEditor, with a text field with the xtext + * completion and syntax instead of the CLabel. + */ +public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog + implements IContextElementProvider, SelectionListener { + + /** + * The xtext adapter. + */ + private StyledTextXtextAdapter xtextAdapter; + + /** + * The xtext direct editor configuration used. + */ + private DefaultXtextDirectEditorConfiguration configuration; + + /** + * The context element adapter. + */ + final private ContextElementAdapter contextElementAdapter = new ContextElementAdapter( + this); + + /** + * Constructor. + * + * @param parent + * The composite in which the widget will be displayed. + * @param style + * The style for the widget. + */ + public UMLXtextReferenceValueEditor(final Composite parent, final int style) { + super(parent, style); + styledTextStringEditor.getText().addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + IParser parser = getParser(); + if (null == xtextAdapter) { + return; + } + + if (null != xtextAdapter + && null != xtextAdapter.getCompletionProposalAdapter() + && xtextAdapter.getCompletionProposalAdapter() + .delayedIsPopupOpen()) { + // ignore focus lost + return; + } + manageParserCommand(parser); + } + + public void focusGained(FocusEvent e) { + // Nothing + } + }); + } + + /** + * This allow to manage the parser command. + * + * @param parser + * The parser used. + */ + protected void manageParserCommand(final IParser parser) { + if (null != parser) { + ICommand command = null; + if (null != modelProperty + && modelProperty.getValueType() instanceof EStructuralFeature) { + command = parser.getParseCommand(new EObjectAdapter( + (EStructuralFeature) modelProperty.getValueType()), + styledTextStringEditor.getText().getText(), 0); + } else { + command = parser.getParseCommand(new EObjectAdapter( + (EObject) getValue()), styledTextStringEditor.getText() + .getText(), 0); + } + + TransactionalEditingDomain domain = TransactionUtil + .getEditingDomain(getContextElement()); + if (null == domain) { + // can be null for opaque expression that have been + // created but have not been added to parent + // try to get resource set from nested dialog context + ResourceSet rs = NestedEditingDialogContext.getInstance() + .getResourceSet(); + domain = TransactionUtil.getEditingDomain(rs); + } + if (null != domain) { + domain.getCommandStack().execute( + new GMFtoEMFCommandWrapper(command)); + } + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog#createStyledTextStringEditor(org.eclipse.swt.widgets.Composite, + * java.lang.String, int) + */ + @Override + protected StyledTextStringEditor createStyledTextStringEditor( + final Composite parent, final String initialValue, final int style) { + // Change the style to set the singleText to a single line + int createdStyle = style | SWT.SINGLE; + return new StyledTextStringEditor(parent, createdStyle) { + public StyledText createStyledText(Composite parent, String value, + int createdStyle) { + StyledText txt = new StyledText(parent, createdStyle); + if (null != labelProvider) { + txt.setText(labelProvider.getText(getValue())); + } + return txt; + } + }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog#update() + */ + @Override + public void update() { + super.update(); + updateControls(); + } + + /** + * This allow to update the xtext adapter for the styled text. + * + * @param styledText + * The styled text which one to adapt the xtext adapter. + */ + protected void updateXtextAdapters(final Control styledText) { + final Object oldObjectToEdit = null != configuration ? configuration + .getObjectToEdit() : null; + + final DefaultXtextDirectEditorConfiguration newConfiguration = getConfigurationFromSelection(); + // Check if configuration has changed and update adapters + if (null != newConfiguration && newConfiguration != configuration) { + if (null != xtextAdapter) { + xtextAdapter.getFakeResourceContext().getFakeResource() + .eAdapters().remove(contextElementAdapter); + } + configuration = newConfiguration; + xtextAdapter = new StyledTextXtextAdapter( + configuration.getInjector()); + + EObject semanticElement = (EObject) getValue(); + if (null != semanticElement) { + newConfiguration.preEditAction(semanticElement); + } + + xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters() + .add(contextElementAdapter); + xtextAdapter.adapt((StyledText) styledText); + } + + if (null != configuration + && configuration.getObjectToEdit() != oldObjectToEdit) { + IContextElementProvider provider = configuration + .getContextProvider(); + if (provider instanceof IContextElementProviderWithInit) { + // update resource, if required by text editor + if (null != xtextAdapter) { + ((IContextElementProviderWithInit) provider) + .initResource(xtextAdapter.getFakeResourceContext() + .getFakeResource()); + } + } + } + } + + /** + * This allow to get the xtext direct editor configuration depending on the + * value of the styled text. + * + * @return The {@link DefaultXtextDirectEditorConfiguration} corresponding. + */ + protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() { + DefaultXtextDirectEditorConfiguration result = null; + final Object feature = modelProperty.getValueType(); + if (null != feature && feature instanceof EStructuralFeature) { + IPreferenceStore store = Activator.getDefault() + .getPreferenceStore(); + String semanticClassName = ((EStructuralFeature) feature) + .getEType().getInstanceClassName(); + + String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT + + semanticClassName; + String languagePreferred = store.getString(key); + + if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$ + IDirectEditorConfiguration configuration = DirectEditorsUtil + .findEditorConfigurationWithPriority(languagePreferred, + semanticClassName); + if (configuration instanceof DefaultXtextDirectEditorConfiguration) { + + final Object contextElement = getContextElement(); + if (null != contextElement + && contextElement instanceof EObject) { + DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration; + xtextConfiguration + .preEditAction(((EObject) contextElement) + .eGet((EStructuralFeature) feature)); + result = xtextConfiguration; + } + } + } + } + + if (null == result) { + EObject semanticElement = (EObject) getValue(); + + if (null != semanticElement) { + 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 + .findEditorConfigurationWithPriority(languagePreferred, + semanticClassName); + if (configuration instanceof DefaultXtextDirectEditorConfiguration) { + + DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration; + xtextConfiguration.preEditAction(semanticElement); + return xtextConfiguration; + } + } + } + } + return result; + } + + /** + * Get the parser corresponding to the value. + * + * @return The {@link IParser} + */ + protected IParser getParser() { + EObject parentSemanticElement = null; + final Object contextElement = getContextElement(); + if (null != contextElement && contextElement instanceof EObject) { + parentSemanticElement = (EObject) contextElement; + } + if (null != configuration && null != parentSemanticElement) { + return configuration.createParser(parentSemanticElement); + } + return null; + } + + /** + * {@inheritDoc} Update the xtext adapter. + * + * @see org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog#doBinding() + */ + @Override + protected void doBinding() { + super.doBinding(); + updateXtextAdapters(styledTextStringEditor.getText()); + styledTextStringEditor.setValue(labelProvider.getText(getValue())); + updateLabel(); + } + + /** + * {@inheritDoc} Dispose the xtext adapter. + * + * @see org.eclipse.papyrus.infra.widgets.editors.StyledTextReferenceDialog#dispose() + * + */ + @Override + public void dispose() { + // dispose resources to avoid memory leaks + if (null != styledTextStringEditor) { + styledTextStringEditor.dispose(); + } + if (null != xtextAdapter) { + xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters() + .remove(contextElementAdapter); + xtextAdapter.dispose(); + xtextAdapter = null; + } + } + + /** + * + * {@inheritDoc} + * + * @see org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProvider#getContextObject() + */ + public EObject getContextObject() { + final Object value = getValue(); + return value instanceof EObject ? (EObject) value : null; + } +} diff --git a/examples/uml/org.eclipse.papyrus.textual.editors.example/src/org/eclipse/papyrus/textual/editors/example/widget/property/UMLStyledTextReferenceDialog.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/property/UMLStyledTextReferenceDialog.java index a8cca8619a8..b3dc3dda2fd 100644 --- a/examples/uml/org.eclipse.papyrus.textual.editors.example/src/org/eclipse/papyrus/textual/editors/example/widget/property/UMLStyledTextReferenceDialog.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/property/UMLStyledTextReferenceDialog.java @@ -10,11 +10,11 @@ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation * *****************************************************************************/ -package org.eclipse.papyrus.textual.editors.example.widget.property; +package org.eclipse.papyrus.uml.properties.xtext.widget.property; import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory; import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; -import org.eclipse.papyrus.textual.editors.example.widget.UMLXtextReferenceValueEditor; +import org.eclipse.papyrus.uml.properties.xtext.widget.UMLXtextReferenceValueEditor; import org.eclipse.papyrus.views.properties.widgets.AbstractPropertyEditor; import org.eclipse.swt.widgets.Composite; diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml index 15cc3f2bf0d..7e54fcea8eb 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui/plugin.xml @@ -351,7 +351,7 @@ editorConfiguration="org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution.ValueSpecificationXtextDirectEditorConfiguration"> </popupeditor> <Priority - name="Medium"> + name="Lowest"> </Priority> </DirectEditor> </extension> diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/META-INF/MANIFEST.MF b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/META-INF/MANIFEST.MF index c3a2396516f..5dc8ecbdf66 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/META-INF/MANIFEST.MF +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils/META-INF/MANIFEST.MF @@ -1,6 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName +Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils;singleton:=true Bundle-Version: 1.0.2.qualifier Bundle-Activator: org.eclipse.papyrus.uml.textedit.valuespecification.xtext.utils.Activator diff --git a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/META-INF/MANIFEST.MF b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/META-INF/MANIFEST.MF index 422cbcd5e06..4529e1ff769 100644 --- a/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/META-INF/MANIFEST.MF +++ b/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.xtext/META-INF/MANIFEST.MF @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.xtext, org.apache.log4j, org.eclipse.papyrus.uml.xtext.integration.core;bundle-version="1.0.2", org.eclipse.xtext.xbase.lib, - org.eclipse.papyrus.infra.emf + org.eclipse.papyrus.infra.emf;bundle-version="1.0.2" Export-Package: org.eclipse.papyrus.uml.textedit.valuespecification.xtext, org.eclipse.papyrus.uml.textedit.valuespecification.xtext.formatting, org.eclipse.papyrus.uml.textedit.valuespecification.xtext.generator, diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF index aa5364f0a81..18b1b418f29 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/META-INF/MANIFEST.MF @@ -1,24 +1,24 @@ -Manifest-Version: 1.0
-Require-Bundle: org.eclipse.uml2.uml,
- org.eclipse.jface;bundle-version="3.4.1",
- org.eclipse.emf.transaction;bundle-version="1.2.1",
- org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.2",
- org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.2",
- org.eclipse.ui.workbench;bundle-version="3.105.0",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.infra.widgets
-Export-Package: org.eclipse.papyrus.uml.tools.utils
-Bundle-Vendor: %pluginProvider
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.2.qualifier
-Bundle-Name: %pluginName
-Bundle-Localization: plugin
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.uml.tools.utils.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.uml.tools.utils;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Manifest-Version: 1.0 +Require-Bundle: org.eclipse.uml2.uml, + org.eclipse.jface;bundle-version="3.4.1", + org.eclipse.emf.transaction;bundle-version="1.2.1", + org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0", + org.eclipse.papyrus.infra.emf;bundle-version="1.0.2", + org.eclipse.gmf.runtime.notation;bundle-version="1.5.0", + org.eclipse.papyrus.infra.core;bundle-version="1.0.2", + org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2", + org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.2", + org.eclipse.ui.workbench;bundle-version="3.105.0", + org.eclipse.papyrus.infra.tools;bundle-version="1.0.2", + com.google.guava;bundle-version="11.0.0", + org.eclipse.papyrus.infra.widgets;bundle-version="1.0.2" +Export-Package: org.eclipse.papyrus.uml.tools.utils +Bundle-Vendor: %pluginProvider +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.0.2.qualifier +Bundle-Name: %pluginName +Bundle-Localization: plugin +Bundle-ManifestVersion: 2 +Bundle-Activator: org.eclipse.papyrus.uml.tools.utils.Activator +Bundle-SymbolicName: org.eclipse.papyrus.uml.tools.utils;singleton:=true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/plugin.properties b/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/plugin.properties index dda0477e38a..befcd918a84 100644 --- a/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/plugin.properties +++ b/tests/junit/plugins/uml/textedit/org.eclipse.papyrus.uml.textedit.valuespecification.tests/plugin.properties @@ -8,6 +8,6 @@ # Contributors: # Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - initial API and implementation ################################################################################## -pluginName = XText ValueSpecification Editor Tests -providerName = Eclipse Modeling Project +pluginName=XText ValueSpecification Editor Tests +providerName=Eclipse Modeling Project pluginDescription=This plugin define the xtext editor for the cell of NatTable
\ No newline at end of file |