Community
Participate
Working Groups
This bug discusses only the annotations related to navigation node events. It is a branch of bug #335691
For specifying the annotation(s) there are (at least) two possibilities: 1. A more "generic" version, i.e. one annotation for all events, e.g. @OnNavigationNodeEvent(Event.BeforeActivate) or @OnNavigationNodeEvent(Event.AfterActivate) where Event is a Java-Enum. 2. The "flat" version, i.e. several annotations, e.g. @OnNavigationNodeEventBeforeActivate or @OnNavigationNodeEventAfterActivate Both version support the application developer with auto completion. Version 2 "pollutes" the annotaion space. Comments!?
I prefer the first version, because the name is shorter and the API can be easier extended.
I also prefer the first concept…… However I see two problems. - While NavigationNodeEvent is technically what the application developer consumes, he might more think along the lines of the controller lifecyle events. Since NavigationNode and controller go hand in hand it might be the same. Another option is RienaViewLifecycle and yes that specific name is bad but I hope you know what I mean. Something point to "Riena" + "Controller/View" "Lifecycle/Event" But I can also go with the current name - The parameter Event.xxxx seems to reference an enumeration (not sure) or to some sort of class. "Event" is a pretty generic often used type name. I would just hate it if Eclipse pops up and ask me which "Event" class I am refering to each and every time I organize my imports.
in reply to comment 3 I simply derived the annotation from this pattern: "On" + <source of the event> +"Event" Yes, it is technical - but precise. If we choose another name than it should unequivocal. Yes, Event is a Java enum, as I said in comment #1!! And yes, there are several classes with the same name. But, if the annotation would be defined like this: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface OnNavigationNodeEvent { enum Event { BEFORE_ACTIVATE, AFTER_ACTIVATE // , .. }; Event event(); } Now, if you would add this annotation to a method, the code completion would show you the parameter 'event' and after typing '=' code completion would immediatly offer you the Event enum of the annotation as well as 'BEFORE_ACTIVATE' and AFTER_ACTIVATE, .. No need to select from other Event classes/enums/..
The solution follows the proposed annotation in comment #4. With this it is now possible to annotate methods of INavigationNodeControllers like this: @OnNavigationNodeEvent(event = Event.ACTIVATED) public void activated(final ISubModuleNode source) { synchJumpActionState(); } Where the signature of the "callback" method may either have the same parameters as the corresponding ISimpleNavigationNodeListener event method or none.