viewpart data initialization in an mvc [message #436007] |
Mon, 29 August 2005 15:55 |
Eclipse User |
|
|
|
Originally posted by: antonio.ballerini.dsdata.it
I've to develop a form of an application with typical CRUD operations.
To visualize such interface i've to use the viewpart in the RCP.
In some cases i've to pass an initialized 'model' to the viewpart (so the
user can edit model data and then save it to a some persistent storage)
The problem is that i have to pass to the viewpart an instance of a model
class initialized.
The problem is that the framewrok invoke the no-arg constructor to
instantiate the viewpart.
For example this is the scenario :
1. An user select a menu item
2. The system query an object on a remote server
3. The object is wrapped in a model then the model is passed to the viewpart
(so it can visualize it)
4. The viewpart shows the model contents and the widgets for editing such
model
Maybe i've the wrong the approach to this problem.
What is the right ?
Thank in advance.
Antonio
|
|
|
Re: viewpart data initialization in an mvc [message #436011 is a reply to message #436007] |
Mon, 29 August 2005 17:04 |
|
Antonio Ballerini wrote:
> I've to develop a form of an application with typical CRUD operations.
> To visualize such interface i've to use the viewpart in the RCP.
> In some cases i've to pass an initialized 'model' to the viewpart (so the
> user can edit model data and then save it to a some persistent storage)
> The problem is that i have to pass to the viewpart an instance of a model
> class initialized.
> The problem is that the framewrok invoke the no-arg constructor to
> instantiate the viewpart.
>
> For example this is the scenario :
>
> 1. An user select a menu item
> 2. The system query an object on a remote server
> 3. The object is wrapped in a model then the model is passed to the viewpart
> (so it can visualize it)
> 4. The viewpart shows the model contents and the widgets for editing such
> model
>
You could probably still do what you want ... allow the view to show up
empty, like if the user selected it from Window>Show View.
Your action can use IWorkbenchPage#findView(yourId) to get your view
(showView(...) if it's not there already), and then carefully class-cast
to MyViewPart and hand it your model as a newInput(myModel). That would
reset the view and you could update the controls to your new model.
But why not use an editor instead of a view. Editors have an
input/edit/save lifecycle built into their API.
You can use the menu item to execute your query and wrap your model in
an IEditorInput. You could override the save operations to send it to
persistent store. A new IEditorInput would open a new editor window.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: viewpart data initialization in an mvc [message #436024 is a reply to message #436011] |
Tue, 30 August 2005 08:02 |
Eclipse User |
|
|
|
Originally posted by: antonio.ballerini.dsdata.it
Thank you very much Paul, your idea seem very interesting !
I'll try to do this, than i'll let you know...
Antonio Ballerini
"Paul Webster" <pwebster@ca.ibm.com> ha scritto nel messaggio
news:devf7m$8en$1@news.eclipse.org...
> Antonio Ballerini wrote:
> > I've to develop a form of an application with typical CRUD operations.
> > To visualize such interface i've to use the viewpart in the RCP.
> > In some cases i've to pass an initialized 'model' to the viewpart (so
the
> > user can edit model data and then save it to a some persistent storage)
> > The problem is that i have to pass to the viewpart an instance of a
model
> > class initialized.
> > The problem is that the framewrok invoke the no-arg constructor to
> > instantiate the viewpart.
> >
> > For example this is the scenario :
> >
> > 1. An user select a menu item
> > 2. The system query an object on a remote server
> > 3. The object is wrapped in a model then the model is passed to the
viewpart
> > (so it can visualize it)
> > 4. The viewpart shows the model contents and the widgets for editing
such
> > model
> >
>
> You could probably still do what you want ... allow the view to show up
> empty, like if the user selected it from Window>Show View.
>
> Your action can use IWorkbenchPage#findView(yourId) to get your view
> (showView(...) if it's not there already), and then carefully class-cast
> to MyViewPart and hand it your model as a newInput(myModel). That would
> reset the view and you could update the controls to your new model.
>
> But why not use an editor instead of a view. Editors have an
> input/edit/save lifecycle built into their API.
>
> You can use the menu item to execute your query and wrap your model in
> an IEditorInput. You could override the save operations to send it to
> persistent store. A new IEditorInput would open a new editor window.
>
> Later,
> PW
|
|
|
Powered by
FUDForum. Page generated in 0.03065 seconds