IDEMPIERE-5923 Info Window should use key and display columns setting from lookup (#2108)

This commit is contained in:
hengsin 2023-11-24 23:09:13 +08:00 committed by GitHub
parent ce48a8835e
commit 6f484ee701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 282 additions and 65 deletions

View File

@ -56,6 +56,13 @@ public class DefaultInfoFactory implements IInfoFactory {
value, multiSelection, whereClause, AD_InfoWindow_ID, lookup, null, null); 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 @Override
public InfoPanel create(int WindowNo, String tableName, String keyColumn, public InfoPanel create(int WindowNo, String tableName, String keyColumn,
String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field) { String value, boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field) {
@ -79,17 +86,37 @@ public class DefaultInfoFactory implements IInfoFactory {
*/ */
public InfoPanel create(int WindowNo, String tableName, String keyColumn, 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) { 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; InfoPanel info = null;
setSOTrxBasedOnDocType(WindowNo); setSOTrxBasedOnDocType(WindowNo);
if (tableName.equals("C_BPartner")) { 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()) { if (!info.loadedOK()) {
info = new InfoBPartnerPanel (value,WindowNo, !Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx").equals("N"), info = new InfoBPartnerPanel (value,WindowNo, !Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx").equals("N"),
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("M_Product")) { } 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()) { if (!info.loadedOK()) {
info = new InfoProductPanel ( WindowNo, info = new InfoProductPanel ( WindowNo,
Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"), Env.getContextAsInt(Env.getCtx(), WindowNo, "M_Warehouse_ID"),
@ -97,31 +124,31 @@ public class DefaultInfoFactory implements IInfoFactory {
multiSelection, value,whereClause, lookup); multiSelection, value,whereClause, lookup);
} }
} else if (tableName.equals("C_Invoice")) { } 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()) { if (!info.loadedOK()) {
info = new InfoInvoicePanel ( WindowNo, value, info = new InfoInvoicePanel ( WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("A_Asset")) { } 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()) { if (!info.loadedOK()) {
info = new InfoAssetPanel (WindowNo, 0, value, info = new InfoAssetPanel (WindowNo, 0, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("C_Order")) { } 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()) { if (!info.loadedOK()) {
info = new InfoOrderPanel ( WindowNo, value, info = new InfoOrderPanel ( WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("M_InOut")) { } 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()) { if (!info.loadedOK()) {
info = new InfoInOutPanel (WindowNo, value, info = new InfoInOutPanel (WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else if (tableName.equals("C_Payment")) { } 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()) { if (!info.loadedOK()) {
info = new InfoPaymentPanel (WindowNo, value, multiSelection, whereClause, lookup); info = new InfoPaymentPanel (WindowNo, value, multiSelection, whereClause, lookup);
} }
@ -129,13 +156,13 @@ public class DefaultInfoFactory implements IInfoFactory {
info = new InfoCashLinePanel (WindowNo, value, info = new InfoCashLinePanel (WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} else if (tableName.equals("S_ResourceAssignment")) { } 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()) { if (!info.loadedOK()) {
info = new InfoAssignmentPanel (WindowNo, value, info = new InfoAssignmentPanel (WindowNo, value,
multiSelection, whereClause, lookup); multiSelection, whereClause, lookup);
} }
} else { } 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()) { if (!info.loadedOK()) {
info = new InfoGeneralPanel (value, WindowNo, info = new InfoGeneralPanel (value, WindowNo,
tableName, keyColumn, tableName, keyColumn,
@ -164,7 +191,7 @@ public class DefaultInfoFactory implements IInfoFactory {
if (col.equals("M_Product_ID")) 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()) if (infoWindow.loadedOK())
return infoWindow; return infoWindow;
@ -195,7 +222,7 @@ public class DefaultInfoFactory implements IInfoFactory {
String tempIsSOTrx = ("Y".equals(originalIsSOTrx) ? "N" : "Y"); String tempIsSOTrx = ("Y".equals(originalIsSOTrx) ? "N" : "Y");
Env.setContext(Env.getCtx(), lookup.getWindowNo(), "IsSOTrx", tempIsSOTrx); 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()) if (infoWindow.loadedOK())
return infoWindow; return infoWindow;
} finally { } finally {
@ -213,7 +240,7 @@ public class DefaultInfoFactory implements IInfoFactory {
} }
else // General Info 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; return info;
} }

View File

@ -40,6 +40,22 @@ public interface IInfoFactory {
String tableName, String keyColumn, String value, String tableName, String keyColumn, String value,
boolean multiSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup); 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);
/** /**
* *
* @param lookup * @param lookup

View File

@ -25,6 +25,7 @@
package org.adempiere.webui.info; package org.adempiere.webui.info;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MAsset; import org.compiere.model.MAsset;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -91,6 +92,26 @@ public class InfoAssetWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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 @Override
protected void saveSelectionDetail() { protected void saveSelectionDetail() {
int row = contentPanel.getSelectedRow(); int row = contentPanel.getSelectedRow();

View File

@ -25,6 +25,7 @@
package org.adempiere.webui.info; package org.adempiere.webui.info;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
/** /**
* Info window for S_ResourceAssignment * Info window for S_ResourceAssignment
@ -89,4 +90,25 @@ public class InfoAssignmentWindow extends InfoWindow {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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);
}
} }

View File

@ -28,6 +28,7 @@ import java.util.logging.Level;
import org.adempiere.webui.panel.InvoiceHistory; import org.adempiere.webui.panel.InvoiceHistory;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MBPartner; import org.compiere.model.MBPartner;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -95,6 +96,26 @@ public class InfoBPartnerWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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 * Has History
* @return true * @return true

View File

@ -25,6 +25,7 @@
package org.adempiere.webui.info; package org.adempiere.webui.info;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
/** /**
* Info window for M_InOut * Info window for M_InOut
@ -88,4 +89,25 @@ public class InfoInOutWindow extends InfoWindow {
super(WindowNo, tableName, keyColumn, queryValue, multipleSelection, super(WindowNo, tableName, keyColumn, queryValue, multipleSelection,
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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);
}
} }

View File

@ -25,6 +25,7 @@
package org.adempiere.webui.info; package org.adempiere.webui.info;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MInvoice; import org.compiere.model.MInvoice;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -91,6 +92,26 @@ public class InfoInvoiceWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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 @Override
protected void saveSelectionDetail() { protected void saveSelectionDetail() {
int row = contentPanel.getSelectedRow(); int row = contentPanel.getSelectedRow();

View File

@ -25,6 +25,7 @@
package org.adempiere.webui.info; package org.adempiere.webui.info;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
/** /**
* Info window for C_Order * Info window for C_Order
@ -89,4 +90,24 @@ public class InfoOrderWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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);
}
} }

View File

@ -25,6 +25,7 @@
package org.adempiere.webui.info; package org.adempiere.webui.info;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
/** /**
* Info window for C_Payment * Info window for C_Payment
@ -89,4 +90,24 @@ public class InfoPaymentWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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);
}
} }

View File

@ -55,6 +55,7 @@ import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.EmbedWinInfo; import org.compiere.minigrid.EmbedWinInfo;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.Lookup;
import org.compiere.model.MDocType; import org.compiere.model.MDocType;
import org.compiere.model.MInfoWindow; import org.compiere.model.MInfoWindow;
import org.compiere.model.MProduct; import org.compiere.model.MProduct;
@ -182,6 +183,26 @@ public class InfoProductWindow extends InfoWindow {
whereClause, AD_InfoWindow_ID, lookup, field, predefinedContextVariables); 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 @Override
protected String getSQLWhere() { protected String getSQLWhere() {
/** /**

View File

@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.function.Consumer;
import java.util.Properties; import java.util.Properties;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Level; import java.util.logging.Level;
@ -226,6 +225,10 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
/** true to auto collapse parameter panel after execution of query */ /** true to auto collapse parameter panel after execution of query */
private boolean autoCollapsedParameterPanel = false; private boolean autoCollapsedParameterPanel = false;
protected Lookup lookupModel = null;
private ArrayList<String> lookupIdentifiers;
/** /**
* @param WindowNo * @param WindowNo
* @param tableName * @param tableName
@ -285,6 +288,25 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
*/ */
public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue, public InfoWindow(int WindowNo, String tableName, String keyColumn, String queryValue,
boolean multipleSelection, String whereClause, int AD_InfoWindow_ID, boolean lookup, GridField field, String predefinedContextVariables) { 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, super(WindowNo, tableName, keyColumn, multipleSelection, whereClause,
lookup, AD_InfoWindow_ID, queryValue); lookup, AD_InfoWindow_ID, queryValue);
this.m_gridfield = field; this.m_gridfield = field;
@ -315,6 +337,14 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
Env.setPredefinedVariables(Env.getCtx(), getWindowNo(), predefinedContextVariables); Env.setPredefinedVariables(Env.getCtx(), getWindowNo(), predefinedContextVariables);
infoContext = new Properties(Env.getCtx()); 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<String>(mLookup.getLookupInfo().lookupDisplayColumnNames);
}
}
}
p_loadedOK = loadInfoDefinition(); p_loadedOK = loadInfoDefinition();
// make process button only in window mode // make process button only in window mode
@ -705,57 +735,12 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
} }
protected void testQueryForSplit(String [] values) { protected void testQueryForSplit(String [] values) {
// store identifiers on info window, sort to follow identifier on m_table // do fill value to editor
List<WEditor> 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<String> fillValues = new ArrayList<>();
List<String> 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<String> 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<WEditor>)(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++) { for(int i = 0; i < values.length && i < identifiers.size(); i++) {
fillIdentifiers.add(identifiers.get(i)); WEditor editor = identifiers.get(i);
fillValues.add(values[i]); editor.setValue(values[i].trim());
}
}
// 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());
} }
testCount(false); testCount(false);
} }
@Override @Override
@ -1887,6 +1872,20 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
if (!isAutoComplete) if (!isAutoComplete)
dynamicDisplay(null); dynamicDisplay(null);
//if using lookupIdentifiers, sort identifiers in the order of lookupIdentifiers
if (lookupIdentifiers != null && lookupIdentifiers.size() > 0 && identifiers.size() > 0) {
List<WEditor> list = new ArrayList<WEditor>();
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(); 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); identifiers.add(editor);
} }