Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » viewpart data initialization in an mvc
viewpart data initialization in an mvc [message #436007] Mon, 29 August 2005 15:55 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Re: viewpart data initialization in an mvc [message #436024 is a reply to message #436011] Tue, 30 August 2005 08:02 Go to previous message
Eclipse UserFriend
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
Previous Topic:Text Field on ToolBar
Next Topic:getViewByID(String id) or so?
Goto Forum:
  


Current Time: Sun Dec 21 20:58:14 GMT 2014

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

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