Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Remove referenced nodes
Remove referenced nodes [message #210742] Fri, 07 November 2008 14:04 Go to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
Hello!

I want to remove the nodes, referenced by a selected node (and all the
links).

The question is: how to better do this?

There are generally 2 ways to go:

1. Through the model
2. Working just with the graphical nodes.

In 1-st case I should remove the corresponding elements from the model,
using a RecordingCommand. But how to do this right?

In the 2-nd case I need to remove the node from the view. Is there any
way to do so?

And which way is better and more correct?

Thanks!

Viktor Kazakov
Re: Remove referenced nodes [message #210804 is a reply to message #210742] Mon, 10 November 2008 12:01 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Viktor,

> I want to remove the nodes, referenced by a selected node (and all the
> links).
you can do something like:

EditPart editPart = (EditPart) getHost().getViewer().getEditPartRegistry().get(view);
DestroyElementRequest request = new DestroyElementRequest(getEditingDomain(),
false);
Command cmd = editPart.getCommand(new EditCommandRequestWrapper(request,
Collections.EMPTY_MAP));

and then execute this command.

> In the 2-nd case I need to remove the node from the view. Is there any
> way to do so?
In GMF we have two different kind of diagrams - synchronized and non-synchronized.
Content of the synchronized diagram will always reflect actual model content,
so you can not remove only visual representation of the node from there.
If you have non-synchronized diagram then content of thsi diagram should
be managed externally (in this case yu can remove only visual representation
of the node keeping the node in a model.

-----------------
Alex Shatalin
Re: Remove referenced nodes [message #210863 is a reply to message #210804] Tue, 11 November 2008 10:23 Go to previous messageGo to next message
Viktor Kazakov is currently offline Viktor KazakovFriend
Messages: 14
Registered: July 2009
Junior Member
> you can do something like:
>
> EditPart editPart = (EditPart)
> getHost().getViewer().getEditPartRegistry().get(view);
> DestroyElementRequest request = new
> DestroyElementRequest(getEditingDomain(), false);
> Command cmd = editPart.getCommand(new
> EditCommandRequestWrapper(request, Collections.EMPTY_MAP));
>
> and then execute this command.
Cool! Maybe I can create the element in a similar way? That is what I
was asking about just a moment before.

> In GMF we have two different kind of diagrams - synchronized and
> non-synchronized. Content of the synchronized diagram will always
> reflect actual model content, so you can not remove only visual
> representation of the node from there.
> If you have non-synchronized diagram then content of thsi diagram
> should be managed externally (in this case yu can remove only visual
> representation of the node keeping the node in a model.
For now I think I just can make nodes non-visible and use synchronized
model (thanks for the hint before!). But in future maybe we'll have to
switch to non-synchronized model to get more fine-grained control. Is
there any manual / tutorial on non-synchronized model?

Viktor
Re: Remove referenced nodes [message #210880 is a reply to message #210863] Tue, 11 November 2008 11:21 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Viktor,

> Cool! Maybe I can create the element in a similar way? That is what I
> was asking about just a moment before.
Try using "CreateElementRequest".

> switch to non-synchronized model to get more fine-grained control. Is
> there any manual / tutorial on non-synchronized model?
Unfortunately now. But in general you should just switch one property in
a .genmodel and regenerate the code. As a result diagram synchronization
will be switched off. In addition you can find this document useful http://wiki.eclipse.org/GMF_GenModel_Hints.

-----------------
Alex Shatalin
Previous Topic:Cannot open logic example diagram
Next Topic:Shared Editing Domain disposed when closing editor
Goto Forum:
  


Current Time: Thu Sep 19 06:56:59 GMT 2024

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

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

Back to the top