常见错误

     1、Caused by: java.lang.NullPointerException
          at org.eclipse.e4.ui.internal.workbench.E4Workbench.processHierarchy(E4Workbench.java:xxxx)

     解决方法:

     在Application.e4xmi文件中添加:      

<addons xmi:id="_XGB3wPZlEd-XstlTZ6nTXg" elementId="org.eclipse.e4.core.commands.service" contributionURI="platform:/plugin/org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_XGB3wPZlEd-XstlTZ6nTXh" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="platform:/plugin/org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_XGB3wPZlEd-XstlTZ6nTXi" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="platform:/plugin/org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
<addons xmi:id="_LK0NgPZmEd-XstlTZ6nTXj" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
<addons xmi:id="_LK0NgPZmEd-XstlTZ6nTXk" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
<addons xmi:id="_LK0NgPZmEd-XstlTZ6nTXl" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="platform:/plugin/org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>

 

    2、@UIEventHandler 编译错误

     解决方法:

     org.eclipse.e4.core.services.annotations.UIEventHandler@UIEventHandler 替换成 org.eclipse.e4.core.di.extensions.@UIEventTopic

     org.eclipse.e4.core.services.annotations.UIEventHandler@EventHandler 替换成 org.eclipse.e4.core.di.extensions.@EventTopic

 

使用技巧

     1、获取IEclipseContext实例

public static IEclipseContext getServiceContext() {
        return EclipseContextFactory.getServiceContext(Activator.getDefault().getContext());
    }
 
2.获取在e4.xmi文件中ID为app.base的应用程序

@Inject
@Named("app.base")
private MApplication application;

    

     3、纯代码创建MApplication

return app;
}

      4、使用ModelService.findElements查找模型对象。

);
   List<MUIElement> oneTags = modelService.findElements(application, null,null, tags);
   assertEquals(oneTags.size(), 1);

    5、使用ModelService.insert插入对象

, mapplication), EModelService.ABOVE, 35);

    6、在上下文中查找当前激活窗体

class.getName());
}
});

   7、获得Eclipse 实例安装地址。

return (Location) locationTracker.getService();
}

   8、Handler的 @Execute和@CanExecute用法

void execute(@Named(IServiceConstants.ACTIVE_PART) MContext context) {
Contact contact = (Contact) context.getContext().get(IServiceConstants.ACTIVE_SELECTION);
ContactsRepositoryFactory.getContactsRepository().removeContact(contact);
}
}

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2021-08-08
  • 2021-09-24
  • 2021-07-22
  • 2021-08-30
猜你喜欢
  • 2022-12-23
  • 2021-05-30
  • 2021-08-05
  • 2021-06-27
  • 2022-01-25
  • 2021-12-22
  • 2021-09-23
相关资源
相似解决方案