I try to create an eclipse plugin which deletes some files when eclipse workbench is closed. I started with the Hello, World command plugin project and added a IWorkbenchListener like mentioned in this toppic Eclipse shut down hook able to stop the termination. The listener is added when I press a special button in the eclipse menu bar (which is added by this plugin).
How can I automatically add this IWorkbenchListener, without the need of clicking on any menu entry?
1 Answer 1
Use the org.eclipse.ui.startup extension point to specify a class that implements org.eclipse.ui.IStartup. This will be called early on during Eclipse initialization.
So in the plugin.xml:
<extension
point="org.eclipse.ui.startup">
<startup
class="your class implementing IStartup"/>
</extension>
Class:
public class Startup implements IStartup
{
@Override
public void earlyStartup()
{
// you action
}
}