eloy_gomez 2010-06-04 12:32:36 +00:00
parent 180221152a
commit 4e53264e7e
6 changed files with 158 additions and 0 deletions

View File

@ -52,6 +52,7 @@ Export-Package: com.keypoint,
groovyjarjarasm.asm.tree,
groovyjarjarcommonscli,
org.adempiere.apps.graph,
org.adempiere.osgi,
org.codehaus.groovy,
org.codehaus.groovy.ant,
org.codehaus.groovy.antlr,

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="org.adempiere.osgi.IMenuAction" name="MenuAction" schema="schema/org.adempiere.osgi.IMenuAction.exsd"/>
<extension
id="RF"
name="RF"

View File

@ -0,0 +1,101 @@
<?xml version='1.0' encoding='UTF-8'?>
<schema targetNamespace="org.adempiere.client" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.adempiere.client" id="org.adempiere.osgi.IMenuAction" name="MenuAction"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice>
<element ref="client" minOccurs="1" maxOccurs="unbounded"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="client">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.adempiere.osgi.IMenuAction"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View File

@ -0,0 +1,35 @@
package org.adempiere.osgi;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
public abstract class AbstractMenuAction implements IMenuAction {
protected CLogger log = CLogger.getCLogger(getClass());
protected JMenu getMenu(JMenuBar menuBar, String label) {
// Translated text
String text = Msg.getMsg(Env.getCtx(), label);
int pos = text.indexOf('&');
if (pos != -1) {
text = text.substring(0, pos) + text.substring(pos+1);
}
for (int i=0; i < menuBar.getMenuCount(); i++) {
JMenu menu = menuBar.getMenu(i);
if (text.equals(menu.getText())) {
return menu;
}
}
// menu not found.
log.warning("Menu " + label + " not found.");
return null;
}
}

View File

@ -0,0 +1,11 @@
package org.adempiere.osgi;
import javax.swing.JMenuBar;
import org.adempiere.base.IService;
public interface IMenuAction extends IService {
public void addAction(JMenuBar menuBar);
}

View File

@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
@ -59,6 +60,8 @@ import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.adempiere.base.Service;
import org.adempiere.osgi.IMenuAction;
import org.compiere.apps.form.FormFrame;
import org.compiere.apps.search.Find;
import org.compiere.grid.APanelTab;
@ -525,6 +528,12 @@ public final class APanel extends CPanel
toolBar.add(aEnd.getButton());
}
// Create OSGi menu actions..
List<IMenuAction> osgiActions = Service.list(IMenuAction.class);
for (IMenuAction action:osgiActions) {
action.addAction(menuBar);
}
//
if (CLogMgt.isLevelAll())
Util.printActionInputMap(this);