【问题标题】:Eclipse plugin doesn't work in CDTEclipse 插件在 CDT 中不起作用
【发布时间】:2015-10-10 09:34:23
【问题描述】:

我已经实现了一个在测试工作台中运行良好的 Eclipse 插件,Eclipse IDE 用于 PHP Developers 和 Eclipse IDE 用于 JavaDevelopers 但是在 Eclipse CDT 中不起作用。没有错误信息,所以我不知道,为什么。

我的插件添加了一个弹出菜单条目并执行一个操作。我注意到插件在此行之后停止:

 IFile file = (IFile) ((IStructuredSelection) wbw.getSelectionService().getSelection()).getFirstElement();

所有 IDE 都在 kubuntu 14.04 上运行。

【问题讨论】:

    标签: java eclipse pde


    【解决方案1】:

    选择服务返回的选择通常是用户界面对象,而不是IFile。您需要使用IAdapterManager 将此对象适配为文件。

    Object selected = ((IStructuredSelection) wbw.getSelectionService().getSelection()).getFirstElement();
    
    IAdapterManager manager = Platform.getAdapterManager();
    
    IFile file = (IFile)manager.getAdapter(selected, IFile.class);
    

    【讨论】:

      猜你喜欢
      • 2011-07-12
      • 1970-01-01
      • 2013-05-23
      • 2016-03-26
      • 1970-01-01
      • 2011-10-31
      • 2018-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多