简体   繁体   English

创建新的MPart时如何获取在Application.e4xmi中注册的bundleclass-Eclipse RCP e4

[英]How to get bundleclass that is registered in Application.e4xmi when new MPart is created - Eclipse RCP e4

How to get bundleclass that is registered in Application.e4xmi when new MPart is created dynamically: 动态创建新的MPart时,如何获取在Application.e4xmi中注册的bundleclass:

EPartService lService = (EPartService)Activator.getContext().getServiceReference(EPartService.class);
    MPart lPart = lService.showPart(pViewId, PartState.CREATE);
    //pass some initial parameters to lPart...

or how to pass some parameters to the bundleclass of new MPart 或如何将一些参数传递给新的MPart的bundleclass

Call the getObject() method of MPart to get the class created for the part: 调用MPartgetObject()方法以获取为零件创建的类:

MyPartClass partObject = (MyPartClass)lpart.getObject();

Note: You should inject the EPartService in to your handler rather than trying to get it via getServiceReference . 注意:您应该将EPartService注入到处理程序中,而不是尝试通过getServiceReference获得它。 There are multiple part services and you need to get the correct one. 有多个零件服务,您需要获取正确的零件服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM