Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse plugin life cycle(How to initialize a plugin in E4 style without an Activator)
Eclipse plugin life cycle [message #1746724] Thu, 03 November 2016 18:18 Go to next message
Paolo M. is currently offline Paolo M.Friend
Messages: 8
Registered: November 2016
Junior Member
I am trying to develop a plugin which contributes to eclipse ide (eclipse 4.6.1).
I would to have an initializartion code, so I try to use a "org.eclipse.core.runtime.products" extension with a property

<property
    name="lifeCycleURI"
    value="bundleclass://com.mysite.plugin/com.mysite.plugin.E4LifeCycle">
</property>


public class E4LifeCycle {

	public E4LifeCycle(){
		System.err.println("E4LifeCycle Constructor called");
	}

	@PostContextCreate
	void postContextCreate(IApplicationContext context) {
		System.err.println("postContextCreate called");
	}
}



but launching product id="org.eclipse.platform.ide" with application="org.eclipse.ui.ide.workbench" , the code in method annotated with @PostContextCreate isn't called.

In a similar example with an E4 RCP product with application="org.eclipse.e4.ui.workbench.swt.E4Application", the code of E4LifeCycle is called.

My question is: how can I initialize my plugin in e4 style, without using an Activator?
I have to use a fragment? An addon?

Thanks
Re: Eclipse plugin life cycle [message #1746778 is a reply to message #1746724] Fri, 04 November 2016 13:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2614
Registered: July 2012
Senior Member
It depends on what you want to initialize. An Addon might be fine in case you want to do something with the model. If it is more some sort of backend initialization where you don't need the model or anything from the EclipseContext I would suggest to use Declarative Services and create an immediate component.
Re: Eclipse plugin life cycle [message #1746781 is a reply to message #1746778] Fri, 04 November 2016 13:57 Go to previous messageGo to next message
Paolo M. is currently offline Paolo M.Friend
Messages: 8
Registered: November 2016
Junior Member
No Message Body

[Updated on: Fri, 04 November 2016 14:00]

Report message to a moderator

Re: Eclipse plugin life cycle [message #1746782 is a reply to message #1746778] Fri, 04 November 2016 13:57 Go to previous message
Paolo M. is currently offline Paolo M.Friend
Messages: 8
Registered: November 2016
Junior Member
Thank you.
I used addon:

	@Inject
	@Optional
	public void applicationStarted(@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) Event event, 
			@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
			LogService log) {
		
		Preferences preferences = InstanceScope.INSTANCE.getNode(NODE);
		boolean firstStart = preferences.getBoolean(FIRST_START, true);
		if(firstStart){
			log.log(LogService.LOG_INFO, "Starting maximized");
			shell.setMaximized(true);
			preferences.putBoolean(FIRST_START, false);
			try {
				preferences.flush();
			} catch (BackingStoreException e) {
				log.log(LogService.LOG_ERROR, "Cannot flush " + NODE + " preferences");
			}
		}
	}



This works for IDE contribution an RCP too.
Previous Topic:How to use @Translation in E4 application
Next Topic:Use PreferenceStore and IScopeContext together
Goto Forum:
  


Current Time: Sun Sep 23 03:01:15 GMT 2018

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

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

Back to the top