Eclipse RCP:在不同ViewPart中创建的元素之间的通信?

时间:2020-12-14 22:22:20

what's the best way to make communications between page widgets residing on differents ViewPart?

什么是在不同的ViewPart上的页面小部件之间进行通信的最佳方法?

via listener or via shared object instances like "getViewSite().getPart()/getPage()" ? what pro/contra and what's the best strategy for You?

通过监听器或通过共享对象实例,如“getViewSite()。getPart()/ getPage()”?什么是pro / contra,对你来说最好的策略是什么?

Thanks, regards

2 个解决方案

#1


I would suggest looking at the Eclipse Modeling Framework

我建议看一下Eclipse Modeling Framework

#2


The answer depends on the nature of the changes. Why is one ViewPart causing changes in another ViewPart?

答案取决于变化的性质。为什么一个ViewPart会导致另一个ViewPart发生变化?

For example, if the change is because one ViewPart is changing the model data and the other ViewPart is displaying the same data then you should be going through the model. One ViewPart updates the model and the other is listening to the model for changes. This is basic MVC.

例如,如果更改是因为一个ViewPart正在更改模型数据而另一个ViewPart正在显示相同的数据,那么您应该浏览模型。一个ViewPart更新模型,另一个ViewPart正在监听模型的更改。这是基本的MVC。

If, on the other hand, the change is caused because of a selection (for example, a change in the selection in the navigation view causes another view to display the contents of that selection) then you should be using the global selection handler.

另一方面,如果由于选择而导致更改(例如,导航视图中的选择更改导致另一个视图显示该选择的内容),那么您应该使用全局选择处理程序。

The question needs to be updated to be more specific to get the correct answer.

需要更新问题以更具体地获得正确答案。

#1


I would suggest looking at the Eclipse Modeling Framework

我建议看一下Eclipse Modeling Framework

#2


The answer depends on the nature of the changes. Why is one ViewPart causing changes in another ViewPart?

答案取决于变化的性质。为什么一个ViewPart会导致另一个ViewPart发生变化?

For example, if the change is because one ViewPart is changing the model data and the other ViewPart is displaying the same data then you should be going through the model. One ViewPart updates the model and the other is listening to the model for changes. This is basic MVC.

例如,如果更改是因为一个ViewPart正在更改模型数据而另一个ViewPart正在显示相同的数据,那么您应该浏览模型。一个ViewPart更新模型,另一个ViewPart正在监听模型的更改。这是基本的MVC。

If, on the other hand, the change is caused because of a selection (for example, a change in the selection in the navigation view causes another view to display the contents of that selection) then you should be using the global selection handler.

另一方面,如果由于选择而导致更改(例如,导航视图中的选择更改导致另一个视图显示该选择的内容),那么您应该使用全局选择处理程序。

The question needs to be updated to be more specific to get the correct answer.

需要更新问题以更具体地获得正确答案。