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

View File

@ -107,6 +107,9 @@ public class Doc_Inventory extends Doc
for (int i = 0; i < lines.length; i++) for (int i = 0; i < lines.length; i++)
{ {
MInventoryLine line = lines[i]; MInventoryLine line = lines[i];
if (!line.isActive())
continue;
String docSubTypeInv; String docSubTypeInv;
if (Util.isEmpty(parentDocSubTypeInv)) { if (Util.isEmpty(parentDocSubTypeInv)) {
// IDEMPIERE-675: for backward compatibility - to post old documents that could have subtypeinv empty // 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(); MLookup mLookup = (MLookup)dependentField.getLookup();
// if the lookup is dynamic (i.e. contains this columnName as variable) // 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 - " if (log.isLoggable(Level.FINE)) log.fine(columnName + " changed - "
+ dependentField.getColumnName() + " set to null"); + 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 ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; 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 = "APPLICATION_MAIN_VERSION";
public static final String APPLICATION_MAIN_VERSION_SHOWN = "APPLICATION_MAIN_VERSION_SHOWN"; 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_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 ATTACH_EMBEDDED_2PACK = "ATTACH_EMBEDDED_2PACK";
public static final String AUTOMATIC_PACKIN_FOLDERS = "AUTOMATIC_PACKIN_FOLDERS"; public static final String AUTOMATIC_PACKIN_FOLDERS = "AUTOMATIC_PACKIN_FOLDERS";
public static final String AUTOMATIC_PACKIN_INITIAL_DELAY = "AUTOMATIC_PACKIN_INITIAL_DELAY"; 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_IN_MAINTENANCE_MODE = "SYSTEM_IN_MAINTENANCE_MODE";
public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG"; public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG";
public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE"; 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 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_COMMIT_DDL = "2PACK_COMMIT_DDL";
public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS"; 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]*\\|", ""); variable = variable.replaceFirst("[0-9][0-9]*\\|", "");
if (variable.indexOf(".") > 0) if (variable.indexOf(".") > 0)
variable = variable.substring(0, variable.indexOf(".")); variable = variable.substring(0, variable.indexOf("."));
if (variable.indexOf(":") > 0)
variable = variable.substring(0, variable.indexOf(":"));
list.add(variable); list.add(variable);
} }
} // parseDepends } // parseDepends

View File

@ -302,7 +302,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
ClientInfo browserInfo = SessionManager.getAppDesktop().getClientInfo(); ClientInfo browserInfo = SessionManager.getAppDesktop().getClientInfo();
int browserHeight = browserInfo.desktopHeight; int browserHeight = browserInfo.desktopHeight;
int prefHeight = Integer.valueOf(height.replace("px", "")); 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; int maxHeight = browserHeight - topmarginpx;
if (prefHeight <= maxHeight) { if (prefHeight <= maxHeight) {
height = Integer.toString(prefHeight) + "px"; 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; : gridPanelFields[i].getVO().ctx;
//check context //check context
if (!gridPanelFields[i].isDisplayed(ctx, true)){ 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(); GridField mField = comp.getGridField();
if (mField != null) if (mField != null)
{ {
Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab)
: mField.getVO().ctx;
if (noData) if (noData)
{ {
comp.setReadWrite(false); comp.setReadWrite(false);
@ -1017,12 +1020,9 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
mField.refreshLookup(); mField.refreshLookup();
comp.setReadWrite(rw); comp.setReadWrite(rw);
comp.setMandatory(mField.isMandatory(true)); // check context 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)); 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; private static String m_ApplicationUrl = null;
public static String getApplicationUrl() { 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")) 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) if (m_ApplicationUrl != null)
return m_ApplicationUrl; return m_ApplicationUrl;
int port = Executions.getCurrent().getServerPort(); int port = Executions.getCurrent().getServerPort();

View File

@ -167,8 +167,20 @@ public class WReport implements EventListener<Event> {
private void launchReport (MPrintFormat pf) private void launchReport (MPrintFormat pf)
{ {
int Record_ID = 0; 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(); 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( PrintInfo info = new PrintInfo(
pf.getName(), pf.getName(),
pf.getAD_Table_ID(), pf.getAD_Table_ID(),

View File

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

View File

@ -24,6 +24,7 @@ import java.beans.PropertyChangeEvent;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.webui.ClientInfo; import org.adempiere.webui.ClientInfo;
@ -946,6 +947,16 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
return null; 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 { static class CustomSearchBox extends Searchbox {
/** /**

View File

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

View File

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