OSGi Factory for menu entries in the UserPanel (upper right corner in WebUI)
Description
Environment
Attachments
Activity

Jan ThielemannAugust 21, 2014 at 10:30 AM
I found a bug in my previous implementation. Due to the fact that i return menu entries from within my factory and due to the fact that the factory acted as event handler, i found out that if two people log into idempiere, only one could use the functionality. The other person got an error saying that the component belongs to another desktop.
I created another class called IUserPanelMenu. In the factory, i now just return a new instance of a class implementing the IUserPanelMenu. Then this class can act as a event handler without problems since the factory creates a new instance for each user.
So now, this feature consists of 3 additional classes. The IUserPanelMenuFactory, the IUserPanelMenu and the UserPanelMenu.
The factory only returns a new IUserPanelMenu. The IUserPanelMenu now implement sthe methods which where previously located in the IUserPanelMenuFactory. The UserPanelMenus are then returned by the IUserPanelMenu class.

Jan ThielemannJune 17, 2014 at 7:26 AM
A detailled tutorial of how to use the factory can be found here: http://wiki.idempiere.org/en/Developing_Plug-Ins_-_IUserPanelMenuFactory

Jan ThielemannJune 17, 2014 at 7:03 AM
Due to suggestions from Heng Sin, i made some changes in the IUserPanelMenuFactory. You now provide an array of UserPanelMenu objects (instead of Strings) which can store the menu-id, -name, -image -tooltip and -sclass. This way you can decide by yourself if you only want to display an image, a name or both. also you can display a tooltip if you like. Also you now have to do all the translations by yourself.
Details
Assignee
UnassignedUnassignedReporter
Jan ThielemannJan ThielemannLabels
Tested By
Nicolas MicoudPriority
Major
Details
Details
Assignee
Reporter

Labels
Tested By

We needed a way to display additional menu entries besides the Feedback, Preference, Change Role and Log Out buttons so i implemented a small factory pattern to add additional entries via plugins. The use of the factory is simple and it consists of three methods. One method to return ids (String) of the menu entries. This ids will be used to translate the entries so just add messages with the search key of the id. Then it has a method to store the component (see UserPanel.onEvent() for what the component can be used, e. g. display FDialog on it) and a onEvent() method where you can check for the events target id. I attached the patch as well as an example implementation.