diff options
author | vlorenzo | 2014-01-28 09:50:12 +0000 |
---|---|---|
committer | vlorenzo | 2014-01-28 09:50:12 +0000 |
commit | a91bc947d06b5ea53e3a1c8f3d037635e397833d (patch) | |
tree | 0bf07d0eb1001b23601b06bd437887377de932e8 /plugins/infra | |
parent | 9ae0b8190e1bf584f39dd3aa0a28d57cf7a9c065 (diff) | |
download | org.eclipse.papyrus-a91bc947d06b5ea53e3a1c8f3d037635e397833d.tar.gz org.eclipse.papyrus-a91bc947d06b5ea53e3a1c8f3d037635e397833d.tar.xz org.eclipse.papyrus-a91bc947d06b5ea53e3a1c8f3d037635e397833d.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 'plugins/infra')
4 files changed, 30 insertions, 19 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java index 297e2a3a5cf..7b627dcf198 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java +++ b/plugins/infra/nattable/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/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java index e2ffd90c082..8e44156f8dc 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/cell/ModelViewsCellManager.java +++ b/plugins/infra/nattable/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/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java index e24a9c648e4..a8c7c3fd4f1 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/AbstractCellManager.java +++ b/plugins/infra/nattable/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/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java index f239a73bd7c..b4a83c67385 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/ICellManager.java +++ b/plugins/infra/nattable/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);
|