From 4c50d922c57557fdc9a1c04346b94297c51567d7 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 1 Dec 2008 22:19:24 +0000 Subject: [PATCH] Implement Validator for beforeSaveProperties - ID: 2373679 --- .../compiere/model/ModelValidationEngine.java | 34 +++++++++++++++++-- looks/src/org/compiere/util/Ini.java | 32 +++++++++++++---- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/base/src/org/compiere/model/ModelValidationEngine.java b/base/src/org/compiere/model/ModelValidationEngine.java index 8bc993944b..5b7300e58c 100644 --- a/base/src/org/compiere/model/ModelValidationEngine.java +++ b/base/src/org/compiere/model/ModelValidationEngine.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -736,5 +736,35 @@ public class ModelValidationEngine } } } - + + /** + * Before Save Properties for selected client. + */ + public void beforeSaveProperties () + { + int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); + for (int i = 0; i < m_validators.size(); i++) + { + ModelValidator validator = (ModelValidator)m_validators.get(i); + if (AD_Client_ID == validator.getAD_Client_ID() + || m_globalValidators.contains(validator)) + { + java.lang.reflect.Method m = null; + try { + m = validator.getClass().getMethod("beforeSaveProperties"); + } + catch(NoSuchMethodException e) { + // ignore + } + try { + if (m != null) + m.invoke(validator); + } + catch (Exception e) { + log.warning("" + validator + ": " + e.getLocalizedMessage()); + } + } + } + } + } // ModelValidatorEngine diff --git a/looks/src/org/compiere/util/Ini.java b/looks/src/org/compiere/util/Ini.java index 0503a36ffc..7a3177bf88 100644 --- a/looks/src/org/compiere/util/Ini.java +++ b/looks/src/org/compiere/util/Ini.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -16,14 +16,25 @@ *****************************************************************************/ package org.compiere.util; -import java.awt.*; -import java.io.*; +import java.awt.Dimension; +import java.awt.Point; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Serializable; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.Charset; -import java.sql.*; -import java.util.*; -import java.util.logging.*; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.jnlp.BasicService; import javax.jnlp.FileContents; @@ -31,7 +42,9 @@ import javax.jnlp.PersistenceService; import javax.jnlp.ServiceManager; import javax.jnlp.UnavailableServiceException; -import org.adempiere.plaf.*; +import org.adempiere.plaf.AdempiereLookAndFeel; +import org.adempiere.plaf.AdempiereThemeInnova; +import org.compiere.model.ModelValidationEngine; /** @@ -231,6 +244,11 @@ public final class Ini implements Serializable */ public static void saveProperties (boolean tryUserHome) { + if (Ini.isClient() && DB.isConnected()) { + // Call ModelValidators beforeSaveProperties + ModelValidationEngine.get().beforeSaveProperties(); + } + if (isWebStartClient()) { saveWebStartProperties();