简体   繁体   English

启动和停止主机插件

[英]Starting and Stopping Host Plug-ins

We have a standard Eclipse plug-in with the usual GUI elements, and since our applications don't have the same structure, the registration of these elements is done in a fragment, for example: 我们有一个带有常规GUI元素的标准Eclipse插件,并且由于我们的应用程序没有相同的结构,因此这些元素的注册是在一个片段中完成的,例如:

<fragment>
    <extension point="org.eclipse.ui.menus">
        <menuContribution allPopups="false" locationURI="popup:org.acme.menu>
            <command commandId="org.acme.command" style="push" />
        </menuContribution>
    </extension>
</fragment>

Now everything works as expected. 现在一切都按预期进行。 The problem comes when stopping the host plug-in, because evidently the fragment gets not stopped as well, the menu in question stays populated, preference pages stay in the dialog, and so on. 停止主机插件时出现问题,因为显然片段也没有停止,有问题的菜单仍然填充,首选项页面保留在对话框中,依此类推。

I previously asked if I could just start and stop the fragment directly, but it was confirmed that you should not (and in fact, cannot) do stuff like that to fragments. 之前曾问过我是否可以直接启动和停止片段,但可以肯定的是,您不应该(实际上也不能)对片段执行类似的操作。

Then I started to install / uninstall the fragment, which lead to some bug in the PackageAdmin . 然后,我开始安装/卸载该片段,这导致PackageAdmin中出现一些错误

As far as I can tell, it's fair game to put the registration of GUI elements in an fragment, and as far as I understand, the fragment's life cycle should be bound to the host, so it shouldn't contribute GUI elements when the host is stopped. 据我所知,将GUI元素的注册放在一个片段中是公平的游戏,据我所知,片段的生命周期应该绑定到主机,因此当主机时它不应该贡献GUI元素已停止。

Can somebody point out what I'm doing wrong here? 有人可以指出我在做什么错吗?

The extension point declarations are available from any installed plugin or fragment regardless of whether or not they have been started. 扩展点声明可从任何已安装的插件或片段中获得,无论它们是否已启动。 Stopping the host plugin won't make that menu declaration unavailable. 停止主机插件不会使该菜单声明不可用。

To achieve this you may need to register the menu contribution programmatically when the bundle starts and remove it when the bundle stops. 为此,您可能需要在捆绑包启动时以编程方式注册菜单内容,并在捆绑包停止时将其删除。 This would probably mean using a separate plugin rather than a fragment as fragments don't have Activators. 这可能意味着要使用单独的插件而不是片段,因为片段没有激活器。

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

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