| 
| Hide and Show Figure on the fly [message #157059] | Sat, 06 November 2004 02:29  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: jsk_lam.hotmail.com 
 Hi,
 
 I want to allow users to show and hide certain figures on the fly.  Could
 someone please show me how to make the figures visible and invisible
 programmatically?  Also, if I make a figure invisible then will those
 connection links be automatically disappear as well?
 
 Thanks,
 SL.
 |  |  |  | 
|  | 
| 
| Re: Hide and Show Figure on the fly [message #157282 is a reply to message #157156] | Mon, 08 November 2004 10:39  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: gaslade.yahoo.com 
 Unfortunately it is not quite as easy as setVisible(boolean). This
 method will stop the part from visually show on the free form surface
 but it is still there....there is still an edit part for it. This means
 a couple of things
 
 1. If any hidden parts are off the current view port the user can still
 scroll the view port to these hidden parts.... and see nothing....which
 is confusing
 
 2. Accessibility gets screwed up. Although the parts do not show, you
 can still use the key board to navigate to them and the screen reader
 will still read what ever you have set up for it to read.
 
 What you really need to do is fool the GEF framework into thinking that
 there are no model objects for the hidden parts.... so no edit parts get
 created.
 
 The easy part of this is 'hidding' the nodes..Your container model
 object needs to be smart in its implementation of getChildren(). It
 needs to return a List of only children that are visible. But it will
 obviously have to be doing some internal bookkeeping so that it knows
 ALL of its children...both hidden and visible ones.
 
 The slightly harder part is handling connections..... if you 'hide' a
 node by tweaking the getChildren() method and one of the children you
 hide has connections drawn to or from it then suddenly there will be no
 source/target for the connection. GEF, by default will draw the the
 connection with the missing source/target by attaching the broken end to
 10,10 ( or is it 0,0 .... I can't remember ). So you end up with a
 connection that either comes from or goes to nowhere. So you also have
 to tweak the getSourceConnections() and getTargetConnections() methods
 so that if the source or target have been hidden then the connection
 model object does not get included in the returned list. Obviously if
 you are supporting filtering of connection types then the user could
 hide a connection type and your tweak would have to cater for this as well.
 
 Once you have tweaked these methods you need to get them invoked. In my
 case I have an object that knows when a filter setting has changed and
 fires an event that any container objects are listening for. The
 containers then figure out what their hidden and visible children are
 and fire a ChildrenAddedEvent and then a FilterEvent of mine.
 
 The ChildrenAddedEvent causes GEF to kick into action and the
 corresponding edit part will refresh the children. This takes care of
 the nodes
 
 The FilterEvent is caught by the edit parts and handled by calling
 refreshTargetConnections() and refreshSourceConnections(). This takes
 care of the connections
 
 Guy
 
 
 Kiril Mitov wrote:
 >
 > Try figure.setVisible(boolean). - works for me.
 >
 > You can call it in the refreshVisuals() method of the editPart.
 > SL wrote:
 >
 >> Hi,
 >
 >
 >> I want to allow users to show and hide certain figures on the fly.
 >> Could someone please show me how to make the figures visible and
 >> invisible programmatically?  Also, if I make a figure invisible then
 >> will those connection links be automatically disappear as well?
 >
 >
 >> Thanks,
 >> SL.
 >
 >
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03675 seconds