From 6f484ee7013318d32c1278e618ecc22b2022958d Mon Sep 17 00:00:00 2001 From: hengsin Date: Fri, 24 Nov 2023 23:09:13 +0800 Subject: [PATCH] IDEMPIERE-5923 Info Window should use key and display columns setting from lookup (#2108) --- .../webui/factory/DefaultInfoFactory.java | 53 ++++++--- .../adempiere/webui/factory/IInfoFactory.java | 16 +++ .../adempiere/webui/info/InfoAssetWindow.java | 21 ++++ .../webui/info/InfoAssignmentWindow.java | 22 ++++ .../webui/info/InfoBPartnerWindow.java | 21 ++++ .../adempiere/webui/info/InfoInOutWindow.java | 22 ++++ .../webui/info/InfoInvoiceWindow.java | 23 +++- .../adempiere/webui/info/InfoOrderWindow.java | 21 ++++ .../webui/info/InfoPaymentWindow.java | 21 ++++ .../webui/info/InfoProductWindow.java | 21 ++++ .../org/adempiere/webui/info/InfoWindow.java | 106 +++++++++--------- 11 files changed, 282 insertions(+), 65 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/DefaultInfoFactory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/DefaultInfoFactory.java index 62e1ac5672..cb61611e36 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/DefaultInfoFactory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/DefaultInfoFactory.java @@ -56,6 +56,13 @@ public class DefaultInfoFactory implements IInfoFactory { value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, null, null); } + @Override + public InfoPanel create(int WindowNo, String tableName, String keyColumn, String value, boolean multiSelection, + String whereClause, int AD_InfoWindow_ID, Lookup lookup) { + return create(WindowNo, tableName, keyColumn, + value, multiSelection, whereClause, AD_InfoWindow_ID, (lookup != null), null, null, lookup); + } + @Override public InfoPanel create(int WindowNo, String tableName, String keyColumn, String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field) { @@ -76,20 +83,40 @@ public class DefaultInfoFactory implements IInfoFactory { * @param predefinedContextVariables * @param field * @return InfoPanel - */ + */ public InfoPanel create(int WindowNo, String tableName, String keyColumn, String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables, GridField field) { + return create(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, predefinedContextVariables, field, + (field != null ? field.getLookup() : null)); + } + + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param value + * @param multiSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param predefinedContextVariables + * @param field + * @param lookupModel + * @return InfoPanel + */ + public InfoPanel create(int WindowNo, String tableName, String keyColumn, + String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, String predefinedContextVariables, GridField field, Lookup lookupModel) { InfoPanel info = null; setSOTrxBasedOnDocType(WindowNo); if (tableName.equals("C_BPartner")) { - info = new InfoBPartnerWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoBPartnerWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoBPartnerPanel (value,WindowNo, !Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx").equals("N"), multiSelection, whereClause, lookup); } } else if (tableName.equals("M_Product")) { - info = new InfoProductWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoProductWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoProductPanel ( WindowNo, Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"), @@ -97,31 +124,31 @@ public class DefaultInfoFactory implements IInfoFactory { multiSelection, value,whereClause, lookup); } } else if (tableName.equals("C_Invoice")) { - info = new InfoInvoiceWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoInvoiceWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoInvoicePanel ( WindowNo, value, multiSelection, whereClause, lookup); } } else if (tableName.equals("A_Asset")) { - info = new InfoAssetWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoAssetWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoAssetPanel (WindowNo, 0, value, multiSelection, whereClause, lookup); } } else if (tableName.equals("C_Order")) { - info = new InfoOrderWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoOrderWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoOrderPanel ( WindowNo, value, multiSelection, whereClause, lookup); } } else if (tableName.equals("M_InOut")) { - info = new InfoInOutWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoInOutWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoInOutPanel (WindowNo, value, multiSelection, whereClause, lookup); } } else if (tableName.equals("C_Payment")) { - info = new InfoPaymentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoPaymentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoPaymentPanel (WindowNo, value, multiSelection, whereClause, lookup); } @@ -129,13 +156,13 @@ public class DefaultInfoFactory implements IInfoFactory { info = new InfoCashLinePanel (WindowNo, value, multiSelection, whereClause, lookup); } else if (tableName.equals("S_ResourceAssignment")) { - info = new InfoAssignmentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoAssignmentWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoAssignmentPanel (WindowNo, value, multiSelection, whereClause, lookup); } } else { - info = new InfoWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); + info = new InfoWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, lookupModel); if (!info.loadedOK()) { info = new InfoGeneralPanel (value, WindowNo, tableName, keyColumn, @@ -164,7 +191,7 @@ public class DefaultInfoFactory implements IInfoFactory { if (col.equals("M_Product_ID")) { - InfoWindow infoWindow = new InfoProductWindow(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, field); + InfoWindow infoWindow = new InfoProductWindow(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, field, null, lookup); if (infoWindow.loadedOK()) return infoWindow; @@ -195,7 +222,7 @@ public class DefaultInfoFactory implements IInfoFactory { String tempIsSOTrx = ("Y".equals(originalIsSOTrx) ? "N" : "Y"); Env.setContext(Env.getCtx(), lookup.getWindowNo(), "IsSOTrx", tempIsSOTrx); } - InfoWindow infoWindow = new InfoBPartnerWindow(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, field); + InfoWindow infoWindow = new InfoBPartnerWindow(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, field, null, lookup); if (infoWindow.loadedOK()) return infoWindow; } finally { @@ -213,7 +240,7 @@ public class DefaultInfoFactory implements IInfoFactory { } else // General Info { - info = create(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, field); + info = create(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, (String)null, field, lookup); } return info; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/IInfoFactory.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/IInfoFactory.java index c3b7433a68..eaf4fbb124 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/IInfoFactory.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/factory/IInfoFactory.java @@ -39,6 +39,22 @@ public interface IInfoFactory { public InfoPanel create (int WindowNo, String tableName, String keyColumn, String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup); + + /** + * + * @param WindowNo + * @param tableName + * @param keyColumn + * @param value + * @param multiSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @return {@link InfoPanel} + */ + public InfoPanel create (int WindowNo, + String tableName, String keyColumn, String value, + boolean multiSelection, String whereClause, int AD_InfoWindow_ID, Lookup lookup); /** * diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssetWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssetWindow.java index fb9554823c..f4f3591760 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssetWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssetWindow.java @@ -25,6 +25,7 @@ package org.adempiere.webui.info; import org.compiere.model.GridField; +import org.compiere.model.Lookup; import org.compiere.model.MAsset; import org.compiere.util.Env; @@ -91,6 +92,26 @@ public class InfoAssetWindow extends InfoWindow { whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoAssetWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + @Override protected void saveSelectionDetail() { int row = contentPanel.getSelectedRow(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssignmentWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssignmentWindow.java index afc83d8890..92288d542f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssignmentWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoAssignmentWindow.java @@ -25,6 +25,7 @@ package org.adempiere.webui.info; import org.compiere.model.GridField; +import org.compiere.model.Lookup; /** * Info window for S_ResourceAssignment @@ -89,4 +90,25 @@ public class InfoAssignmentWindow extends InfoWindow { super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoAssignmentWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoBPartnerWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoBPartnerWindow.java index 52b3ffb4f0..2d2c9d1d3d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoBPartnerWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoBPartnerWindow.java @@ -28,6 +28,7 @@ import java.util.logging.Level; import org.adempiere.webui.panel.InvoiceHistory; import org.compiere.model.GridField; +import org.compiere.model.Lookup; import org.compiere.model.MBPartner; import org.compiere.util.Env; @@ -95,6 +96,26 @@ public class InfoBPartnerWindow extends InfoWindow { whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoBPartnerWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + /** * Has History * @return true diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInOutWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInOutWindow.java index e301f49d75..79d055ebc8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInOutWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInOutWindow.java @@ -25,6 +25,7 @@ package org.adempiere.webui.info; import org.compiere.model.GridField; +import org.compiere.model.Lookup; /** * Info window for M_InOut @@ -88,4 +89,25 @@ public class InfoInOutWindow extends InfoWindow { super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoInOutWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInvoiceWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInvoiceWindow.java index d15d43ec08..2d5fc8b108 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInvoiceWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoInvoiceWindow.java @@ -25,6 +25,7 @@ package org.adempiere.webui.info; import org.compiere.model.GridField; +import org.compiere.model.Lookup; import org.compiere.model.MInvoice; import org.compiere.util.Env; @@ -90,7 +91,27 @@ public class InfoInvoiceWindow extends InfoWindow { super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } - + + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoInvoiceWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + @Override protected void saveSelectionDetail() { int row = contentPanel.getSelectedRow(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoOrderWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoOrderWindow.java index 4276ce61c6..cd1ca8282e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoOrderWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoOrderWindow.java @@ -25,6 +25,7 @@ package org.adempiere.webui.info; import org.compiere.model.GridField; +import org.compiere.model.Lookup; /** * Info window for C_Order @@ -89,4 +90,24 @@ public class InfoOrderWindow extends InfoWindow { whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoOrderWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoPaymentWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoPaymentWindow.java index a5141d89e1..70263e43eb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoPaymentWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoPaymentWindow.java @@ -25,6 +25,7 @@ package org.adempiere.webui.info; import org.compiere.model.GridField; +import org.compiere.model.Lookup; /** * Info window for C_Payment @@ -89,4 +90,24 @@ public class InfoPaymentWindow extends InfoWindow { whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoPaymentWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java index 4f1f670e36..f46fbd6db5 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoProductWindow.java @@ -55,6 +55,7 @@ import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.EmbedWinInfo; import org.compiere.model.GridField; +import org.compiere.model.Lookup; import org.compiere.model.MDocType; import org.compiere.model.MInfoWindow; import org.compiere.model.MProduct; @@ -182,6 +183,26 @@ public class InfoProductWindow extends InfoWindow { whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); } + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoProductWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, + String predefinedContextVariables, Lookup lookupModel) { + super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, + predefinedContextVariables, lookupModel); + } + @Override protected String getSQLWhere() { /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java index 3e542962e1..86ae8d9131 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java @@ -31,7 +31,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.function.Consumer; import java.util.Properties; import java.util.TreeMap; import java.util.logging.Level; @@ -225,6 +224,10 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL /** true to auto collapse parameter panel after execution of query */ private boolean autoCollapsedParameterPanel = false; + + protected Lookup lookupModel = null; + + private ArrayList lookupIdentifiers; /** * @param WindowNo @@ -285,6 +288,25 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL */ public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue, boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, String predefinedContextVariables) { + this(WindowNo, tableName, keyColumn, queryValue, multipleSelection, whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables, + (field != null ? field.getLookup() : null)); + } + + /** + * @param WindowNo + * @param tableName + * @param keyColumn + * @param queryValue + * @param multipleSelection + * @param whereClause + * @param AD_InfoWindow_ID + * @param lookup + * @param field + * @param predefinedContextVariables + * @param lookupModel + */ + public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue, + boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, String predefinedContextVariables, Lookup lookupModel) { super(WindowNo, tableName, keyColumn, multipleSelection, whereClause, lookup, AD_InfoWindow_ID, queryValue); this.m_gridfield = field; @@ -315,6 +337,14 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL Env.setPredefinedVariables(Env.getCtx(), getWindowNo(), predefinedContextVariables); infoContext = new Properties(Env.getCtx()); + if (lookupModel != null) { + this.lookupModel = lookupModel; + if (lookupModel instanceof MLookup mLookup) { + if (mLookup.getLookupInfo().lookupDisplayColumnNames != null && mLookup.getLookupInfo().lookupDisplayColumnNames.size() > 0) { + this.lookupIdentifiers = new ArrayList(mLookup.getLookupInfo().lookupDisplayColumnNames); + } + } + } p_loadedOK = loadInfoDefinition(); // make process button only in window mode @@ -705,57 +735,12 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL } protected void testQueryForSplit(String [] values) { - // store identifiers on info window, sort to follow identifier on m_table - List fillIdentifiers = new ArrayList<>(); - // store query value, ignore value for identifier not exists on info window - // this list is sync with fillIdentifiers (size and order) - List fillValues = new ArrayList<>(); - - List tableIdentifiers = null; - if (m_gridfield != null && m_gridfield.getLookup() != null - && m_gridfield.getLookup() instanceof MLookup) { - - MLookup mLookup = (MLookup)m_gridfield.getLookup(); - if (mLookup.getLookupInfo().lookupDisplayColumnNames.size() > 0) - tableIdentifiers = mLookup.getLookupInfo().lookupDisplayColumnNames; - } - - if (tableIdentifiers != null) { - for (int i = 0; i < tableIdentifiers.size(); i++) { - // final local variable to access inside lambda expression - int indexFinal = i; - List tableIdentifiersFinal = tableIdentifiers; - - // sort identifiers of info window to follow m_table - // ignore identifiers exists on m_table but not exists on info window - identifiers.forEach((Consumer)(identifierEditor) -> { - if (identifierEditor.getColumnName().equals(tableIdentifiersFinal.get(indexFinal))) { - fillIdentifiers.add(identifierEditor); - fillValues.add(values[indexFinal]); - } - }); - } - } - - // case not exists mLookup.getLookupInfo().lookupDisplayColumnNames - // or no identifiers on info window exists on m_table - // fall back to old logic and just set values to identifiers - if (fillIdentifiers.size() == 0) { - for(int i = 0; i < values.length && i < identifiers.size(); i++) { - fillIdentifiers.add(identifiers.get(i)); - fillValues.add(values[i]); - } - } - - - - // do fill value to editor (for both corrected order and fall back) - for(int i = 0; i < fillIdentifiers.size(); i++) { - WEditor editor = fillIdentifiers.get(i); - editor.setValue(fillValues.get(i).trim()); + // do fill value to editor + for(int i = 0; i < values.length && i < identifiers.size(); i++) { + WEditor editor = identifiers.get(i); + editor.setValue(values[i].trim()); } testCount(false); - } @Override @@ -1887,6 +1872,20 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL if (!isAutoComplete) dynamicDisplay(null); + + //if using lookupIdentifiers, sort identifiers in the order of lookupIdentifiers + if (lookupIdentifiers != null && lookupIdentifiers.size() > 0 && identifiers.size() > 0) { + List list = new ArrayList(); + for(String columnName : lookupIdentifiers) { + for(WEditor editor : identifiers) { + if (columnName.equals(editor.getColumnName())) { + list.add(editor); + break; + } + } + } + identifiers = list; + } } /** @@ -1982,7 +1981,12 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL editor.showMenu(); - if (infoColumn.isIdentifier()) { + //if MLookup is available, use display columns of MLookup instead of InfoColumn's IsIdentifier flag + if (lookupIdentifiers != null && lookupIdentifiers.size() > 0) { + if (lookupIdentifiers.contains(infoColumn.getColumnName()) ) { + identifiers.add(editor); + } + } else if (infoColumn.isIdentifier()) { identifiers.add(editor); }