diff --git a/org.adempiere.base/src/org/adempiere/base/IDisplayTypeFactory.java b/org.adempiere.base/src/org/adempiere/base/IDisplayTypeFactory.java index 1f667e62f8..53b9d7fec2 100644 --- a/org.adempiere.base/src/org/adempiere/base/IDisplayTypeFactory.java +++ b/org.adempiere.base/src/org/adempiere/base/IDisplayTypeFactory.java @@ -29,6 +29,9 @@ public interface IDisplayTypeFactory { public Integer getDefaultPrecision(int displayType); public boolean isText(int displayType); public boolean isDate (int displayType); + public default boolean isList (int displayType) { + return false; + } public boolean isLookup(int displayType); public boolean isLOB (int displayType); public DecimalFormat getNumberFormat(int displayType, Language language, String pattern); diff --git a/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java b/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java index 5a878c6db9..0aa7480f00 100644 --- a/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java +++ b/org.adempiere.base/src/org/compiere/db/CreateAdempiere.java @@ -609,7 +609,7 @@ public class CreateAdempiere values.append("NULL"); } else if (DisplayType.isText(dt) || dt == DisplayType.YesNo - || dt == DisplayType.List || dt == DisplayType.Button + || DisplayType.isList(dt) || dt == DisplayType.Button || columnName.equals("AD_Language")) { String s = rs.getString(columnName); diff --git a/org.adempiere.base/src/org/compiere/model/MColumn.java b/org.adempiere.base/src/org/compiere/model/MColumn.java index b281d5ca1b..899f8c77bc 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -800,7 +800,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport foreignTable = "AD_Org"; else if ("C_ProjectType_ID".equalsIgnoreCase(getColumnName())) foreignTable = "C_ProjectType"; - } else if (DisplayType.List == refid || DisplayType.Payment == refid) { + } else if (DisplayType.isList(refid) || DisplayType.Payment == refid) { foreignTable = "AD_Ref_List"; } else if (DisplayType.Location == refid) { foreignTable = "C_Location"; @@ -941,7 +941,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())) && !column.isVirtualColumn()) { int refid = column.getAD_Reference_ID(); - if (refid != DisplayType.List && refid != DisplayType.Payment) + if (!DisplayType.isList(refid) && refid != DisplayType.Payment) { String referenceTableName = column.getReferenceTableName(); if (referenceTableName != null) @@ -1153,7 +1153,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport return ""; int refid = column.getAD_Reference_ID(); - if (refid != DisplayType.List && refid != DisplayType.Payment) + if (!DisplayType.isList(refid) && refid != DisplayType.Payment) { String referenceTableName = column.getReferenceTableName(); if (referenceTableName != null) diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index dcebbbb787..0d773c78a3 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -188,7 +188,7 @@ public class MLookupFactory MLookupInfo info = null; boolean needToAddSecurity = true; // List - if (AD_Reference_ID == DisplayType.List || AD_Reference_ID == DisplayType.ChosenMultipleSelectionList || AD_Reference_ID == DisplayType.RadiogroupList) // 17 + if (DisplayType.isList(AD_Reference_ID)) // 17 { info = getLookup_List(language, AD_Reference_Value_ID); needToAddSecurity = false; @@ -925,7 +925,7 @@ public class MLookupFactory displayColumn.append("(").append(embeddedSQL).append(")"); } // List - else if (ldc.DisplayType == DisplayType.List) + else if (DisplayType.isList(ldc.DisplayType)) { String embeddedSQL = getLookup_ListEmbed(language, ldc.AD_Reference_ID, ldc.ColumnName); if (embeddedSQL != null) diff --git a/org.adempiere.base/src/org/compiere/model/MProcessPara.java b/org.adempiere.base/src/org/compiere/model/MProcessPara.java index 84eec30890..4d2537e3a2 100644 --- a/org.adempiere.base/src/org/compiere/model/MProcessPara.java +++ b/org.adempiere.base/src/org/compiere/model/MProcessPara.java @@ -348,7 +348,7 @@ public class MProcessPara extends X_AD_Process_Para implements ImmutablePOSuppor if (rt != null) foreignTable = rt.getAD_Table().getTableName(); } - } else if (DisplayType.List == getAD_Reference_ID()) { + } else if (DisplayType.isList(getAD_Reference_ID())) { foreignTable = "AD_Ref_List"; } diff --git a/org.adempiere.base/src/org/compiere/print/DataEngine.java b/org.adempiere.base/src/org/compiere/print/DataEngine.java index c074ee75ac..562ab19748 100644 --- a/org.adempiere.base/src/org/compiere/print/DataEngine.java +++ b/org.adempiere.base/src/org/compiere/print/DataEngine.java @@ -456,7 +456,7 @@ public class DataEngine } // -- List or Button with ReferenceValue -- - else if (AD_Reference_ID == DisplayType.List + else if (DisplayType.isList(AD_Reference_ID) || (AD_Reference_ID == DisplayType.Button && AD_Reference_Value_ID != 0)) { if (ColumnSQL.length() > 0) diff --git a/org.adempiere.base/src/org/compiere/report/core/RColumn.java b/org.adempiere.base/src/org/compiere/report/core/RColumn.java index bf989c31ff..277bdda94f 100644 --- a/org.adempiere.base/src/org/compiere/report/core/RColumn.java +++ b/org.adempiere.base/src/org/compiere/report/core/RColumn.java @@ -121,7 +121,7 @@ public class RColumn else if (displayType == DisplayType.Integer) m_colClass = Integer.class; // List - else if (displayType == DisplayType.List) + else if (DisplayType.isList(displayType)) { Language language = Language.getLanguage(Env.getAD_Language(ctx)); m_colSQL = "(" + MLookupFactory.getLookup_ListEmbed( diff --git a/org.adempiere.base/src/org/compiere/util/DisplayType.java b/org.adempiere.base/src/org/compiere/util/DisplayType.java index ff787da52a..c1c86ac07f 100644 --- a/org.adempiere.base/src/org/compiere/util/DisplayType.java +++ b/org.adempiere.base/src/org/compiere/util/DisplayType.java @@ -363,6 +363,35 @@ public final class DisplayType return false; } // isDate + + /** + * Returns true if DisplayType is a List. + * (stored as Text) + * @param displayType Display Type + * @return true if List + */ + public static boolean isList(int displayType) + { + if (DisplayType.List == displayType || DisplayType.RadiogroupList == displayType + || DisplayType.ChosenMultipleSelectionList == displayType) + return true; + + IServiceReferenceHolder cache = s_displayTypeFactoryCache.get(displayType); + if (cache != null) { + IDisplayTypeFactory service = cache.getService(); + if (service != null) + return service.isList(displayType); + } + Optional> found = getDisplayTypeFactories().stream() + .filter(e -> e.getService() != null && e.getService().isList(displayType)) + .findFirst(); + if (found.isPresent()) { + s_displayTypeFactoryCache.put(displayType, found.get()); + return true; + } + + return false; + } // isList /** * Returns true if DisplayType is a VLookup (List, Table, TableDir, Search). diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackRollProcess.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackRollProcess.java index 1604496cdb..68f203d16b 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackRollProcess.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackRollProcess.java @@ -197,7 +197,7 @@ public class PackRollProcess extends SvrProcess { if (v_AD_Reference_ID == DisplayType.String || v_AD_Reference_ID == DisplayType.Text || v_AD_Reference_ID == DisplayType.Memo - || v_AD_Reference_ID == DisplayType.List + || DisplayType.isList(v_AD_Reference_ID) // Carlos Ruiz globalqss, special // treatment for EntityType // it's a Table reference but must diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java index 5328ee0d2a..ac9888c8e6 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PoExporter.java @@ -255,7 +255,7 @@ public class PoExporter { tableName = columnName.substring(0, columnName.length() - 3); } addTableReference(columnName, tableName, new AttributesImpl()); - } else if (DisplayType.List == displayType) { + } else if (DisplayType.isList(displayType)) { add(columnName, "", new AttributesImpl()); } else if (DisplayType.isLookup(displayType)) { String tableName = null; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java index adf76d5ff9..ac13b286ea 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java @@ -546,7 +546,7 @@ public class WWFActivity extends ADForm implements EventListener } fAnswerList.setVisible(true); } - else if (dt == DisplayType.List) + else if (DisplayType.isList(dt)) { ValueNamePair[] values = MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false); for(int i = 0; i < values.length; i++) @@ -680,7 +680,7 @@ public class WWFActivity extends ADForm implements EventListener // Do we have an answer? int dt = m_column.getAD_Reference_ID(); String value = fAnswerText.getText(); - if (dt == DisplayType.YesNo || dt == DisplayType.List) + if (dt == DisplayType.YesNo || DisplayType.isList(dt)) { ListItem li = fAnswerList.getSelectedItem(); if(li != null) value = li.getValue().toString(); diff --git a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java index ea79e032fa..0680cb1ab3 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java @@ -1412,7 +1412,7 @@ public class DB_Oracle implements AdempiereDatabase && ( ! (DisplayType.isID(column.getAD_Reference_ID()) && defaultValue.equals("-1") ) ) ) // not for ID's with default -1 { if (DisplayType.isText(column.getAD_Reference_ID()) - || column.getAD_Reference_ID() == DisplayType.List + || DisplayType.isList(column.getAD_Reference_ID()) || column.getAD_Reference_ID() == DisplayType.YesNo // Two special columns: Defined as Table but DB Type is String || column.getColumnName().equals("EntityType") || column.getColumnName().equals("AD_Language") @@ -1485,7 +1485,7 @@ public class DB_Oracle implements AdempiereDatabase && ( ! (DisplayType.isID(column.getAD_Reference_ID()) && defaultValue.equals("-1") ) ) ) // not for ID's with default -1 { if (DisplayType.isText(column.getAD_Reference_ID()) - || column.getAD_Reference_ID() == DisplayType.List + || DisplayType.isList(column.getAD_Reference_ID()) || column.getAD_Reference_ID() == DisplayType.YesNo || column.getAD_Reference_ID() == DisplayType.Payment // Two special columns: Defined as Table but DB Type is String diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index f0d8dfc6c9..fa58d1a0b2 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -1313,7 +1313,7 @@ public class DB_PostgreSQL implements AdempiereDatabase && ( ! (DisplayType.isID(column.getAD_Reference_ID()) && defaultValue.equals("-1") ) ) ) // not for ID's with default -1 { if (DisplayType.isText(column.getAD_Reference_ID()) - || column.getAD_Reference_ID() == DisplayType.List + || DisplayType.isList(column.getAD_Reference_ID()) || column.getAD_Reference_ID() == DisplayType.YesNo // Two special columns: Defined as Table but DB Type is String || column.getColumnName().equals("EntityType") || column.getColumnName().equals("AD_Language") diff --git a/org.idempiere.test/src/org/idempiere/test/performance/FakeDisplayTypeFactory.java b/org.idempiere.test/src/org/idempiere/test/performance/FakeDisplayTypeFactory.java index 06d3d6ba4e..c7c5b0da4f 100644 --- a/org.idempiere.test/src/org/idempiere/test/performance/FakeDisplayTypeFactory.java +++ b/org.idempiere.test/src/org/idempiere/test/performance/FakeDisplayTypeFactory.java @@ -39,6 +39,11 @@ public class FakeDisplayTypeFactory implements IDisplayTypeFactory { public boolean isDate(int displayType) { return false; } + + @Override + public boolean isList(int displayType) { + return false; + } @Override public boolean isLookup(int displayType) { diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java index 920aea86eb..cf587196fe 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ModelADServiceImpl.java @@ -1095,7 +1095,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic AD_Reference_ID = ((MLookup)lookup).getDisplayType(); } - if(AD_Reference_ID==DisplayType.List) + if(DisplayType.isList(AD_Reference_ID)) { if (lookup.getSize() == 0) lookup.refresh(); diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java index 052a60cdf8..d0e7ab4f6c 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/Process.java @@ -543,7 +543,7 @@ public class Process { Object value = valueString; if (valueString != null && valueString.length() == 0) value = null; - if (value != null && (DisplayType.List == displayType || + if (value != null && (DisplayType.isList(displayType) || DisplayType.TableDir== displayType || DisplayType.Table== displayType)&& value.equals("-1")) value= null;