Creating own Selection Events? (Converting selected Objects first) [message #293032] |
Sat, 15 October 2005 20:43  |
Eclipse User |
|
|
|
Originally posted by: bobruney.gmx.net
Hi,
i got pretty specialised objects within each view (for example "TreeBook").
When a user clicks on such an item and selects it, i want to "transform"
the clicked class to another class type first (for example into "Book"),
before i send the selected type (the transformed type) as selection
towards the workspace.
I implemented it with a regular TreeSelectionProvider (View 1) and a
SelectionListener (View 2) at the moment. But all i get in the
"selectionChanged" mehtod in the View 2 are classes of type "TreeBook".
But I need to transform them first before sending, so that "Book" objects
are sent.
I guess the transformation has to be done in View1 but i donŽt know how.
Has anybody a hint how i can do this?
Sorry, but i have found no examples and also looking up the literature i
have here brought no results.
sorry to bother you,
Andreas
|
|
|
|
Design of the Software Architecture (best pracitce for Event Handling) [message #293043 is a reply to message #293038] |
Sun, 16 October 2005 14:26   |
Eclipse User |
|
|
|
Originally posted by: bobruney.gmx.net
Emil van Galen wrote:
> At the my current project we developed a large application UI with Eclipse
3.0 RCP. We have a advanced selection system that connect to selection from
one view to multiple others.
> Each view that want's to use this system should set it's selection provider
(ie. a JFace TableViewer) on the view site
(getViewSite().setSelectionProvider(ISelectionProvider)).
> Our 'global selection' implementation is loosely coupled between the views,
since no view listens to the selection of one explicit view. Instead we listen
to a global selection provider that broadcasts selection changes to a
registers views.
> To convert the elements inside the selection from local (view specific) to
global type and vice versa we created the view selection converter interface
that can be registered.
> In your case it might me the quickest to create a
TransformedSelectionProvider that wraps around a selection provider and allows
you to set and get a selection with the global type (not the view specific
type).
Emil,
thanks a lot for your answer. The wrapper approach seems like a good idea!
Your project sounds very interesting, we are currently in the early stages
of developing a big RCP, too.
One more thing, you wrote:
> Our 'global selection' implementation is loosely coupled between the views,
> since no view listens to the selection of one explicit view. Instead we
> listen to a global selection provider that broadcasts selection changes to a
> registers views.
I want to implement it in a similar way. I have a central "model" object
to which i want to register all views to listen to "selection" events (MVC
like).
So when a selection happens wihtin one view, the other views should not be
listening to the view selection, instead they should listen to the central
model object, to which the selection within the view is propagated to and
then fired.
In my opinion this is a more modular design, than when i listen to
selection in views directly in other views. I would be glad if you could
provide me with your opinon on that (whehter this is good or not good,
Software Design wise), when you have the time to post.
For my code, this would mean, that i would implement the
"ISelectionProvider" and "SelectionListener" interface in this central
model class.
But now i donŽt know whatŽs the best way to register the views.
Should i register the views as Selection Providers in the workspace (like
you did (judging from the sample code you posted), for "outgoing events".
And then register them as listeners onto the central model for "incoming
events"?
Or should i forget about registerin them at the Workspace and simply
register every view directly with the model?
IŽm a littel bit confused at the moment on what is the cleanes solution to
that.
Maybe you, Emil or somebody else wants to contribute to my thoughts.
IŽm looking for the most appropriate Event Handling Design and donŽt know
whatŽs best at the moment.
Thanks for your input
Andreas
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03885 seconds