Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2014-01-28 03:52:26 -0500
committervlorenzo2014-01-28 03:54:29 -0500
commit19159b61b28baa91caa16698dd5b69296f2c9fa7 (patch)
treeb4c0abd38df1c6f8f435035e55f564882dfaad85 /extraplugins
parentde7ed4f140c3b677ff5f64cc7b5a462223b69bfa (diff)
downloadorg.eclipse.papyrus-19159b61b28baa91caa16698dd5b69296f2c9fa7.tar.gz
org.eclipse.papyrus-19159b61b28baa91caa16698dd5b69296f2c9fa7.tar.xz
org.eclipse.papyrus-19159b61b28baa91caa16698dd5b69296f2c9fa7.zip
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 Fix this bug but with 2 commands in the stack. Moreover in case of Cancel during the editions, the stereotype is not unapplied
Diffstat (limited to 'extraplugins')
-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
5 files changed, 576 insertions, 4 deletions
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