Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Change a reference from the owner, after creating a new object in one command (EMF/GEF/GMF)?
Change a reference from the owner, after creating a new object in one command (EMF/GEF/GMF)? [message #484468] Mon, 07 September 2009 15:21 Go to next message
Eclipse UserFriend
Originally posted by: dennis.freese.gmx.net

Hello all,

I'm a bit confused about the command handling in EMF/GEF/GMF. Maybe
somebody can help me with that.

My problem is, I want to set a reference of the owner object after
creating a new object.
For example: When a new object o1 is created it should be added to the
owners list(this is automatically done) and also the owners reference
owner.startObject should also be set. (I can't do it in the creation
command, because of an exception with the historyStack). This is clear.

I know if a new object will be created then a XXXCreateCommand will be
called. This is a GMF-Command.
If an attribute/reference in the property editor will be changed an EMF
command will be created.
Why is the first command a gmf and the second one an emf one?
It should be better if they were both gmf commands, or isn't it?

It is possible to create a CompoundCommand with a new XXXCreateCommand
and adding a SetValueCommand, but how can I get the created object when
creating the setValueCommand? The command isn't executed when creating it.

Maybe I have to write a new command which is derived from
AbstractCommand? Or maybe from the gmf/emf command
AbstractTransactionalCommand? When I try this, where I have to integrate
it? Is the XXXItemSemanticEditPolicy the correct place?

After looking in the newsgroups and some website's (e.g.
http://help.eclipse.org/galileo/index.jsp,
http://wiki.eclipse.org/index.php/GMF_Tips#Creating_New_Elem ents_And_Corresponding_Views),
I found very much posts and hints but no answers to the questions. Maybe
I don't see the answer after reading much entries.

Help is very appreciated. I will be grateful to get answers.

With best regards

Dennis
Re: Change a reference from the owner, after creating a new object inone command (EMF/GEF/GMF)? [message #484819 is a reply to message #484468] Wed, 09 September 2009 12:41 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Dennis,

First of all, if you need to set additional refrence of the parent element
to point to the child one - try specifying this reference as "childrenFeature"
in a corresponding NodeReference.

> owner.startObject should also be set. (I can't do it in the creation
> command, because of an exception with the historyStack). This is
Can you post this exception here?

I suggest you modifying GMF-generated ???CreateCommand (but i suppose the
best solution is to use GMF way to set this reference for the created element
- see above).

-----------------
Alex Shatalin
Re: Change a reference from the owner, after creating a new object inone command (EMF/GEF/GMF)? [message #484881 is a reply to message #484819] Wed, 09 September 2009 15:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dennis.freese.gmx.net

Hello Alex,

I have tried to reproduce my error to get the exception, but no error
occurs. So I think my problem is resolved. :)

I want to ask you if you have some information about my further
questions like:

It is possible to create a CompoundCommand with a new XXXCreateCommand
and adding a SetValueCommand. But how can I get the created object when
creating the setValueCommand? The command isn't executed when creating it.
Is this possible or is this way of using a CompoundCommand not correct?

When I want to write a special command and I derive it from
AbstractTransactionalCommand, where I have to integrate it? Is the
XXXItemSemanticEditPolicy the correct place?

I think there aren't much informations about this topic.
Maybe you have some hints, like a website so I can get the information.

Thank you very much

Dennis


Alex Shatalin schrieb:
> Hello Dennis,
>
> First of all, if you need to set additional refrence of the parent
> element to point to the child one - try specifying this reference as
> "childrenFeature" in a corresponding NodeReference.
>
>> owner.startObject should also be set. (I can't do it in the creation
>> command, because of an exception with the historyStack). This is
> Can you post this exception here?
>
> I suggest you modifying GMF-generated ???CreateCommand (but i suppose
> the best solution is to use GMF way to set this reference for the
> created element - see above).
>
> -----------------
> Alex Shatalin
>
>
Re: Change a reference from the owner, after creating a new object inone command (EMF/GEF/GMF)? [message #484882 is a reply to message #484881] Wed, 09 September 2009 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dennis.freese.gmx.net

Hello Alex,

I also tried your approach, but this didn't work. I have one main object
(where all elements from this editor will be saved). Additionally I have
a list with objects (containments) and a reference which I want set to a
new object (when it is a special type).
When I try your hint with the "childrenFeature" I don't have the option
to set the reference from the main object.

thanks for your answers.

Dennis


Dennis F schrieb:
> Hello Alex,
>
> I have tried to reproduce my error to get the exception, but no error
> occurs. So I think my problem is resolved. :)
>
> I want to ask you if you have some information about my further
> questions like:
>
> It is possible to create a CompoundCommand with a new XXXCreateCommand
> and adding a SetValueCommand. But how can I get the created object when
> creating the setValueCommand? The command isn't executed when creating it.
> Is this possible or is this way of using a CompoundCommand not correct?
>
> When I want to write a special command and I derive it from
> AbstractTransactionalCommand, where I have to integrate it? Is the
> XXXItemSemanticEditPolicy the correct place?
>
> I think there aren't much informations about this topic.
> Maybe you have some hints, like a website so I can get the information.
>
> Thank you very much
>
> Dennis
>
>
> Alex Shatalin schrieb:
>> Hello Dennis,
>>
>> First of all, if you need to set additional refrence of the parent
>> element to point to the child one - try specifying this reference as
>> "childrenFeature" in a corresponding NodeReference.
>>
>>> owner.startObject should also be set. (I can't do it in the creation
>>> command, because of an exception with the historyStack). This is
>> Can you post this exception here?
>>
>> I suggest you modifying GMF-generated ???CreateCommand (but i suppose
>> the best solution is to use GMF way to set this reference for the
>> created element - see above).
>>
>> -----------------
>> Alex Shatalin
>>
>>
Re: Change a reference from the owner, after creating a new objectinone command (EMF/GEF/GMF)? [message #484907 is a reply to message #484881] Wed, 09 September 2009 16:22 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Dennis,

Newly created element will be wrapped into CommandResult returned from ???CreateCommand.doExecuteWithResult()
method.
If your command is the next in a CompositeTransactionalCommand, so you can
access resulting value by calling CompositeTransactionalCommand.getCommandResult(),
but I recommend you patching GMF-generated ???CreateCommand.

-----------------
Alex Shatalin
Previous Topic:read-only DiagramEditor / disableEditMode()
Next Topic:Reacting to changes in other resources in the same TransactionalEditingDomain
Goto Forum:
  


Current Time: Fri Sep 20 15:43:51 GMT 2024

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

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

Back to the top