开发者

How to integrate a custom ISelectionProvider with Eclipse enabledWhen expressions?

I have a custom graphical EditorPart in a Eclipse RCP application.

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

@Override
public void createPartControl(Composite parent) {
    // [snip] 
    getSite().setSelectionProvider((ISelectionProvider)model.getSelection());
}开发者_如何学Python

I have two ViewParts listening to selection changes via the ISelectionService. They get notified when the selection in the EditorPart changes. So far so good.

Now I've 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 elements, this should enable the handler my.custom.Handler, but it doesn't.

It is, however enabled if the selection provided by built-in selection providers changes to > 0 element (i.e. those provided by JFace viewers).

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜