hg merge release-5.1 (merge release5.1 into default)

This commit is contained in:
Heng Sin Low 2017-11-17 05:21:18 +08:00
commit 0aa9041931
14 changed files with 141 additions and 69 deletions

View File

@ -5,9 +5,12 @@ package org.adempiere.util;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
@ -31,30 +34,23 @@ implements Evaluatee
private final Properties ctx;
private final GridTab gridTab;
private final GridTable gridTable;
private final int windowNo;
private final int row;
public GridRowCtx(Properties ctx, GridTab tab)
{
this(ctx, tab, -1);
}
public GridRowCtx(Properties ctx, GridTab tab, int row)
{
super();
this.ctx = ctx;
this.gridTab = tab;
this.gridTable = tab.getTableModel();
this.windowNo = tab.getWindowNo();
this.row = row;
}
public GridRowCtx(Properties ctx, GridTable table, int windowNo, int row)
{
super();
this.ctx = ctx;
this.gridTab = null;
this.gridTable = table;
this.windowNo = windowNo;
this.row = row;
}
private String getColumnName(Object key)
{
if (! (key instanceof String) )
@ -82,12 +78,13 @@ implements Evaluatee
{
return ctx.get(key);
}
GridTable gridTable = gridTab.getTableModel();
int col = gridTable.findColumn(columnName);
if (col == -1)
{
return ctx.get(key);
}
Object value = gridTable.getValueAt(row, col);
Object value = gridTable.getValueAt(getRow(), col);
if (value == null)
{
value = "";
@ -107,6 +104,10 @@ implements Evaluatee
return value.toString();
}
private int getRow() {
return row >= 0 ? row : gridTab.getCurrentRow();
}
@Override
public synchronized void clear() {
ctx.clear();
@ -115,22 +116,19 @@ implements Evaluatee
@Override
public synchronized Object clone() {
final GridRowCtx grc;
if (this.gridTab != null)
grc = new GridRowCtx((Properties)this.ctx.clone(), this.gridTab, this.row);
else
grc = new GridRowCtx((Properties)this.ctx.clone(), this.gridTable, this.windowNo, this.row);
return grc;
}
@Override
public synchronized boolean contains(Object value) {
// TODO: check if that value exists in one of our GridFields
return this.ctx.contains(value);
return this.containsValue(value);
}
@Override
public synchronized boolean containsKey(Object key)
{
GridTable gridTable = gridTab.getTableModel();
String columnName = getColumnName(key);
if (columnName != null && gridTable.findColumn(columnName) != -1)
return true;
@ -139,20 +137,42 @@ implements Evaluatee
@Override
public boolean containsValue(Object value) {
// TODO: check if that value exists in one of our GridFields
if (value != null) {
GridField[] fields = gridTab.getFields();
for(GridField field : fields) {
Object fieldValue = gridTab.getValue(getRow(), field.getColumnName());
if (fieldValue != null && fieldValue.equals(value)) {
return true;
}
}
}
return ctx.containsValue(value);
}
@Override
public synchronized Enumeration<Object> elements() {
// TODO: implement for GridField values too
return ctx.elements();
Vector<Object> list = new Vector<>(ctx.values());
GridField[] fields = gridTab.getFields();
for(GridField field : fields) {
Object fieldValue = gridTab.getValue(getRow(), field.getColumnName());
if (fieldValue != null) {
list.add(fieldValue);
}
}
return list.elements();
}
@Override
public Set<java.util.Map.Entry<Object, Object>> entrySet() {
// TODO: implement for GridField values too
return ctx.entrySet();
Set<java.util.Map.Entry<Object, Object>> set = new HashSet<>(ctx.entrySet());
GridField[] fields = gridTab.getFields();
Map<Object, Object> fieldMap = new LinkedHashMap<>();
for(GridField field : fields) {
Object fieldValue = gridTab.getValue(getRow(), field.getColumnName());
fieldMap.put(field.getColumnName(), fieldValue);
}
set.addAll(fieldMap.entrySet());
return set;
}
@Override
@ -162,39 +182,29 @@ implements Evaluatee
@Override
public synchronized Enumeration<Object> keys() {
// TODO: implement for GridField values too
return ctx.keys();
Vector<Object> list = new Vector<Object>(ctx.keySet());
GridField[] fields = gridTab.getFields();
for(GridField field : fields) {
list.add(field.getColumnName());
}
return list.elements();
}
@Override
public Set<Object> keySet() {
// TODO: implement for GridField values too
return ctx.keySet();
Set<Object> set = new HashSet<>(ctx.keySet());
GridField[] fields = gridTab.getFields();
for(GridField field : fields) {
set.add(field.getColumnName());
}
return set;
}
@Override
public synchronized Object put(Object key, Object value)
{
if (gridTab == null)
throw new IllegalStateException("Method not supported (gridTab is null)");
if (gridTab.getCurrentRow() != row)
{
return ctx.put(key, value);
}
String columnName = getColumnName(key);
if (columnName == null)
{
return ctx.put(key, value);
}
GridField field = gridTab.getField(columnName);
if (field == null)
{
return ctx.put(key, value);
}
Object valueOld = field.getValue();
field.setValue(value, false);
return valueOld;
}
@Override
public synchronized void putAll(Map<? extends Object, ? extends Object> t) {
@ -204,20 +214,37 @@ implements Evaluatee
@Override
public synchronized Object remove(Object key) {
// TODO: implement for GridField values too
return ctx.remove(key);
}
@Override
public synchronized int size() {
// TODO: implement for GridField values too
return ctx.size();
return ctx.size() + gridTab.getFieldCount();
}
@Override
public synchronized String toString() {
// TODO: implement for GridField values too
return ctx.toString();
StringBuilder builder = new StringBuilder(ctx.toString());
if (builder.length() > 0) {
builder.deleteCharAt(builder.length()-1);
if (builder.length() > 1) {
builder.append(", ");
}
} else {
builder.append("{");
}
GridField[] fields = gridTab.getFields();
for(int i = 0; i < fields.length; i++) {
builder.append(fields[i].getColumnName()).append("=");
Object value = gridTab.getValue(getRow(), fields[i].getColumnName());
builder.append(value==null ? "" : value.toString());
if (i == fields.length-1) {
builder.append("}");
} else {
builder.append(", ");
}
}
return builder.toString();
}
@Override

View File

@ -107,6 +107,9 @@ public class Doc_Inventory extends Doc
for (int i = 0; i < lines.length; i++)
{
MInventoryLine line = lines[i];
if (!line.isActive())
continue;
String docSubTypeInv;
if (Util.isEmpty(parentDocSubTypeInv)) {
// IDEMPIERE-675: for backward compatibility - to post old documents that could have subtypeinv empty

View File

@ -2794,7 +2794,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
MLookup mLookup = (MLookup)dependentField.getLookup();
// if the lookup is dynamic (i.e. contains this columnName as variable)
if (mLookup.getValidation().indexOf("@"+columnName+"@") != -1)
if (mLookup.getValidation().indexOf("@"+columnName+"@") != -1
|| mLookup.getValidation().matches(".*[@]"+columnName+"[:].+[@].*$"))
{
if (log.isLoggable(Level.FINE)) log.fine(columnName + " changed - "
+ dependentField.getColumnName() + " set to null");

View File

@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = -4917976995339273240L;
private static final long serialVersionUID = 2617379167881737860L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -59,6 +59,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String APPLICATION_MAIN_VERSION = "APPLICATION_MAIN_VERSION";
public static final String APPLICATION_MAIN_VERSION_SHOWN = "APPLICATION_MAIN_VERSION_SHOWN";
public static final String APPLICATION_OS_INFO_SHOWN = "APPLICATION_OS_INFO_SHOWN";
public static final String APPLICATION_URL = "APPLICATION_URL";
public static final String ATTACH_EMBEDDED_2PACK = "ATTACH_EMBEDDED_2PACK";
public static final String AUTOMATIC_PACKIN_FOLDERS = "AUTOMATIC_PACKIN_FOLDERS";
public static final String AUTOMATIC_PACKIN_INITIAL_DELAY = "AUTOMATIC_PACKIN_INITIAL_DELAY";
@ -138,6 +139,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String SYSTEM_IN_MAINTENANCE_MODE = "SYSTEM_IN_MAINTENANCE_MODE";
public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG";
public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE";
public static final String TOP_MARGIN_PIXELS_FOR_HEADER = "TOP_MARGIN_PIXELS_FOR_HEADER";
public static final String TRACE_ALL_TRX_CONNECTION_GET = "TRACE_ALL_TRX_CONNECTION_GET";
public static final String TWOPACK_COMMIT_DDL = "2PACK_COMMIT_DDL";
public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS";

View File

@ -293,6 +293,8 @@ public class Evaluator
variable = variable.replaceFirst("[0-9][0-9]*\\|", "");
if (variable.indexOf(".") > 0)
variable = variable.substring(0, variable.indexOf("."));
if (variable.indexOf(":") > 0)
variable = variable.substring(0, variable.indexOf(":"));
list.add(variable);
}
} // parseDepends

View File

@ -302,7 +302,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
ClientInfo browserInfo = SessionManager.getAppDesktop().getClientInfo();
int browserHeight = browserInfo.desktopHeight;
int prefHeight = Integer.valueOf(height.replace("px", ""));
int topmarginpx = MSysConfig.getIntValue("TOP_MARGIN_PIXELS_FOR_HEADER", 222);
int topmarginpx = MSysConfig.getIntValue(MSysConfig.TOP_MARGIN_PIXELS_FOR_HEADER, 222);
int maxHeight = browserHeight - topmarginpx;
if (prefHeight <= maxHeight) {
height = Integer.toString(prefHeight) + "px";

View File

@ -700,7 +700,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
}
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab, gridTab.getCurrentRow())
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab)
: gridPanelFields[i].getVO().ctx;
//check context
if (!gridPanelFields[i].isDisplayed(ctx, true)){

View File

@ -1006,6 +1006,9 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
GridField mField = comp.getGridField();
if (mField != null)
{
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab)
: mField.getVO().ctx;
if (noData)
{
comp.setReadWrite(false);
@ -1017,12 +1020,9 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
mField.refreshLookup();
comp.setReadWrite(rw);
comp.setMandatory(mField.isMandatory(true)); // check context
comp.dynamicDisplay();
comp.dynamicDisplay(ctx);
}
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab, gridTab.getCurrentRow())
: mField.getVO().ctx;
comp.setVisible((isHasCustomizeData || mField.isDisplayedGrid()) && mField.isDisplayed(ctx, true));
}
}

View File

@ -813,9 +813,9 @@ public final class AEnv
private static String m_ApplicationUrl = null;
public static String getApplicationUrl() {
String url = MSysConfig.getValue("APPLICATION_URL", Env.getAD_Client_ID(Env.getCtx()));
String url = MSysConfig.getValue(MSysConfig.APPLICATION_URL, Env.getAD_Client_ID(Env.getCtx()));
if (!Util.isEmpty(url) && !url.equals("USE_HARDCODED"))
return MSysConfig.getValue("APPLICATION_URL", Env.getAD_Client_ID(Env.getCtx()));
return MSysConfig.getValue(MSysConfig.APPLICATION_URL, Env.getAD_Client_ID(Env.getCtx()));
if (m_ApplicationUrl != null)
return m_ApplicationUrl;
int port = Executions.getCurrent().getServerPort();

View File

@ -167,8 +167,20 @@ public class WReport implements EventListener<Event> {
private void launchReport (MPrintFormat pf)
{
int Record_ID = 0;
if (m_query.getRestrictionCount()==1 && m_query.getCode(0) instanceof Integer)
if (m_query.getRestrictionCount() == 1) {
if (m_query.getColumnName(0).equals(m_query.getTableName()+"_ID")) {
Object vrec = m_query.getCode(0);
if (vrec instanceof Integer) {
Record_ID = ((Integer)m_query.getCode(0)).intValue();
} else {
try {
Record_ID = Integer.parseInt(m_query.getCode(0).toString());
} catch (NumberFormatException e) {
log.info(e.getMessage());
}
}
}
}
PrintInfo info = new PrintInfo(
pf.getName(),
pf.getAD_Table_ID(),

View File

@ -21,6 +21,7 @@ import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Properties;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.ClientInfo;
@ -542,10 +543,15 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
return this.mandatory;
}
public void dynamicDisplay()
{
dynamicDisplay(gridField != null ? gridField.getVO().ctx : Env.getCtx());
}
/**
* allow subclass to perform dynamic loading of data
*/
public void dynamicDisplay()
public void dynamicDisplay(Properties ctx)
{
if (gridField != null)
{

View File

@ -24,6 +24,7 @@ import java.beans.PropertyChangeEvent;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.webui.ClientInfo;
@ -946,6 +947,16 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
return null;
}
@Override
public void dynamicDisplay(Properties ctx) {
if (lookup instanceof MLookup) {
((MLookup) lookup).getLookupInfo().ctx = ctx;
}
super.dynamicDisplay(ctx);
}
static class CustomSearchBox extends Searchbox {
/**

View File

@ -20,6 +20,7 @@ package org.adempiere.webui.editor;
import java.beans.PropertyChangeEvent;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Properties;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
@ -40,6 +41,7 @@ import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MBPartnerLocation;
import org.compiere.model.MLocation;
import org.compiere.model.MLookup;
import org.compiere.model.MTable;
import org.compiere.util.CCache;
import org.compiere.util.CLogger;
@ -656,11 +658,17 @@ ContextMenuListener, IZoomableEditor
}
@Override
public void dynamicDisplay()
public void dynamicDisplay(Properties ctx)
{
if (lookup instanceof MLookup)
{
((MLookup) lookup).getLookupInfo().ctx = ctx;
}
if ((lookup != null) && (!lookup.isValidated() || !lookup.isLoaded()
|| (isReadWrite() && lookup.getSize() != getComponent().getItemCount())))
this.actionRefresh();
super.dynamicDisplay(ctx);
}
private static class EditorCombobox extends Combobox {

View File

@ -1032,7 +1032,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
return;
}
if (AD_Table_ID != 0)
new WReport (AD_Table_ID, query, component, 0);
new WReport (AD_Table_ID, query, component, m_WindowNo);
else
log.warning("No Table found for " + query.getWhereClause(true));
} // executeDrill