How to integrate a custom ISelectionProvider with Eclipse enabled In what expressions?

I have a custom graphics editor in an Eclipse RCP application.

It sets a custom ISelectionProvider in the createPartControl (..) method:

@Override
public void createPartControl(Composite parent) {
    // [snip] 
    getSite().setSelectionProvider((ISelectionProvider)model.getSelection());
}

      

I have two ViewParts listening for selection changes via ISelectionService. They are notified when a selection changes in the editor. So far so good.

I have now added a handler using the following XML:

<handlerclass="my.custom.Handler" commandId="org.eclipse.ui.edit.delete">
    <enabledWhen>
        <count value="+"/>
    </enabledWhen>
</handler>

      

If the selection in the EditPart contains> 0 items, this should include the my.custom.Handler handler, but it doesn't.

However, it is enabled if the choices provided by the built-in select providers change to a> 0 element (i.e. those provided by JFace viewers).

Any hint on how to integrate a custom ISelectionProvider implementation with the expression framework used in the handler declaration?

+2


a source to share


1 answer


enabledWhen can contain any expression. You need to indicate that you want to select the selection variable. See here for an example: http://eclipse-tips.com/tutorials/1-actions-vs-commands?start=1



+1


a source







All Articles