Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Different behavior for changes of "active selection"
Different behavior for changes of "active selection" [message #1852346] Wed, 11 May 2022 11:43
Marko Herchet is currently offline Marko HerchetFriend
Messages: 13
Registered: May 2012
Junior Member
Hi all,
I encountered an unexpected behavior when developing an e4-Application (no compatibility layer) and hope someone can help me understand where I didnt get the concept yet.

There are Objects reacting to changes to the "Workbench Selection" the following way...
    @Inject
    public void selectionChanged(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) final Object sel)
    {
        System.err.println("---> selChange(injection) --->" + sel);
    }


But there are also Objects that are not under the control of EclipseContexts and they react to changes this way...
    public MyObject(final ESelectionService selectionService)
    {
            selectionService.addSelectionListener(this);
    }

    @Override
    public void selectionChanged(final MPart part, final Object objSelection)
    {
        System.err.println("---> selChange(listener) --->" + sel);
    }


The strange thing here is, that when I now open two Editors that provide a Selection, the injection-variant automatically gets called when I switch between the Editors (=when the active part changes) but the listener-variant does not get called.
I expected them to behave the exact same way.

Addition: When I call ESelectionService.setSelection(anySelection) both variants get called
Addition: We use Eclipse 2021_12

[Updated on: Wed, 11 May 2022 11:50]

Report message to a moderator

Previous Topic:dynamically create view with toolbar
Next Topic:Separate part focus and activation during keyboard navigation
Goto Forum:
  


Current Time: Fri Apr 19 21:12:13 GMT 2024

Powered by FUDForum. Page generated in 0.02426 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top