Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » eclipse startup
eclipse startup [message #329188] Mon, 16 June 2008 11:53 Go to next message
Eclipse UserFriend
Originally posted by: prasad.chand.gmail.com

Hi All,

I wish to "initialize" certain non-static classes at the beginning of a
plugin startup. I want to access this class using some kind of
mechanism. Presently I am using a workaround by declaring them in a view
and obtaining the instance of the view using


Viewpart view =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().
findViewReference(View.ID).getView(false);

view.getObject();

I looked at the startup extension point but I am not sure if it could
get the job done. Any help would be great.

Thank,
Prasad
Re: eclipse startup [message #329197 is a reply to message #329188] Mon, 16 June 2008 12:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Prasad Chand wrote:
> Hi All,
>
> I wish to "initialize" certain non-static classes at the beginning of a
> plugin startup. I want to access this class using some kind of
> mechanism. Presently I am using a workaround by declaring them in a view
> and obtaining the instance of the view using

Often you see the plugin activator class (subclass of AbstractPlugin or
AbstractUIPlugin) have references to objects that are used across the
plugin. So in the activator's start() method you initialize them and
then provide access to other classes via getter methods.

Or you could use a factory that provides access to the shared objects
and call its initialization method(s) from the activator's start() method.

Hope this helps,
Eric
Re: eclipse startup [message #329203 is a reply to message #329197] Mon, 16 June 2008 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: prasad.chand.gmail.com

Eric Rizzo wrote:
> Prasad Chand wrote:
>> Hi All,
>>
>> I wish to "initialize" certain non-static classes at the beginning of
>> a plugin startup. I want to access this class using some kind of
>> mechanism. Presently I am using a workaround by declaring them in a
>> view and obtaining the instance of the view using
>
> Often you see the plugin activator class (subclass of AbstractPlugin or
> AbstractUIPlugin) have references to objects that are used across the
> plugin. So in the activator's start() method you initialize them and
> then provide access to other classes via getter methods.

I have tried this but as i said I am not able to obtain non-static objects.

MyPlugin.<non-static object> is not possible by this method.


>
> Or you could use a factory that provides access to the shared objects
> and call its initialization method(s) from the activator's start() method.
>

Can you please elaborate as to how I can achieve this.I am just not able
to obtain the non-static instance of the object I want.

> Hope this helps,
> Eric

Thanks for your time,
Prasad
Re: eclipse startup [message #329249 is a reply to message #329203] Tue, 17 June 2008 09:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Prasad Chand wrote:
> Eric Rizzo wrote:
>> Prasad Chand wrote:
>>> Hi All,
>>>
>>> I wish to "initialize" certain non-static classes at the beginning of
>>> a plugin startup. I want to access this class using some kind of
>>> mechanism. Presently I am using a workaround by declaring them in a
>>> view and obtaining the instance of the view using
>>
>> Often you see the plugin activator class (subclass of AbstractPlugin
>> or AbstractUIPlugin) have references to objects that are used across
>> the plugin. So in the activator's start() method you initialize them
>> and then provide access to other classes via getter methods.
>
> I have tried this but as i said I am not able to obtain non-static objects.
>
> MyPlugin.<non-static object> is not possible by this method.

If you let the Eclipse proejct wizard generate the activator class for
you, you'll notice that it includes a static singleton variable and
accessor method (getDefault()). You can use this to get to the instance
and through that get to any references to other objects that it contains.

Hope this helps,
Eric
Re: eclipse startup [message #329257 is a reply to message #329249] Tue, 17 June 2008 13:11 Go to previous message
Eclipse UserFriend
Originally posted by: prasad.chand.gmail.com

Eric Rizzo wrote:
> Prasad Chand wrote:
>> Eric Rizzo wrote:
>>> Prasad Chand wrote:
>>>> Hi All,
>>>>
>>>> I wish to "initialize" certain non-static classes at the beginning
>>>> of a plugin startup. I want to access this class using some kind of
>>>> mechanism. Presently I am using a workaround by declaring them in a
>>>> view and obtaining the instance of the view using
>>>
>>> Often you see the plugin activator class (subclass of AbstractPlugin
>>> or AbstractUIPlugin) have references to objects that are used across
>>> the plugin. So in the activator's start() method you initialize them
>>> and then provide access to other classes via getter methods.
>>
>> I have tried this but as i said I am not able to obtain non-static
>> objects.
>>
>> MyPlugin.<non-static object> is not possible by this method.
>
> If you let the Eclipse proejct wizard generate the activator class for
> you, you'll notice that it includes a static singleton variable and
> accessor method (getDefault()). You can use this to get to the instance
> and through that get to any references to other objects that it contains.

Works fine now. Thanks a lot.

Prasad

>
> Hope this helps,
> Eric
Previous Topic:Add an action to both main menu & view context menu
Next Topic:Migration Questions
Goto Forum:
  


Current Time: Wed Apr 30 13:40:35 EDT 2025

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

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

Back to the top