Eclipse e4 RCP: Core Expressions - Something less XML-hell?

前端 未结 1 1892
日久生厌
日久生厌 2021-01-13 18:44

I\'m working on an E4 RCP application, and have a context menu which has menu items visible or not depending on the selection. The way I\'ve found to do this is with core ex

相关标签:
1条回答
  • 2021-01-13 19:24

    Core expressions are not working for toolbar items, for example. You can use the following workaround in command handlers:

    public class SomeHandler {
        protected MToolItem toolItem;
    
        @CanExecute
        @Inject
        public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional ISelection selection)
        {
            boolean canExecute = ...
            setToolItemVisible(canExecute);
            ...
        }
    
        private void setToolItemVisible(final boolean visible) {
            if (toolItem != null) {
                Display.getDefault().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        toolItem.setVisible(visible);
                    }
                });
            }
        }
    }
    

    where toolItem is retrieved by EModelService

    0 讨论(0)
提交回复
热议问题