Repository navigation
Support POJO handlers in the org.eclipse.ui.handlers extension point - #4242
Conversation
|
Why would an E4 handler be additional being registered through |
|
This is for the migration path e3 handlers -> POJO -> later to model similar to what we offer for view and e4 views. As a migration path is currently missing we have seen zero migration of e3 to e4 handlers in the last 10 years in platform. |
You know that "later" is a synonym for "never" in computer programming right? So I don't see how this would benefit anything from going straight to e4-model - what should actually be possible already. If not it would better be enabled like that instead of offering to use a middle-ground between e3 + e4. |
|
Lots of my RCP client would be able to migrate their handler code to POJOs with little risk with this change. |
But again, what is the risk of declaring them in e4.xmi directly? If I remember right there is/was even an automatic migration offered there for views as well. That would offer a much more sustainable migration path here. |
The e4 model persists its state while plugin.xml is recreated every startup so e4 model contributions have the risk of getting stale. So the client hesitate to do this one by one for a handler. With this change they can first migrate the Java code and afterwards do the model migration. |
1b492d9 to
a2e6c9d
Compare
29353ac to
31f611b
Compare
40bf8fb to
46f224b
Compare
A handler contributed via the class attribute had to implement IHandler. Anything else failed the cast in HandlerProxy with a logged ClassCastException and left the proxy permanently disabled. Contributions that do not implement IHandler are now wrapped in an adapter that dispatches to their @execute and @CanExecute methods through dependency injection, the same mechanism the E4 application model already uses for its handlers. Field and method injection plus @PostConstruct work as well. The methods run in the active part context, as legacy enablement refreshes pass the window-level evaluation state and E4 handlers resolve the active leaf. Instantiation still goes through createExecutableExtension, so IExecutableExtension and the <class><parameter> form keep working unchanged, and handlers implementing IHandler take the previous path untouched. The same path serves the defaultHandler attribute of org.eclipse.ui.commands; QuitHandler is migrated as the first such POJO. Assisted-by: multiple AI agents and layers of automated tooling 🤖
46f224b to
b487076
Compare
|
This also now migrates the first handler (QuitHandler) so that the change is also used by platform. #4390 is the next wave of handler migrations to e4 POJOs. |
Handlers contributed through the
classattribute oforg.eclipse.ui.handlersor thedefaultHandlerattribute oforg.eclipse.ui.commandshad to implementIHandler; anything else failed the cast inHandlerProxyand left the proxy permanently disabled. Such contributions are now wrapped in an adapter that dispatches to their@Executeand@CanExecutemethods through dependency injection in the active part context, the same mechanism E4 model handlers use. Field and method injection plus@PostConstructwork as well, so plug-ins written against the E4 programming model can contribute handlers declaratively without deriving fromAbstractHandler.Instantiation still goes through
createExecutableExtension, soIExecutableExtensionand the<class><parameter>form keep working, and handlers implementingIHandlertake the previous path untouched.QuitHandler(File > Exit) is migrated as the first platform POJO handler. Constructor injection andIObjectWithStateare not supported, since instantiation stays on the registry path andHandlerProxyholds the command state itself.