Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.java26
5 files changed, 165 insertions, 50 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 8e0f70479b0..1eaf657361b 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
@@ -16,7 +16,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.105.0",
org.eclipse.papyrus.uml.properties;bundle-version="1.1.0",
org.eclipse.papyrus.views.properties;bundle-version="1.1.0",
org.eclipse.papyrus.infra.widgets;bundle-version="1.1.0",
- org.eclipse.core.databinding;bundle-version="1.4.100"
+ org.eclipse.core.databinding;bundle-version="1.4.100",
+ org.eclipse.papyrus.uml.textedit.valuespecification.xtext.ui;bundle-version="1.1.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.1.0.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..778cc0be98d 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,9 +39,9 @@ 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);
@@ -119,24 +119,24 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
}
/**
- * 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;
+ public void setDirectEditorConfiguration(final String directEditorConfiguration) {
+ this.directEditorConfiguration = directEditorConfiguration;
if(null != editor){
- editor.setObjectInstance(objectInstance);
+ 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