Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How do i initialize a ViewPart ?
How do i initialize a ViewPart ? [message #438730] Mon, 24 October 2005 05:40 Go to next message
Eclipse UserFriend
Originally posted by: gkurien.icope.com

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...
Re: How do i initialize a ViewPart ? [message #438750 is a reply to message #438730] Mon, 24 October 2005 12:47 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
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()

Later,
PW


Re: How do i initialize a ViewPart ? [message #438777 is a reply to message #438750] Tue, 25 October 2005 09:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gkurien.icope.com

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...
Re: How do i initialize a ViewPart ? [message #438778 is a reply to message #438777] Tue, 25 October 2005 12:26 Go to previous messageGo to next message
Haris Peco is currently offline Haris PecoFriend
Messages: 1072
Registered: July 2009
Senior Member
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...

try use multiple view property (multipel="true" in extension point) and add
parameter secondary ID when you open view
Re: How do i initialize a ViewPart ? [message #438835 is a reply to message #438777] Wed, 26 October 2005 13:50 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
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.

Later,
PW


Re: How do i initialize a ViewPart ? [message #438890 is a reply to message #438835] Fri, 28 October 2005 07:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gkurien.icope.com

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 ?
Re: How do i initialize a ViewPart ? [message #438944 is a reply to message #438890] Fri, 28 October 2005 13:32 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
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 ?
>

the unoptimized way is:

Say your action is opening the view:

ActionDelegate
public void run() {
Map options = TestPlugin.getOptions(MY_VIEW_ID);
options.clear();
options.put(VIEW_INFO, "SLOW_VIEW");
}

MyViewPart
public void init(IViewSite s) {
super(s);
Map options = TestPlugin.getOptions(MY_VIEW_ID);
goSlow = "SLOW_VIEW".equals(options.get(VIEW_INFO));
}

You'd have to make sure that the code is safe, but basically that's one way.

Later,
PW


Re: How do i initialize a ViewPart ? [message #438954 is a reply to message #438777] Fri, 28 October 2005 14:13 Go to previous messageGo to next message
Nick Edgar is currently offline Nick EdgarFriend
Messages: 439
Registered: July 2009
Senior Member
See also
https://bugs.eclipse.org/bugs/show_bug.cgi?id=82621

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...
Re: How do i initialize a ViewPart ? [message #899737 is a reply to message #438835] Thu, 02 August 2012 07:33 Go to previous message
Allan Zarsuela is currently offline Allan ZarsuelaFriend
Messages: 5
Registered: April 2012
Junior Member
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?


>ActionDelegate
>public void run() {
>Map options = TestPlugin.getOptions(MY_VIEW_ID);
>options.clear();
>options.put(VIEW_INFO, "SLOW_VIEW");
>}
Previous Topic:Setting custom workspace
Next Topic:Unwanted Menu in RCP application
Goto Forum:
  


Current Time: Tue Dec 03 03:05:35 GMT 2024

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

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

Back to the top