简体   繁体   中英

Eclipse RCP - Application wide code that responds to property changes from sourceProvider

I'm trying to create an application wide listener that will switch perspectives when a boolean sourceProvider property changes.

My RCP experience extends to Views and Source Providers, Is there a way to register some code to execute globally when a source changes, but doesn't lie inside a view or provider?

If you are using e4 you can publish events in publish subscribe style. The Eclipse platform will act as your global message bus. Here is a short introduction: http://wiki.eclipse.org/Eclipse4/RCP/Event_Model The event's receiver then switches perspectives.

If you have a RCP 3.x application you might consider running it in compatibility mode using the above feature (I did not try that).

Using only 3.x features I can think of the following solution: 1. In the activator class of your main plugin create a property change listener and register this listener to listen for property changes of your source (which must implement property change support, ie must fire events and must accept listeners). If you do not have access to the source upon startup do that sometimes later. 2. if the listener receives an appropriate event switch perspectives.

I cannot think of any native feature of the platform to do that.

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