Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractPapyrusStyledTextCellEditor.java93
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractStyledTextCellEditor.java469
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java22
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java9
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java112
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CompoundFilteredRestrictedContentProvider.java6
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.classpath7
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.project28
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF24
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/OSGI-INF/l10n/bundle.properties3
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/about.html28
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/build.properties8
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/plugin.pdoc4
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java53
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java154
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java73
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java12
18 files changed, 1094 insertions, 18 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractPapyrusStyledTextCellEditor.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractPapyrusStyledTextCellEditor.java
new file mode 100644
index 00000000000..4f0a3d6a0a9
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractPapyrusStyledTextCellEditor.java
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.nattable.celleditor.AbstractStyledTextCellEditor;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ * Abstract Class for StyledText cell editor.
+ * This class is used for XText Cell Editor
+ *
+ * @author vl222926
+ *
+ */
+public abstract class AbstractPapyrusStyledTextCellEditor extends AbstractStyledTextCellEditor {
+
+ /**
+ * the table
+ */
+ protected final Table table;
+
+ /**
+ * the axis element on which this cell editor is declared
+ */
+ protected final Object axisElement;
+
+ /**
+ * the table element provider
+ */
+ protected final ITableAxisElementProvider elementProvider;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * @param axisElement
+ * @param elementProvider
+ * @param commitOnUpDown
+ * @param moveSelectionOnEnter
+ */
+ public AbstractPapyrusStyledTextCellEditor(final Table table, final Object axisElement, final ITableAxisElementProvider elementProvider, boolean commitOnUpDown, boolean moveSelectionOnEnter) {
+ super(commitOnUpDown, moveSelectionOnEnter);
+ this.table = table;
+ this.axisElement = axisElement;
+ this.elementProvider = elementProvider;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * @param axisElement
+ * @param elementProvider
+ */
+ public AbstractPapyrusStyledTextCellEditor(final Table table, final Object axisElement, final ITableAxisElementProvider elementProvider) {
+ this(table, axisElement, elementProvider, false);
+ }
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * @param axisElement
+ * @param elementProvider
+ * @param commitOnUpDown
+ */
+ public AbstractPapyrusStyledTextCellEditor(final Table table, final Object axisElement, final ITableAxisElementProvider elementProvider, boolean commitOnUpDown) {
+ this(table, axisElement, elementProvider, commitOnUpDown, false);
+ }
+
+ /**
+ *
+ * @return the edited object
+ */
+ protected abstract EObject getEditedEObject();
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractStyledTextCellEditor.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractStyledTextCellEditor.java
new file mode 100644
index 00000000000..0f875521e60
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/AbstractStyledTextCellEditor.java
@@ -0,0 +1,469 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.celleditor;
+
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.config.RenderErrorHandling;
+import org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor;
+import org.eclipse.nebula.widgets.nattable.edit.editor.ControlDecorationProvider;
+import org.eclipse.nebula.widgets.nattable.edit.editor.EditorSelectionEnum;
+import org.eclipse.nebula.widgets.nattable.edit.editor.IEditErrorHandler;
+import org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
+import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
+import org.eclipse.nebula.widgets.nattable.style.IStyle;
+import org.eclipse.nebula.widgets.nattable.widget.EditModeEnum;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * duplicated code from {@link TextCellEditor}. Here we replace Text by StyledText
+ * This code is used with XText Cell Editor
+ *
+ * @author vl222926
+ *
+ */
+public abstract class AbstractStyledTextCellEditor extends AbstractCellEditor {
+
+ /**
+ * The StyledText control which is the editor wrapped by this TextCellEditor.
+ */
+ private StyledText text = null;
+
+ /**
+ * Flag to configure if the wrapped text editor control is editable or not.
+ */
+ private boolean editable = true;
+
+ /**
+ * Flag to configure whether the editor should commit and move the selection
+ * in the corresponding way if the up or down key is pressed.
+ */
+ private final boolean commitOnUpDown;
+
+ /**
+ * Flag to configure whether the selection should move after a value was
+ * committed after pressing enter.
+ */
+ private final boolean moveSelectionOnEnter;
+
+ /**
+ * The selection mode that should be used on activating the wrapped text control.
+ * By default the behaviour is to set the selection at the end of the containing text
+ * if the text editor control is activated with an initial value. If it is activated
+ * only specifying the original canonical value, the default behaviour is to select
+ * the whole text contained in the text editor control.
+ *
+ * <p>
+ * You can override this default behaviour by setting an {@link EditorSelectionEnum} explicitly. With this you are able e.g. to set the selection
+ * at the beginning of the contained text, so writing in the text control will result in prefixing.
+ *
+ * <p>
+ * Note that on overriding the behaviour, you override both activation cases.
+ */
+ private EditorSelectionEnum selectionMode;
+
+ /**
+ * The {@link ControlDecorationProvider} responsible for adding a {@link ControlDecoration} to the wrapped editor control. Can be configured via
+ * convenience methods of this TextCellEditor.
+ */
+ protected final ControlDecorationProvider decorationProvider = new ControlDecorationProvider();
+
+ /**
+ * The {@link IEditErrorHandler} that is used for showing conversion errors on typing into
+ * this editor. By default this is the {@link RenderErrorHandling} which will render the
+ * content in the editor red to indicate a conversion error.
+ */
+ private IEditErrorHandler inputConversionErrorHandler = new RenderErrorHandling(decorationProvider);
+
+ /**
+ * The {@link IEditErrorHandler} that is used for showing validation errors on typing into
+ * this editor. By default this is the {@link RenderErrorHandling} which will render the
+ * content in the editor red to indicate a validation error.
+ */
+ private IEditErrorHandler inputValidationErrorHandler = new RenderErrorHandling(decorationProvider);
+
+ /**
+ * Flag to determine whether this editor should try to commit and close on pressing the enter key.
+ * The default is of course <code>true</code>, but for a multi line text editor, the enter key
+ * should be treated as inserting a new line instead of committing.
+ */
+ protected boolean commitOnEnter = true;
+
+ /**
+ * Creates the default TextCellEditor that does not commit on pressing the up/down arrow keys
+ * and will not move the selection on committing a value by pressing enter.
+ */
+ public AbstractStyledTextCellEditor() {
+ this(false);
+ }
+
+ /**
+ * Creates a TextCellEditor that will not move the selection on committing a value by pressing enter.
+ *
+ * @param commitOnUpDown
+ * Flag to configure whether the editor should commit
+ * and move the selection in the corresponding way if the up or down key is pressed.
+ */
+ public AbstractStyledTextCellEditor(boolean commitOnUpDown) {
+ this(commitOnUpDown, false);
+ }
+
+ /**
+ * Creates a TextCellEditor.
+ *
+ * @param commitOnUpDown
+ * Flag to configure whether the editor should commit
+ * and move the selection in the corresponding way if the up or down key is pressed.
+ * @param moveSelectionOnEnter
+ * Flag to configure whether the selection should move after a value was
+ * committed after pressing enter.
+ */
+ public AbstractStyledTextCellEditor(boolean commitOnUpDown, boolean moveSelectionOnEnter) {
+ this.commitOnUpDown = commitOnUpDown;
+ this.moveSelectionOnEnter = moveSelectionOnEnter;
+ }
+
+ @Override
+ protected Control activateCell(final Composite parent, Object originalCanonicalValue) {
+ this.text = createEditorControl(parent);
+
+ // If the originalCanonicalValue is a Character it is possible the editor is activated by keypress
+ if(originalCanonicalValue instanceof Character) {
+ this.text.setText(originalCanonicalValue.toString());
+ selectText(this.selectionMode != null ? this.selectionMode : EditorSelectionEnum.END);
+ }
+ //if there is no initial value, handle the original canonical value to transfer it to the text control
+ else {
+ setCanonicalValue(originalCanonicalValue);
+ selectText(this.selectionMode != null ? this.selectionMode : EditorSelectionEnum.ALL);
+ }
+
+ if(!isEditable()) {
+ this.text.setEditable(false);
+ }
+
+ //show an error decoration if this is enabled
+ this.decorationProvider.createErrorDecorationIfRequired(this.text);
+
+ //if the input error handlers are of type RenderErrorHandler (default) than
+ //we also check for a possible configured error styling in the configuration
+ //Note: this is currently only implemented in here, as the TextCellEditor is
+ // the only editor that supports just in time conversion/validation
+ if(this.inputConversionErrorHandler instanceof RenderErrorHandling) {
+ IStyle conversionErrorStyle = this.configRegistry.getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, DisplayMode.EDIT, this.labelStack.getLabels());
+
+ ((RenderErrorHandling)this.inputConversionErrorHandler).setErrorStyle(conversionErrorStyle);
+ }
+
+ if(this.inputValidationErrorHandler instanceof RenderErrorHandling) {
+ IStyle validationErrorStyle = this.configRegistry.getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, DisplayMode.EDIT, this.labelStack.getLabels());
+
+ ((RenderErrorHandling)this.inputValidationErrorHandler).setErrorStyle(validationErrorStyle);
+ }
+
+ this.text.forceFocus();
+
+ return this.text;
+ }
+
+ @Override
+ public Object getEditorValue() {
+ return this.text.getText();
+ }
+
+ @Override
+ public void setEditorValue(Object value) {
+ this.text.setText(value != null && value.toString().length() > 0 ? value.toString() : ""); //$NON-NLS-1$
+ }
+
+ @Override
+ public StyledText getEditorControl() {
+ return this.text;
+ }
+
+ @Override
+ public StyledText createEditorControl(Composite parent) {
+ int style = HorizontalAlignmentEnum.getSWTStyle(this.cellStyle);
+ if(this.editMode == EditModeEnum.DIALOG) {
+ style = style | SWT.BORDER;
+ }
+ return createEditorControl(parent, style);
+ }
+
+ /**
+ *
+ * @param parent
+ * the composite parent
+ * @param style
+ * the style of the editor
+ * @return
+ * the created StyledText
+ */
+ protected StyledText createStyledText(final Composite parent, final int style) {
+ return new StyledText(parent, style);
+ }
+
+ /**
+ * Creates the editor control that is wrapped by this ICellEditor.
+ * Will use the style configurations in ConfigRegistry for styling the control.
+ *
+ * @param parent
+ * The Composite that will be the parent of the new editor control.
+ * Can not be <code>null</code>
+ * @param style
+ * The SWT style of the text control to create.
+ * @return The created editor control that is wrapped by this ICellEditor.
+ */
+ protected StyledText createEditorControl(final Composite parent, int style) {
+ //create the Text control based on the specified style
+ final StyledText textControl = createStyledText(parent, style);
+
+ //set style information configured in the associated cell style
+ textControl.setBackground(this.cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
+ textControl.setForeground(this.cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
+ textControl.setFont(this.cellStyle.getAttributeValue(CellStyleAttributes.FONT));
+
+ textControl.setCursor(new Cursor(Display.getDefault(), SWT.CURSOR_IBEAM));
+
+ //add a key listener that will commit or close the editor for special key strokes
+ //and executes conversion/validation on input to the editor
+ textControl.addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyPressed(KeyEvent event) {
+ if(commitOnEnter && (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR)) {
+
+ MoveDirectionEnum move = MoveDirectionEnum.NONE;
+ if(moveSelectionOnEnter && editMode == EditModeEnum.INLINE) {
+ if(event.stateMask == 0) {
+ move = MoveDirectionEnum.DOWN;
+ } else if(event.stateMask == SWT.SHIFT) {
+ move = MoveDirectionEnum.UP;
+ }
+ }
+
+ commit(move);
+
+ if(editMode == EditModeEnum.DIALOG) {
+ parent.forceFocus();
+ }
+ } else if(event.keyCode == SWT.ESC && event.stateMask == 0) {
+ close();
+ } else if(commitOnUpDown && editMode == EditModeEnum.INLINE) {
+ if(event.keyCode == SWT.ARROW_UP) {
+ commit(MoveDirectionEnum.UP);
+ } else if(event.keyCode == SWT.ARROW_DOWN) {
+ commit(MoveDirectionEnum.DOWN);
+ }
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ try {
+ //always do the conversion
+ Object canonicalValue = getCanonicalValue(inputConversionErrorHandler);
+ //and always do the validation
+ //even if for commiting the validation should be skipped, on editing
+ //a validation failure should be made visible
+ //otherwise there would be no need for validation!
+ validateCanonicalValue(canonicalValue, inputValidationErrorHandler);
+ } catch (Exception ex) {
+ //do nothing as exceptions caused by conversion or validation are handled already
+ //we just need this catch block for stopping the process if conversion failed with
+ //an exception
+ }
+ }
+ });
+
+ return textControl;
+ }
+
+ @Override
+ public void close() {
+ super.close();
+
+ this.decorationProvider.dispose();
+ }
+
+ /**
+ * @return <code>true</code> if the wrapped Text control is editable, <code>false</code> if not.
+ */
+ public boolean isEditable() {
+ return editable;
+ }
+
+ /**
+ *
+ * @param editable
+ * <code>true</code> if the wrapped Text control should be editable, <code>false</code> if not.
+ */
+ public void setEditable(boolean editable) {
+ this.editable = editable;
+ }
+
+ /**
+ * Returns the current configured selection mode that is used on activating the wrapped
+ * text editor control. By default this is <code>null</code> which causes the following
+ * default behaviour. If the text editor control is activated with an initial value then
+ * the selection is set at the end of the containing text. If it is activated
+ * only specifying the original canonical value, the default behaviour is to select
+ * the whole text contained in the text editor control.
+ *
+ * @return The current configured selection mode, <code>null</code> for default behaviour.
+ */
+ public final EditorSelectionEnum getSelectionMode() {
+ return selectionMode;
+ }
+
+ /**
+ * Set the selection mode that should be used on the content of the wrapped text editor control
+ * when it gets activated. By setting a value explicitly you configure the selection mode for
+ * both cases, activating the wrapped text editor control with and without an initial value.
+ * Setting this value to <code>null</code> will reactivate the default behaviour like described
+ * here {@link TextCellEditor#getSelectionMode()}.
+ *
+ * @param selectionMode
+ * The selection mode that should be used on the content of the
+ * wrapped text editor control when it gets activated.
+ */
+ public final void setSelectionMode(EditorSelectionEnum selectionMode) {
+ this.selectionMode = selectionMode;
+ }
+
+ /**
+ * Will set the selection to the wrapped text control regarding the configured {@link EditorSelectionEnum}.
+ *
+ * <p>
+ * This method is called
+ *
+ * @see Text#setSelection(int, int)
+ */
+ private void selectText(EditorSelectionEnum selectionMode) {
+ int textLength = this.text.getText().length();
+ if(textLength > 0) {
+ if(selectionMode == EditorSelectionEnum.ALL) {
+ this.text.setSelection(0, textLength);
+ } else if(selectionMode == EditorSelectionEnum.END) {
+ this.text.setSelection(textLength, textLength);
+ } else if(selectionMode == EditorSelectionEnum.START) {
+ this.text.setSelection(0);
+ }
+ }
+ }
+
+ /**
+ * @return The {@link ControlDecorationProvider} responsible for adding a {@link ControlDecoration} to the wrapped editor control.
+ */
+ public ControlDecorationProvider getDecorationProvider() {
+ return this.decorationProvider;
+ }
+
+ /**
+ * Enables/disables the error decoration for the wrapped text control.
+ *
+ * @param enabled
+ * <code>true</code> if an error decoration should be added to
+ * the wrapped text control, <code>false</code> if not.
+ */
+ public void setErrorDecorationEnabled(boolean enabled) {
+ this.decorationProvider.setErrorDecorationEnabled(enabled);
+ }
+
+ /**
+ * Set the error description text that will be shown in the decoration hover.
+ *
+ * @param errorText
+ * The text to be shown as a description for the decoration, or <code>null</code> if there should be no description.
+ *
+ * @see ControlDecoration#setDescriptionText(String)
+ */
+ public void setErrorDecorationText(String errorText) {
+ this.decorationProvider.setErrorDecorationText(errorText);
+ }
+
+ /**
+ * Force the error decoration hover to show immediately.
+ *
+ * @param customErrorText
+ * The text to show in the hover popup.
+ *
+ * @see ControlDecoration#show()
+ * @see ControlDecoration#showHoverText(String)
+ */
+ public void showErrorDecorationHover(String customErrorText) {
+ this.decorationProvider.showErrorDecorationHover(customErrorText);
+ }
+
+ /**
+ * Set the position of the control decoration relative to the control.
+ * It should include style bits describing both the vertical and horizontal orientation.
+ *
+ * @param decorationPositionOverride
+ * bit-wise or of position constants (<code>SWT.TOP</code>, <code>SWT.BOTTOM</code>, <code>SWT.LEFT</code>, <code>SWT.RIGHT</code>, and
+ * <code>SWT.CENTER</code>).
+ *
+ * @see ControlDecoration#ControlDecoration(Control, int)
+ */
+ public void setDecorationPositionOverride(int decorationPositionOverride) {
+ this.decorationProvider.setDecorationPositionOverride(decorationPositionOverride);
+ }
+
+ /**
+ * @return The {@link IEditErrorHandler} that is used for showing conversion errors on typing into
+ * this editor. By default this is the {@link RenderErrorHandling} which will render the
+ * content in the editor red to indicate a conversion error.
+ */
+ public IEditErrorHandler getInputConversionErrorHandler() {
+ return this.inputConversionErrorHandler;
+ }
+
+ /**
+ * @param inputConversionErrorHandler
+ * The {@link IEditErrorHandler} that is should be used for showing
+ * conversion errors on typing into this editor.
+ */
+ public void setInputConversionErrorHandler(IEditErrorHandler inputConversionErrorHandler) {
+ this.inputConversionErrorHandler = inputConversionErrorHandler;
+ }
+
+ /**
+ * @return The {@link IEditErrorHandler} that is used for showing validation errors on typing into
+ * this editor. By default this is the {@link RenderErrorHandling} which will render the
+ * content in the editor red to indicate a validation error.
+ */
+ public IEditErrorHandler getInputValidationErrorHandler() {
+ return this.inputValidationErrorHandler;
+ }
+
+ /**
+ * @param inputValidationErrorHandler
+ * The {@link IEditErrorHandler} that is should used for showing
+ * validation errors on typing into this editor.
+ */
+ public void setInputValidationErrorHandler(IEditErrorHandler inputValidationErrorHandler) {
+ this.inputValidationErrorHandler = inputValidationErrorHandler;
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
index 2a9db3d3784..e03aa979278 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
@@ -15,13 +15,12 @@ package org.eclipse.papyrus.infra.nattable.handler;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
@@ -227,14 +226,17 @@ public abstract class AbstractTableHandler extends AbstractHandler {
if(evaluationContext instanceof IEvaluationContext) {
Object selection = HandlerUtil.getVariable(evaluationContext, "selection"); //$NON-NLS-1$
- if(selection instanceof IStructuredSelection) {
- Iterator<?> iter = ((IStructuredSelection)selection).iterator();
- while(iter.hasNext() && wrapper == null) {
- Object current = iter.next();
- if(current instanceof TableSelectionWrapper) {
- wrapper = (TableSelectionWrapper)current;
- }
- }
+ // if(selection instanceof IStructuredSelection) {
+ // Iterator<?> iter = ((IStructuredSelection)selection).iterator();
+ // while(iter.hasNext() && wrapper == null) {
+ // Object current = iter.next();
+ // if(current instanceof TableSelectionWrapper) {
+ // wrapper = (TableSelectionWrapper)current;
+ // }
+ // }
+ // }
+ if(selection instanceof IAdaptable) {
+ wrapper = (TableSelectionWrapper)((IAdaptable)selection).getAdapter(TableSelectionWrapper.class);
}
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
index ed28d362b40..87f00f096ff 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
@@ -86,12 +86,12 @@ public class TableSelectionProvider implements ISelectionProvider, IDisposable {
protected/* synchronized */void calculateAndStoreNewSelection(final ILayerEvent event) {
//the list of the selected elements
final List<Object> selection = new ArrayList<Object>();
-
+ final ISelection newSelection;
if(event instanceof ISelectionEvent) {
//add the cell selection
final Collection<PositionCoordinate> selectedCells = Arrays.asList(this.selectionLayer.getSelectedCellPositions());
final TableSelectionWrapper wrapper = new TableSelectionWrapper(selectedCells);
- selection.add(0, wrapper);
+ // selection.add(0, wrapper);
//we returns the contents of the last selected cell
//we could returns the contents of all selected cells if its required
@@ -117,8 +117,11 @@ public class TableSelectionProvider implements ISelectionProvider, IDisposable {
}
}
}
+ newSelection = new TableStructuredSelection(selection, wrapper);
+ } else {
+ newSelection = new StructuredSelection();
}
- setSelection(new StructuredSelection(selection));
+ setSelection(newSelection);
}
public void dispose() {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java
new file mode 100644
index 00000000000..7645aae87bf
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
+
+/**
+ * The StructuredSelection filled by the tables. It able to embed more precision about the selected elements in the table.
+ *
+ * @author vl222926
+ *
+ */
+public class TableStructuredSelection extends StructuredSelection implements IAdaptable {
+
+ /**
+ * the wrapper for the table selection
+ */
+ private final TableSelectionWrapper wrapper;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param wrapper
+ */
+ public TableStructuredSelection(TableSelectionWrapper wrapper) {
+ super();
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param elements
+ * @param comparer
+ * @param wrapper
+ */
+ public TableStructuredSelection(List<?> elements, IElementComparer comparer, TableSelectionWrapper wrapper) {
+ super(elements, comparer);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param elements
+ * @param wrapper
+ */
+ public TableStructuredSelection(List<?> elements, TableSelectionWrapper wrapper) {
+ super(elements);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param element
+ * @param wrapper
+ */
+ public TableStructuredSelection(Object element, TableSelectionWrapper wrapper) {
+ super(element);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param elements
+ * @param wrapper
+ */
+ public TableStructuredSelection(Object[] elements, TableSelectionWrapper wrapper) {
+ super(elements);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ *
+ * @param adapter
+ * @return
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ if(adapter == TableSelectionWrapper.class) {
+ return this.wrapper;
+ }
+ return null;
+ }
+
+
+}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CompoundFilteredRestrictedContentProvider.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CompoundFilteredRestrictedContentProvider.java
index 63b60f34532..2c7cb7e27c8 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CompoundFilteredRestrictedContentProvider.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/CompoundFilteredRestrictedContentProvider.java
@@ -13,6 +13,8 @@ package org.eclipse.papyrus.infra.widgets.providers;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
/**
@@ -35,7 +37,7 @@ public class CompoundFilteredRestrictedContentProvider extends AbstractFilteredC
public Object[] getElements(Object inputElement) {
- List<Object> asList = new ArrayList<Object>();
+ Collection<Object> asList = new HashSet<Object>();
for(IRestrictedContentProvider encapsulatedContentProvider : encapsulatedContentProviders) {
Object[] directElements = encapsulatedContentProvider.getElements(inputElement);
@@ -46,7 +48,7 @@ public class CompoundFilteredRestrictedContentProvider extends AbstractFilteredC
public Object[] getChildren(Object parentElement) {
- List<Object> asList = new ArrayList<Object>();
+ Collection<Object> asList = new HashSet<Object>();
for(IRestrictedContentProvider encapsulatedContentProvider : encapsulatedContentProviders) {
Object[] directElements = encapsulatedContentProvider.getChildren(parentElement);
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.classpath b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.classpath
new file mode 100644
index 00000000000..8a8f1668cdc
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.project b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.project
new file mode 100644
index 00000000000..77452aaf98e
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.uml.nattable.xtext.integration</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.settings/org.eclipse.jdt.core.prefs b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..f287d53cf45
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a7de579937f
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.papyrus.uml.nattable.xtext.integration
+Bundle-Version: 0.10.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.infra.nattable.xtext.integration.Activator
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.nattable.common;bundle-version="0.10.1",
+ org.eclipse.emf.ecore,
+ org.eclipse.papyrus.infra.nattable;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="0.10.1",
+ org.eclipse.papyrus.uml.xtext.integration.ui;bundle-version="0.10.1",
+ org.eclipse.emf.mwe.core,
+ com.google.inject,
+ org.eclipse.xtext;bundle-version="2.4.2",
+ org.eclipse.nebula.widgets.nattable.core;bundle-version="1.0.0",
+ org.eclipse.gmf.runtime.common.core,
+ org.eclipse.gmf.runtime.common.ui.services
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.infra.nattable.xtext.integration.celleditor
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/OSGI-INF/l10n/bundle.properties b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000000..f34bb2889da
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.papyrus.infra.nattable.xtext.integration
+Bundle-Vendor = Eclipse Modeling Project
+Bundle-Name = UML XText Integration for NatTable (Incubation) \ No newline at end of file
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/about.html b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/about.html
new file mode 100644
index 00000000000..598b3684879
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>May 12, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/build.properties b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/build.properties
new file mode 100644
index 00000000000..efe5828f95a
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/,\
+ about.html,\
+ plugin.pdoc
+src.includes = about.html
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/plugin.pdoc b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/plugin.pdoc
new file mode 100644
index 00000000000..a289d22c016
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/plugin.pdoc
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doc:Documentation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:doc="http://www.eclipse.org/papyrus/documentation/plugin/documentation" description="This plugin provides the required classes to open XText Editor as CellEditor in Papyrus Table">
+ <referent firstName="Vincent" lastName="LORENZO" eMail="vincent.lorenzo@cea.fr" currentCompany="CEA LIST"/>
+</doc:Documentation>
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java
new file mode 100644
index 00000000000..33574d1f36b
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/Activator.java
@@ -0,0 +1,53 @@
+package org.eclipse.papyrus.infra.nattable.xtext.integration;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+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.nattable.xtext.integration"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
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
new file mode 100644
index 00000000000..87c23ef2b62
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/celleditor/AbstractNatTableXTextCellEditor.java
@@ -0,0 +1,154 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.xtext.integration.celleditor;
+
+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.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.xtext.integration.util.XTextEditorResultWrapper;
+import org.eclipse.papyrus.uml.xtext.integration.DefaultXtextDirectEditorConfiguration;
+import org.eclipse.papyrus.uml.xtext.integration.XtextFakeResourceContext;
+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;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public abstract class AbstractNatTableXTextCellEditor extends AbstractPapyrusStyledTextCellEditor {
+
+ protected DefaultXtextDirectEditorConfiguration xTextConfiguration;
+
+ /**
+ * the JFace cellEditor
+ */
+ protected CellEditor jfaceCellEditor;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * @param axisElement
+ * @param elementProvider
+ * @param commitOnUpDown
+ * @param moveSelectionOnEnter
+ */
+ public AbstractNatTableXTextCellEditor(final Table table, final Object axisElement, final ITableAxisElementProvider elementProvider, final boolean commitOnUpDown, final boolean moveSelectionOnEnter) {
+ super(table, axisElement, elementProvider, commitOnUpDown, moveSelectionOnEnter);
+ this.commitOnEnter = false;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * @param axisElement
+ * @param elementProvider
+ * @param commitOnUpDown
+ */
+ public AbstractNatTableXTextCellEditor(final Table table, final Object axisElement, final ITableAxisElementProvider elementProvider, boolean commitOnUpDown) {
+ this(table, axisElement, elementProvider, commitOnUpDown, false);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * @param axisElement
+ * @param elementProvider
+ */
+ public AbstractNatTableXTextCellEditor(final Table table, final Object axisElement, final ITableAxisElementProvider elementProvider) {
+ this(table, axisElement, elementProvider, false);
+ }
+
+ /**
+ *
+ * @return
+ * the XText DirectEditor Configuration
+ */
+ protected abstract DefaultXtextDirectEditorConfiguration createXTextEditorConfiguration();
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.AbstractStyledTextCellEditor#createStyledText(org.eclipse.swt.widgets.Composite, int)
+ *
+ * @param parent
+ * @param style
+ * @return
+ */
+ @Override
+ protected StyledText createStyledText(Composite parent, int style) {
+ //add me as parameter!
+ this.xTextConfiguration = createXTextEditorConfiguration();
+
+ final EObject editedObject = getEditedEObject();
+
+ //must be done here!
+ XtextFakeResourceContext context = new XtextFakeResourceContext(xTextConfiguration.getInjector());
+ IContextElementProvider provider = new IContextElementProvider() {
+
+ public EObject getContextObject() {
+ return editedObject;
+ }
+ };
+ context.getFakeResource().eAdapters().add(new ContextElementAdapter(provider));
+
+ jfaceCellEditor = xTextConfiguration.createCellEditor(parent, editedObject);
+ return (StyledText)jfaceCellEditor.getControl();
+ }
+
+ /**
+ * Creates the editor control that is wrapped by this ICellEditor.
+ * Will use the style configurations in ConfigRegistry for styling the control.
+ *
+ * @param parent
+ * The Composite that will be the parent of the new editor control.
+ * Can not be <code>null</code>
+ * @param style
+ * The SWT style of the text control to create.
+ * @return The created editor control that is wrapped by this ICellEditor.
+ */
+ protected StyledText createEditorControl(final Composite parent, int style) {
+ final StyledText textControl = super.createEditorControl(parent, style);
+ textControl.setVisible(true);
+ return textControl;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.AbstractStyledTextCellEditor#getEditorValue()
+ *
+ * @return
+ */
+ @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);
+ return new XTextEditorResultWrapper(typedString, parseCommand);
+ }
+
+
+}
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java
new file mode 100644
index 00000000000..6c866a80702
--- /dev/null
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.xtext.integration/src/org/eclipse/papyrus/infra/nattable/xtext/integration/util/XTextEditorResultWrapper.java
@@ -0,0 +1,73 @@
+package org.eclipse.papyrus.infra.nattable.xtext.integration.util;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+
+/**
+ *
+ * This class is used to wrap the result of the XText editor and the set value command
+ *
+ */
+public class XTextEditorResultWrapper implements IAdaptable {
+
+ /**
+ * the text typed by the user in the Xtext editor
+ */
+ private final String text;
+
+ /**
+ * the command to use to do the set value
+ */
+ private final ICommand parseCommand;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param text
+ * the text typed by the user
+ * @param parseCommand
+ * the command to do the set value according to the typed text. Could be <code>null</code> if the text can't be parsed
+ */
+ public XTextEditorResultWrapper(String text, ICommand parseCommand) {
+ this.text = text;
+ this.parseCommand = parseCommand;
+ }
+
+ /**
+ *
+ * @return
+ * the text typed by the user
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ *
+ * @return
+ * the command to set the value in the model according to the text. The command can be <code>null</code> if the text can't be parsed
+ */
+ public ICommand getParseCommand() {
+ return parseCommand;
+ }
+
+ /**
+ *
+ * @param adapter
+ * @return
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ if(adapter == ICommand.class) {
+ return this.parseCommand;
+ }
+ if(adapter == String.class) {
+ return text;
+ }
+ return null;
+ }
+
+
+
+}
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
index 8e80c181780..0155b9fb47c 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
@@ -68,8 +68,14 @@ public class UMLStereotypePropertyAxisManager extends UMLFeatureAxisManager impl
boolean result = false;
if(object instanceof Property) {
final Property prop = (Property)object;
- result = prop.getOwner() instanceof Stereotype;
- result = result && EMFHelper.isReadOnly(prop);
+ final Element owner = prop.getOwner();
+ result = owner instanceof Stereotype;
+ if(result) {
+ result = owner.getOwner() instanceof Profile;
+ if(result) {
+ result = EMFHelper.isReadOnly(prop);
+ }
+ }
}
return result;
}
@@ -114,7 +120,7 @@ public class UMLStereotypePropertyAxisManager extends UMLFeatureAxisManager impl
public Command getAddAxisCommand(final TransactionalEditingDomain domain, final Collection<Object> objectToAdd) {
final List<String> allPropertyQN = new ArrayList<String>();
for(Object object : objectToAdd) {
- if(object instanceof Property) {
+ if(isAllowedContents(object)) {
allPropertyQN.add(Constants.PROPERTY_OF_STEREOTYPE_PREFIX + ((NamedElement)object).getQualifiedName());
}
}

Back to the top