Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2015-04-08 13:34:57 +0000
committervincent lorenzo2015-04-08 14:58:22 +0000
commita286b50e9a326557a10328618c4c6455a5fca857 (patch)
treeb8d5fe0495aa6b233cd69f8261ab386738d2ddc8
parent247bca9eb37f8c4e96a8a5a27343cf41c6563c39 (diff)
downloadorg.eclipse.papyrus-a286b50e9a326557a10328618c4c6455a5fca857.tar.gz
org.eclipse.papyrus-a286b50e9a326557a10328618c4c6455a5fca857.tar.xz
org.eclipse.papyrus-a286b50e9a326557a10328618c4c6455a5fca857.zip
Bug 463881: [XText] The ValueSpecification XText editor in properties
view must be defined by XWT element https://bugs.eclipse.org/bugs/show_bug.cgi?id=463881 - Recvery code which allow to get the direct editor configuration to get it from XWT attribute with java reflexive instead of getting direct editor configuration from object to edit with defined extension points Change-Id: I127ca82c42f80611884fcdf6b09fb4c1699516c1 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net> Reviewed-on: https://git.eclipse.org/r/45457 Tested-by: Hudson CI Reviewed-by: vincent lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--examples/uml/org.eclipse.papyrus.uml.textual.editors.example/model/UML/ui/PropertyExample.xwt2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/Activator.java115
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java68
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/property/UMLStyledTextReferenceDialog.java33
5 files changed, 169 insertions, 53 deletions
diff --git a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/model/UML/ui/PropertyExample.xwt b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/model/UML/ui/PropertyExample.xwt
index f757324cadb..afde1ae27a9 100644
--- a/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/model/UML/ui/PropertyExample.xwt
+++ b/examples/uml/org.eclipse.papyrus.uml.textual.editors.example/model/UML/ui/PropertyExample.xwt
@@ -36,7 +36,7 @@
<ppe:ReferenceDialog input="{Binding}"
property="UML:Property:defaultValue"></ppe:ReferenceDialog>
<xtexteditor:UMLStyledTextReferenceDialog
- property="UML:Property:defaultValue" input="{Binding}" objectInstance="org.eclipse.uml2.uml.ValueSpecification"></xtexteditor:UMLStyledTextReferenceDialog>
+ property="UML:Property:defaultValue" input="{Binding}" directEditorConfiguration="org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui.contribution.ValueSpecificationXtextDirectEditorConfiguration"></xtexteditor:UMLStyledTextReferenceDialog>
<ppe:EnumCombo input="{Binding}" property="UML:Property:aggregation"></ppe:EnumCombo>
<ppe:MultiReference input="{Binding}"
property="UML:Property:subsettedProperty"></ppe:MultiReference>
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 7d39d358496..68656245565 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
@@ -17,7 +17,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.105.0",
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
+ org.eclipse.core.databinding,
+ org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.2"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.2.qualifier
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/Activator.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/Activator.java
new file mode 100644
index 00000000000..ec6ab95544e
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/Activator.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * 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;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.properties.xtext"; //$NON-NLS-1$
+
+ /** The shared instance */
+ private static Activator plugin;
+
+ /** The plug-in's logger */
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ // Nothing
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(plugin);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Gets the IPath representing the plugin's preferences folder location
+ *
+ * @return The IPath representing the plugin's preferences folder location
+ */
+ public IPath getPreferencesPath() {
+ return getStateLocation();
+ }
+
+ /**
+ * Returns the image at the given path from this plugin
+ *
+ * @param path
+ * the path of the image to be displayed
+ * @return The Image at the given location, or null if it couldn't be found
+ */
+ public Image getImage(final String path) {
+ return getImage(PLUGIN_ID, path);
+ }
+
+ /**
+ * Returns the image from the given image descriptor
+ *
+ * @param pluginId
+ * The plugin in which the image is located
+ * @param path
+ * The path to the image from the plugin
+ * @return
+ * The Image at the given location, or null if it couldn't be found
+ */
+ public Image getImage(final String pluginId, final String path) {
+ final ImageRegistry registry = getImageRegistry();
+ String key = pluginId + "/" + path; //$NON-NLS-1$
+ Image image = registry.get(key);
+ if (image == null) {
+ registry.put(key, AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, path));
+ image = registry.get(key);
+ }
+ return image;
+ }
+
+}
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
index fa7586bc39c..e65e313da96 100644
--- 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
@@ -12,8 +12,6 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.xtext.widget;
-import java.util.List;
-
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -23,12 +21,11 @@ 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.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
-import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil;
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.infra.widgets.selectors.StringSelector;
+import org.eclipse.papyrus.uml.properties.xtext.Activator;
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;
@@ -73,9 +70,9 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
private boolean canParse = false;
/**
- * The object instance class name edited.
+ * The direct editor configuration class name to use.
*/
- private String objectInstance;
+ private String directEditorConfiguration;
/**
* Constructor.
@@ -301,34 +298,35 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
* @return The {@link DefaultXtextDirectEditorConfiguration} corresponding.
*/
protected DefaultXtextDirectEditorConfiguration getConfigurationFromSelection() {
- if (null != objectInstance && !objectInstance.isEmpty()) {
- Object feature = null;
- Object contextElement = null;
- if (null != modelProperty) {
- feature = modelProperty.getValueType();
- contextElement = getContextElement();
- } else {
- contextElement = getValue();
- }
-
- if (contextElement instanceof EObject) {
- // allow to init the extension point and allow to get existing language for the elements
- final List<String> languages = DirectEditorsUtil.getLanguages(objectInstance);
-
- // if we are here, the default is not a Xtext editor
- for (String currentLanguage : languages) {
- IDirectEditorConfiguration directEditorConfiguration = DirectEditorsUtil.findEditorConfigurationWithPriority(currentLanguage, objectInstance);
- if (directEditorConfiguration instanceof DefaultXtextDirectEditorConfiguration) {
- DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) directEditorConfiguration;
- if (null != feature) {
- xtextConfiguration.preEditAction(((EObject) contextElement)
- .eGet((EStructuralFeature) feature));
+ if (null != directEditorConfiguration && !directEditorConfiguration.isEmpty()) {
+ try {
+ // Search the direct editor configuration by the class name filled in XWT file
+ final Class<?> directEditorConfigurationClass = Class.forName(directEditorConfiguration);
+ if (null != directEditorConfigurationClass) {
+ // Create an instance of the found class
+ final Object classInstance = directEditorConfigurationClass.newInstance();
+ // If the created instance is a direct xtext editor configuration, return the created direct editor configuration
+ if (classInstance instanceof DefaultXtextDirectEditorConfiguration) {
+ final DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) classInstance;
+
+ // Set the correct object to edit as pre edit action
+ if (null != modelProperty && getContextElement() instanceof EObject && modelProperty.getValueType() instanceof EStructuralFeature) {
+ xtextConfiguration.preEditAction(((EObject) getContextElement())
+ .eGet((EStructuralFeature) modelProperty.getValueType()));
} else {
- xtextConfiguration.preEditAction((EObject) contextElement);
+ xtextConfiguration.preEditAction((EObject) getValue());
}
+
+ // Return the created direct editor configuration
return xtextConfiguration;
}
}
+ } catch (final ClassNotFoundException e) {
+ Activator.log.error(e);
+ } catch (final InstantiationException e) {
+ Activator.log.error(e);
+ } catch (final IllegalAccessException e) {
+ Activator.log.error(e);
}
}
return null;
@@ -396,14 +394,14 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
}
/**
- * Sets the object instance class name.
+ * Sets the direct editor configuration class name.
*
- * @param objectInstance
- * The object instance class name.
+ * @param directEditorConfiguration
+ * The direct editor configuration class name.
*/
- public void setObjectInstance(final String objectInstance) {
- this.objectInstance = objectInstance;
- // React of the object instance modification (this will happened after the binding call)
+ public void setDirectEditorConfiguration(final String directEditorConfiguration) {
+ this.directEditorConfiguration = directEditorConfiguration;
+ // React of the direct editor configuration modification (this will happened after the binding call)
updateXtextAdapters(styledTextStringEditor.getText());
}
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/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 adb5cb44c0d..084dfd6a4e2 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/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
@@ -39,10 +39,10 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
protected UMLXtextReferenceValueEditor editor;
/**
- * The object instance attribute available in the XWT file.
+ * The direct editor configuration class name.
*/
- private String objectInstance;
-
+ private String directEditorConfiguration;
+
/**
* Constructor.
*
@@ -78,8 +78,8 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
protected void doBinding() {
IStaticContentProvider provider = input
.getContentProvider(propertyPath);
- if(null != getObjectInstance()){
- editor.setObjectInstance(getObjectInstance());
+ if (null != getDirectEditorConfiguration()) {
+ editor.setDirectEditorConfiguration(getDirectEditorConfiguration());
}
editor.setLabelProvider(input.getLabelProvider(propertyPath));
editor.setContentProvider(provider);
@@ -117,26 +117,27 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
public ReferenceValueFactory getFactory() {
return factory;
}
-
+
/**
- * Sets the object instance attribute from XWT file.
+ * Sets the direct editor configuration class name from XWT file.
*
- * @param objectInstance The object instance value.
+ * @param directEditorConfiguration
+ * The direct editor configuration class name value.
*/
- public void setObjectInstance(String objectInstance) {
- this.objectInstance = objectInstance;
- if(null != editor){
- editor.setObjectInstance(objectInstance);
+ public void setDirectEditorConfiguration(final String directEditorConfiguration) {
+ this.directEditorConfiguration = directEditorConfiguration;
+ if (null != editor) {
+ editor.setDirectEditorConfiguration(directEditorConfiguration);
}
}
/**
- * Gets the object instance attribute value.
+ * Gets the direct editor configuration class name value.
*
- * @return The object instance attribute value.
+ * @return The direct editor configuration class name value.
*/
- public String getObjectInstance() {
- return objectInstance;
+ public String getDirectEditorConfiguration() {
+ return directEditorConfiguration;
}
}

Back to the top