| Summary: | Annotations for Action/Selection/Focus events | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [RT] Riena | Reporter: | Holger Hoch <holger.hoch> | ||||||
| Component: | UI | Assignee: | Stefan Liebig <Stefan.Liebig> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | enhancement | ||||||||
| Priority: | P3 | CC: | christian.campo, Stefan.Liebig, stephan.mann | ||||||
| Version: | 2.0.0 | ||||||||
| Target Milestone: | 3.0.0.M7 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 335691 | ||||||||
| Attachments: |
|
||||||||
|
Description
Holger Hoch
Created attachment 187946 [details]
Annotations for action and selection listeners
o.e.r.e.c.c.ComboAndChoiceSubModuleController and o.e.r.e.c.c.ListSubModuleController from the org.eclipse.riena.example.client plugin have been changed to use annotation for action and selection listeners
I fully second that enhancement! It would make controllers so much more readable and easier to develop. Please consider improving the patch for the following use cases: 1. Provide a default annotation for double clicks in a list or table. AFAICS this is a common use case. 2. Provide a possibility to attach a listener to multiple ridgets. As an example, it might be useful to do some UI updates when one of multiple ridgets looses focus. in reply to comment #2 1) yes 2) If this can be done by annotating a 'listener' method with multiple annotations each with a different ridget id - would that be ok? General question: How specific or how general shall annotation handlers be? E.g. the handler responsible for 'addListener(IActionCallback)' performs the 'addListener' on just IActionRidgets. Shall it also perform that action on any kind of ridget supporting this signature? In this case also for ITraverseRidget? Maybe use duck typing!? I am against duck-typing since that means using reflection. But I would be PRO having that annocation for IActionRidget and ITraverseRidget. Thanks Holger! Patch applied with a few refactorings. in reply to comment 4: NO duck typing! I was just trying to use this new, very cool feature but sadly I can't use it for all use cases I was hoping for. As described in comment#2 I'd like to use it, among other things, to react to change events and trigger an UI update: @OnPropertyChange(ridgetId = BINDING_ID_RIDGET1) @OnPropertyChange(ridgetId = BINDING_ID_RIDGET2) public void doUiRefresh() { [...] } I guess that's not possible but it would be nice to be at least able to provide a list of ridget IDs. Otherwise one would have to fall back to "the old ways" in this case. I guess the same goes for all other annotations. Reopened because of comment #7 Yes, this is very sad. Unfortunately Java does not allow this.
However, there are common patterns (requiring additional coding) to solve such issues.
1. Nested annotations, e.g.
@OnPropertyChanges( {
@OnPropertyChange(ridgetId = BINDING_ID_RIDGET1),
@OnPropertyChange(ridgetId = BINDING_ID_RIDGET2) } )
public void doUiRefresh() {
[...]
}
2. Allow multiple values (array) for ridgetId (would become ridgitIds)
@OnPropertyChange(ridgetIds ={ BINDING_ID_RIDGET1, BINDING_ID_RIDGET2 } )
public void doUiRefresh() {
[...]
}
3. Allow the mutliple values be expressed within a single comma separated string
@OnPropertyChange(ridgetId = BINDING_ID_RIDGET1 + "," + BINDING_ID_RIDGET2 )
public void doUiRefresh() {
[...]
}
I would go for solution 1. since this is the most flexibel and obvious solution.
I too would prefer solution 1, since the other ones become unreadable if an additional parameter needs to be provided (e.g. propertyName for this @OnPropertyChange). (In reply to comment #10) > I too would prefer solution 1, since the other ones become unreadable if an > additional parameter needs to be provided (e.g. propertyName for this > @OnPropertyChange). I could agree if we agree that the unnested version for one ridget continue to exist. That the 80 % use case and I would hate if I had to write a nested annotation for that simple use case…. (In reply to comment #11) > I could agree if we agree that the unnested version for one ridget continue to > exist. That the 80 % use case and I would hate if I had to write a nested > annotation for that simple use case…. Of course, do they still exist! They are part of the outer "container" annotation. All of the "ridget"-event annotations will get a corresponding "container" annotation with the same name in plural. Created attachment 191859 [details]
OnActionCallbacks annotation
Added annotations (suggestion 1)and handler as described in comment #9 |