IDEMPIERE-537 Zk: Dynamic Validation Rule for Advanced Query

This commit is contained in:
Heng Sin Low 2012-12-24 18:17:04 +08:00
parent f8fa9e9a71
commit 679b9ca1f9
2 changed files with 43 additions and 8 deletions

View File

@ -72,7 +72,7 @@ import org.compiere.util.Evaluator;
* @version $Id: GridField.java,v 1.5 2006/07/30 00:51:02 jjanke Exp $
*/
public class GridField
implements Serializable, Evaluatee
implements Serializable, Evaluatee, Cloneable
{
@ -1988,4 +1988,16 @@ public class GridField
return m_vo.displayType == DisplayType.Button && m_vo.IsToolbarButton;
}
public GridField clone(Properties ctx)
{
try {
GridField field = (GridField) super.clone();
field.m_vo.ctx = ctx;
field.m_vo.lookupInfo = null;
return field;
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e.getLocalizedMessage(), e);
}
}
} // MField

View File

@ -32,6 +32,7 @@ import java.util.Comparator;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Vector;
import java.util.logging.Level;
import java.util.regex.Pattern;
@ -200,6 +201,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
private Combobox historyCombo = new Combobox();
private Properties m_findCtx;
/**
* FindPanel Constructor
@ -227,6 +230,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
m_minRecords = minRecords;
m_isCancel = true;
//
m_findCtx = new Properties(Env.getCtx());
this.setBorder("normal");
this.setShadow(false);
@ -1613,16 +1617,27 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
else
{
//lookupinfo is null for invisible field
if (DisplayType.isLookup(field.getDisplayType()) && field.getLookup() == null) {
field.loadLookupNoValidate();
//reload lookupinfo for find window
if (DisplayType.isLookup(field.getDisplayType()) )
{
GridField findField = (GridField) field.clone(m_findCtx);
findField.loadLookupNoValidate();
editor = WebEditorFactory.getEditor(findField, true);
findField.addPropertyChangeListener(editor);
}
else
{
editor = WebEditorFactory.getEditor(field, true);
field.addPropertyChangeListener(editor);
}
editor = WebEditorFactory.getEditor(field, true);
}
if (editor == null)
{
editor = new WStringEditor(field);
field.addPropertyChangeListener(editor);
}
field.addPropertyChangeListener(editor);
editor.addValueChangeListener(this);
editor.setValue(null);
editor.setReadWrite(enabled);
@ -2079,6 +2094,14 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
Component component = editor.getComponent();
ListCell listcell = (ListCell)component.getParent();
listcell.setAttribute("value", evt.getNewValue());
if (evt.getNewValue() == null)
Env.setContext(m_findCtx, m_targetWindowNo, editor.getColumnName(), "");
else if (evt.getNewValue() instanceof Boolean)
Env.setContext(m_findCtx, m_targetWindowNo, editor.getColumnName(), (Boolean)evt.getNewValue());
else if (evt.getNewValue() instanceof Timestamp)
Env.setContext(m_findCtx, m_targetWindowNo, editor.getColumnName(), (Timestamp)evt.getNewValue());
else
Env.setContext(m_findCtx, m_targetWindowNo, editor.getColumnName(), evt.getNewValue().toString());
}
}