简体   繁体   English

Eclipse RCP-实现扩展点。 在哪里评估?

[英]Eclipse RCP - implementing extension point. Where to evaluate?

  • I'm implementing an extension with an own extension-point in Eclipse 3.7 Indigo. 我正在Eclipse 3.7 Indigo中使用自己的扩展点实现扩展。
  • I found a way to get all plugins, which will contribute functionality to my extension-point. 我找到了一种获取所有插件的方法,这将为我的扩展点提供功能。 This is described here 在这里描述

Question: 题:
Where should the evaluation of the contributed information be done? 应在何处评估所提供的信息? In which class? 在哪个级别?

It should be triggered when something you contribute needs that information. 当您做出的贡献需要该信息时,应触发该事件。 A common pattern for example is you contribute a view and use an extension point to allow others to contribute to your view. 例如,一种常见的模式是您贡献视图,并使用扩展点允许其他人贡献您的视图。 Put your extension point code in MyViewRegistry and have it read the extension point on instantiation. 将扩展点代码放入MyViewRegistry中,并在实例化时读取扩展点。 Then create: 然后创建:

private static MyViewRegistry registry = null;
public MyViewRegistry getRegistry() {
    if (registry == null) {
        registry = new MyViewRegistry();
        registry.read();
    }
    return registry;
}

Then when you view actually needs the extension information, it will trigger the load. 然后,当您查看实际需要的扩展信息时,它将触发负载。

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

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