Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2014-01-28 05:11:51 -0500
committerrschnekenbu2014-01-28 05:11:51 -0500
commit692d8ad4f83c3b652ada4ac4817d9d6ba0e4846f (patch)
treecc35f91077d7128573f21c12275c77d9d8c969d6
parente313fe8197ce46d97be5273470c74eb9334dfb4a (diff)
parent757e19a6bf506c50befc5d9d9991953cba3429c8 (diff)
downloadorg.eclipse.papyrus-692d8ad4f83c3b652ada4ac4817d9d6ba0e4846f.tar.gz
org.eclipse.papyrus-692d8ad4f83c3b652ada4ac4817d9d6ba0e4846f.tar.xz
org.eclipse.papyrus-692d8ad4f83c3b652ada4ac4817d9d6ba0e4846f.zip
Merge remote-tracking branch 'origin/streams/0.10-maintenance' into streams/0.10-maintenance
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java21
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java21
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java5
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java2
-rw-r--r--extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java15
-rw-r--r--extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierCellEditorWrapper.java426
-rw-r--r--extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierDialogCellEditorWrapper.java104
-rw-r--r--extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java8
-rw-r--r--extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java27
9 files changed, 606 insertions, 23 deletions
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java b/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java
index 297e2a3a5cf..7b627dcf198 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java
@@ -22,13 +22,11 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
@@ -41,8 +39,6 @@ import org.eclipse.papyrus.commands.wrappers.EMFtoGMFCommandWrapper;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.emf.utils.EMFStringValueConverter;
import org.eclipse.papyrus.infra.nattable.manager.cell.AbstractCellManager;
-import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory;
-import org.eclipse.papyrus.infra.nattable.manager.cell.ICellManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.paste.IValueSetter;
import org.eclipse.papyrus.infra.nattable.paste.ReferenceValueSetter;
@@ -183,6 +179,17 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
* the command to set the value
*/
protected Command getSetValueCommand(final TransactionalEditingDomain domain, final EObject elementToEdit, final EStructuralFeature featureToEdit, final Object newValue) {
+ //426731: [Table 2] Opening then closing cells editors without modifiyng values execute a command in the stack
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=426731
+ //1. we verify that the new valu eis not the same thjan the current value
+ final Object currentValue = elementToEdit.eGet(featureToEdit);
+ if(newValue == null && currentValue == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ if(newValue != null && newValue.equals(currentValue)) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ //2. if not we do the job
final AbstractEditCommandRequest request = new SetRequest(domain, elementToEdit, featureToEdit, newValue);
final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToEdit);
final ICommand cmd = provider.getEditCommand(request);
@@ -229,9 +236,9 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
}
return new GMFtoEMFCommandWrapper(returnedCommand);
}
-
-
- protected final ICommand getOpenConfirmChangeContainmentDialogCommand(final TransactionalEditingDomain domain, final ICommand defaultCommand, final boolean isMany){
+
+
+ protected final ICommand getOpenConfirmChangeContainmentDialogCommand(final TransactionalEditingDomain domain, final ICommand defaultCommand, final boolean isMany) {
final String messageDialog;
if(isMany) {
messageDialog = "Your are setting a value in a containment feature. This action will change the owner of the dropped element(s).\nContinue?";
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java
index e2ffd90c082..8e44156f8dc 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java
@@ -36,6 +36,7 @@ import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
/**
* The Cell manager for the ModelViews table
+ * TODO : should inherits from emf.nattable
*
* @author Vincent Lorenzo
*
@@ -160,9 +161,13 @@ public class ModelViewsCellManager extends AbstractCellManager {
final String featureName = ((String)objects.get(1)).replace(Utils.NATTABLE_EDITOR_PAGE_ID, ""); //$NON-NLS-1$
if(Utils.VIEW_NAME.equals(featureName)) {
final EStructuralFeature feature = editor.eClass().getEStructuralFeature(Utils.VIEW_NAME);
- final AbstractEditCommandRequest request = new SetRequest((TransactionalEditingDomain)domain, editor, feature, newValue);
- final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(editor);
- return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ if(!newValue.equals(editor.eClass().eGet(feature))) {
+ // 426731: [Table 2] Opening then closing cells editors without modifiyng values execute a command in the stack
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=426731
+ final AbstractEditCommandRequest request = new SetRequest((TransactionalEditingDomain)domain, editor, feature, newValue);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(editor);
+ return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ }
}
return null;
}
@@ -218,12 +223,10 @@ public class ModelViewsCellManager extends AbstractCellManager {
*/
protected Object getEditorName(final Object editor) {
if(editor instanceof EObject) {
- if(editor instanceof EObject) {
- final EObject eobject = (EObject)editor;
- EStructuralFeature feature = eobject.eClass().getEStructuralFeature(Utils.VIEW_NAME);
- if(feature != null) {
- return eobject.eGet(feature);
- }
+ final EObject eobject = (EObject)editor;
+ EStructuralFeature feature = eobject.eClass().getEStructuralFeature(Utils.VIEW_NAME);
+ if(feature != null) {
+ return eobject.eGet(feature);
}
}
return NOT_AVALAIBLE;
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java
index e24a9c648e4..a8c7c3fd4f1 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java
@@ -98,8 +98,9 @@ public abstract class AbstractCellManager implements ICellManager {
@Override
public void setValue(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager) {
final Command cmd = getSetValueCommand(domain, columnElement, rowElement, newValue, tableManager);
- assert cmd != null;
- domain.getCommandStack().execute(cmd);
+ if(cmd != null) {
+ domain.getCommandStack().execute(cmd);
+ }
}
/**
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java
index f239a73bd7c..b4a83c67385 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java
@@ -99,7 +99,7 @@ public interface ICellManager {
* the new value to set to the intersection of these 2 objects
* @param tableManager
* @return
- * the command to set the value
+ * the command to set the value or <code>null</code>
*/
public Command getSetValueCommand(final TransactionalEditingDomain domain, final Object columnElement, final Object rowElement, final Object newValue, final INattableModelManager tableManager);
diff --git a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java
index ec321760dad..a70adb0d6b9 100644
--- a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java
+++ b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java
@@ -15,12 +15,12 @@ import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
import org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor;
+import org.eclipse.nebula.widgets.nattable.edit.gui.AbstractDialogCellEditor;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
import org.eclipse.papyrus.infra.emf.nattable.celleditor.config.EStructuralFeatureEditorConfig;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
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.nattableaxis.IAxis;
@@ -35,6 +35,8 @@ import org.eclipse.papyrus.uml.nattable.editor.MultiReferenceCellEditor;
import org.eclipse.papyrus.uml.nattable.editor.MultiStringCellEditor;
import org.eclipse.papyrus.uml.nattable.editor.MultiUnlimitedNaturalCellEditor;
import org.eclipse.papyrus.uml.nattable.editor.SingleReferenceValueCellEditor;
+import org.eclipse.papyrus.uml.nattable.editor.StereotypeApplierCellEditorWrapper;
+import org.eclipse.papyrus.uml.nattable.editor.StereotypeApplierDialogCellEditorWrapper;
import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils;
import org.eclipse.papyrus.uml.nattable.validator.RealDataValidator;
import org.eclipse.papyrus.uml.nattable.validator.UnlimitedNaturalDataValidator;
@@ -133,7 +135,6 @@ public class UMLFeatureCellEditorConfig extends EStructuralFeatureEditorConfig {
// conf.setAction(action);
// conf.setTooltipText("Open a dialog to select the value");
// editor = new ComboBoxWithButtonCellEditor(dataProvider, conf);
- INattableModelManager manager = (INattableModelManager)elementProvider;
editor = new SingleReferenceValueCellEditor(axisElement, elementProvider);
break;
case SINGLE_UML_ENUMERATION:
@@ -167,6 +168,14 @@ public class UMLFeatureCellEditorConfig extends EStructuralFeatureEditorConfig {
editor = super.getICellEditor(table, axisElement, elementProvider);
break;
}
+ // to apply required stereotype before edition
+ // see bug 426709: [Table 2][Stereotype] Papyrus Table must allows to edit stereotype properties even if the required stereotypes is not yet applied
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=426709
+ if(editor instanceof AbstractDialogCellEditor) {
+ editor = new StereotypeApplierDialogCellEditorWrapper((AbstractDialogCellEditor)editor, axisElement, elementProvider);
+ } else if(editor instanceof ICellEditor) {
+ editor = new StereotypeApplierCellEditorWrapper(editor, axisElement, elementProvider);
+ }
return editor;
}
@@ -499,4 +508,4 @@ public class UMLFeatureCellEditorConfig extends EStructuralFeatureEditorConfig {
public String getEditorConfigId() {
return EDITOR_CONFIG_ID;
}
-} \ No newline at end of file
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierCellEditorWrapper.java b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierCellEditorWrapper.java
new file mode 100644
index 00000000000..c7871b0a79a
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierCellEditorWrapper.java
@@ -0,0 +1,426 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.uml.nattable.editor;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.edit.ICellEditHandler;
+import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
+import org.eclipse.nebula.widgets.nattable.edit.editor.IEditErrorHandler;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
+import org.eclipse.nebula.widgets.nattable.widget.EditModeEnum;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils;
+import org.eclipse.papyrus.uml.tools.commands.ApplyStereotypeCommand;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Stereotype;
+
+/**
+ * Wrapper to apply stereotypes if required before to do the edition
+ * see bug 426709: [Table 2][Stereotype] Papyrus Table must allows to edit stereotype properties even if the required stereotypes is not yet applied
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=426709
+ *
+ * elementProvider
+ */
+public class StereotypeApplierCellEditorWrapper implements ICellEditor {
+
+ /** the wrapped celleditor. */
+ protected final ICellEditor wrappedCellEditor;
+
+ /**
+ * the edited axis
+ */
+ protected final Object axisElement;
+
+ /**
+ * the table element provider
+ */
+ protected final ITableAxisElementProvider elementProvider;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param wrappedCellEditor
+ * the wrapped cell editor
+ * @param axisElement
+ * the edited axis
+ * @param elementProvider
+ * the axis element provider
+ */
+ public StereotypeApplierCellEditorWrapper(final ICellEditor wrappedCellEditor, final Object axisElement, final ITableAxisElementProvider elementProvider) {
+ this.wrappedCellEditor = wrappedCellEditor;
+ this.axisElement = axisElement;
+ this.elementProvider = elementProvider;
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#activateCell(org.eclipse.swt.widgets.Composite, java.lang.Object,
+ * org.eclipse.nebula.widgets.nattable.widget.EditModeEnum, org.eclipse.nebula.widgets.nattable.edit.ICellEditHandler,
+ * org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)
+ *
+ * @param parent
+ * @param originalCanonicalValue
+ * @param editMode
+ * @param editHandler
+ * @param cell
+ * @param configRegistry
+ * @return
+ */
+
+ @Override
+ public Control activateCell(Composite parent, Object originalCanonicalValue, EditModeEnum editMode, ICellEditHandler editHandler, ILayerCell cell, IConfigRegistry configRegistry) {
+ int columnIndex = cell.getColumnIndex();
+ int rowIndex = cell.getRowIndex();
+ Object row = this.elementProvider.getRowElement(rowIndex);
+ Object column = this.elementProvider.getColumnElement(columnIndex);
+ row = AxisUtils.getRepresentedElement(row);
+ column = AxisUtils.getRepresentedElement(column);
+ Element editedElement = null;
+ Object feature = null;
+ if(row instanceof EObject && column == this.axisElement) {
+ editedElement = (Element)row;
+ feature = column;
+ } else {
+ editedElement = (Element)column;
+ feature = row;
+ }
+
+ if(!(feature instanceof EStructuralFeature)) {
+ final String id = AxisUtils.getPropertyId(this.axisElement);
+ applyRequiredStereotype(editedElement, id);
+ }
+ return this.wrappedCellEditor.activateCell(parent, originalCanonicalValue, editMode, editHandler, cell, configRegistry);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getColumnIndex()
+ *
+ * @return
+ */
+
+ @Override
+ public int getColumnIndex() {
+ return this.wrappedCellEditor.getColumnIndex();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getRowIndex()
+ *
+ * @return
+ */
+
+ @Override
+ public int getRowIndex() {
+ return this.wrappedCellEditor.getRowIndex();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getColumnPosition()
+ *
+ * @return
+ */
+
+ @Override
+ public int getColumnPosition() {
+ return this.wrappedCellEditor.getColumnPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getRowPosition()
+ *
+ * @return
+ */
+
+ @Override
+ public int getRowPosition() {
+ return this.wrappedCellEditor.getRowPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getEditorValue()
+ *
+ * @return
+ */
+
+ @Override
+ public Object getEditorValue() {
+ return this.wrappedCellEditor.getEditorValue();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#setEditorValue(java.lang.Object)
+ *
+ * @param value
+ */
+
+ @Override
+ public void setEditorValue(Object value) {
+ this.wrappedCellEditor.setEditorValue(value);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getCanonicalValue()
+ *
+ * @return
+ */
+
+ @Override
+ public Object getCanonicalValue() {
+ return this.wrappedCellEditor.getCanonicalValue();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getCanonicalValue(org.eclipse.nebula.widgets.nattable.edit.editor.IEditErrorHandler)
+ *
+ * @param conversionErrorHandler
+ * @return
+ */
+
+ @Override
+ public Object getCanonicalValue(IEditErrorHandler conversionErrorHandler) {
+ return this.wrappedCellEditor.getCanonicalValue(conversionErrorHandler);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#setCanonicalValue(java.lang.Object)
+ *
+ * @param canonicalValue
+ */
+
+ @Override
+ public void setCanonicalValue(Object canonicalValue) {
+ this.wrappedCellEditor.setCanonicalValue(canonicalValue);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#validateCanonicalValue(java.lang.Object)
+ *
+ * @param canonicalValue
+ * @return
+ */
+
+ @Override
+ public boolean validateCanonicalValue(Object canonicalValue) {
+ return this.wrappedCellEditor.validateCanonicalValue(canonicalValue);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#validateCanonicalValue(java.lang.Object,
+ * org.eclipse.nebula.widgets.nattable.edit.editor.IEditErrorHandler)
+ *
+ * @param canonicalValue
+ * @param validationErrorHandler
+ * @return
+ */
+
+ @Override
+ public boolean validateCanonicalValue(Object canonicalValue, IEditErrorHandler validationErrorHandler) {
+ return this.wrappedCellEditor.validateCanonicalValue(canonicalValue, validationErrorHandler);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#commit(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum)
+ *
+ * @param direction
+ * @return
+ */
+
+ @Override
+ public boolean commit(MoveDirectionEnum direction) {
+ return this.wrappedCellEditor.commit(direction);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#commit(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum,
+ * boolean)
+ *
+ * @param direction
+ * @param closeAfterCommit
+ * @return
+ */
+
+ @Override
+ public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit) {
+ return this.wrappedCellEditor.commit(direction, closeAfterCommit);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#commit(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum,
+ * boolean, boolean)
+ *
+ * @param direction
+ * @param closeAfterCommit
+ * @param skipValidation
+ * @return
+ */
+
+ @Override
+ public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit, boolean skipValidation) {
+ return this.wrappedCellEditor.commit(direction, closeAfterCommit, skipValidation);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#close()
+ *
+ */
+
+ @Override
+ public void close() {
+ this.wrappedCellEditor.close();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#isClosed()
+ *
+ * @return
+ */
+
+ @Override
+ public boolean isClosed() {
+ return this.wrappedCellEditor.isClosed();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#getEditorControl()
+ *
+ * @return
+ */
+
+ @Override
+ public Control getEditorControl() {
+ return this.wrappedCellEditor.getEditorControl();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#createEditorControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+
+ @Override
+ public Control createEditorControl(Composite parent) {
+ return this.wrappedCellEditor.createEditorControl(parent);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#openInline(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry,
+ * java.util.List)
+ *
+ * @param configRegistry
+ * @param configLabels
+ * @return
+ */
+
+ @Override
+ public boolean openInline(IConfigRegistry configRegistry, List<String> configLabels) {
+ return this.wrappedCellEditor.openInline(configRegistry, configLabels);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#supportMultiEdit(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry,
+ * java.util.List)
+ *
+ * @param configRegistry
+ * @param configLabels
+ * @return
+ */
+
+ @Override
+ public boolean supportMultiEdit(IConfigRegistry configRegistry, List<String> configLabels) {
+ return this.wrappedCellEditor.supportMultiEdit(configRegistry, configLabels);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#openAdjacentEditor()
+ *
+ * @return
+ */
+
+ @Override
+ public boolean openAdjacentEditor() {
+ return this.wrappedCellEditor.openAdjacentEditor();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#activateAtAnyPosition()
+ *
+ * @return
+ */
+
+ @Override
+ public boolean activateAtAnyPosition() {
+ return this.wrappedCellEditor.activateAtAnyPosition();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#addEditorControlListeners()
+ *
+ */
+
+ @Override
+ public void addEditorControlListeners() {
+ this.wrappedCellEditor.addEditorControlListeners();
+ }
+
+ /**
+ * Removes the editor control listeners.
+ *
+ * @see org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor#removeEditorControlListeners()
+ */
+
+ @Override
+ public void removeEditorControlListeners() {
+ this.wrappedCellEditor.removeEditorControlListeners();
+ }
+
+ /**
+ *
+ * @param el
+ * an element of the model
+ * @param propertyId
+ * the id of the edited property
+ * @return <code>true</code> if a stereotype has been applied
+ */
+ private static final boolean applyRequiredStereotype(final Element el, final String propertyId) {
+ if(UMLTableUtils.getAppliedStereotypesWithThisProperty(el, propertyId).size() == 0) {
+ final List<Stereotype> stereotypesList = UMLTableUtils.getApplicableStereotypesWithThisProperty(el, propertyId);
+ if(stereotypesList.size() == 1) {
+ TransactionalEditingDomain domain = null;
+ try {
+ domain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(el);
+ final ApplyStereotypeCommand applyCommand = new ApplyStereotypeCommand(el, stereotypesList.get(0), domain);
+ domain.getCommandStack().execute(applyCommand);
+ return true;
+ } catch (ServiceException e) {
+ Activator.log.error("EditingDomain not found", e); //$NON-NLS-1$
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierDialogCellEditorWrapper.java b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierDialogCellEditorWrapper.java
new file mode 100644
index 00000000000..ae176b4a7c7
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/editor/StereotypeApplierDialogCellEditorWrapper.java
@@ -0,0 +1,104 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.uml.nattable.editor;
+
+import java.util.Map;
+
+import org.eclipse.nebula.widgets.nattable.edit.EditTypeEnum;
+import org.eclipse.nebula.widgets.nattable.edit.gui.AbstractDialogCellEditor;
+import org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog;
+import org.eclipse.papyrus.infra.nattable.manager.table.ITableAxisElementProvider;
+
+
+/**
+ * Wrapper for cell editor dialogs
+ * see bug 426709: [Table 2][Stereotype] Papyrus Table must allows to edit stereotype properties even if the required stereotypes is not yet applied
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=426709
+ */
+public class StereotypeApplierDialogCellEditorWrapper extends StereotypeApplierCellEditorWrapper implements ICellEditDialog {
+
+ /**
+ * Instantiates a new stereotyped element dialog cell editor wrapper.
+ *
+ * @param wrappedCellEditor
+ * the wrapped cell editor
+ * @param axisElement
+ * the edited axis
+ * @param elementProvider
+ * the axis element provider
+ */
+ public StereotypeApplierDialogCellEditorWrapper(final AbstractDialogCellEditor wrappedCellEditor, final Object axisElement, final ITableAxisElementProvider elementProvider) {
+ super(wrappedCellEditor, axisElement, elementProvider);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog#getCommittedValue()
+ *
+ * @return
+ */
+
+ @Override
+ public Object getCommittedValue() {
+ return ((AbstractDialogCellEditor)this.wrappedCellEditor).getCommittedValue();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog#getEditType()
+ *
+ * @return
+ */
+
+ @Override
+ public EditTypeEnum getEditType() {
+ return ((AbstractDialogCellEditor)this.wrappedCellEditor).getEditType();
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog#calculateValue(java.lang.Object, java.lang.Object)
+ *
+ * @param currentValue
+ * @param processValue
+ * @return
+ */
+
+ @Override
+ public Object calculateValue(Object currentValue, Object processValue) {
+ return ((AbstractDialogCellEditor)this.wrappedCellEditor).calculateValue(currentValue, processValue);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog#open()
+ *
+ * @return
+ */
+
+ @Override
+ public int open() {
+ return ((AbstractDialogCellEditor)this.wrappedCellEditor).open();
+ }
+
+ /**
+ * Sets the dialog settings.
+ *
+ * @param editDialogSettings
+ * the edit dialog settings
+ * @see org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog#setDialogSettings(java.util.Map)
+ */
+
+ @Override
+ public void setDialogSettings(Map<String, Object> editDialogSettings) {
+ ((AbstractDialogCellEditor)this.wrappedCellEditor).setDialogSettings(editDialogSettings);
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java
index 090ef4431d7..df1a74c8e4d 100644
--- a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/cell/StereotypePropertyCellManager.java
@@ -141,9 +141,15 @@ public class StereotypePropertyCellManager extends UMLFeatureCellManager {
final List<Object> umlObjects = organizeAndResolvedObjects(columnElement, rowElement, null);
final Element el = (Element)umlObjects.get(0);
final String id = (String)umlObjects.get(1);
+ final Property prop = UMLTableUtils.getRealStereotypeProperty(el, id);
switch(UMLTableUtils.getAppliedStereotypesWithThisProperty(el, id).size()) {
+ case 0:
+ // to apply required stereotype before edition
+ // see bug 426709: [Table 2][Stereotype] Papyrus Table must allows to edit stereotype properties even if the required stereotypes is not yet applied
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=426709
+ final int nbApplicablesSte = UMLTableUtils.getApplicableStereotypesWithThisProperty(el, id).size();
+ return nbApplicablesSte == 1 && !prop.isDerived() && !prop.isReadOnly();
case 1:
- final Property prop = UMLTableUtils.getRealStereotypeProperty(el, id);
return !prop.isDerived() && !prop.isReadOnly();
default:
return false;
diff --git a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java
index 61526ace9c2..cefd7a205f1 100644
--- a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java
+++ b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/utils/UMLTableUtils.java
@@ -143,6 +143,33 @@ public class UMLTableUtils {
* the UML::Element on which we are looking for applied Stereotype with the property identified by its id
* @param id
* the id used to identify the property of the stereotype
+ *
+ * @return
+ * the list of UML::Stereotype which have the property identified by this id and which are applied on the Element or <code>null</code> if
+ * we can't resolve it (the required profile is not applied)
+ */
+ public static final List<Stereotype> getApplicableStereotypesWithThisProperty(final Element element, final String id) {
+ assert id.startsWith(PROPERTY_OF_STEREOTYPE_PREFIX);
+ final List<Stereotype> stereotypes = new ArrayList<Stereotype>();
+ if(element.eResource() != null) {
+ final Object prop = getRealStereotypeProperty(element, id);
+ if(prop instanceof Property) {
+ for(final Stereotype current : element.getApplicableStereotypes()) {
+ if(current.getAllAttributes().contains(prop)) {
+ stereotypes.add(current);
+ }
+ }
+ }
+ }
+ return stereotypes;
+ }
+
+ /**
+ *
+ * @param element
+ * the UML::Element on which we are looking for applied Stereotype with the property identified by its id
+ * @param id
+ * the id used to identify the property of the stereotype
* @param sharedMap
* a map owning interesting information, like {@link StereotypeApplicationStructure} which can be used to find stereotype, stereotype
* application and so on

Back to the top