Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Combining EMF Commands and Text Editor operations
Combining EMF Commands and Text Editor operations [message #1075319] Mon, 29 July 2013 08:20 Go to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi,

I have a multi page editor . One tab has a model and another one has a corresponding source
I trigger an EMF AddCommand (A1) in the model editor followed by a text operation (T1) (Initiated by the text editor editor framework).

Then I have number of set commands (S1...S3) depending upon some condition. (for e.g. on page change)

Like this A1->T1->S1->S2->S3

Now I would like to have undo/redo for a transaction shown as the sequence above. How this can this be achieved in a better way. Both text operation and EMF model commands have to work seamlessly.

The framework must revert in the above order starting from S3.

Do I have to put all the commands in the Compound Command. In that case how can I achieve the text operation synchronization ?.

Cheers,
Saurav


Re: Combining EMF Commands and Text Editor operations [message #1075332 is a reply to message #1075319] Mon, 29 July 2013 08:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Saurav,

Comments below.

On 29/07/2013 10:20 AM, saurav sarkar wrote:
> Hi,
>
> I have a multi page editor . One tab has a model and another one has a
> corresponding source
> I trigger an EMF AddCommand (A1) in the model editor followed by a
> text operation (T1) (Initiated by the text editor editor framework).
> Then I have number of set commands (S1...S3) depending upon some
> condition. (for e.g. on page change)
>
> Like this A1->T1->S1->S2->S3
>
> Now I would like to have undo/redo for a transaction shown as the
> sequence above. How this can this be achieved in a better way. Both
> text operation and EMF model commands have to work seamlessly.
I've never looked at solving that problem. Each has their own command
stack but you need for there to be one command stack.
>
> The framework must revert in the above order starting from S3.
>
> Do I have to put all the commands in the Compound Command.
Each separately undoable thing needs to be part of a single command in
EMF's command stack.
> In that case how can I achieve the text operation synchronization ?.
Perhaps you should try to use EMF's command stack with commands to
encapsulate the text actions so that an undo on that command will undo
the text action or call the text editor's command stack to undo it. As
I said, I've never looked into how to solve such a problem...
>
> Cheers,
> Saurav
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Combining EMF Commands and Text Editor operations [message #1075529 is a reply to message #1075319] Mon, 29 July 2013 15:31 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Thanks for the comments Ed.

I could achieve the same by using Compound Command and overriding the doUndo() method to undo the text editor stack changes.

Just a curiosity on what would EMFCompositeOperation and NonEMFTransaction in org.eclipse.emf.workspace plugin are used for ?any sample implementation done on those ?

cheers,
Saurav


Re: Combining EMF Commands and Text Editor operations [message #1075531 is a reply to message #1075529] Mon, 29 July 2013 15:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Saurav,

Comments below.

On 29/07/2013 5:31 PM, saurav sarkar wrote:
> Thanks for the comments Ed.
>
> I could achieve the same by using Compound Command and overriding the
> doUndo() method to undo the text editor stack changes.
Yes. I'm not sure how you're doing the text change itself right now,
but it should be part of the doExecute and then you reverse the effect
in doUndo...
>
> Just a curiosity on what would EMFCompositeOperation and
> NonEMFTransaction in org.eclipse.emf.workspace plugin are used for ?
I can't really comment on the transaction framework because I have
pretty much no experience with that. Maybe someone else will answer...
> any sample implementation done on those ?
>
> cheers,
> Saurav


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Combining EMF Commands and Text Editor operations [message #1075548 is a reply to message #1075531] Mon, 29 July 2013 16:11 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Yes i forgot to mention about the actual text change.
Its done as you mentioned.

cheers,
Saurav


Re: Combining EMF Commands and Text Editor operations [message #1075628 is a reply to message #1075529] Mon, 29 July 2013 19:29 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Saurav,

EMFCompositeOperation is an IUndoableOperation (as defined by the
Eclipse Operation History API) that aggregates multiple discrete
operations on EMF models/editing-domains. It is analogous to the
CompoundCommand in EMF.Edit.

The NonEMFTransaction is intended to encapsulate undoable state changes
in stuff that is not EMF model content, to embed it in an EMF
transaction's change description for undo/redo. Updates to the state
of UI components is an example of what this is intended to capture.

As far as I recall (it has been several years, now) the
NonEMFTransaction is supposed only to be used internally by the
TransactionalEditingDomain, but I could be wrong. I don't there is
public API for creating and manipulating these transactions ... A
search of the code would answer that for you.

HTH,

Christian


On 2013-07-29 15:31:29 +0000, saurav sarkar said:

> Thanks for the comments Ed.
>
> I could achieve the same by using Compound Command and overriding the
> doUndo() method to undo the text editor stack changes.
>
> Just a curiosity on what would EMFCompositeOperation and
> NonEMFTransaction in org.eclipse.emf.workspace plugin are used for ?any
> sample implementation done on those ?
>
> cheers,
> Saurav
Previous Topic:Regenerating Ecore from XSD
Next Topic:where could I get map file of EMF?
Goto Forum:
  


Current Time: Thu Apr 25 23:33:58 GMT 2024

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

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

Back to the top