Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335691

Summary: Annotations for eventHandling and action / selection listener - collecting ideas in this bug report
Product: [RT] Riena Reporter: Christian Campo <christian.campo>
Component: UIAssignee: Stefan Liebig <Stefan.Liebig>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: holger.hoch, Stefan.Liebig
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 335827, 338386, 338661    
Bug Blocks:    

Description Christian Campo CLA 2011-01-28 10:04:52 EST
In a recent discussion we came across the idea that it would a good enhancement to Riena if you could use annotations in the SubModuleController for certain events (like beforeActivate) or you could use instead off inner classes for selectionlisteners or actionlisteners.

This bug describes a few of these things. In it is the expectation that we have more bugreports for the individual features.

Currently in the SubModuleController to consume an afterActivate event in the controller (called when the view of controller was just activated) you have to register an event handler in the NavigationNode:

So somewhere maybe in configureRidgets you call:

getNavigationNode().addSimpleListener(new SimpleNavigationNodeAdapter() {
		void afterActivated(INavigationNode<?> source) {
				// your code
		}
	});
	
AddSimpleListener expects an instance of a class implementing ISimpleNavigationNodeListener with around 30 methods which are implemented as empty in the SimpleNavigationNodeAdaption.

It should be far easier to define in your subclass of SubModuleController something like this:

    @afterActivate
	public void afterActivated(INavigationNode<?> source) {
		// your code
	}
	
And then let Riena figure out what to do. Maybe the systax for the annotation is different and its more
    @nodeEvent(afterActivate)
That is detail and should be discussed in a different bug. But the idea is to make as simple as possible to consume LifeCycle Events in Riena.

The same is true for actionListener or selectionListener

Rather than writing

	getRidget("myButton").addActionListener() { new IActionListener() {
			public void callback() {
					// do something when the button is clicked
			}
	});

you could also write:
   
    @action (name="myButton")
    public void callBackForMyButton() {
     	// do something when the button is clicked
    }
    
again the name for the button is up for discussion.

Not only does this reduce the amount of code but it als reduces the amounts of inner classes. It also makes view controller easier to test. You can directly call in your testcode the method that is annotated which is not so simply if you had the wrap it into an inner class. The current concept of controller testing invented a method on the button ridget to fire a button click. If you had the annotation for the action listener back then, unit tests could simply call the action listener in the controller.

I expect to have at least two sub bugzilla entries one for the Lifecycle events and one for the various types of listeners....
Comment 1 Holger Hoch CLA 2011-01-31 05:56:35 EST
The details of the annotations for action, selection and focus events enhancement are described in bug 335827
Comment 2 Stefan Liebig CLA 2011-02-28 05:18:14 EST
Details of the annotations for navigation node events are described in bug #338386
Comment 3 Stefan Liebig CLA 2011-06-20 07:42:05 EDT
All dependent bugs have been fixed!