Synchronizing some unsync classes from zkwebui 341 to stable

This commit is contained in:
Carlos Ruiz 2008-08-29 22:57:30 +00:00
parent 1c1b967813
commit e92957b06d
7 changed files with 2569 additions and 2976 deletions

View File

@ -29,7 +29,6 @@ import java.util.Enumeration;
import java.util.logging.Level;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
@ -48,6 +47,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.zkoss.web.servlet.Servlets;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
@ -715,4 +715,24 @@ public final class AEnv
return false;
}
}
/**
*
* @param parent
* @param child
* @return boolean
*/
public static boolean contains(Component parent, Component child) {
if (child == parent)
return true;
Component c = child.getParent();
while (c != null) {
if (c == parent)
return true;
c = c.getParent();
}
return false;
}
} // AEnv

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.adempiere.webui.apps.form.WCreateFrom;
import org.compiere.util.KeyNamePair;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
@ -239,5 +239,46 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
*/
public void addActionListener(EventListener listener) {
addEventListener(Events.ON_SELECT, listener);
}
/**
* shortcut for appendItem(pp.getName(), pp.getValue()), to ease porting of swing form
* @param pp
*/
public void addItem(ValueNamePair pp) {
appendItem(pp.getName(), pp.getValue());
}
/**
* select selected item base on vp.getValue, to ease porting of swing form
* @param vp
*/
public void setSelectedValueNamePair(ValueNamePair vp) {
int count = this.getItemCount();
for(int i = 0; i < count; i++) {
ListItem item = getItemAtIndex(i);
if (vp.getValue().equals(item.getValue())) {
setSelectedIndex(i);
break;
}
}
}
/**
* select selected item base on kp.getKey, to ease porting of swing form
* @param kp
*/
public void setSelectedKeyNamePair(KeyNamePair kp) {
int count = this.getItemCount();
for(int i = 0; i < count; i++) {
ListItem item = getItemAtIndex(i);
if (item.getValue() instanceof Integer) {
if (kp.getKey() == (Integer)item.getValue()) {
setSelectedIndex(i);
break;
}
}
}
}
}

View File

@ -42,4 +42,14 @@ public class ListboxFactory {
return dataTable;
}
public static Listbox newDropdownListbox(String[] items) {
Listbox listbox = newDropdownListbox();
if (items != null && items.length > 0) {
for(int i = 0; i < items.length; i++) {
listbox.appendChild(new ListItem(items[i], items[i]));
}
}
return listbox;
}
}

View File

@ -34,6 +34,8 @@ import org.zkoss.zk.ui.event.Events;
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
* @date Mar 11, 2007
* @version $Revision: 0.10 $
*
* @author Low Heng Sin
*/
public class WNumberEditor extends WEditor
{
@ -45,6 +47,15 @@ public class WNumberEditor extends WEditor
private boolean mandatory = false;
public WNumberEditor()
{
this("Number", false, false, true, DisplayType.Number, "");
}
/**
*
* @param gridField
*/
public WNumberEditor(GridField gridField)
{
super(new NumberBox(gridField.getDisplayType() == DisplayType.Integer),
@ -52,19 +63,49 @@ public class WNumberEditor extends WEditor
init();
}
/**
*
* @param gridField
* @param integral
*/
public WNumberEditor(GridField gridField, boolean integral)
{
super(new NumberBox(integral), gridField);
init();
}
private void init()
/**
*
* @param columnName
* @param mandatory
* @param readonly
* @param updateable
* @param displayType
* @param title
*/
public WNumberEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
int displayType, String title)
{
getComponent().setMaxlength(gridField.getFieldLength());
super(new NumberBox(displayType == DisplayType.Integer), columnName, title, null, mandatory,
readonly, updateable);
init();
}
private void init()
{
if (gridField != null)
{
getComponent().setMaxlength(gridField.getFieldLength());
getComponent().setTooltiptext(gridField.getDescription());
}
getComponent().setCols(MAX_DISPLAY_LENGTH);
getComponent().setTooltiptext(gridField.getDescription());
}
/**
* Event handler
* @param event
*/
public void onEvent(Event event)
{
String newValue = getComponent().getValue();
@ -131,14 +172,19 @@ public class WNumberEditor extends WEditor
}
}
@Override
public String[] getEvents()
{
return LISTENER_EVENTS;
}
/**
* Handle context menu events
* @param evt
*/
public void onMenu(ContextMenuEvent evt)
{
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()))
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()) && gridField != null)
{
if (MRole.getDefault().isShowPreference())
ValuePreference.start (this.getGridField(), getValue());

View File

@ -37,9 +37,11 @@ import org.adempiere.webui.panel.InfoProductPanel;
import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MRole;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
@ -840,4 +842,42 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
}
}
/**
* @param windowNo
* @return WSearchEditor
*/
public static WSearchEditor createBPartner(int windowNo) {
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
try
{
Lookup lookup = MLookupFactory.get (Env.getCtx(), windowNo,
0, AD_Column_ID, DisplayType.Search);
return new WSearchEditor ("C_BPartner_ID", false, false, true, lookup);
}
catch (Exception e)
{
log.log(Level.SEVERE, "", e);
}
return null;
}
/**
* @param windowNo
* @return WSearchEditor
*/
public static WSearchEditor createProduct(int windowNo) {
int AD_Column_ID = 3840; // C_InvoiceLine.M_Product_ID
try
{
Lookup lookup = MLookupFactory.get (Env.getCtx(), windowNo, 0,
AD_Column_ID, DisplayType.Search);
return new WSearchEditor("M_Product_ID", false, false, true, lookup);
}
catch (Exception e)
{
log.log(Level.SEVERE, "", e);
}
return null;
}
}