简体   繁体   中英

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.

Can anyone please suggest me how to do this 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. Or you could use MPart.getObject() and store the data in your part object.

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. You can put the data in the context in a life cycle class or by using an AddOn or by using a ContextFunction .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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