Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Clear the undo history within a command
Clear the undo history within a command [message #705179] Fri, 29 July 2011 10:38 Go to next message
baudryvincent is currently offline baudryvincent
Messages: 5
Registered: July 2011
Junior Member
Hi,

I'm in a case where I use a Command that triggers some checking. In some cases, I want to clear the undo history to not let the user make an undo.

As I am within a Command, and this command is still not added to the UndoHistory, if I use for instance :
OperationHistoryFactory.getOperationHistory().dispose(new EditingDomainUndoContext(getEditingDomain()), true, true, true);

It won't work, as it will clear the history but the current command will still be added to it after it's finished.

What would be the best way to clear the UndoHistory after the current command ? If I create another command I will have the same issue over and over again. I tried to use an CommandStackListener or a IOperationHistoryListener, but using those kind of listeners will be slow things heavily, plus it's very complicated to filter the good kind of event (not much relevant information in them) to know when I have to clear the history, given my workflow.

Feel free to give me some advice, maybe I'm not seeing something simple ?

Thanks a lot !
Re: Clear the undo history within a command [message #705620 is a reply to message #705179] Sat, 30 July 2011 01:00 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad Bandaru
Messages: 98
Registered: March 2010
Location: Hyderabad
Member

i am assuming that comand execution happens in a display thread.. so when u run the clear history code inside display async thread (Display.Default.asyncExexc()) it will be executed when the ui thread is free. ui thread becomes free only after current command execution is finished which will ensure that current command is also cleared in the clear history action..

Re: Clear the undo history within a command [message #707955 is a reply to message #705620] Tue, 02 August 2011 05:11 Go to previous message
baudryvincent is currently offline baudryvincent
Messages: 5
Registered: July 2011
Junior Member
Alright, will try that, thanks !
Previous Topic:How to add shape in GEF editor using BPMN2
Next Topic:How to avoid Overlapping of components/figure
Goto Forum:
  


Current Time: Fri Jul 25 03:05:08 EDT 2014

Powered by FUDForum. Page generated in 0.03143 seconds