Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » run-once initialization of a plug-in on first launch
run-once initialization of a plug-in on first launch [message #639191] Mon, 15 November 2010 15:11 Go to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
Hi,

I would like to give my users the opportunity to install some dummy data into my RCP app, and it would be most convenient to provide that as an optional bundle.

Is there a run-on-install method or extension that I can implement, that will run some logic to configure dummy data, and then never be run again?

Thanks,
T
Re: run-once initialization of a plug-in on first launch [message #639247 is a reply to message #639191] Mon, 15 November 2010 18:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can run it on startup once, and then never again (just store a
ranAlready flag in your plugin state location or a preference).

For doing things on install in general, there's
http://wiki.eclipse.org/Equinox/p2/Engine/Touchpoint_Instruc tions and
http://wiki.eclipse.org/Equinox/p2/Customizing_Metadata

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: run-once initialization of a plug-in on first launch [message #639270 is a reply to message #639247] Mon, 15 November 2010 19:39 Go to previous messageGo to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
Hi,
I tried that following your message on IRC. Thanks!

However I am having problems actually getting the dummydata plugin to actually start, without adding a UI contribution..

so I have a new plugin that does nothing but pass a message to the console like so;

public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
System.out.println("Starting the dummy activator");
}

I have added this to my product configuration, however the message is never printed. I presume this is because of the lazy activation.

1) if I remove the lazy activation from MANIFEST.MF it still doesn't start.

2) if I add a UI contribution like a menu action bar button to the plugin, the start function is called when the button is clicked.

3) the start() button is called when the button is clicked whether I have Bundle-ActivationPolicy: lazy or not in the MANIFEST.MF but I get a NullPointerException without Bundle-ActivationPolicy: lazy

4) if I add the plug-in and set it to autostart and set its start level to 4, it starts (well it prints the System.out.println) message before my main application plug-in has initialized, (Which is tooo early to be useful)

5) same thing happens if set it to 5 and any higher I get an Exception;
org.osgi.framework.BundleException: Exception in myapp.ui.internal.UIActivator.start() of bundle myapp.ui.

which is some plug-in it depends on.

I am clearly missing something here, any suggestions?

Thanks
Tom
Re: run-once initialization of a plug-in on first launch [message #639412 is a reply to message #639270] Tue, 16 November 2010 13:11 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you control your RCP app, you could do it in your WorkbenchAdvisor,
there are postStartup() methods and such.


You can also use org.eclipse.ui.startup to force your plugin to start
early. We don't recommend this, but if you have a really small plugin
with no UI contributions, then it will be started in a worker thread
after the workbench/workbench windows have all been initialized. You
can check there, and if it is not already done then do your initialization.


PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:Switch to another window
Next Topic:beginner mistake
Goto Forum:
  


Current Time: Thu Mar 28 11:51:32 GMT 2024

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

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

Back to the top