Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with programmatic use of EMF undo operations #9

Open
pcdavid opened this issue Sep 4, 2022 · 1 comment
Open

Problem with programmatic use of EMF undo operations #9

pcdavid opened this issue Sep 4, 2022 · 1 comment
Labels
bugzilla Issues migrated from the old Eclipse Bugzilla

Comments

@pcdavid
Copy link
Contributor

pcdavid commented Sep 4, 2022

  • πŸ†” Bugzilla ID: #283563
  • πŸ“˜ Project: Modeling / EMF Services / Transaction
  • πŸ—“ Created: 2009-07-15T14:51:20Z
  • ❓ Status: NEW /
@pcdavid pcdavid added the bugzilla Issues migrated from the old Eclipse Bugzilla label Sep 4, 2022
@pcdavid
Copy link
Contributor Author

pcdavid commented Sep 4, 2022

Comment #0 on Wed Jul 15 2009 16:51:20 GMT+0200 (Central European Summer Time):

Build ID: 3.4.2.v200902111700

Steps To Reproduce:
1. Use the following code snippet to execute 26 undoable operations

    TransactionalEditingDomain domain = UMLModeler.getEditingDomain();
    IOperationHistory history = ((IWorkspaceCommandStack)domain.getCommandStack()).getOperationHistory();
    IUndoContext undoContext = ((IWorkspaceCommandStack)domain.getCommandStack()).getDefaultUndoContext();
    history.setLimit(undoContext, 3);

    // Loop
        IUndoableOperation undoableOperation = new MyUndoableOperation(); // MyUndoableOperation extends AbstractTransactionalCommand
        undoableOperation.addContext(undoContext);
        IStatus iStatus = history.execute(undoableOperation, monitor, null);
    // End of loop	

2. Select Edit->Undo <my AbstractTransactionalCommand label>
   Because I have set the history limit to 3, I would expect to be able to undo 3 times but it works for 20 times before being disabled.     
   If I set the limit to 26, the Undo can only be clicked on 20 times.

More information:

Comment #1 on Wed Jul 15 2009 22:09:04 GMT+0200 (Central European Summer Time):

It sounds to me as if the undo context used by the UMLModeler's command stack is not the same undo context that is active in the editor.  When you use Edit->Undo, it is going to operate on the editing context of the active editor.

Perhaps you could load org.eclipse.ui.examples.undo and use the UndoHistoryView to help show what is going on here.  

Comment #2 on Thu Jul 16 2009 13:43:56 GMT+0200 (Central European Summer Time):

Thanks for the pointer. The UndoHistoryView example proved useful in that it showed that all of my undoableoperations were tagged with the default undo context but only the first 20 were also tagged with the EditingDomainUndoContext!
Tried applying EditingDomainUndoContext explicitly to all my undoableoperations to no avail.
The solution was to extend my undoableoperation from AbstractEMFOperation and not from AbstractTransactionalCommand.

Comment #3 on Thu Jul 16 2009 15:13:06 GMT+0200 (Central European Summer Time):

Please ignore my previous comment.
When the view for the UndoHistoryView example was open it resolved the issue as it registers an undoActionHandler for the workbench Edit->Undo toolbar action. 
My plugin does not have a view or editor open when it is making changes to the UML model so I wont be able to supply actionHandlers.
I still don't understand why only the first 20 of my undoableoperations are tagged with EditingDomainUndoContext!

I need to investigate further. 

Comment #4 on Thu Jul 16 2009 17:50:27 GMT+0200 (Central European Summer Time):

I'm going to reroute this bug to EMF because it sounds like the interaction involves EMF's use of platform undo, not an inherent bug in the undo history.  


Comment #5 on Sat May 14 2022 15:51:34 GMT+0200 (Central European Summer Time):

Eclipse EMF Transaction is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/emf-transaction.

If this issue is relevant to you and still present in the latest release:

* Create a new issue at https://github.com/eclipse/emf-transaction/issues/.
  * Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience)
  * In the GitHub description, start with a link to this bugzilla ticket
  * Optionally add new content to the description if it can helps towards resolution
* Update bugzilla ticket
  * Add to "See also" property (up right column) the link to the newly created GitHub issue
  * Add a comment "Migrated to <link-to-newly-created-GitHub-issue>"
  * Set status as CLOSED MOVED

All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for EMF Transaction will be archived and made read-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from the old Eclipse Bugzilla
Projects
None yet
Development

No branches or pull requests

1 participant