Skip to main content
Jump to: navigation, search

Difference between revisions of "Eclipse4/RCP/Modeled UI/Listening to Model Changes"

< Eclipse4‎ | RCP‎ | Modeled UI
(New page: When the model changes and it is not a no-op (for example, setting its label to its current label), an event will be dispatched to all interested event handlers. Eclipse 4 uses a [[E4/RCP/...)
 
Line 1: Line 1:
 
When the model changes and it is not a no-op (for example, setting its label to its current label), an event will be dispatched to all interested event handlers. Eclipse 4 uses a [[E4/RCP/Event Model|global listener pattern]] so all handler subscriptions are done through the event broker.
 
When the model changes and it is not a no-op (for example, setting its label to its current label), an event will be dispatched to all interested event handlers. Eclipse 4 uses a [[E4/RCP/Event Model|global listener pattern]] so all handler subscriptions are done through the event broker.
 +
 +
Topics for event subscriptions can be generated from the <tt>UIEvents</tt> class.
 +
 +
<source lang="java">
 +
// subscribe to all events generated from MUILabels
 +
eventBroker.subscribe(UIEvents.buildTopic(UIEvents.UILabel.TOPIC), eventHandler);
 +
 +
// subscribe only to events generated from MItems's selected attribute being switched
 +
eventBroker.subscribe(UIEvents.buildTopic(UIEvents.Item.TOPIC, UIEvents,Item.SELECTED), eventHandler);
 +
</source>

Revision as of 13:13, 11 April 2011

When the model changes and it is not a no-op (for example, setting its label to its current label), an event will be dispatched to all interested event handlers. Eclipse 4 uses a global listener pattern so all handler subscriptions are done through the event broker.

Topics for event subscriptions can be generated from the UIEvents class.

// subscribe to all events generated from MUILabels
eventBroker.subscribe(UIEvents.buildTopic(UIEvents.UILabel.TOPIC), eventHandler);
 
// subscribe only to events generated from MItems's selected attribute being switched
eventBroker.subscribe(UIEvents.buildTopic(UIEvents.Item.TOPIC, UIEvents,Item.SELECTED), eventHandler);

Back to the top