Implemented field editor factory extension for zk client
This commit is contained in:
parent
5832e19b79
commit
6003245f32
|
@ -17,17 +17,20 @@
|
|||
|
||||
package org.adempiere.webui.editor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.webui.factory.IEditorFactory;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DisplayType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @date Mar 12, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
*
|
||||
*
|
||||
* @author Low Heng Sin
|
||||
* @date July 14 2008
|
||||
*/
|
||||
|
@ -36,145 +39,27 @@ public class WebEditorFactory
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
private final static CLogger logger;
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
logger = CLogger.getCLogger(WebEditorFactory.class);
|
||||
}
|
||||
|
||||
|
||||
public static WEditor getEditor(GridField gridField, boolean tableEditor)
|
||||
{
|
||||
return getEditor(null, gridField, tableEditor);
|
||||
}
|
||||
|
||||
|
||||
public static WEditor getEditor(GridTab gridTab, GridField gridField, boolean tableEditor)
|
||||
{
|
||||
if (gridField == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
WEditor editor = null;
|
||||
int displayType = gridField.getDisplayType();
|
||||
|
||||
/** Not a Field */
|
||||
if (gridField.isHeading())
|
||||
List<IEditorFactory> factoryList = Service.list(IEditorFactory.class);
|
||||
for(IEditorFactory factory : factoryList)
|
||||
{
|
||||
return null;
|
||||
editor = factory.getEditor(gridTab, gridField, tableEditor);
|
||||
if (editor != null)
|
||||
break;
|
||||
}
|
||||
|
||||
/** String (clear/password) */
|
||||
if (displayType == DisplayType.String
|
||||
|| displayType == DisplayType.PrinterName
|
||||
|| (tableEditor && (displayType == DisplayType.Text || displayType == DisplayType.TextLong)))
|
||||
{
|
||||
if (gridField.isEncryptedField())
|
||||
{
|
||||
editor = new WPasswordEditor(gridField);
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = new WStringEditor(gridField, tableEditor);
|
||||
}
|
||||
}
|
||||
/** File */
|
||||
else if (displayType == DisplayType.FileName)
|
||||
{
|
||||
editor = new WFilenameEditor(gridField);
|
||||
}
|
||||
/** File Path */
|
||||
else if (displayType == DisplayType.FilePath)
|
||||
{
|
||||
editor = new WFileDirectoryEditor(gridField);
|
||||
}
|
||||
/** Number */
|
||||
else if (DisplayType.isNumeric(displayType))
|
||||
{
|
||||
editor = new WNumberEditor(gridField);
|
||||
}
|
||||
|
||||
/** YesNo */
|
||||
else if (displayType == DisplayType.YesNo)
|
||||
{
|
||||
editor = new WYesNoEditor(gridField);
|
||||
if (tableEditor)
|
||||
((WYesNoEditor)editor).getComponent().setLabel("");
|
||||
}
|
||||
|
||||
/** Text */
|
||||
else if (displayType == DisplayType.Text || displayType == DisplayType.Memo || displayType == DisplayType.TextLong)
|
||||
{
|
||||
editor = new WStringEditor(gridField);
|
||||
}
|
||||
|
||||
/** Date */
|
||||
else if (DisplayType.isDate(displayType))
|
||||
{
|
||||
if (displayType == DisplayType.Time)
|
||||
editor = new WTimeEditor(gridField);
|
||||
else if (displayType == DisplayType.DateTime)
|
||||
editor = new WDatetimeEditor(gridField);
|
||||
else
|
||||
editor = new WDateEditor(gridField);
|
||||
}
|
||||
|
||||
/** Button */
|
||||
else if (displayType == DisplayType.Button)
|
||||
{
|
||||
editor = new WButtonEditor(gridField);
|
||||
}
|
||||
|
||||
/** Table Direct */
|
||||
else if (displayType == DisplayType.TableDir ||
|
||||
displayType == DisplayType.Table || displayType == DisplayType.List
|
||||
|| displayType == DisplayType.ID )
|
||||
{
|
||||
editor = new WTableDirEditor(gridField);
|
||||
}
|
||||
|
||||
else if (displayType == DisplayType.URL)
|
||||
{
|
||||
editor = new WUrlEditor(gridField);
|
||||
}
|
||||
|
||||
else if (displayType == DisplayType.Search)
|
||||
{
|
||||
editor = new WSearchEditor(gridField);
|
||||
}
|
||||
|
||||
else if (displayType == DisplayType.Location)
|
||||
{
|
||||
editor = new WLocationEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Locator)
|
||||
{
|
||||
editor = new WLocatorEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Account)
|
||||
{
|
||||
editor = new WAccountEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Image)
|
||||
{
|
||||
editor = new WImageEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Binary)
|
||||
{
|
||||
editor = new WBinaryEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.PAttribute)
|
||||
{
|
||||
editor = new WPAttributeEditor(gridTab, gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Assignment)
|
||||
{
|
||||
editor = new WAssignmentEditor(gridField);
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = new WUnknownEditor(gridField);
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,181 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2010 Heng Sin Low *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.factory;
|
||||
|
||||
import org.adempiere.webui.editor.WAccountEditor;
|
||||
import org.adempiere.webui.editor.WAssignmentEditor;
|
||||
import org.adempiere.webui.editor.WBinaryEditor;
|
||||
import org.adempiere.webui.editor.WButtonEditor;
|
||||
import org.adempiere.webui.editor.WDateEditor;
|
||||
import org.adempiere.webui.editor.WDatetimeEditor;
|
||||
import org.adempiere.webui.editor.WEditor;
|
||||
import org.adempiere.webui.editor.WFileDirectoryEditor;
|
||||
import org.adempiere.webui.editor.WFilenameEditor;
|
||||
import org.adempiere.webui.editor.WImageEditor;
|
||||
import org.adempiere.webui.editor.WLocationEditor;
|
||||
import org.adempiere.webui.editor.WLocatorEditor;
|
||||
import org.adempiere.webui.editor.WNumberEditor;
|
||||
import org.adempiere.webui.editor.WPAttributeEditor;
|
||||
import org.adempiere.webui.editor.WPasswordEditor;
|
||||
import org.adempiere.webui.editor.WSearchEditor;
|
||||
import org.adempiere.webui.editor.WStringEditor;
|
||||
import org.adempiere.webui.editor.WTableDirEditor;
|
||||
import org.adempiere.webui.editor.WTimeEditor;
|
||||
import org.adempiere.webui.editor.WUnknownEditor;
|
||||
import org.adempiere.webui.editor.WUrlEditor;
|
||||
import org.adempiere.webui.editor.WYesNoEditor;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.util.DisplayType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class DefaultEditorFactory implements IEditorFactory {
|
||||
|
||||
@Override
|
||||
public WEditor getEditor(GridTab gridTab, GridField gridField,
|
||||
boolean tableEditor) {
|
||||
if (gridField == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
WEditor editor = null;
|
||||
int displayType = gridField.getDisplayType();
|
||||
|
||||
/** Not a Field */
|
||||
if (gridField.isHeading())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/** String (clear/password) */
|
||||
if (displayType == DisplayType.String
|
||||
|| displayType == DisplayType.PrinterName
|
||||
|| (tableEditor && (displayType == DisplayType.Text || displayType == DisplayType.TextLong)))
|
||||
{
|
||||
if (gridField.isEncryptedField())
|
||||
{
|
||||
editor = new WPasswordEditor(gridField);
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = new WStringEditor(gridField, tableEditor);
|
||||
}
|
||||
}
|
||||
/** File */
|
||||
else if (displayType == DisplayType.FileName)
|
||||
{
|
||||
editor = new WFilenameEditor(gridField);
|
||||
}
|
||||
/** File Path */
|
||||
else if (displayType == DisplayType.FilePath)
|
||||
{
|
||||
editor = new WFileDirectoryEditor(gridField);
|
||||
}
|
||||
/** Number */
|
||||
else if (DisplayType.isNumeric(displayType))
|
||||
{
|
||||
editor = new WNumberEditor(gridField);
|
||||
}
|
||||
|
||||
/** YesNo */
|
||||
else if (displayType == DisplayType.YesNo)
|
||||
{
|
||||
editor = new WYesNoEditor(gridField);
|
||||
if (tableEditor)
|
||||
((WYesNoEditor)editor).getComponent().setLabel("");
|
||||
}
|
||||
|
||||
/** Text */
|
||||
else if (displayType == DisplayType.Text || displayType == DisplayType.Memo || displayType == DisplayType.TextLong)
|
||||
{
|
||||
editor = new WStringEditor(gridField);
|
||||
}
|
||||
|
||||
/** Date */
|
||||
else if (DisplayType.isDate(displayType))
|
||||
{
|
||||
if (displayType == DisplayType.Time)
|
||||
editor = new WTimeEditor(gridField);
|
||||
else if (displayType == DisplayType.DateTime)
|
||||
editor = new WDatetimeEditor(gridField);
|
||||
else
|
||||
editor = new WDateEditor(gridField);
|
||||
}
|
||||
|
||||
/** Button */
|
||||
else if (displayType == DisplayType.Button)
|
||||
{
|
||||
editor = new WButtonEditor(gridField);
|
||||
}
|
||||
|
||||
/** Table Direct */
|
||||
else if (displayType == DisplayType.TableDir ||
|
||||
displayType == DisplayType.Table || displayType == DisplayType.List
|
||||
|| displayType == DisplayType.ID )
|
||||
{
|
||||
editor = new WTableDirEditor(gridField);
|
||||
}
|
||||
|
||||
else if (displayType == DisplayType.URL)
|
||||
{
|
||||
editor = new WUrlEditor(gridField);
|
||||
}
|
||||
|
||||
else if (displayType == DisplayType.Search)
|
||||
{
|
||||
editor = new WSearchEditor(gridField);
|
||||
}
|
||||
|
||||
else if (displayType == DisplayType.Location)
|
||||
{
|
||||
editor = new WLocationEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Locator)
|
||||
{
|
||||
editor = new WLocatorEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Account)
|
||||
{
|
||||
editor = new WAccountEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Image)
|
||||
{
|
||||
editor = new WImageEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Binary)
|
||||
{
|
||||
editor = new WBinaryEditor(gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.PAttribute)
|
||||
{
|
||||
editor = new WPAttributeEditor(gridTab, gridField);
|
||||
}
|
||||
else if (displayType == DisplayType.Assignment)
|
||||
{
|
||||
editor = new WAssignmentEditor(gridField);
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = new WUnknownEditor(gridField);
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 2010 Heng Sin Low *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.factory;
|
||||
|
||||
import org.adempiere.webui.editor.WEditor;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IEditorFactory {
|
||||
|
||||
/**
|
||||
* @param gridTab
|
||||
* @param gridField
|
||||
* @param tableEditor
|
||||
* @return WEditor
|
||||
*/
|
||||
public WEditor getEditor(GridTab gridTab, GridField gridField, boolean tableEditor);
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
<plugin>
|
||||
<extension-point id="org.adempiere.webui.Form" name="Web Form" schema="schema/org.adempiere.webui.Form.exsd"/>
|
||||
<extension-point id="org.adempiere.webui.factory.IInfoFactory" name="Info Factory extension" schema="schema/org.adempiere.webui.factory.IInfoFactory.exsd"/>
|
||||
<extension-point id="org.adempiere.webui.factory.IEditorFactory" name="Field editor factory" schema="schema/org.adempiere.webui.factory.IEditorFactory.exsd"/>
|
||||
<extension
|
||||
point="org.compiere.print.ReportViewerProvider">
|
||||
<provider
|
||||
|
@ -36,5 +37,14 @@
|
|||
priority="0">
|
||||
</factory>
|
||||
</extension>
|
||||
<extension
|
||||
id="org.adempiere.webui.factory.DefaultEditorFactory"
|
||||
name="Default field editor factory"
|
||||
point="org.adempiere.webui.factory.IEditorFactory">
|
||||
<factory
|
||||
class="org.adempiere.webui.factory.DefaultEditorFactory"
|
||||
priority="0">
|
||||
</factory>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.adempiere.ui.zk" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.adempiere.ui.zk" id="org.adempiere.webui.factory.IEditorFactory" name="Field editor factory"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<choice>
|
||||
<element ref="factory"/>
|
||||
</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="factory">
|
||||
<complexType>
|
||||
<attribute name="priority" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
numeric priority value, higher value is of higher priority.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.adempiere.webui.factory.IEditorFactory"/>
|
||||
</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>
|
Loading…
Reference in New Issue