Setting visibility of nodes - problems with edges [message #67363] |
Sun, 22 October 2006 15:02 |
Eclipse User |
|
|
|
Originally posted by: jan.herriger.gmx.de
Hello,
I've added an action to the diagram content navigator, wich allows me to
select model elements and to show/hide them in the diagram
(corresponding edges should be hidden too).
This works well for nodes. But the behavior of edges seems strange to me:
1. Hiding a node results in hiding all target egdes. But only one source
egde gets hidden (while all edges have visible="false").
2. Setting the visibility of a hidden node back to true results in edges
appearing in the upper left corner, not connected to any nodes (visually).
Everything is fine, when I reopen the diagram.
Any ideas where the mistake is?
Following code is executed:
protected CommandResult doExecuteWithResult(
IProgressMonitor progressMonitor, IAdaptable info)
throws ExecutionException {
boolean visible = !this.selectedView.isVisible();
List sources = this.selectedView.getSourceEdges();
List targets = this.selectedView.getTargetEdges();
for (Object o : sources)
{
((Edge)o).setVisible(visible);
}
for (Object o : targets)
{
((Edge)o).setVisible(visible);
}
this.selectedView.setVisible(visible);
return CommandResult.newOKCommandResult();
}
Best regards,
Jan
|
|
|
Re: Setting visibility of nodes - problems with edges [message #68100 is a reply to message #67363] |
Mon, 23 October 2006 17:20 |
Mohammed Mostafa Messages: 143 Registered: July 2009 |
Senior Member |
|
|
Hi Jan ;
Setting the view visibility to false will result in the removal of the
view's edit part from the diagram.
As a result all connected edges to this view should disappear from the
diagram surface regardless of their visibility status, otherwise these
edges will be pointing to/from nowhere and might show up in the upper
left corner.
To achieve this, refresh had to be called on any edit part connected to
the edit part being removed.
Shape compartments do this by using a ConnectionRefreshMgr take a look
at ShapeCompartmentEditPart#ConnectionRefreshMgr
I'm guessing that in your case the views are direct children of the
diagram, not inside a shape compartment.
What i suggest is, just set your nodes visibility to false no need to
change the visibility in the edges for now. Place a break point in
refresh method in AbstractGraphicalEditPart, make sure it get called on
any edit parts that is connected to the edit part being removed.
for example : if your diagram looks like this
A --> B
|---> C
|<--- D
Setting the visibility on A to false ; should result in refreshing B,C and D
If this is not the case; then this is a bug in GMF runtime
Jan Herriger wrote:
> Hello,
>
> I've added an action to the diagram content navigator, wich allows me to
> select model elements and to show/hide them in the diagram
> (corresponding edges should be hidden too).
>
> This works well for nodes. But the behavior of edges seems strange to me:
>
> 1. Hiding a node results in hiding all target egdes. But only one source
> egde gets hidden (while all edges have visible="false").
>
> 2. Setting the visibility of a hidden node back to true results in edges
> appearing in the upper left corner, not connected to any nodes (visually).
>
> Everything is fine, when I reopen the diagram.
>
> Any ideas where the mistake is?
>
>
> Following code is executed:
>
> protected CommandResult doExecuteWithResult(
> IProgressMonitor progressMonitor, IAdaptable info)
> throws ExecutionException {
>
> boolean visible = !this.selectedView.isVisible();
> List sources = this.selectedView.getSourceEdges();
> List targets = this.selectedView.getTargetEdges();
> for (Object o : sources)
> {
> ((Edge)o).setVisible(visible);
> }
> for (Object o : targets)
> {
> ((Edge)o).setVisible(visible);
> }
> this.selectedView.setVisible(visible);
> return CommandResult.newOKCommandResult();
> }
>
> Best regards,
> Jan
|
|
|
Re: Setting visibility of nodes - problems with edges [message #1458167 is a reply to message #67363] |
Sat, 01 November 2014 04:01 |
Jimmy Lu Messages: 11 Registered: October 2014 |
Junior Member |
|
|
Is there a solution to this problem? I ran into similar problem except in my case I do not change the visibility of edges and the edges disappear after I toggle the visibility of nodes. Reopen the diagram and everything is OK.
If look at the DiagramEditPart, I can find that when the nodes are invisible, all the edges linked to them are detached from the EditPart, but when I set the node back to visible, the links are not added back. Is this a bug in GMF?
[Updated on: Sat, 01 November 2014 05:24] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03284 seconds