简体   繁体   English

将值从一个处理程序传递给Eclipse e4中的另一个处理程序?

[英]pass value from one handler to another handler in eclipse e4?

I am calculating a value in one handler and I need to pass that value to the other handler. 我正在一个处理程序中计算一个值,我需要将该值传递给另一个处理程序。 In other words, I have created two menu items in which one menu item(XYZ) calculate values when it is clicked and I need to pass those values so that when the other menu item(ABC) get those values and when "ABC" menu item is clicked the value should be displayed in a message dialog box. 换句话说,我创建了两个菜单项,其中一个菜单项(XYZ)在单击时会计算值,我需要传递这些值,以便当另一个菜单项(ABC)获得这些值时以及在“ ABC”菜单时单击该项目,该值应显示在消息对话框中。

Can anyone please suggest me how to do this eclipse rcp e4?? 谁能建议我如何做这个Eclipse RCP E4?

There are many ways to do this. 有很多方法可以做到这一点。

If the menus are both on the same MPart you could use MPart.getTransientData() which returns a Map where you can store temporary data. 如果两个菜单都在同一MPart ,则可以使用MPart.getTransientData()返回一个可以存储临时数据的Map Or you could use MPart.getObject() and store the data in your part object. 或者,您可以使用MPart.getObject()并将数据存储在零件对象中。

If this data needs to be available between parts you could define a class containing the data and store it in the application IEclipseContext so that it can be injected where it is required. 如果需要在各部分之间提供此数据,则可以定义一个包含该数据的类,并将其存储在应用程序IEclipseContext以便可以将其IEclipseContext到需要的位置。 You can put the data in the context in a life cycle class or by using an AddOn or by using a ContextFunction . 您可以将数据放在生命周期类中的上下文中,或者使用AddOn或使用ContextFunction

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

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