Semantic of getChildern() method ? [message #165900] |
Thu, 27 January 2005 07:28  |
Eclipse User |
|
|
|
Originally posted by: user.domain.invalid
Hello!
As a newbie in GEF I have the following conceptual (design) problem. It
concerns the semantics and usage of getChildern() method.
I have my data stored in the XML document. I load the data to a DOM
Document object. The only elements that I want to display to the user
are those named 'TheNode'. These element have hierarchical (i.e. tree)
structure in the XML. I want to display the structure both in the
graphical editor and in the outline view -- in both of them as a tree.
The tree as it should aprear in the outline view should have the
'TheNode' emebedded one in another as they appear in the XML. For
example like this:
+ TheNode (name=SpacecraftControlSystem)
+ TheNode (name=Sensor)
+ TheNode (name=PositionSensor)
+ TheNode (name=AtitudeSensor)
+ TheNode (name=SelfTest)
+ TheNode (name=Actuator)
+ TheNode (name=AtitudeActuator)
+ TheNode (name=SelfTest)
+ TheNode (name=Processor)
+ TheNode (name=InternalMemorySize)
The same structure should be implemented in the graphical editor,
although with different layout. See
http://control.ee.ethz.ch/~rohliko/xml/XFeatureScreenshotSCS .png if you
are interested.
When designing the model (according to MVC) I have the following dilemma:
As far as i understand the GEF concept (from reading the major articles
i.e. 'How to get started with GEF', 'Shape Diagram Editor' and
'GefDecription' at eclipsewiki) I understand that 'TheNode' is a child
of 'TheDiagram' i.e. getChildren() of model class TheDiagram must return
list of *all* TheNode objects. It should *not* be that (in the case of
the sample code/picture above) the getChildren() of model class
TheDiagram returs only one element in the list -- TheNode with name
attribute 'SpaceControlSystem' ... and in turn ... when calling
getChildren() on TheNode with name attribute 'SpaceControlSystem' it
returns three TheNode elements: Sonsor, Actuator and Processor.
As I understand the whole concept getChildren() of TheNode, it should
always return an empty list since there is nothing drawn on the part of
canvas that belongs to TheNode. From the GEF point of view all TheNode
objects are childs of the TheDiagram
object because the are drawn in the area on TheDiagram (they are
childern at the same level, there is no tree hierarchy). At the same
time none TheNode is child
od another TheNode because no TheNode is drawn to the area of another
TheNode. This implies how the getChildren() should work for the
graphical editor.
On the other hand when using the TreeViev, other behaviour of method
getChildern() is required. Here when I call getChildren() on, say,
TheNode with name 'SpacecraftControlSystem' I want to get triplet
'Sensor', 'Actuator' and 'SelfTest'. That is the way how the TreeeView
work, right?
As a result, the two previous paragrapah are in contradiction. What is
the right way to resolve this issue of the right model and right
implementation of getChildren() method? To have two paralel models, each
implementing getChildern() in its own way?
I would be happy for your hints since this looks like I could do serious
mistake at the very beginning of my work just because I missed something
in GEF concept.
Thank you in advance
Ondrej
|
|
|
Re: Semantic of getChildern() method ? [message #165977 is a reply to message #165900] |
Thu, 27 January 2005 12:03   |
Eclipse User |
|
|
|
You don't need two models. The difference is in the View (of MVC), and can
be handled at that level. Your DiagramEditPart should traverse all nodes in
the tree and return them all as its children. And your NodeEditParts don't
need to do anything for getModelChildren() (the default method already
returns an empty list). So, you just need to override
DiagramEditPart#getModelChildren(). Your TreeEditParts' getModelChildren()
method would, as expected, return the model node's actual children. Simple.
<user@domain.invalid> wrote in message
news:41F8DE68.1030900@domain.invalid...
> Hello!
>
> As a newbie in GEF I have the following conceptual (design) problem. It
> concerns the semantics and usage of getChildern() method.
>
> I have my data stored in the XML document. I load the data to a DOM
> Document object. The only elements that I want to display to the user
> are those named 'TheNode'. These element have hierarchical (i.e. tree)
> structure in the XML. I want to display the structure both in the
> graphical editor and in the outline view -- in both of them as a tree.
> The tree as it should aprear in the outline view should have the
> 'TheNode' emebedded one in another as they appear in the XML. For
> example like this:
>
> + TheNode (name=SpacecraftControlSystem)
> + TheNode (name=Sensor)
> + TheNode (name=PositionSensor)
> + TheNode (name=AtitudeSensor)
> + TheNode (name=SelfTest)
> + TheNode (name=Actuator)
> + TheNode (name=AtitudeActuator)
> + TheNode (name=SelfTest)
> + TheNode (name=Processor)
> + TheNode (name=InternalMemorySize)
>
> The same structure should be implemented in the graphical editor,
> although with different layout. See
> http://control.ee.ethz.ch/~rohliko/xml/XFeatureScreenshotSCS .png if you
> are interested.
>
>
>
> When designing the model (according to MVC) I have the following dilemma:
>
> As far as i understand the GEF concept (from reading the major articles
> i.e. 'How to get started with GEF', 'Shape Diagram Editor' and
> 'GefDecription' at eclipsewiki) I understand that 'TheNode' is a child
> of 'TheDiagram' i.e. getChildren() of model class TheDiagram must return
> list of *all* TheNode objects. It should *not* be that (in the case of
> the sample code/picture above) the getChildren() of model class
> TheDiagram returs only one element in the list -- TheNode with name
> attribute 'SpaceControlSystem' ... and in turn ... when calling
> getChildren() on TheNode with name attribute 'SpaceControlSystem' it
> returns three TheNode elements: Sonsor, Actuator and Processor.
>
> As I understand the whole concept getChildren() of TheNode, it should
> always return an empty list since there is nothing drawn on the part of
> canvas that belongs to TheNode. From the GEF point of view all TheNode
> objects are childs of the TheDiagram
> object because the are drawn in the area on TheDiagram (they are
> childern at the same level, there is no tree hierarchy). At the same
> time none TheNode is child
> od another TheNode because no TheNode is drawn to the area of another
> TheNode. This implies how the getChildren() should work for the
> graphical editor.
>
> On the other hand when using the TreeViev, other behaviour of method
> getChildern() is required. Here when I call getChildren() on, say,
> TheNode with name 'SpacecraftControlSystem' I want to get triplet
> 'Sensor', 'Actuator' and 'SelfTest'. That is the way how the TreeeView
> work, right?
>
> As a result, the two previous paragrapah are in contradiction. What is
> the right way to resolve this issue of the right model and right
> implementation of getChildren() method? To have two paralel models, each
> implementing getChildern() in its own way?
>
> I would be happy for your hints since this looks like I could do serious
> mistake at the very beginning of my work just because I missed something
> in GEF concept.
>
> Thank you in advance
>
> Ondrej
|
|
|
Re: Semantic of getChildern() method ? [message #166057 is a reply to message #165977] |
Thu, 27 January 2005 17:41  |
Eclipse User |
|
|
|
Pratik Shah wrote:
> You don't need two models. The difference is in the View (of MVC), and can
> be handled at that level. Your DiagramEditPart should traverse all nodes in
> the tree and return them all as its children. And your NodeEditParts don't
> need to do anything for getModelChildren() (the default method already
> returns an empty list). So, you just need to override
> DiagramEditPart#getModelChildren(). Your TreeEditParts' getModelChildren()
> method would, as expected, return the model node's actual children. Simple.
>
Yes so simple! It's like with Columbus. Now it is obvious.
Many thanks, Pratik
Ondrej
|
|
|
Powered by
FUDForum. Page generated in 0.03922 seconds