Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » StrictCompoundCommand and TransactionalEditingDomain
StrictCompoundCommand and TransactionalEditingDomain [message #36786] Fri, 09 June 2006 18:18 Go to next message
Eclipse UserFriend
Originally posted by: vhirsl.gmail.com

Hi,
I am using CreateChildCommand to create a new child modeling element.
Since this is a CommandWrapper it will try to create an AddCommand when
canExecute is called. The createAddCommand method is overridden in
parent's ItemAdapterProvider to return a StrictCompoundCommand. Then
when canExecute is called on this compound command the first command is
actually executed without a transition being created and that causes an
IllegalStateException exception.

My question is: Is it possible to use StrictCompoundCommand-s with
TransactionalEditingDomain? If not, what would you suggest using instead
to create another modeling element before desired new element is created?

Before the CreateChildCommand the model looks like this:
M - PE
Desired model after the CreateChildCommand is executed:
M - PE - PE2 - CE

Thanks,
Vmir
Re: StrictCompoundCommand and TransactionalEditingDomain [message #36820 is a reply to message #36786] Fri, 09 June 2006 22:50 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Vladimir,

The StrictCompoundCommand is not compatible with the Transaction API,
because (as you indicated), it attempts to update the model while it is
expected only to be reading.

I would recommend having a look at the "trigger" mechanism to /post facto/
ensure that your model has the correct structure. A pre-commit
ResourceSetListener can provide additional commands, such as would insert
PE2 between PE and CE in your example. If it is unable to do so, then it
can throw a RollbackException to force the changes done so far to be
reverted.

If, however, it is not possible to even begin to create a CE in the model
without first creating and attaching a PE2, then you might have a look at
the Element Type API in GMF (esp. if your application already uses GMF).
This framework allows clients to extend all kinds of editing behaviours,
including element creation, in exactly the way that you need. Have a look
at how GMF's CreateElementRequest uses a GetEditContextRequest to obtain a
command that will create additional context elements (such as PE2) that
will be executed before the command to create CE. At the time of
constructing these commands, no model changes are actually performed: GMF
is simply determining what additional changes will be required to complete
the original creation request.

HTH,

Christian


Vmir wrote:

> Hi,
> I am using CreateChildCommand to create a new child modeling element.
> Since this is a CommandWrapper it will try to create an AddCommand when
> canExecute is called. The createAddCommand method is overridden in
> parent's ItemAdapterProvider to return a StrictCompoundCommand. Then
> when canExecute is called on this compound command the first command is
> actually executed without a transition being created and that causes an
> IllegalStateException exception.
>
> My question is: Is it possible to use StrictCompoundCommand-s with
> TransactionalEditingDomain? If not, what would you suggest using instead
> to create another modeling element before desired new element is created?
>
> Before the CreateChildCommand the model looks like this:
> M - PE
> Desired model after the CreateChildCommand is executed:
> M - PE - PE2 - CE
>
> Thanks,
> Vmir
Re: StrictCompoundCommand and TransactionalEditingDomain [message #580345 is a reply to message #36786] Fri, 09 June 2006 22:50 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Vladimir,

The StrictCompoundCommand is not compatible with the Transaction API,
because (as you indicated), it attempts to update the model while it is
expected only to be reading.

I would recommend having a look at the "trigger" mechanism to /post facto/
ensure that your model has the correct structure. A pre-commit
ResourceSetListener can provide additional commands, such as would insert
PE2 between PE and CE in your example. If it is unable to do so, then it
can throw a RollbackException to force the changes done so far to be
reverted.

If, however, it is not possible to even begin to create a CE in the model
without first creating and attaching a PE2, then you might have a look at
the Element Type API in GMF (esp. if your application already uses GMF).
This framework allows clients to extend all kinds of editing behaviours,
including element creation, in exactly the way that you need. Have a look
at how GMF's CreateElementRequest uses a GetEditContextRequest to obtain a
command that will create additional context elements (such as PE2) that
will be executed before the command to create CE. At the time of
constructing these commands, no model changes are actually performed: GMF
is simply determining what additional changes will be required to complete
the original creation request.

HTH,

Christian


Vmir wrote:

> Hi,
> I am using CreateChildCommand to create a new child modeling element.
> Since this is a CommandWrapper it will try to create an AddCommand when
> canExecute is called. The createAddCommand method is overridden in
> parent's ItemAdapterProvider to return a StrictCompoundCommand. Then
> when canExecute is called on this compound command the first command is
> actually executed without a transition being created and that causes an
> IllegalStateException exception.
>
> My question is: Is it possible to use StrictCompoundCommand-s with
> TransactionalEditingDomain? If not, what would you suggest using instead
> to create another modeling element before desired new element is created?
>
> Before the CreateChildCommand the model looks like this:
> M - PE
> Desired model after the CreateChildCommand is executed:
> M - PE - PE2 - CE
>
> Thanks,
> Vmir
Previous Topic:StrictCompoundCommand and TransactionalEditingDomain
Next Topic:How do you make an untracked change?
Goto Forum:
  


Current Time: Sun May 19 05:18:00 GMT 2024

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

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

Back to the top