Visual folding editor - how? [message #169490] |
Wed, 23 February 2005 15:18  |
Eclipse User |
|
|
|
Originally posted by: alan.battersby.ntlworld.com
I would like to create subfigures in a graph that can be expanded when
selected or folded back down to an icon from the its expanded view.
Unfortunately I am new to gef and this task has exposed holes in my
understanding of how gef works. My understanding is that upon
initialisation figures are associated with editparts and that figure
creation only occurs once. My initial idea was that there should be two
figures associated with an editpart to represent its folded and unfolded
state so that switching state changes the figure to be displayed. Upon
unfolding I am assuming that I would have to add all the editparts
children to the graph, and remove them on folding up again. So how can I
associate two figures with the same editpart or do I need two editparts
one for folded and one for unfolded. I am assuming that folding is only
a visual attribute and should not change the structure of the associated
model.
I am sure that mine is a naive view so can anyone enlighten me as to the
best way of doing this and are there any examples ?
Alan
|
|
|
Re: Visual folding editor - how? [message #169505 is a reply to message #169490] |
Wed, 23 February 2005 18:17   |
Eclipse User |
|
|
|
Originally posted by: d.ozsen.blueyonder.co.uk
Yes, your idea of using two different figures for the different states
(folded and unfolded) is a good one. HOWEVER, you shouldn't add or
remove EditParts just for showing or hiding something. The way you've
got to think about it is that the things that you're showing/hiding are
always there, just that when they're hidden they are not shown. An
EditPart should only be removed when its corresponding element in the
model is removed. So, as you identified correctly, folding is only a
visual thing, because as far as I understood you are using this only for
presentational purposes, so keep it out of the model.
There are several ways in which you could fold your figures. The two
ways I can think of right now are (1) changing the size (the bounds) of
the figure containing the subfigures you want to fold away, in such a
way that they're just clipped away, or (2) use the setVisible(boolean)
method. You might have to fiddle around with the figure's preferred size
and/or the LayoutManagers you're using to be able to do the sizing. Also
I don't know how exactly the setVisible method behaves (eg what happens
to the children of the figure, what happens to the spacing of other
figures placed next to the hidden figure etc).
I am still fairly new to GEF and draw2D, so if there's anything wrong
with what I said, someone please correct me! Hope this helped though.
D
Alan Battersby wrote:
> I would like to create subfigures in a graph that can be expanded when
> selected or folded back down to an icon from the its expanded view.
> Unfortunately I am new to gef and this task has exposed holes in my
> understanding of how gef works. My understanding is that upon
> initialisation figures are associated with editparts and that figure
> creation only occurs once. My initial idea was that there should be two
> figures associated with an editpart to represent its folded and unfolded
> state so that switching state changes the figure to be displayed. Upon
> unfolding I am assuming that I would have to add all the editparts
> children to the graph, and remove them on folding up again. So how can I
> associate two figures with the same editpart or do I need two editparts
> one for folded and one for unfolded. I am assuming that folding is only
> a visual attribute and should not change the structure of the associated
> model.
>
> I am sure that mine is a naive view so can anyone enlighten me as to the
> best way of doing this and are there any examples ?
>
> Alan
--
Deniz Ozsen
Pers Mail: d.ozsen [at] blueyonder.co.uk
Academ Mail: d.ozsen [at] ucl.ac.uk
Web: http://ozsen.pwp.blueyonder.co.uk
UCL Page: http://www.cs.ucl.ac.uk/students/D.Ozsen
|
|
|
Re: Visual folding editor - how? [message #169522 is a reply to message #169505] |
Thu, 24 February 2005 02:23   |
Eclipse User |
|
|
|
Deniz Özsen schrieb:
> Yes, your idea of using two different figures for the different states
> (folded and unfolded) is a good one. HOWEVER, you shouldn't add or
> remove EditParts just for showing or hiding something.
Why not? EditParts arn't model elements. They are the controlers in the
MVC thing.
> The way you've
> got to think about it is that the things that you're showing/hiding are
> always there, just that when they're hidden they are not shown.
Well, that doesn't scale for large trees. Imagine the Windows Explorer
would create items for all folders in the system and just hide them if a
tree is folded.
> An
> EditPart should only be removed when its corresponding element in the
> model is removed.
No. You can use EditParts to build a totaly different view than just a
plain 1:1 mapping to model elements.
> So, as you identified correctly, folding is only a
> visual thing, because as far as I understood you are using this only for
> presentational purposes, so keep it out of the model.
Yes, folding should be kept out of the model but EditParts arn't the model.
IMHO a simple solution would be to add the folding state to the
EditParts. If an EditPart is folded, it has no children
(getModelChildren returns an empty list). The figure must also have a
folding state and will paint differently if it is expanded or folded.
Cu, Gunnar
|
|
|
Re: Visual folding editor - how? [message #169544 is a reply to message #169522] |
Thu, 24 February 2005 05:37   |
Eclipse User |
|
|
|
Originally posted by: d.ozsen.blueyonder.co.uk
That's a very good idea, Gunner. Sorry for giving my slightly naive
view, I'm still quite new to the MVC concept. This has opened my eyes a
bit, and should be of some help to Alan. Just remember that when folding
up a figure, you need to do two things: remove the children EditParts
AND make the getModelChildren method return an empty list, so you
maintain the integrity of the controller. And of course you need to make
the necessary changes to your Figure.
Regards,
D
Gunnar Wagenknecht wrote:
> Deniz Özsen schrieb:
>
>>Yes, your idea of using two different figures for the different states
>>(folded and unfolded) is a good one. HOWEVER, you shouldn't add or
>>remove EditParts just for showing or hiding something.
>
>
> Why not? EditParts arn't model elements. They are the controlers in the
> MVC thing.
>
>
>>The way you've
>>got to think about it is that the things that you're showing/hiding are
>>always there, just that when they're hidden they are not shown.
>
>
> Well, that doesn't scale for large trees. Imagine the Windows Explorer
> would create items for all folders in the system and just hide them if a
> tree is folded.
>
>
>>An
>>EditPart should only be removed when its corresponding element in the
>>model is removed.
>
>
> No. You can use EditParts to build a totaly different view than just a
> plain 1:1 mapping to model elements.
>
>
>>So, as you identified correctly, folding is only a
>>visual thing, because as far as I understood you are using this only for
>>presentational purposes, so keep it out of the model.
>
>
> Yes, folding should be kept out of the model but EditParts arn't the model.
>
> IMHO a simple solution would be to add the folding state to the
> EditParts. If an EditPart is folded, it has no children
> (getModelChildren returns an empty list). The figure must also have a
> folding state and will paint differently if it is expanded or folded.
>
> Cu, Gunnar
--
Deniz Ozsen
Pers Mail: d.ozsen [at] blueyonder.co.uk
Academ Mail: d.ozsen [at] ucl.ac.uk
Web: http://ozsen.pwp.blueyonder.co.uk
UCL Page: http://www.cs.ucl.ac.uk/students/D.Ozsen
|
|
|
Re: Visual folding editor - how? [message #170462 is a reply to message #169490] |
Fri, 04 March 2005 10:55  |
Eclipse User |
|
|
|
Originally posted by: alan.battersby.ntlworld.com
On Wed, 23 Feb 2005 20:18:24 +0000, Alan Battersby wrote:
> I would like to create subfigures in a graph that can be expanded when
> selected or folded back down to an icon from the its expanded view.
> Unfortunately I am new to gef and this task has exposed holes in my
> understanding of how gef works. My understanding is that upon
> initialisation figures are associated with editparts and that figure
> creation only occurs once. My initial idea was that there should be two
> figures associated with an editpart to represent its folded and unfolded
> state so that switching state changes the figure to be displayed. Upon
> unfolding I am assuming that I would have to add all the editparts
> children to the graph, and remove them on folding up again. So how can I
> associate two figures with the same editpart or do I need two editparts
> one for folded and one for unfolded. I am assuming that folding is only
> a visual attribute and should not change the structure of the associated
> model.
>
> I am sure that mine is a naive view so can anyone enlighten me as to the
> best way of doing this and are there any examples ?
>
> Alan
Thanks for the information. I am using the flow example and now have basic
folding in place after following Deniz & Gunnar's advice. However I still
have a problem in that if I have a block within a block and I fold both
inner and outer blocks. When I unfold the outer block the inner one is also
unfolded but I want the inner block to remain folded.
As I am still discovering how the flowExample works I am unsure as to where
to change the code. I know that SequentialActivityPart has a function
called contributeNodesToGraph. My block class inherits from this and adds a
boolean called folded, and so I have overidden the contributeNodesToGraph
function so that if folded is true then the children of the editpart are
not added to the graph. However this doesnt seem to have made a difference
so I am not sure what to try next.
Any suggestions would be appreciated.
Alan
|
|
|
Powered by
FUDForum. Page generated in 0.05966 seconds