(Eclipse RCP的)我怎样才能得到编辑的命令处理程序的参考

StackOverflow https://stackoverflow.com/questions/2111232

  •  22-09-2019
  •  | 
  •  

我想要得到编辑的文本命令处理程序,所以我怎么能得到编辑的参照,谢谢

有帮助吗?

解决方案

要获得编辑的命令处理程序,你可以做到这一点参考:

public class myCommandHandler extends AbstractHandler implements IHandler {

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
        IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
        IEditorInput editorInput = page.getActiveEditor().getEditorInput();
...

好运

其他提示

@Override
public void setEnabled(Object evaluationContext) {
    Object editor = ((EvaluationContext)evaluationContext).getParent().getVariable("activeEditor");

然后键入铸所以用上面的回答结合现在执行和实现两个人都要上班。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top