开发者

eclipse-rcp : how to add double click listener on a ListViewer's item?

I开发者_StackOverflow中文版 have a ListViewer in my eclipse-plugin, I want to do some work when user double click on the items in that ListViewer.

I had attached a doubleClick listener with my ListViewer instance, but it will be fired when I double click on anywhere inside the ListViewer


Check the current selection inside your listener. Like in the following code:

viewer.addDoubleClickListener(new IDoubleClickListener() {
    @Override
    public void doubleClick(DoubleClickEvent event) {
        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
        if (selection.isEmpty()) return;

        List<Object> list = selection.toList();
        ///...
    }
});

Remember that the selection for ListView (and TableViewer, ComboViewer, and TreeViewer) is always a IStructuredSelection..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜