Tree: "Good Practice" when base domain doesnŽt represent Tree structure? [message #461072] |
Thu, 15 September 2005 09:27  |
Eclipse User |
|
|
|
Hi everybody,
iŽm having this problem:
I got a domain data model which has no Tree structure, yet.
However, with a little bit of transformation the Domain Model could also
be represented as a tree.
I therefore would mainly need to add the "getParent" and "getChildren"
information (which i then could access in the Content Provider) to the
objects of the domain model.
But now i donŽt know what is the "best practice" on how to do this or
whether there is a certain pattern for it.
Polluting my base domain model with the "getParent" and "getChildren"
information doesnŽt seem like a good idea to me, as the base domain model
would get specific Tree infomration it doesnŽt need.
Is the best practice to establish a seperate Tree Model with the
"getChildren" and "getParent" information?
But then: When a user selects an item in the tree, how can i map this item
(which then would represent an Item of the TreeDataModel) back onto the
"base" domain model?
I hope you understand what iŽm trying to communicate and am happy about
every answer/inspiration/advice on how to do something like this in the
best way.
Greetings
Andreas
|
|
|
|
Re: Tree: "Good Practice" when base domain doesnŽt represent Tree structure ? [message #461121 is a reply to message #461076] |
Fri, 16 September 2005 10:28  |
Eclipse User |
|
|
|
Hello,
and thanks again for the help.
I can now display my wrapped domain model as a tree.
However, i donŽt know how i can propagate events from the underlying
domain model to the tree now.
More concrete:
The domain model fires a SELECTION_CHANGED event whenever a selection
occurs on one of the domain model objects.
I already catch this Selection in the TreeViewPartClass, via a
PropertyChange() Method. (I implemented the ViewPartClass as a
PropertyChangeListener).
I now want to select the corresponding object in the Tree, which
represents the object, which was selected in the domain.
From there on i donŽt know how to go further.
I got the Selection Object in the ViewPart from the Tree, but i donŽt know
how to make the tree select the corresponding TreeWrapperObject.
When i try to set the selection via:
TreeViewer.setSelection(...);
I get an
"org.eclipse.swt.SWTException: Invalid thread access"
error.
Furthermore the setSelection wants an object which implements the
ISelection Interface...
What object should i put into this method?
I guess the WrapperObjects for my model, am i right? So i have to
implement the ISelectionInterface for those models to?
Could anybody give me a hint on how to do this best?
Sorry if this posting got a little bit confusing.
But iŽm quite confused at the moment, too, on how to handle this.
Any help/idea is appreciated very much, since this is my first time with
SWT.
Greetings
Andreas
|
|
|
Powered by
FUDForum. Page generated in 0.04356 seconds