Hi RCP developers,
I want to iplement postWindowClose()
in my ECLIPSE RCP application.
Before coding this method, I just did a small test to see if when I close my application, the method is called, so I did that :
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
public class MainWindowControl extends WorkbenchWindowAdvisor{
public MainWindowControl(IWorkbenchWindowConfigurer configurer) {
super(configurer);
// TODO Auto-generated constructor stub
}
@Override
public void postWindowClose() {
// TODO Auto-generated method stub
super.postWindowClose();
System.out.println("close");
}
}
I am expecting to see : close
in ECLIPSE console, but it's still blank after closing the application.
All the required plugins are added , and I have no error while launching or closing the application.
So, AM I missing something ?
The reasons why to implemets this method are :
Are you sure you want to close the application
Edit :
My life cycle class :
package upload.center.util;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
import org.eclipse.e4.ui.workbench.lifecycle.PreSave;
public class WindowLifeCycle {
@PostContextCreate
public void postContextCreate()
{
// TODO start up code here
System.out.println("open");
}
@PreSave
public void preSave()
{
// TODO add shutdown code here
System.out.println("close");
}
}
My plugin.xml :
<product ....
<property
name="windowLifeCycle"
value="bundleclass://UploadCenter.Source/upload.center.util.WindowLifeCycle">
</property>
...</product>
I hope that I am clear enough.
Ismail
For a pure Eclipse 4 (e4) application the workbench window advisor (and the other advisors) are not used. You use the @PreSave
method of a life cycle class to run code during shutdown.
public class LifeCycle
{
@PostContextCreate
public void postContextCreate()
{
// TODO start up code here
}
@PreSave
public void preSave()
{
// TODO add shutdown code here
}
}
declare the life cycle class in the product definition in the plugin.xml
:
<extension
id="product"
point="org.eclipse.core.runtime.products">
<product
name="%product.name"
application="org.eclipse.e4.ui.workbench.swt.E4Application">
<property
name="lifeCycleURI"
value="bundleclass://plugin-id/package.LifeCycle">
</property>
.... more properties ...
For more details see here