Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2013-10-07 13:44:15 +0000
committerVincent Lorenzo2013-10-07 13:44:15 +0000
commitc8baff8d7b94cdba1dc709fe775ed1787a56e73f (patch)
treeb3532363ead030d0a72b6ea51fcad6b1f031f9db /plugins
parent022f0d9b2da46708e8a480283ab3ee654d910f16 (diff)
downloadorg.eclipse.papyrus-c8baff8d7b94cdba1dc709fe775ed1787a56e73f.tar.gz
org.eclipse.papyrus-c8baff8d7b94cdba1dc709fe775ed1787a56e73f.tar.xz
org.eclipse.papyrus-c8baff8d7b94cdba1dc709fe775ed1787a56e73f.zip
417915: [Table 2] Papyrus Table must provides the API to open Xtext
Editor as CellEditor https://bugs.eclipse.org/bugs/show_bug.cgi?id=417915
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java49
1 files changed, 46 insertions, 3 deletions
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
index 87c23ef2b62..d068294aa8b 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
@@ -13,14 +13,18 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.xtext.integration.celleditor;
+import java.util.List;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
import org.eclipse.papyrus.infra.nattable.celleditor.AbstractPapyrusStyledTextCellEditor;
import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableproblem.StringResolutionProblem;
import org.eclipse.papyrus.infra.nattable.xtext.integration.util.XTextEditorResultWrapper;
import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
import org.eclipse.papyrus.uml.xtext.integration.XtextFakeResourceContext;
@@ -28,6 +32,7 @@ import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter;
import org.eclipse.papyrus.uml.xtext.integration.core.ContextElementAdapter.IContextElementProvider;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
/**
*
@@ -92,6 +97,30 @@ public abstract class AbstractNatTableXTextCellEditor extends AbstractPapyrusSty
/**
*
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.AbstractStyledTextCellEditor#activateCell(org.eclipse.swt.widgets.Composite,
+ * java.lang.Object)
+ *
+ * @param parent
+ * @param originalCanonicalValue
+ * @return
+ */
+ protected Control activateCell(final Composite parent, final Object originalCanonicalValue) {
+ //we display the full string which have a problem to display it in the Xtext Editor
+ Object value = originalCanonicalValue;
+ if(originalCanonicalValue instanceof List<?>) {
+ if(((List<?>)originalCanonicalValue).size() > 0) {
+ final Object firstValue = ((List<?>)originalCanonicalValue).get(0);
+ if(firstValue instanceof StringResolutionProblem) {
+ value = ((StringResolutionProblem)firstValue).getValueAsString();
+ }
+ }
+ }
+ return super.activateCell(parent, value);
+ }
+
+
+ /**
+ *
* @see org.eclipse.papyrus.infra.nattable.celleditor.AbstractStyledTextCellEditor#createStyledText(org.eclipse.swt.widgets.Composite, int)
*
* @param parent
@@ -114,7 +143,6 @@ public abstract class AbstractNatTableXTextCellEditor extends AbstractPapyrusSty
}
};
context.getFakeResource().eAdapters().add(new ContextElementAdapter(provider));
-
jfaceCellEditor = xTextConfiguration.createCellEditor(parent, editedObject);
return (StyledText)jfaceCellEditor.getControl();
}
@@ -145,10 +173,25 @@ public abstract class AbstractNatTableXTextCellEditor extends AbstractPapyrusSty
@Override
public Object getEditorValue() {
final IParser parser = ((ICustomDirectEditorConfiguration)xTextConfiguration).createParser(getEditedEObject());
- final String typedString = ((StyledText)jfaceCellEditor.getControl()).getText();
- final ICommand parseCommand = parser.getParseCommand(null, typedString, 0);
+ final StyledText styledText = ((StyledText)jfaceCellEditor.getControl());
+ ICommand parseCommand = null;
+ String typedString = "";
+ if(styledText != null) {
+ typedString = styledText.getText();
+ final IParserEditStatus result = parser.isValidEditString(null, typedString);
+ System.out.println(result);
+ if(result.isOK()) {
+ parseCommand = parser.getParseCommand(null, typedString, 0);
+ }
+ }
return new XTextEditorResultWrapper(typedString, parseCommand);
}
+ @Override
+ public void close() {
+ //TODO requred?
+// jfaceCellEditor.deactivate();
+// jfaceCellEditor.dispose();
+ }
}

Back to the top