Search code examples
eclipse-plugineclipse-rcprcpe4

How to call @canExecute method from a class


I'm working on eclipse rcp4 application and I'm facing a problem with @canExecute annotation method . When I send broker.send(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, UIEvents.ALL_ELEMENT_ID); it will trigger all canExecute method but I want to restrict to a certain classes only . Could any one help on this


Solution

  • The second argument to the UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC event call can be something that implements org.eclipse.e4.ui.workbench.Selector.

    So, for example, to just update a specific element id you could use:

    Selector selector = element -> "element id".equals(element.getElementId());
    
    eventBroker.send(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, selector);
    

    If you just want to update a single element you can just specify the element id as the second parameter:

    eventBroker.send(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC, "element id");