IDEMPIERE-5528 Context parsing on process Parameter not considering tab no (#1765)
- implement parent Evaluatee for GridField and ProcessParameterPanel
This commit is contained in:
parent
ee1b6828f4
commit
65f565e542
|
@ -1344,6 +1344,11 @@ public class GridField
|
|||
*/
|
||||
public String get_ValueAsString (Properties ctx, String variableName)
|
||||
{
|
||||
if (m_parentEvaluatee != null) {
|
||||
String value = m_parentEvaluatee.get_ValueAsString(variableName);
|
||||
if (value != null)
|
||||
return value;
|
||||
}
|
||||
return new DefaultEvaluatee(getGridTab(), m_vo.WindowNo, m_vo.TabNo).get_ValueAsString(ctx, variableName);
|
||||
} // get_ValueAsString
|
||||
|
||||
|
@ -2423,6 +2428,9 @@ public class GridField
|
|||
|
||||
/** Is the initial context value for this field backup ? - teo_sarca [ 1699826 ] */
|
||||
private boolean m_isBackupValue = false;
|
||||
|
||||
/** Optional Parent Evaluatee that take precedence over the value return from GridField's Evaluatee implementation */
|
||||
private Evaluatee m_parentEvaluatee = null;
|
||||
|
||||
/**
|
||||
* Backup the context value
|
||||
|
@ -2705,4 +2713,12 @@ public class GridField
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent Evaluatee that take precedence over value return from GridField's Evaluatee implementation.
|
||||
* @param evaluatee
|
||||
*/
|
||||
public void setParentEvaluatee(Evaluatee evaluatee) {
|
||||
m_parentEvaluatee = evaluatee;
|
||||
}
|
||||
} // GridField
|
||||
|
|
|
@ -19,8 +19,11 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -70,6 +73,7 @@ import org.compiere.util.CLogger;
|
|||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Evaluatee;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
@ -94,7 +98,7 @@ import org.zkoss.zul.impl.XulElement;
|
|||
* @version 2006-12-01
|
||||
*/
|
||||
public class ProcessParameterPanel extends Panel implements
|
||||
ValueChangeListener, IProcessParameter, EventListener<Event> {
|
||||
ValueChangeListener, IProcessParameter, EventListener<Event>, Evaluatee {
|
||||
/**
|
||||
* generated serial id
|
||||
*/
|
||||
|
@ -311,6 +315,7 @@ public class ProcessParameterPanel extends Panel implements
|
|||
GridFieldVO voF = listVO.get(i);
|
||||
GridField field = new GridField(voF);
|
||||
m_mFields.add(field); // add to Fields
|
||||
field.setParentEvaluatee(this);
|
||||
|
||||
String fieldGroup = field.getFieldGroup();
|
||||
if (!Util.isEmpty(fieldGroup) && !fieldGroup.equals(currentFieldGroup)) // group changed
|
||||
|
@ -1360,4 +1365,45 @@ public class ProcessParameterPanel extends Panel implements
|
|||
return m_WindowNo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get_ValueAsString(String variableName) {
|
||||
for(WEditor editor : m_wEditors) {
|
||||
if (editor.getGridField().getColumnName().equals(variableName)) {
|
||||
//base on code in GridField.updateContext() method
|
||||
int displayType = editor.getGridField().getVO().displayType;
|
||||
if (displayType == DisplayType.Text
|
||||
|| displayType == DisplayType.Memo
|
||||
|| displayType == DisplayType.TextLong
|
||||
|| displayType == DisplayType.Binary
|
||||
|| displayType == DisplayType.RowID
|
||||
|| editor.getGridField().isEncrypted())
|
||||
return ""; // ignore
|
||||
|
||||
Object value = editor.getValue();
|
||||
if (value == null)
|
||||
return "";
|
||||
else if (value instanceof Boolean)
|
||||
{
|
||||
return (((Boolean)value) ? "Y" : "N");
|
||||
}
|
||||
else if (value instanceof Timestamp)
|
||||
{
|
||||
String stringValue = null;
|
||||
if (value != null && !value.toString().equals("")) {
|
||||
Calendar c1 = Calendar.getInstance();
|
||||
c1.setTime((Date) value);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
stringValue = sdf.format(c1.getTime());
|
||||
}
|
||||
return stringValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
} // ProcessParameterPanel
|
||||
|
|
Loading…
Reference in New Issue