Data Model [message #467449] |
Thu, 03 May 2007 21:59  |
Eclipse User |
|
|
|
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 #467499 is a reply to message #467461] |
Fri, 04 May 2007 12:49  |
Eclipse User |
|
|
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03568 seconds