Difference between revisions of "Developing Plug-Ins - IUserPanelMenuFactory"

From iDempiere en
Line 50: Line 50:
  
 
}
 
}
 +
</pre>
 +
 +
The third step is to create a new component definition so that the core can know that your Plug-In provides a factory. To do this, select File>New>Other... from the Eclipse menu and chose Component Definition from the Plug-in Development section. Give it a unique name in your Plug-In and click on finish.
 +
 +
[[File:Menu2.png|320px]]
 +
 +
In the component definition, provide a unique name (unique in the whole application). The best is to use the reverse domain identifier or the plugin name followd by menufactory (e. g. org.evenos.menutest.menufactory). Then chose you class which implements the IUserPanelMenuFactory and add a new property called "service.ranking" which is a integer and has a value > 0. Then go to the Services tab and select the org.adempiere.webui.panel.IUserPanelMenuFactory service in the provided services section. The component definition should now look like this:
 +
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.evenos.menutest.menufactory">
 +
  <implementation class="org.evenos.menutest.MenuFactory"/>
 +
  <service>
 +
      <provide interface="org.adempiere.webui.panel.IUserPanelMenuFactory"/>
 +
  </service>
 +
  <property name="service.ranking" type="Integer" value="100"/> 
 +
</scr:component>
 
</pre>
 
</pre>

Revision as of 10:19, 16 June 2014

This tutorial is brought to you by Jan Thielemann from evenos GmbH (www.evenos-consulting.de). If you have questions, criticism or improvement suggestions, feel free to visit me (Jan.thielemann) or write me an email

Goal of this tutorial

The goal of this tutorial is to show you how you can use the IUserPanelMenuFactory service in you plug-in project. The reason why you might want to use this service is to provide additional menu entries in the WebUI (besides Feedback, Preference, Change Role and Log Out).


Prerequisites

Before you start this tutorial, you should take a look at the follwing tutorials:

Also if not already integreated into the trunk, you need to install the provided patch from https://idempiere.atlassian.net/browse/IDEMPIERE-2000

The workflow

The first thing you want to do is to create a Plug-In. If you already have a Plug-In and just want to add the MenuFactory there, thats also ok. To create a new Plug-In you select the Eclipse-Menu File>New>Other... Here you go to the "Plug-in Development" section and chose Plug-in Project. Chose a name and a location, make sure the OSGi framework is Equinox and click on next. Chose your name and the execution environment and click on finish.

The second step is to create a class which implements the IUserPanelMenuFactory interface. To do this, create a package of your choice and create a new class in there:

Menu1.png

package org.evenos.menutest;

import org.adempiere.webui.panel.IUserPanelMenuFactory;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;

public class MenuFactory implements IUserPanelMenuFactory {

	@Override
	public void onEvent(Event event) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String[] getMenus() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setComponent(Component component) {
		// TODO Auto-generated method stub
		
	}

}

The third step is to create a new component definition so that the core can know that your Plug-In provides a factory. To do this, select File>New>Other... from the Eclipse menu and chose Component Definition from the Plug-in Development section. Give it a unique name in your Plug-In and click on finish.

Menu2.png

In the component definition, provide a unique name (unique in the whole application). The best is to use the reverse domain identifier or the plugin name followd by menufactory (e. g. org.evenos.menutest.menufactory). Then chose you class which implements the IUserPanelMenuFactory and add a new property called "service.ranking" which is a integer and has a value > 0. Then go to the Services tab and select the org.adempiere.webui.panel.IUserPanelMenuFactory service in the provided services section. The component definition should now look like this:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.evenos.menutest.menufactory">
   <implementation class="org.evenos.menutest.MenuFactory"/>
   <service>
      <provide interface="org.adempiere.webui.panel.IUserPanelMenuFactory"/>
   </service>
   <property name="service.ranking" type="Integer" value="100"/>  
</scr:component>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.