简体   繁体   English

Eclipse插件RCP:如何在视图之间传递数据

[英]Eclipse Plugin RCP: How to pass data between Views

I have an Eclipse Plugin with two views. 我有一个带有两个视图的Eclipse插件。 I would like to pass an ArrayList from one view to the other view. 我想将ArrayList从一个视图传递到另一个视图。 I am OK with a Pull model although an Observor based method would be nice too. 尽管基于Observor的方法也不错,但我对Pull模型还可以。

The answer here is the closest I've found after much searching: Passing parameters while showing a view in Eclipse RCP 答案是经过大量搜索后找到的最接近的答案: 在Eclipse RCP中显示视图时传递参数

However, I don't believe it fits my use case. 但是,我认为它不适合我的用例。

Put the data in a class that all the views can access. 将数据放在所有视图都可以访问的类中。

You could use a singleton class instance managed by the plug-in Activator for example. 例如,您可以使用由插件激活程序管理的单例类实例。

If you need to react to changes in class data use listeners to listen for changes to the data. 如果您需要对类数据的更改做出反应,请使用侦听器来侦听数据的更改。 The org.eclipse.core.runtime.ListenerList class provides some code to help with listener lists. org.eclipse.core.runtime.ListenerList类提供一些代码来帮助侦听器列表。

For e4 applications you can use a class annotated with @Creatable and @Singleton and inject it where required. 对于E4应用程序,你可以使用带有注释的类@Creatable@Singleton并在必要时注入它。 For e4 you can use the Event Broker to broadcast events. 对于e4,您可以使用事件代理来广播事件。

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

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