Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Delete link programatically
Delete link programatically [message #819062] Mon, 12 March 2012 12:52 Go to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hi!!

I am having some trouble in something I think it should be very simple. In my model, I have some links contained by some nodes.

What I want to do is to delete one of those links when a specific condition happens.

The problem comes when I try to delete the old link. I tried with this:

node.getLinks().remove(oldlink);


but the only thing it does is to remove the reference from the node to the link, that is, the link keeps existing but it does not belong to the node. So when I try to save the model, a message saying "Save could not be completed. Reason: The object 'linkImpl@whatever' is not contained in a resource" and the model cannot be saved.

I have tried in many different manners, but I never succeed.

How can I do to delete the link object, and not only the reference from its container?

Thanks in advance!
Re: Delete link programatically [message #819093 is a reply to message #819062] Mon, 12 March 2012 13:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Iban,

Aren't you using commands? A DeleteCommand should remove the object
from its container and remove all references to it...


On 12/03/2012 1:52 PM, Iban Ayestaran wrote:
> Hi!!
>
> I am having some trouble in something I think it should be very
> simple. In my model, I have some links contained by some nodes.
> What I want to do is to delete one of those links when a specific
> condition happens.
> The problem comes when I try to delete the old link. I tried with this:
> node.getLinks().remove(oldlink);
>
> but the only thing it does is to remove the reference from the node to
> the link, that is, the link keeps existing but it does not belong to
> the node. So when I try to save the model, a message saying "Save
> could not be completed. Reason: The object 'linkImpl@whatever' is not
> contained in a resource" and the model cannot be saved.
> I have tried in many different manners, but I never succeed.
> How can I do to delete the link object, and not only the reference
> from its container?
>
> Thanks in advance!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete link programatically [message #819117 is a reply to message #819093] Mon, 12 March 2012 14:19 Go to previous messageGo to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hi Ed,
How can I use commands? I am quite new in GMF and I don´t know how they are used...
I´ve tried with this:
DeleteCommand.create(getEditingDomain(), oldlink); 

but it doesn´t work...
Re: Delete link programatically [message #819774 is a reply to message #819117] Tue, 13 March 2012 10:04 Go to previous messageGo to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Well, after trying in several ways, this seems to work:
Command com = DeleteCommand.create(getEditingDomain(), oldconn);
if (com.canExecute()) {
     com.execute();
}


Is there a more polite way to do it or this is the correct one?

[Updated on: Tue, 13 March 2012 10:05]

Report message to a moderator

Re: Delete link programatically [message #819783 is a reply to message #819774] Tue, 13 March 2012 10:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Iban,

You must execute commands on the command stack so that they're properly
undoable.


On 13/03/2012 11:04 AM, Iban Ayestaran wrote:
> Well, after trying in several ways, this seems to work:
>
> Command com = DeleteCommand.create(getEditingDomain(), oldconn);
> if (com.canExecute()) {
> com.execute();
> }
>
>
> Is there a more polite way to do it or this is the correct one?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete link programatically [message #819784 is a reply to message #819783] Tue, 13 March 2012 10:22 Go to previous messageGo to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Excuse me Ed, I don´t understand you. What is the command stack?
Re: Delete link programatically [message #825789 is a reply to message #819784] Wed, 21 March 2012 09:06 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

you can get the command stack via your editing domain.

Ralph
Previous Topic:Constraint ocl
Next Topic:Symbol Positions inside Compartment
Goto Forum:
  


Current Time: Wed Apr 24 22:19:41 GMT 2024

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

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

Back to the top