Eclipse RCP: how to register an ISourceProviderListener

喜夏-厌秋 提交于 2019-12-08 09:06:33

问题


today i tried the following:

I have:

  • a View with a form (FormView)
  • a AbstractSourceProvider (Provider) to provide changes in FormView to the world
  • a View (ConsumerView) that should consume information from Provider it implements ISourceProviderListener

FormView updates the Provider, which fires the fireSourceChanged. But how can I register the ConsumerView so that it listens for changes in the Provider?

This answer here on stackoverflow, did not really explain how to do it: How to communicate between views in Eclipse RCP?

Also Lars Vogels tutorials on RCP Commands are mentioned frequently, but I don't get it from there.

Thanks for your help in advance!


回答1:


From within your ConsumerView createPartControl(..) method:

ISourceProviderService service = (ISourceProviderService)getSite().getService(ISourceProviderService.class);

ISourceProvider yourProvider = service.getSourceProvider("yourSourceProviderName");

yourProvider.addSourceProviderListener(this);


来源:https://stackoverflow.com/questions/6874874/eclipse-rcp-how-to-register-an-isourceproviderlistener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!