Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ResourceUndoContext has default Undo limit in DefaultOperationHistory
ResourceUndoContext has default Undo limit in DefaultOperationHistory [message #1561838] Tue, 13 January 2015 10:26 Go to next message
Ais OGorman is currently offline Ais OGormanFriend
Messages: 2
Registered: June 2012
Junior Member
Hi

My project uses the DefaultOperationHistory, and I am currently trying to set an undo limit for my own editor's UndoContext.

My limit is correctly being set for my UndoContext but my operation has 2 UndoContexts. One of these is the ResourceUndoContext and the other is my own UndoContext. But the ResourceUndoContext (which contains my affected resource) is being removed from the operation by the method forceUndoLimit() because it only has the default limit for Undo.
I want to either, not remove the ResourceUndoContext by changing code in forceUndoLimit (which is hacky, I think) or try to figure out a way to add the same limit for the ResourceUndoContext as my own UndoContext.

I've started down the path of extending the WorkspaceCommandStackImpl, copying in the DomainListener and creating my own DomainListener which will add an undo limit for the ResourceUndoContext when it is created.

Is this the best way to resolve this? Thanks for any help in advance.
Re: ResourceUndoContext has default Undo limit in DefaultOperationHistory [message #1562554 is a reply to message #1561838] Tue, 13 January 2015 19:40 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

Two ResourceUndoContexts are equal if they reference the same Resource.
So, if your editor knows a priori the resources that it edits (which
it probably does), it can create ResourceUndoContexts on those
resources to set their undo limits.

Just be sure to flush all of those ResourceUndoContexts when your
editor is closed, otherwise the contexts and the resources that they
reference will leak: the history will keep them in its 'limits' map
forever.

HTH,

Christian


On 2015-01-13 13:18:07 +0000, Ais OGorman said:

> Hi
>
> My project uses the DefaultOperationHistory, and I am currently trying
> to set an undo limit for my own editor's UndoContext.
>
> My limit is correctly being set for my UndoContext but my operation has
> 2 UndoContexts. One of these is the ResourceUndoContext and the other
> is my own UndoContext. But the ResourceUndoContext (which contains my
> affected resource) is being removed from the operation by the method
> forceUndoLimit() because it only has the default limit for Undo. I want
> to either, not remove the ResourceUndoContext by changing code in
> forceUndoLimit (which is hacky, I think) or try to figure out a way to
> add the same limit for the ResourceUndoContext as my own UndoContext.
> I've started down the path of extending the WorkspaceCommandStackImpl,
> copying in the DomainListener and creating my own DomainListener which
> will add an undo limit for the ResourceUndoContext when it is created.
> Is this the best way to resolve this? Thanks for any help in advance.
Re: ResourceUndoContext has default Undo limit in DefaultOperationHistory [message #1565647 is a reply to message #1562554] Thu, 15 January 2015 11:56 Go to previous message
Ais OGorman is currently offline Ais OGormanFriend
Messages: 2
Registered: June 2012
Junior Member
Hi Chrisian

Thanks a million - what an easy solution!
I didn't realise ResourceUndoContexts were equal if they refer to the same resource.

Aisling
Previous Topic:AbstractEnumeratorExternalizeable; no valid constructor
Next Topic:create dynamic instances from an .ecore
Goto Forum:
  


Current Time: Fri Apr 19 23:34:27 GMT 2024

Powered by FUDForum. Page generated in 0.02974 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top