I have an eclipse plugin and I want to perform certain action inside this plugin but after eclipse application is opened.
I tried to do it through overriding
public void postWindowCreate()
but it seems that I can't get inside this function when launching the application
Any ideas ?
Do you use e4? Then maybe the following link may help: http://www.eclipse.org/forums/index.php/m/886197/
Edit:
OK, do you define your own application?
Are the methods provided by
org.eclipse.ui.application.WorkbenchWindowAdvisor
the ones you need? (e.g.preWindowOpen()
,preWindowShellClose()
,postWindowRestore()
,postWindowCreate()
, ...)I also needed that functionality, so here's how I do it:
You need 3 classes, one implementing
org.eclipse.equinox.app.IApplication
e.g. MyApp, one which extendsorg.eclipse.ui.application.WorkbenchAdvisor
e.g. MyAdvisor, and one which extendsorg.eclipse.ui.application.WorkbenchWindowAdvisor
e.g. MyWindowAdvisor.Then in MyApp you will probably call something like
where you actually start the workbench and provide your own
WorkbenchWindowAdvisor
. In MyAdvisor you have to overwrite:in which you provide your
WorkbenchWindowAdvisor
. In classMyWindowAdvisor
you can finally override the appropriate functions, e.g.Of course you have to run the appropriate application for this to work ;) OK, now, to provide arbitrary plug-ins to deal with these events, you could define an extension point.
First you need an interface which defines the "events" you want to listen to, e.g.:
Then the extension point schema (replace all "YOUR-xxx" with your own package/plug-in names, and namespace):
Then, in your MyWindowAdvisor you need to keep a reference to the extensions
load/initialize the extensions
and in each "event" function call the extensions' methods:
The final step is to provide an extension and class in each plug-in you need to listen to these workbench window events.