From 2c568a2ccaddf2bd3fc38cf876e86cc4ee087454 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Mon, 16 Apr 2007 10:36:01 +0000 Subject: [PATCH] FR [ 1670025 ] ModelValidator.afterLoadPreferences will be useful http://sourceforge.net/tracker/index.php?func=detail&aid=1670025&group_id=176962&atid=879335 --- .../compiere/model/ModelValidationEngine.java | 32 +++++++++++++++++++ dbPort/src/org/compiere/util/Login.java | 2 ++ 2 files changed, 34 insertions(+) diff --git a/dbPort/src/org/compiere/model/ModelValidationEngine.java b/dbPort/src/org/compiere/model/ModelValidationEngine.java index d711c56bb0..47c34a5052 100644 --- a/dbPort/src/org/compiere/model/ModelValidationEngine.java +++ b/dbPort/src/org/compiere/model/ModelValidationEngine.java @@ -311,4 +311,36 @@ public class ModelValidationEngine return sb.toString(); } // toString + /** + * After Load Preferences into Context for selected client. + * @param ctx context + * @see org.compiere.util.Login#loadPreferences(KeyNamePair, KeyNamePair, java.sql.Timestamp, String) + * @author Teo Sarca - FR [ 1670025 ] - https://sourceforge.net/tracker/index.php?func=detail&aid=1670025&group_id=176962&atid=879335 + */ + public void afterLoadPreferences (Properties ctx) + { + int AD_Client_ID = Env.getAD_Client_ID(ctx); + for (int i = 0; i < m_validators.size(); i++) + { + ModelValidator validator = (ModelValidator)m_validators.get(i); + if (AD_Client_ID == validator.getAD_Client_ID()) + { + java.lang.reflect.Method m = null; + try { + m = validator.getClass().getMethod("afterLoadPreferences", new Class[]{Properties.class}); + } + catch(NoSuchMethodException e) { + // ignore + } + try { + if (m != null) + m.invoke(validator, ctx); + } + catch (Exception e) { + log.warning("" + validator + ": " + e.getLocalizedMessage()); + } + } + } + } + } // ModelValidatorEngine diff --git a/dbPort/src/org/compiere/util/Login.java b/dbPort/src/org/compiere/util/Login.java index b812d80fd7..76f591c815 100644 --- a/dbPort/src/org/compiere/util/Login.java +++ b/dbPort/src/org/compiere/util/Login.java @@ -894,6 +894,8 @@ public class Login Ini.saveProperties(Ini.isClient()); // Country Env.setContext(m_ctx, "#C_Country_ID", MCountry.getDefault(m_ctx).getC_Country_ID()); + // Call ModelValidators afterLoadPreferences - teo_sarca FR [ 1670025 ] + ModelValidationEngine.get().afterLoadPreferences(m_ctx); return retValue; } // loadPreferences