Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2014-01-28 04:05:13 -0500
committervlorenzo2014-01-28 04:05:13 -0500
commit19117607b2b79bc0e23b81d0f1293a714c2d3730 (patch)
treecfa76f3a84b3f8d9d86f445366a90be853f4750a /extraplugins
parent19159b61b28baa91caa16698dd5b69296f2c9fa7 (diff)
downloadorg.eclipse.papyrus-19117607b2b79bc0e23b81d0f1293a714c2d3730.tar.gz
org.eclipse.papyrus-19117607b2b79bc0e23b81d0f1293a714c2d3730.tar.xz
org.eclipse.papyrus-19117607b2b79bc0e23b81d0f1293a714c2d3730.zip
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
Diffstat (limited to 'extraplugins')
-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
4 files changed, 30 insertions, 19 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);

Back to the top