Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud Cuccuru2013-09-17 08:50:30 +0000
committerArnaud Cuccuru2013-09-17 09:26:54 +0000
commit4181e7c5d2222cee821e00f45970c4570a94bb4b (patch)
tree4a52abdc48bf60dd9270638c09e0594789b29467 /plugins/views
parent48de9cc37e965d8de10ecec9e4fad770eed19a64 (diff)
downloadorg.eclipse.papyrus-4181e7c5d2222cee821e00f45970c4570a94bb4b.tar.gz
org.eclipse.papyrus-4181e7c5d2222cee821e00f45970c4570a94bb4b.tar.xz
org.eclipse.papyrus-4181e7c5d2222cee821e00f45970c4570a94bb4b.zip
Revert "Revert "Bug 315231 - Improvement of xtext integration.""
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java
index e4f776caabe..340a28f7f20 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/xtext/DirectEditorEditingSupport.java
@@ -33,7 +33,8 @@ public class DirectEditorEditingSupport extends EditingSupport {
@Override
protected CellEditor getCellEditor(final Object element) {
ICustomDirectEditorConfiguration configuration = getConfiguration(element);
- EObject semanticObject = (EObject) ((IAdaptable) element).getAdapter(EObject.class);
+ EObject semanticObject = (EObject) ((IAdaptable) element)
+ .getAdapter(EObject.class);
Composite parent = (Composite) getViewer().getControl();
return configuration.createCellEditor(parent, semanticObject);
}
@@ -46,32 +47,43 @@ public class DirectEditorEditingSupport extends EditingSupport {
@Override
protected Object getValue(Object element) {
ICustomDirectEditorConfiguration configuration = getConfiguration(element);
- Object semanticObject = ((IAdaptable) element).getAdapter(EObject.class);
- return configuration.getTextToEdit(semanticObject);
+ Object semanticObject = ((IAdaptable) element)
+ .getAdapter(EObject.class);
+ return configuration.createParser((EObject) semanticObject)
+ .getEditString(new EObjectAdapter((EObject) semanticObject), 0);
}
@Override
protected void setValue(Object element, Object value) {
ICustomDirectEditorConfiguration configuration = getConfiguration(element);
- EObject semanticObject = (EObject) ((IAdaptable) element).getAdapter(EObject.class);
+ EObject semanticObject = (EObject) ((IAdaptable) element)
+ .getAdapter(EObject.class);
IParser parser = configuration.createParser(semanticObject);
- ICommand command = parser.getParseCommand(new EObjectAdapter(semanticObject), (String) value, 0);
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(semanticObject);
- editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(command));
+ ICommand command = parser.getParseCommand(new EObjectAdapter(
+ semanticObject), (String) value, 0);
+ TransactionalEditingDomain editingDomain = TransactionUtil
+ .getEditingDomain(semanticObject);
+ editingDomain.getCommandStack().execute(
+ new GMFtoEMFCommandWrapper(command));
}
protected ICustomDirectEditorConfiguration getConfiguration(Object element) {
if (element instanceof IAdaptable) {
- EObject semanticObject = (EObject) ((IAdaptable) element).getAdapter(EObject.class);
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- String semanticClassName = semanticObject.eClass().getInstanceClassName();
- String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT + semanticClassName;
+ EObject semanticObject = (EObject) ((IAdaptable) element)
+ .getAdapter(EObject.class);
+ IPreferenceStore store = Activator.getDefault()
+ .getPreferenceStore();
+ String semanticClassName = semanticObject.eClass()
+ .getInstanceClassName();
+ String key = IDirectEditorsIds.EDITOR_FOR_ELEMENT
+ + semanticClassName;
String languagePreferred = store.getString(key);
if (languagePreferred != null && !languagePreferred.equals("")) {
- IDirectEditorConfiguration configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred,
- semanticClassName);
+ IDirectEditorConfiguration configuration = DirectEditorsUtil
+ .findEditorConfiguration(languagePreferred,
+ semanticClassName);
if (configuration instanceof ICustomDirectEditorConfiguration) {
return (ICustomDirectEditorConfiguration) configuration;
}

Back to the top