Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Data Model
Data Model [message #467449] Thu, 03 May 2007 21:59 Go to next message
Eclipse UserFriend
Originally posted by: labraticmp3.hotmail.com

I am creating a RCP application with multiple views I want to locate my
data model somewhere where it is available for all my view and not attached
to just one of them. All of the code snippets show the data model created
in the view. So in what object to I instantiate my data model and how would
I reference it from views and actions?

Thanks

Earl
Re: Data Model [message #467453 is a reply to message #467449] Thu, 03 May 2007 23:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi Earl,

Where your views contain tables and/or trees, they can access your data
with a class that implements either ITableContentProvider or a
ITreeContentProvider.

Create a class that implements one of these interfaces.

Within your view, use the Viewer's setContentProvider() method to
associate an instance of the class that you have created with your view.

Charlie


Earl wrote:
> I am creating a RCP application with multiple views I want to locate my
> data model somewhere where it is available for all my view and not attached
> to just one of them. All of the code snippets show the data model created
> in the view. So in what object to I instantiate my data model and how would
> I reference it from views and actions?
>
> Thanks
>
> Earl
>
>
Re: Data Model [message #467461 is a reply to message #467453] Fri, 04 May 2007 02:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: labraticmp3.hotmail.com

Hi Charlie,

Thanks for the reply, but I still have some questions. I have a ViewPart
that displays a TreeViewer, Currently the instance of the data model for
the TreeViewer is located in the ViewPart it is created and intialized in a
method of the ViewPart. I have a ITreeContentProvider and currently is
working OK as is.

But what I want to do is to create and populate the instance of my data
model somewere other than the ViewPart since this data will be used
throughout the application. So my question is what class/interface can I
extend/use to put the data model instance and the code to populate it in so
that is easily referenced from any view and/or actions. Then having done
that how do I get a reference to the data model from the ViewPart to pass to
the TreeViewer.setInput method.

I hope is is clear enough.

Earl

"Charlie Kelly" <Eclipse@CharlieKelly.com> wrote in message
news:f1e9nq$hl6$1@build.eclipse.org...
> Hi Earl,
>
> Where your views contain tables and/or trees, they can access your data
> with a class that implements either ITableContentProvider or a
> ITreeContentProvider.
>
> Create a class that implements one of these interfaces.
>
> Within your view, use the Viewer's setContentProvider() method to
> associate an instance of the class that you have created with your view.
>
> Charlie
>
>
> Earl wrote:
>> I am creating a RCP application with multiple views I want to locate my
>> data model somewhere where it is available for all my view and not
>> attached to just one of them. All of the code snippets show the data
>> model created in the view. So in what object to I instantiate my data
>> model and how would I reference it from views and actions?
>>
>> Thanks
>>
>> Earl
Re: Data Model [message #467487 is a reply to message #467461] Fri, 04 May 2007 09:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: w.jancz.\/\/asko.pl (change \/\/ with w)

> Thanks for the reply, but I still have some questions. I have a ViewPart
> that displays a TreeViewer, Currently the instance of the data model for
> the TreeViewer is located in the ViewPart it is created and intialized in
> a method of the ViewPart. I have a ITreeContentProvider and currently is
> working OK as is.
>
> But what I want to do is to create and populate the instance of my data
> model somewere other than the ViewPart since this data will be used
> throughout the application. So my question is what class/interface can I
> extend/use to put the data model instance and the code to populate it in
> so that is easily referenced from any view and/or actions. Then having
> done that how do I get a reference to the data model from the ViewPart to
> pass to the TreeViewer.setInput method.
>

It sounds for me like a Singleton Pattern :))))

Create a singleton named for example ApplicationManager - and You will be
able to get data from this object, wherever You want...

...::WojT::..
Re: Data Model [message #467497 is a reply to message #467487] Fri, 04 May 2007 12:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: labraticmp3.hotmail.com

Thanks, That looks like what I was looking for.

"..::WojT::.." <w.jancz@\/\/asko.pl (change \/\/ with w)> wrote in message
news:f1fd5r$j0d$1@build.eclipse.org...
>> Thanks for the reply, but I still have some questions. I have a ViewPart
>> that displays a TreeViewer, Currently the instance of the data model for
>> the TreeViewer is located in the ViewPart it is created and intialized in
>> a method of the ViewPart. I have a ITreeContentProvider and currently is
>> working OK as is.
>>
>> But what I want to do is to create and populate the instance of my data
>> model somewere other than the ViewPart since this data will be used
>> throughout the application. So my question is what class/interface can I
>> extend/use to put the data model instance and the code to populate it in
>> so that is easily referenced from any view and/or actions. Then having
>> done that how do I get a reference to the data model from the ViewPart to
>> pass to the TreeViewer.setInput method.
>>
>
> It sounds for me like a Singleton Pattern :))))
>
> Create a singleton named for example ApplicationManager - and You will be
> able to get data from this object, wherever You want...
>
> ..::WojT::..
>
Re: Data Model [message #467499 is a reply to message #467461] Fri, 04 May 2007 12:49 Go to previous message
Eclipse UserFriend
Hi Earl,
Earl wrote:
> Hi Charlie,
>
> Thanks for the reply, but I still have some questions. I have a ViewPart
> that displays a TreeViewer, Currently the instance of the data model for
> the TreeViewer is located in the ViewPart it is created and intialized in a
> method of the ViewPart. I have a ITreeContentProvider and currently is
> working OK as is.

You should refactor the data model out of the ViewPart, and into a class
that Implements ITreeContentProvider.

After you have performed the refactoring, use the setContentProvider()
method of the TreeViewer to associate the Viewer with an instance of
your new class.

Charlie
>
> But what I want to do is to create and populate the instance of my data
> model somewere other than the ViewPart since this data will be used
> throughout the application. So my question is what class/interface can I
> extend/use to put the data model instance and the code to populate it in so
> that is easily referenced from any view and/or actions. Then having done
> that how do I get a reference to the data model from the ViewPart to pass to
> the TreeViewer.setInput method.
>
> I hope is is clear enough.
>
> Earl
>
> "Charlie Kelly" <Eclipse@CharlieKelly.com> wrote in message
> news:f1e9nq$hl6$1@build.eclipse.org...
>> Hi Earl,
>>
>> Where your views contain tables and/or trees, they can access your data
>> with a class that implements either ITableContentProvider or a
>> ITreeContentProvider.
>>
>> Create a class that implements one of these interfaces.
>>
>> Within your view, use the Viewer's setContentProvider() method to
>> associate an instance of the class that you have created with your view.
>>
>> Charlie
>>
>>
>> Earl wrote:
>>> I am creating a RCP application with multiple views I want to locate my
>>> data model somewhere where it is available for all my view and not
>>> attached to just one of them. All of the code snippets show the data
>>> model created in the view. So in what object to I instantiate my data
>>> model and how would I reference it from views and actions?
>>>
>>> Thanks
>>>
>>> Earl
>
>
Previous Topic:Build Update Site
Next Topic:About PropertyTabbed
Goto Forum:
  


Current Time: Sat May 17 20:20:51 EDT 2025

Powered by FUDForum. Page generated in 0.03568 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top