问题
We are looking to create a new Eclipse plugin to perform certain tasks when another commercial 3rd party plugin creates new classes in Eclipse.
The other plugin is ABAP Development Tools by SAP, which unfortunately doesn't provide source code for easy extension (as far as I can see). I'm not too familiar with Eclipse plugin development nor Java, coming from a JS, Delphi, C# background, but I have a main idea that I was hoping to work with. I've not been able to find any documentation for it so I'm not sure that it's possible.
Basically the SAP plugin creates 4 new wizards for different types of entity (Class, Interface, Program and Package) and we want to fire off a new procedure when any of these finish. Ideally, I would want to listen for a 'WizardComplete' event and run if the parameters are correct, but I can't see any such event documented.
The other obvious solution would be to 'decorate' these plugins and wrap a new 'PerformFinish', but I'm not sure on the licensing implications of doing this with commercial code nor am I keen on having to distribute a new wrapper every time SAP release a new version.
Is there an obvious way of firing off a procedure from completion of a Wizard? Possibly also on detection of creation of a new 'class' from the IDE could be an option.
回答1:
There is no way to detect the completion of a Wizard.
You can listen for changes in resources (files, folders, projects) by using the IResourceChangeListener
see here
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(... your listener ...);
The listener is given quite a lot of details about changes so you should be see the creation of the class.
来源:https://stackoverflow.com/questions/51241640/extending-a-3rd-party-eclipse-plugin-to-fire-procedure-on-newwizard-finish