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/infra/gmfdiag/org.eclipse.papyrus.extensionpoints.editors/src/org/eclipse/papyrus/extensionpoints/editors/utils/DirectEditorsUtil.java47
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.valuespecification/src/org/eclipse/papyrus/uml/nattable/xtext/valuespecification/celleditor/ValueSpecificationCellEditor.java44
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/UMLXtextReferenceValueEditor.java98
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties.xtext/src/org/eclipse/papyrus/uml/properties/xtext/widget/property/UMLStyledTextReferenceDialog.java29
5 files changed, 140 insertions, 80 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 7560a5894cc..f757324cadb 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}"></xtexteditor:UMLStyledTextReferenceDialog>
+ property="UML:Property:defaultValue" input="{Binding}" objectInstance="org.eclipse.uml2.uml.ValueSpecification"></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/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 dd020633f84..e024103999f 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
@@ -244,5 +244,52 @@ public class DirectEditorsUtil {
}
return elementConfigurations;
}
+
+ /**
+ * 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 = UNKNOWN_PRIORITY;
+ IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations();
+ for (IDirectEditorExtensionPoint 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() : UNKNOWN_PRIORITY;
+ if (result == null || (directEditorExtensionPointPriority < currentPrority)) {
+ result = directEditorExtensionPoint.getDirectEditorConfiguration();
+ currentPrority = directEditorExtensionPointPriority;
+ }
+ }
+ }
+ return result != null ? result : new DefaultDirectEditorConfiguration();
+ }
+
+ /**
+ * returns the list of languages that are available from extension points
+ *
+ * @return the list of languages that have an extended editor
+ */
+ public static List<String> getLanguages(String objectToEdit) {
+ List<String> languages = new ArrayList<String>();
+ IDirectEditorExtensionPoint[] extensionPoints = DirectEditorExtensionPoint.getDirectEditorConfigurations();
+ for (IDirectEditorExtensionPoint 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 a8db522a61e..d683d442ffb 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
@@ -12,14 +12,13 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.nattable.xtext.valuespecification.celleditor;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
-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.nattable.manager.table.ITableAxisElementProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
@@ -82,36 +81,33 @@ public class ValueSpecificationCellEditor extends AbstractXtextCellEditor {
/**
* This allow to get the configuration for edited object.
*
- * @param editedEObject
- * The edited object.
+ * @param row
+ * The row element.
+ * @param column
+ * The column element.
* @return The {@link DefaultXtextDirectEditorConfiguration} corresponding
* the the edited object.
*/
protected DefaultXtextDirectEditorConfiguration getConfigurationFromEditedEObject(
final Object row, final Object column) {
if (row instanceof EObject && column instanceof EStructuralFeature || row instanceof EStructuralFeature && column instanceof EObject) {
-
final EStructuralFeature feature = (EStructuralFeature) (column instanceof EStructuralFeature ? column : row);
- final EObject eObject = (EObject) (row instanceof EObject ? row : column);
-
- IPreferenceStore store = Activator.getDefault()
- .getPreferenceStore();
- String semanticClassName = feature.getEType()
- .getInstanceClassName();
-
- String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
- + semanticClassName;
- String languagePreferred = store.getString(key);
+ final EObject contextElement = (EObject) (row instanceof EObject ? row : column);
+ final String semanticClassName = feature.getEType().getInstanceClassName();
- if (languagePreferred != null && !languagePreferred.equals("")) { //$NON-NLS-1$
- IDirectEditorConfiguration configuration = DirectEditorsUtil
- .findEditorConfigurationWithPriority(languagePreferred,
- semanticClassName);
- if (configuration instanceof DefaultXtextDirectEditorConfiguration) {
+ 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(semanticClassName);
- DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) configuration;
- xtextConfiguration.preEditAction(eObject.eGet(feature));
- return xtextConfiguration;
+ // if we are here, the default is not a Xtext editor
+ for (String currentLanguage : languages) {
+ IDirectEditorConfiguration directEditorConfiguration = DirectEditorsUtil.findEditorConfigurationWithPriority(currentLanguage, semanticClassName);
+ if (directEditorConfiguration instanceof DefaultXtextDirectEditorConfiguration) {
+ DefaultXtextDirectEditorConfiguration xtextConfiguration = (DefaultXtextDirectEditorConfiguration) directEditorConfiguration;
+ xtextConfiguration.preEditAction(((EObject) contextElement)
+ .eGet((EStructuralFeature) feature));
+ return xtextConfiguration;
+ }
}
}
}
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 74677af4d73..60cfb328010 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,6 +12,8 @@
*****************************************************************************/
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;
@@ -20,12 +22,9 @@ 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;
@@ -72,6 +71,11 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
private boolean isFocus = false;
/**
+ * The object instance class name edited.
+ */
+ private String objectInstance;
+
+ /**
* Constructor.
*
* @param parent
@@ -130,7 +134,8 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
} else {
command = parser.getParseCommand(new EObjectAdapter(
(EObject) getValue()), styledTextStringEditor.getText()
- .getText(), 0);
+ .getText(),
+ 0);
}
TransactionalEditingDomain domain = TransactionUtil
@@ -236,64 +241,37 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
* @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 != objectInstance && !objectInstance.isEmpty()) {
+ Object feature = null;
+ Object contextElement = null;
+ if (null != modelProperty) {
+ feature = modelProperty.getValueType();
+ contextElement = getContextElement();
+ } else {
+ contextElement = getValue();
}
- }
- 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);
+ 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));
+ } else {
+ xtextConfiguration.preEditAction((EObject) contextElement);
+ }
return xtextConfiguration;
}
}
}
}
- return result;
+ return null;
}
/**
@@ -356,4 +334,14 @@ public class UMLXtextReferenceValueEditor extends StyledTextReferenceDialog
final Object value = getValue();
return value instanceof EObject ? (EObject) value : null;
}
+
+ /**
+ * Sets the object instance class name.
+ *
+ * @param objectInstance
+ * The object instance class name.
+ */
+ public void setObjectInstance(String objectInstance) {
+ this.objectInstance = objectInstance;
+ }
}
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 b3dc3dda2fd..adb5cb44c0d 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,6 +39,11 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
protected UMLXtextReferenceValueEditor editor;
/**
+ * The object instance attribute available in the XWT file.
+ */
+ private String objectInstance;
+
+ /**
* Constructor.
*
* @param parent
@@ -73,6 +78,9 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
protected void doBinding() {
IStaticContentProvider provider = input
.getContentProvider(propertyPath);
+ if(null != getObjectInstance()){
+ editor.setObjectInstance(getObjectInstance());
+ }
editor.setLabelProvider(input.getLabelProvider(propertyPath));
editor.setContentProvider(provider);
editor.setDirectCreation(input.getDirectCreation(propertyPath));
@@ -109,5 +117,26 @@ public class UMLStyledTextReferenceDialog extends AbstractPropertyEditor {
public ReferenceValueFactory getFactory() {
return factory;
}
+
+ /**
+ * Sets the object instance attribute from XWT file.
+ *
+ * @param objectInstance The object instance value.
+ */
+ public void setObjectInstance(String objectInstance) {
+ this.objectInstance = objectInstance;
+ if(null != editor){
+ editor.setObjectInstance(objectInstance);
+ }
+ }
+
+ /**
+ * Gets the object instance attribute value.
+ *
+ * @return The object instance attribute value.
+ */
+ public String getObjectInstance() {
+ return objectInstance;
+ }
}

Back to the top