Eclipse,如何在创建WorkBench窗口后在bundle中执行代码?

时间:2022-05-29 11:42:44

So I have a bundle that needs access to the workbench window to add some items to a menu programmatically, which I can do fine.

所以我有一个需要访问工作台窗口的软件包,以编程方式将一些项添加到菜单中,我可以做得很好。

But what I run into is when there's a race condition where my bundle is started before the workbench window is finished being instantiated and it will spit out an error about the workbench not existing yet when my bundle tries to add stuff to a menu with code.

但是我遇到的是当有一个竞争条件,我的包在工作台窗口完成实例化之前就开始了,当我的包试图用包含代码的菜单添加东西时,它会发出一个关于工作台的错误。

So is there an extension point or something that I can use to tell the program to execute such and such code after the workbench window has loaded? I don't want to muck around with start levels for my bundles.

那么在工作台窗口加载后,是否有一个扩展点或者某些东西可以用来告诉程序执行这样的代码?我不想乱用我的捆绑包的起始级别。

1 个解决方案

#1


0  

  • In Eclipse 3 you can register org.eclipse.ui.application.WorkbenchWindowAdvisor to listen for window lifecycle events.
  • 在Eclipse 3中,您可以注册org.eclipse.ui.application.WorkbenchWindowAdvisor来监听窗口生命周期事件。

  • If your items are not dynamically you can add them via plugin.xml (instead of programmatically adding them). Eclipse will load this extensions when appropriate and you don't have to worry about the lifecycle.
  • 如果您的项目不是动态的,您可以通过plugin.xml添加它们(而不是以编程方式添加它们)。 Eclipse将在适当时加载此扩展,您不必担心生命周期。

#1


0  

  • In Eclipse 3 you can register org.eclipse.ui.application.WorkbenchWindowAdvisor to listen for window lifecycle events.
  • 在Eclipse 3中,您可以注册org.eclipse.ui.application.WorkbenchWindowAdvisor来监听窗口生命周期事件。

  • If your items are not dynamically you can add them via plugin.xml (instead of programmatically adding them). Eclipse will load this extensions when appropriate and you don't have to worry about the lifecycle.
  • 如果您的项目不是动态的,您可以通过plugin.xml添加它们(而不是以编程方式添加它们)。 Eclipse将在适当时加载此扩展,您不必担心生命周期。