hi,
i have variable that i want to initialize in the View PArt but since i
can only open a view PArt by calling the find(View) method how do i use a
constructor to initialize some parameters ,before the view part create's
the layout...
Paul Webster Messages: 6813 Registered: July 2009 Location: Ottawa
Senior Member
Genu George wrote:
>
>
> hi,
> i have variable that i want to initialize in the View PArt but since i
> can only open a view PArt by calling the find(View) method how do i use
> a constructor to initialize some parameters ,before the view part
> create's the layout...
>
You can do that in the no-arguments constructor or the IViewPart#init()
method ... both are called before createControl()
Paul Webster Messages: 6813 Registered: July 2009 Location: Ottawa
Senior Member
Oh ...
Because of the way views are created (reference counted from a view
factory) they're constructed and initialized by the time
IWorkbenchPage#showView() returns your IViewPart. I see what you mean.
You have 2 options:
1. behave similarly to the Content Outline ... allow the view to create
in a default state, and once you have the view call
myView.setContents(MyContents) and allow it to be updated then.
2. Store the initialization information for your view somewhere else ...
like in the plugin. Then in IViewPart#init() method go back to your
plugin and initialize the internal variable from the plugin.
You said ---
Store the initialization information for your view somewhere else ... like
in the plugin. Then in IViewPart#init() method go back to your plugin and
initialize the internal variable from the plugin.
---
Paul Webster Messages: 6813 Registered: July 2009 Location: Ottawa
Senior Member
Genu George wrote:
> You said ---
> Store the initialization information for your view somewhere else ...
> like in the plugin. Then in IViewPart#init() method go back to your
> plugin and initialize the internal variable from the plugin.
> ---
>
> can u give me an example how to do that ?
>
Genu George wrote:
> yes i understand that... but i cant pass a parameter to it right ? i
> wanted to initialize it with a value that i pass from another class...
I have the same problem. I need to pass a value to ViewPart's variable from the class that implements IIntroAction. For example the variable is transactType and the parameter value is "create"; this should signal the ViewPart to pop up a dialog. Else no dialog will show. I can't make the code run where I use my own plugin name to replace TestPlugin. Any idea about the given code?