Sending data to View [message #1907] |
Wed, 23 April 2008 12:15  |
Eclipse User |
|
|
|
Originally posted by: andre.rubin.gmail.com
Hi all,
How do I send data to a view? I have one view that is doing some
computations, then I wanna send the results (let's say an object) to
another view, so it can display it. How do I do that?
I'm thinking this is the same thing as Console or JUnit, where they
display what's happening somewhere else.
What I found was:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().showView( "my.view.id");
to bring it up or
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView( "my.view.id");
to get a reference to it through its interface. But I got stuck there.
Any ideas?
Thanks,
Andre
|
|
|
|
Re: Sending data to View [message #2112 is a reply to message #1921] |
Thu, 08 May 2008 15:16  |
Eclipse User |
|
|
|
Originally posted by: andre.rubin.gmail.com
Thanks Eric for the book suggestion. I got my hands on a copy of the book
and implemented the solution, which was more complex than I thought it
would be.
So, just for completion (if anyone without access to the book ever search
for this post), this is what I did:
1) Created a ContentProvider class (that implements IContentProvider)
2) Added a ContentViewer to my view and set the ContentProvider to the
viewer with a call to setContentProvider.
3) Created a Singleton that would handle all model operations (Model as
the M in MVC)
4) Moved all my View GUI code to the ContentViewer class, which would get
the model data using the Singleton.
I'm not sure if this Singleton class needs to be a Singleton at all. I'm
using and studying the solution closer now to see if that's really
necessary.
There are a lot more details to it, which makes it even more complex, but
I don't want this post to be too lengthy.
Anyway, that's it! Thanks again.
Andre
|
|
|
Re: Sending data to View [message #566147 is a reply to message #1907] |
Thu, 24 April 2008 10:27  |
Eclipse User |
|
|
|
Andre wrote:
> Hi all,
>
> How do I send data to a view? I have one view that is doing some
> computations, then I wanna send the results (let's say an object) to
> another view, so it can display it. How do I do that?
>
> I'm thinking this is the same thing as Console or JUnit, where they
> display what's happening somewhere else.
>
> What I found was:
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().showView( "my.view.id");
> to bring it up or
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView( "my.view.id");
> to get a reference to it through its interface. But I got stuck there.
>
> Any ideas?
Views should follow the MVC pattern and have a backing model that
provides the data for the view. By making the model separate, you can
access (and modify) it from other code (such as other views).
The book "Eclipse: Building Commercial-Quality Plug-ins" by Clayberg and
Rubel is an excellent resource and talks quite a bit about structuring
your views in this way. Here's the book's site:
http://www.qualityeclipse.com/
Hope this helps,
Eric
|
|
|
Re: Sending data to View [message #566612 is a reply to message #1921] |
Thu, 08 May 2008 15:16  |
Eclipse User |
|
|
|
Thanks Eric for the book suggestion. I got my hands on a copy of the book
and implemented the solution, which was more complex than I thought it
would be.
So, just for completion (if anyone without access to the book ever search
for this post), this is what I did:
1) Created a ContentProvider class (that implements IContentProvider)
2) Added a ContentViewer to my view and set the ContentProvider to the
viewer with a call to setContentProvider.
3) Created a Singleton that would handle all model operations (Model as
the M in MVC)
4) Moved all my View GUI code to the ContentViewer class, which would get
the model data using the Singleton.
I'm not sure if this Singleton class needs to be a Singleton at all. I'm
using and studying the solution closer now to see if that's really
necessary.
There are a lot more details to it, which makes it even more complex, but
I don't want this post to be too lengthy.
Anyway, that's it! Thanks again.
Andre
|
|
|
Powered by
FUDForum. Page generated in 0.05259 seconds