diff options
author | Christian W. Damus | 2014-03-24 20:46:54 +0000 |
---|---|---|
committer | Christian W. Damus | 2014-03-24 21:13:13 +0000 |
commit | 88a320ee08fe0d1f4546dbb247dbbeb2eab61e22 (patch) | |
tree | aabf4f827239611bdd9638f433d5320bcd27f61a | |
parent | 0854125d2b6a152fccd3dc021d77408c1d341468 (diff) | |
download | org.eclipse.papyrus-88a320ee08fe0d1f4546dbb247dbbeb2eab61e22.tar.gz org.eclipse.papyrus-88a320ee08fe0d1f4546dbb247dbbeb2eab61e22.tar.xz org.eclipse.papyrus-88a320ee08fe0d1f4546dbb247dbbeb2eab61e22.zip |
431023: [Resource Management] Model edits disappear in binary space
https://bugs.eclipse.org/bugs/show_bug.cgi?id=431023
Fix gaps in the dirty-state computation for operation histories that have non-dirtying operations and enforce an undo/redo limit.
18 files changed, 684 insertions, 102 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend index dcac9804228..dea7757c0f4 100644 --- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend +++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/Editor.xtend @@ -11,6 +11,7 @@ * Michael Golubev (Montages) - #386838 - migrate to Xtend2 * Emilien Perico (Atos Origin) - add code to refactor some classes * Christian W. Damus (CEA) - bug 430648 + * Christian W. Damus (CEA) - bug 431023 */ package aspects.xpt.editor
@@ -43,7 +44,7 @@ public static final String CONTEXT_ID = "«contextID»"; «nonNLS» ««« Helps to handle correctly the dirty state «generatedMemberComment» - private org.eclipse.core.commands.operations.IUndoableOperation savedOperation = null; + private org.eclipse.papyrus.commands.util.OperationHistoryDirtyState dirtyState; «generatedMemberComment» private org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain; @@ -103,6 +104,10 @@ override additions (GenEditorView it)''' « doSave(it)» + « getDirtyState(it)» + + « setUndoContext(it)» + « isDirty(it)» «««Documentation. adds method to handle palette changes @@ -152,6 +157,11 @@ def dispose(GenEditorView it)''' // remove preference listener org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService.getInstance().removeProviderChangeListener(this); + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + super.dispose(); } ''' @@ -360,16 +370,37 @@ def doSave (GenEditorView it)''' «generatedMemberComment» public void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor) { // The saving of the resource is done by the CoreMultiDiagramEditor - savedOperation = getOperationHistory().getUndoOperation(getUndoContext()); + getDirtyState().saved(); } ''' +def getDirtyState (GenEditorView it)''' +«generatedMemberComment» + protected org.eclipse.papyrus.commands.util.OperationHistoryDirtyState getDirtyState() { + if(dirtyState == null) { + dirtyState = org.eclipse.papyrus.commands.util.OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory()); + } + return dirtyState; + } +''' + +def setUndoContext (GenEditorView it)''' +«generatedMemberComment» + protected void setUndoContext(org.eclipse.core.commands.operations.IUndoContext context) { + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + + super.setUndoContext(context); + } +''' + //Fix the dirty state def isDirty (GenEditorView it)''' «generatedMemberComment» public boolean isDirty() { - org.eclipse.core.commands.operations.IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext()); - return savedOperation != op && org.eclipse.papyrus.commands.util.OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation); + return getDirtyState().isDirty(); } ''' diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/NotifyingWorkspaceCommandStack.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/NotifyingWorkspaceCommandStack.java index 029f64b1aca..e16879bc14d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/NotifyingWorkspaceCommandStack.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/NotifyingWorkspaceCommandStack.java @@ -12,12 +12,13 @@ * Christian W. Damus (CEA) - 404220: Add contexts for tracking objects changed by operations (CDO)
* Christian W. Damus (CEA) - bug 402525
* Christian W. Damus (CEA) - bug 430648
+ * Christian W. Damus (CEA) - bug 431023
*
*****************************************************************************/
package org.eclipse.papyrus.commands;
import static org.eclipse.papyrus.commands.util.OperationUtils.anyDirtying;
-import static org.eclipse.papyrus.commands.util.OperationUtils.anyDirtyingAfter;
+import static org.eclipse.papyrus.commands.util.OperationUtils.isDirty;
import java.util.Collection;
import java.util.EventObject;
@@ -629,7 +630,7 @@ implements IWorkspaceCommandStack { // return savedContext != null;
return super.isSaveNeeded();
}
- return savedContext != null ? !nextUndoableOperation.hasContext(getSavedContext()) && anyDirtyingAfter(history.getUndoHistory(getDefaultUndoContext()), history.getUndoOperation(savedContext)) : anyDirtying(history.getUndoHistory(getDefaultUndoContext()));
+ return savedContext != null ? !nextUndoableOperation.hasContext(getSavedContext()) && isDirty(history.getUndoHistory(getDefaultUndoContext()), history.getRedoHistory(getDefaultUndoContext()), history.getUndoOperation(savedContext)) : anyDirtying(history.getUndoHistory(getDefaultUndoContext()));
}
@Override
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationHistoryDirtyState.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationHistoryDirtyState.java new file mode 100644 index 00000000000..f9607e1f026 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationHistoryDirtyState.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2014 CEA and others. + * + * 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: + * Christian W. Damus (CEA) - Initial API and implementation + * + */ +package org.eclipse.papyrus.commands.util; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +import org.eclipse.core.commands.operations.IOperationHistory; +import org.eclipse.core.commands.operations.IOperationHistoryListener; +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.core.commands.operations.OperationHistoryEvent; +import org.eclipse.emf.common.command.BasicCommandStack; +import org.eclipse.papyrus.commands.INonDirtying; + + +/** + * A utility class for tracking the dirty state of an operation history. It works in the + * same fashion as the EMF {@link BasicCommandStack}, accounting for operations that {@linkplain INonDirtying do not dirty} the editor. + */ +public class OperationHistoryDirtyState { + + private static final Map<IUndoContext, OperationHistoryDirtyState> instances = new HashMap<IUndoContext, OperationHistoryDirtyState>(); + + private final AtomicInteger refCount = new AtomicInteger(0); + + private final IUndoContext context; + + private final IOperationHistory history; + + private IOperationHistoryListener listener; + + private IUndoableOperation savepoint; + + private boolean forceDirty; + + private OperationHistoryDirtyState(IUndoContext context, IOperationHistory history) { + this.context = context; + this.history = history; + + history.addOperationHistoryListener(createOperationHistoryListener()); + } + + /** + * Obtains a new operation history dirty-state tracker. Every result of this call must eventually be {@linkplain #dispose() disposed}, + * even if it is actually the same instance as returned by an earlier call, because instances are reference-counted. + */ + public static OperationHistoryDirtyState newInstance(IUndoContext context, IOperationHistory history) { + OperationHistoryDirtyState result; + + synchronized(instances) { + result = instances.get(context); + if(result == null) { + result = new OperationHistoryDirtyState(context, history); + instances.put(context, result); + } + } + + result.retain(); + return result; + } + + private IOperationHistoryListener createOperationHistoryListener() { + this.listener = new IOperationHistoryListener() { + + public void historyNotification(OperationHistoryEvent event) { + switch(event.getEventType()) { + case OperationHistoryEvent.DONE: + case OperationHistoryEvent.UNDONE: + case OperationHistoryEvent.REDONE: + case OperationHistoryEvent.OPERATION_CHANGED: + // Check on our savepoint, if any + if((savepoint != null) && !savepoint.hasContext(context)) { + // Our savepoint has been removed from the context (our undo/redo stack), so it + // is effectively lost + savepoint = null; + } + break; + case OperationHistoryEvent.OPERATION_REMOVED: + IUndoableOperation removed = event.getOperation(); + if(removed != null) { + if(removed == savepoint) { + // the savepoint was removed, so now we can never return to it + savepoint = null; + } else if((savepoint == null) && removed.hasContext(context) && !OperationUtils.isNonDirtying(removed)) { + // A dirtying operation has been lost from the history, so we will not now be able to return + // to a state equivalent to the savepoint + forceDirty = true; + } + } + break; + } + } + }; + + return this.listener; + } + + private OperationHistoryDirtyState retain() { + refCount.incrementAndGet(); + return this; + } + + private boolean release() { + return refCount.decrementAndGet() == 0; + } + + public void dispose() { + synchronized(instances) { + if(release()) { + instances.remove(context); + + if(listener != null) { + history.removeOperationHistoryListener(listener); + listener = null; + } + + savepoint = null; + } + } + } + + public boolean isDirty() { + return forceDirty || OperationUtils.isDirty(history.getUndoHistory(context), history.getRedoHistory(context), savepoint); + } + + public void saved() { + this.savepoint = history.getUndoOperation(context); + this.forceDirty = false; + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationUtils.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationUtils.java index 33a04b80dfe..447bc7aece0 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationUtils.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/util/OperationUtils.java @@ -12,6 +12,10 @@ */ package org.eclipse.papyrus.commands.util; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import org.eclipse.core.commands.operations.IUndoableOperation; import org.eclipse.emf.common.command.AbstractCommand; import org.eclipse.emf.common.command.Command; @@ -85,26 +89,49 @@ public class OperationUtils { return result; } - public static boolean anyDirtyingAfter(IUndoableOperation[] undoHistory, IUndoableOperation savepoint) { + public static boolean isDirty(IUndoableOperation[] undoHistory, IUndoableOperation[] redoHistory, IUndoableOperation savepoint) { boolean result = false; if(savepoint == null) { result = anyDirtying(undoHistory); - } else if((undoHistory != null) && (undoHistory.length > 0)) { - int i = 0; - - for(i = 0; i < undoHistory.length; i++) { - if(undoHistory[i] == savepoint) { - i++; // Advance over the save point to start testing - break; + } else { + List<IUndoableOperation> undos = ((undoHistory == null) || (undoHistory.length == 0)) ? Collections.<IUndoableOperation> emptyList() : Arrays.asList(undoHistory); + List<IUndoableOperation> redos = ((redoHistory == null) || (redoHistory.length == 0)) ? Collections.<IUndoableOperation> emptyList() : Arrays.asList(redoHistory); + + if(undos.contains(savepoint)) { + // See whether there is any dirtying command after the savepoint in the undo stack + int i = 0; + + for(; i < undoHistory.length; i++) { + if(undoHistory[i] == savepoint) { + i++; // Advance over the save point to start testing + break; + } } - } - for(; i < undoHistory.length; i++) { - if(!isNonDirtying(undoHistory[i])) { - result = true; - break; + for(; i < undoHistory.length; i++) { + if(!isNonDirtying(undoHistory[i])) { + result = true; + break; + } + } + } else if(redos.contains(savepoint)) { + // See whether there is any dirtying command before the savepoint in the redo stack + for(int i = redoHistory.length - 1; i >= 0; i--) { + if(!isNonDirtying(redoHistory[i])) { + result = true; + break; + } + if(redoHistory[i] == savepoint) { + // Done scanning. Everything up to and including the savepoint is non-dirtying + break; + } } + } else { + // If we have no history but we have a savepoint, then we cannot undo nor redo to that savepoint + // (the history has been flushed) so evidently some change was made that invalidated the history, + // therefore we are dirty + result = true; } } diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/part/BlockDefinitionDiagramEditor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/part/BlockDefinitionDiagramEditor.java index 85d64d90dc1..cbd947a55fc 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/part/BlockDefinitionDiagramEditor.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.blockdefinition/src-gen/org/eclipse/papyrus/sysml/diagram/blockdefinition/part/BlockDefinitionDiagramEditor.java @@ -16,7 +16,7 @@ package org.eclipse.papyrus.sysml.diagram.blockdefinition.part; import java.util.EventObject; import java.util.Set; -import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; @@ -39,7 +39,7 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentPro import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.papyrus.commands.util.OperationUtils; +import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState; import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; @@ -86,7 +86,7 @@ public class BlockDefinitionDiagramEditor extends UmlGmfDiagramEditor implements /** * @generated */ - private IUndoableOperation savedOperation = null; + private OperationHistoryDirtyState dirtyState; /** * @generated @@ -243,15 +243,37 @@ public class BlockDefinitionDiagramEditor extends UmlGmfDiagramEditor implements */ public void doSave(IProgressMonitor progressMonitor) { // The saving of the resource is done by the CoreMultiDiagramEditor - savedOperation = getOperationHistory().getUndoOperation(getUndoContext()); + getDirtyState().saved(); } /** * @generated */ + protected OperationHistoryDirtyState getDirtyState() { + if(dirtyState == null) { + dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory()); + } + return dirtyState; + } + + /** + * @generated + */ + @Override + protected void setUndoContext(IUndoContext context) { + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + + super.setUndoContext(context); + } + + /** + * @generated + */ public boolean isDirty() { - IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext()); - return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation); + return getDirtyState().isDirty(); } /** @@ -272,6 +294,11 @@ public class BlockDefinitionDiagramEditor extends UmlGmfDiagramEditor implements // remove preference listener PapyrusPaletteService.getInstance().removeProviderChangeListener(this); + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + super.dispose(); } diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/part/InternalBlockDiagramEditor.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/part/InternalBlockDiagramEditor.java index 04e328d4d93..b2937e7c59d 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/part/InternalBlockDiagramEditor.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.internalblock/src-gen/org/eclipse/papyrus/sysml/diagram/internalblock/part/InternalBlockDiagramEditor.java @@ -16,7 +16,7 @@ package org.eclipse.papyrus.sysml.diagram.internalblock.part; import java.util.EventObject; import java.util.Set; -import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; @@ -39,7 +39,7 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentPro import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.papyrus.commands.util.OperationUtils; +import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState; import org.eclipse.papyrus.gmf.diagram.common.compatibility.DiagramVersioningUtils; import org.eclipse.papyrus.gmf.diagram.common.compatibility.IDiagramVersionUpdater; import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; @@ -89,7 +89,7 @@ public class InternalBlockDiagramEditor extends UmlGmfDiagramEditor implements I /** * @generated */ - private IUndoableOperation savedOperation = null; + private OperationHistoryDirtyState dirtyState; /** * @generated @@ -261,15 +261,37 @@ public class InternalBlockDiagramEditor extends UmlGmfDiagramEditor implements I */ public void doSave(IProgressMonitor progressMonitor) { // The saving of the resource is done by the CoreMultiDiagramEditor - savedOperation = getOperationHistory().getUndoOperation(getUndoContext()); + getDirtyState().saved(); } /** * @generated */ + protected OperationHistoryDirtyState getDirtyState() { + if(dirtyState == null) { + dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory()); + } + return dirtyState; + } + + /** + * @generated + */ + @Override + protected void setUndoContext(IUndoContext context) { + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + + super.setUndoContext(context); + } + + /** + * @generated + */ public boolean isDirty() { - IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext()); - return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation); + return getDirtyState().isDirty(); } /** @@ -290,6 +312,11 @@ public class InternalBlockDiagramEditor extends UmlGmfDiagramEditor implements I // remove preference listener PapyrusPaletteService.getInstance().removeProviderChangeListener(this); + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + super.dispose(); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLDiagramEditor.java index 06d8e5078a6..d9a4786a9a2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/part/UMLDiagramEditor.java @@ -15,7 +15,7 @@ package org.eclipse.papyrus.uml.diagram.activity.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -41,7 +41,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -94,7 +94,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -300,16 +300,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -330,6 +351,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/part/UMLDiagramEditor.java index 9edb8c98532..0423e82ddf5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/part/UMLDiagramEditor.java @@ -13,7 +13,7 @@ package org.eclipse.papyrus.uml.diagram.clazz.part; import java.util.EventObject; -import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; @@ -37,7 +37,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.papyrus.commands.util.OperationUtils; +import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState; import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; @@ -89,7 +89,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /** * @generated */ - private IUndoableOperation savedOperation = null; + private OperationHistoryDirtyState dirtyState; /** * @generated @@ -271,15 +271,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */ public void doSave(IProgressMonitor progressMonitor) { // The saving of the resource is done by the CoreMultiDiagramEditor - savedOperation = getOperationHistory().getUndoOperation(getUndoContext()); + getDirtyState().saved(); } /** * @generated */ + protected OperationHistoryDirtyState getDirtyState() { + if(dirtyState == null) { + dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory()); + } + return dirtyState; + } + + /** + * @generated + */ + @Override + protected void setUndoContext(IUndoContext context) { + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + + super.setUndoContext(context); + } + + /** + * @generated + */ public boolean isDirty() { - IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext()); - return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation); + return getDirtyState().isDirty(); } /** @@ -300,6 +322,11 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove preference listener PapyrusPaletteService.getInstance().removeProviderChangeListener(this); + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + super.dispose(); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/part/UMLDiagramEditor.java index 60aa9faba71..ccdfff4c97e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/src/org/eclipse/papyrus/uml/diagram/communication/part/UMLDiagramEditor.java @@ -15,7 +15,7 @@ package org.eclipse.papyrus.uml.diagram.communication.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -39,7 +39,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -92,7 +92,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -288,16 +288,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -318,6 +339,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/part/UMLDiagramEditor.java index 9956d936c37..d3af918e99d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/src/org/eclipse/papyrus/uml/diagram/component/part/UMLDiagramEditor.java @@ -14,7 +14,7 @@ package org.eclipse.papyrus.uml.diagram.component.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -36,7 +36,7 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentPro import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -86,7 +86,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -255,16 +255,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -285,6 +306,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/part/UMLDiagramEditor.java index d6d08a4f07d..f77d63f6f79 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/src/org/eclipse/papyrus/uml/diagram/composite/part/UMLDiagramEditor.java @@ -15,7 +15,7 @@ package org.eclipse.papyrus.uml.diagram.composite.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -37,7 +37,7 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentPro import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -87,7 +87,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -253,15 +253,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
}
/**
* @generated
*/
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -281,6 +303,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/part/UMLDiagramEditor.java index 2a524c0589b..ed934e0946d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/src/org/eclipse/papyrus/uml/diagram/deployment/part/UMLDiagramEditor.java @@ -5,7 +5,7 @@ package org.eclipse.papyrus.uml.diagram.deployment.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -27,7 +27,7 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentPro import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -77,7 +77,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -250,16 +250,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -281,6 +302,11 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/part/InteractionOverviewDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/part/InteractionOverviewDiagramEditor.java index bd44e69646e..242b485a5d5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/part/InteractionOverviewDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/src-gen/org/eclipse/papyrus/uml/diagram/interactionoverview/part/InteractionOverviewDiagramEditor.java @@ -13,7 +13,7 @@ package org.eclipse.papyrus.uml.diagram.interactionoverview.part; import java.util.EventObject; import java.util.Set; -import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; @@ -36,7 +36,7 @@ import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentPro import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.papyrus.commands.util.OperationUtils; +import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState; import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; @@ -82,7 +82,7 @@ public class InteractionOverviewDiagramEditor extends UmlGmfDiagramEditor implem /** * @generated */ - private IUndoableOperation savedOperation = null; + private OperationHistoryDirtyState dirtyState; /** * @generated @@ -251,16 +251,37 @@ public class InteractionOverviewDiagramEditor extends UmlGmfDiagramEditor implem @Override public void doSave(final IProgressMonitor progressMonitor) { // The saving of the resource is done by the CoreMultiDiagramEditor - savedOperation = getOperationHistory().getUndoOperation(getUndoContext()); + getDirtyState().saved(); + } + + /** + * @generated + */ + protected OperationHistoryDirtyState getDirtyState() { + if(dirtyState == null) { + dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory()); + } + return dirtyState; } /** * @generated */ @Override + protected void setUndoContext(IUndoContext context) { + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + + super.setUndoContext(context); + } + + /** + * @generated + */ public boolean isDirty() { - final IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext()); - return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation); + return getDirtyState().isDirty(); } /** @@ -282,6 +303,11 @@ public class InteractionOverviewDiagramEditor extends UmlGmfDiagramEditor implem // remove preference listener PapyrusPaletteService.getInstance().removeProviderChangeListener(this); + if(dirtyState != null) { + dirtyState.dispose(); + dirtyState = null; + } + super.dispose(); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java index c26e0641afb..21ae68e821d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/part/UMLDiagramEditor.java @@ -15,7 +15,7 @@ package org.eclipse.papyrus.uml.diagram.profile.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -39,7 +39,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -91,7 +91,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -284,16 +284,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -314,6 +335,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java index d1fe20534ed..8deefe4168a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java @@ -15,7 +15,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -41,7 +41,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -94,7 +94,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -296,15 +296,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
}
/**
* @generated
*/
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -325,6 +347,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java index cf4ec8df06d..0c538db2e8e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java @@ -2,7 +2,7 @@ package org.eclipse.papyrus.uml.diagram.statemachine.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,7 +28,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -81,7 +81,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -296,6 +296,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
@@ -305,7 +311,30 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
}
/**
@@ -448,8 +477,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */
@Override
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLDiagramEditor.java index 3e0d0b16e95..fb409915420 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/src/org/eclipse/papyrus/uml/diagram/timing/part/UMLDiagramEditor.java @@ -10,6 +10,8 @@ package org.eclipse.papyrus.uml.diagram.timing.part; import java.util.EventObject;
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -34,6 +36,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.commands.util.OperationUtils;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -88,7 +91,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -285,16 +288,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(final IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- this.savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- final IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -315,7 +339,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
-
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/part/UMLDiagramEditor.java index e25fa848344..56862ac392d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/src/org/eclipse/papyrus/uml/diagram/usecase/part/UMLDiagramEditor.java @@ -15,7 +15,7 @@ package org.eclipse.papyrus.uml.diagram.usecase.part; import java.util.EventObject;
-import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -40,7 +40,7 @@ import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.commands.util.OperationUtils;
+import org.eclipse.papyrus.commands.util.OperationHistoryDirtyState;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
@@ -92,7 +92,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh /**
* @generated
*/
- private IUndoableOperation savedOperation = null;
+ private OperationHistoryDirtyState dirtyState;
/**
* @generated
@@ -288,16 +288,37 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override
public void doSave(IProgressMonitor progressMonitor) {
// The saving of the resource is done by the CoreMultiDiagramEditor
- savedOperation = getOperationHistory().getUndoOperation(getUndoContext());
+ getDirtyState().saved();
+ }
+
+ /**
+ * @generated
+ */
+ protected OperationHistoryDirtyState getDirtyState() {
+ if(dirtyState == null) {
+ dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory());
+ }
+ return dirtyState;
}
/**
* @generated
*/
@Override
+ protected void setUndoContext(IUndoContext context) {
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
+ super.setUndoContext(context);
+ }
+
+ /**
+ * @generated
+ */
public boolean isDirty() {
- IUndoableOperation op = getOperationHistory().getUndoOperation(getUndoContext());
- return savedOperation != op && OperationUtils.anyDirtyingAfter(getOperationHistory().getUndoHistory(getUndoContext()), savedOperation);
+ return getDirtyState().isDirty();
}
/**
@@ -318,6 +339,12 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener
// remove preference listener
PapyrusPaletteService.getInstance().removeProviderChangeListener(this);
+
+ if(dirtyState != null) {
+ dirtyState.dispose();
+ dirtyState = null;
+ }
+
super.dispose();
}
|