Jump to: navigation, search

Difference between revisions of "Eclipse4/UI/Event/Migration"

(Action Required)
m (UIEvents Migration Notes moved to Eclipse4/UI/Event/Migration: Use proper namespace)
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
== Rational for Change ==
 
== Rational for Change ==
  
Up until the end of M4 the topic strings used to subscribe to UI events where constructed at run time using the UIEvents.buildTopic() methods like this:
+
Up until the end of M4, the topic strings used to subscribe to UI events were constructed at run time using the UIEvents.buildTopic() methods like this:
  
 
<source lang="java">
 
<source lang="java">
Line 19: Line 19:
 
New UI Event TOPIC_* constants with fully qualified values where created for making event subscriptions.
 
New UI Event TOPIC_* constants with fully qualified values where created for making event subscriptions.
  
In essence the string returned by the old
+
In essence the string returned by the old <tt>UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL)</tt> is equal to
<source lang="java">
+
<tt>UIEvents.UILabel.TOPIC_LABEL</tt>
UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL)
+
</source>
+
is equal to
+
<source lang="java">
+
UIEvents.UILabel.TOPIC_LABEL
+
</source>
+
  
 
So a subscribe now looks like:
 
So a subscribe now looks like:
Line 40: Line 34:
 
</source>
 
</source>
  
== Action Required ==
+
== Action Required ==
  
The three  
+
The three <tt>UIEvents.buildTopic()</tt> methods and all the UIEvents TOPIC constants have been deprecated in M4 and will be deleted before M5 is released.  
<source lang="java">
+
UIEvents.buildTopic()
+
</source>
+
methods and all the UIEvents TOPIC constants have been deprecated in M4 and will be deleted before M5 is released. If you where using a call similar to
+
<source lang="java">
+
UIEvents.buildTopic(UIEvents.UILabel.TOPIC)
+
</source>
+
please replace this with direct use of the constant
+
<source lang="java">
+
UIEvents.UILabel.TOPIC_ALL
+
</source>
+
  
If you where using a call similar to  
+
If you where using a call similar to <tt>UIEvents.buildTopic(UIEvents.UILabel.TOPIC)</tt> please replace this with direct use of the constant <tt>UIEvents.UILabel.TOPIC_ALL</tt>  
<source lang="java">
+
UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL)  
+
</source>
+
please replace this with direct use of the constant  
+
<source lang="java">
+
UIEvents.UILabel.TOPIC_LABEL
+
</source>
+
  
Subscribing to a particular tag change of a particular attribute through the use of
+
If you where using a call similar to <tt>UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL)</tt> please replace this with direct use of the constant <tt>UIEvents.UILabel.TOPIC_LABEL</tt>
<source lang="java">
+
UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL, UIEvents.EventTypes.SET)  
+
</source>
+
is no longer supported.  In practice this pattern was never used.  Typical event handlers are interested in all changes to a given attribute.  Some particular change to some particular attribute was too fine grained a filtering for general use and the over all gains of the new strategy where deemed to outweigh the usefulness of this unused pattern.
+
  
For testing attribute names within event handler implementations you should continue to use the attribute constants such as
+
Subscribing to a particular tag change of a particular attribute through the use of <tt>UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL, UIEvents.EventTypes.SET)</tt> is no longer supported. In practice this pattern was never used. Typical event handlers are interested in all changes to a given attribute. Some particular change to some particular attribute was too fine grained a filtering for general use and the over all gains of the new strategy where deemed to outweigh the usefulness of this unused pattern.
<source lang="java">
+
 
UIEvents.UILabel.LABEL
+
For testing attribute names within event handler implementations you should continue to use the attribute constants such as <tt>UIEvents.UILabel.LABEL</tt> as these are the values inserted into the UI Events by UIEventPublisher.
</source>
+
as these are the values inserted into the UI Events by UIEventPublisher
+

Latest revision as of 17:38, 2 December 2011

Take a look at Eclipse4/RCP/Event Model for a description on the Eclipse UI Event model in general.

Rational for Change

Up until the end of M4, the topic strings used to subscribe to UI events were constructed at run time using the UIEvents.buildTopic() methods like this:

eventBroker.subscribe(UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL), handler);

This has the following disadvantages:

  • Long complicated looking code to do simple subscribes
  • Prevents us from using the cleaner @UIEventTopic() dependency injection technique for subscribing to ui events
  • Creating more run time garbage through string concatenation
  • Possibly confusing clients by making them think our eventing model is more complicated than it actually is

Change

New UI Event TOPIC_* constants with fully qualified values where created for making event subscriptions.

In essence the string returned by the old UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL) is equal to UIEvents.UILabel.TOPIC_LABEL

So a subscribe now looks like:

eventBroker.subscribe(UIEvents.UILabel.TOPIC_LABEL)

or better yet, you can use dependency injection

@Inject @Optional
private void closeHandler(@UIEventTopic(UIEvents.UILabel.TOPIC_LABEL) Event event) {}

Action Required

The three UIEvents.buildTopic() methods and all the UIEvents TOPIC constants have been deprecated in M4 and will be deleted before M5 is released.

If you where using a call similar to UIEvents.buildTopic(UIEvents.UILabel.TOPIC) please replace this with direct use of the constant UIEvents.UILabel.TOPIC_ALL

If you where using a call similar to UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL) please replace this with direct use of the constant UIEvents.UILabel.TOPIC_LABEL

Subscribing to a particular tag change of a particular attribute through the use of UIEvents.buildTopic(UIEvents.UILabel.TOPIC, UIEvents.UILabel.LABEL, UIEvents.EventTypes.SET) is no longer supported. In practice this pattern was never used. Typical event handlers are interested in all changes to a given attribute. Some particular change to some particular attribute was too fine grained a filtering for general use and the over all gains of the new strategy where deemed to outweigh the usefulness of this unused pattern.

For testing attribute names within event handler implementations you should continue to use the attribute constants such as UIEvents.UILabel.LABEL as these are the values inserted into the UI Events by UIEventPublisher.