Fixed multi lingual reporting issue

This commit is contained in:
Heng Sin Low 2010-10-26 19:03:16 +08:00
parent fa6dafed7d
commit 6f2f78cd11
5 changed files with 202 additions and 98 deletions

View File

@ -131,7 +131,19 @@ public final class ProcessUtil {
Class<?> processClass = null; Class<?> processClass = null;
//use context classloader if available //use context classloader if available
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) if (classLoader != null)
{
try
{
processClass = classLoader.loadClass(className);
}
catch (ClassNotFoundException ex)
{
log.log(Level.FINE, className, ex);
}
}
if (processClass == null)
{
classLoader = ProcessUtil.class.getClassLoader(); classLoader = ProcessUtil.class.getClassLoader();
try try
{ {
@ -143,6 +155,7 @@ public final class ProcessUtil {
pi.setSummary ("ClassNotFound", true); pi.setSummary ("ClassNotFound", true);
return false; return false;
} }
}
if (processClass == null) { if (processClass == null) {
pi.setSummary("No Instance for " + pi.getClassName(), true); pi.setSummary("No Instance for " + pi.getClassName(), true);

View File

@ -91,7 +91,7 @@ import org.w3c.dom.Element;
* <li>https://sourceforge.net/tracker/?func=detail&aid=2947622&group_id=176962&atid=879332 * <li>https://sourceforge.net/tracker/?func=detail&aid=2947622&group_id=176962&atid=879332
*/ */
public abstract class PO public abstract class PO
implements Serializable, Comparator, Evaluatee implements Serializable, Comparator, Evaluatee, Cloneable
{ {
/** /**
* *
@ -4009,4 +4009,46 @@ public abstract class PO
return false; return false;
} }
@Override
protected Object clone() throws CloneNotSupportedException {
PO clone = (PO) super.clone();
clone.m_trxName = null;
if (m_custom != null)
{
clone.m_custom = new HashMap<String, String>();
clone.m_custom.putAll(m_custom);
}
if (m_newValues != null)
{
clone.m_newValues = new Object[m_newValues.length];
for(int i = 0; i < m_newValues.length; i++)
{
clone.m_newValues[i] = m_newValues[i];
}
}
if (m_oldValues != null)
{
clone.m_oldValues = new Object[m_oldValues.length];
for(int i = 0; i < m_oldValues.length; i++)
{
clone.m_oldValues[i] = m_oldValues[i];
}
}
if (m_IDs != null)
{
clone.m_IDs = new Object[m_IDs.length];
for(int i = 0; i < m_IDs.length; i++)
{
clone.m_IDs[i] = m_IDs[i];
}
}
clone.p_ctx = Env.getCtx();
clone.m_doc = null;
clone.m_lobInfo = null;
clone.m_attachment = null;
clone.m_isReplication = false;
return clone;
}
} // PO } // PO

View File

@ -29,6 +29,7 @@ import javax.sql.RowSet;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.PO;
import org.compiere.model.X_AD_PrintFormat; import org.compiere.model.X_AD_PrintFormat;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -64,7 +65,7 @@ public class MPrintFormat extends X_AD_PrintFormat
{ {
super (ctx, AD_PrintFormat_ID, trxName); super (ctx, AD_PrintFormat_ID, trxName);
// Language=[Deutsch,Locale=de_DE,AD_Language=en_US,DatePattern=DD.MM.YYYY,DecimalPoint=false] // Language=[Deutsch,Locale=de_DE,AD_Language=en_US,DatePattern=DD.MM.YYYY,DecimalPoint=false]
m_language = Language.getLoginLanguage(); m_language = Env.getLanguage(ctx);
if (AD_PrintFormat_ID == 0) if (AD_PrintFormat_ID == 0)
{ {
setStandardHeaderFooter(true); setStandardHeaderFooter(true);
@ -84,7 +85,7 @@ public class MPrintFormat extends X_AD_PrintFormat
public MPrintFormat (Properties ctx, ResultSet rs, String trxName) public MPrintFormat (Properties ctx, ResultSet rs, String trxName)
{ {
super(ctx, rs, trxName); super(ctx, rs, trxName);
m_language = Language.getLoginLanguage(); m_language = Env.getLanguage(ctx);
m_items = getItems(); m_items = getItems();
} // MPrintFormat } // MPrintFormat
@ -823,6 +824,15 @@ public class MPrintFormat extends X_AD_PrintFormat
else else
s_formats.put(key, pf); s_formats.put(key, pf);
} }
if (pf != null)
{
try {
pf = pf.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
return pf; return pf;
} // get } // get
@ -929,6 +939,18 @@ public class MPrintFormat extends X_AD_PrintFormat
return rowSet; return rowSet;
} }
@Override
public MPrintFormat clone() throws CloneNotSupportedException {
MPrintFormat clone = (MPrintFormat) super.clone();
clone.m_items = m_items == null ? null : new MPrintFormatItem[m_items.length];
for(int i = 0; i < m_items.length; i++) {
clone.m_items[i] = m_items[i];
}
clone.m_tFormat = m_tFormat;
clone.m_language = Env.getLanguage(Env.getCtx());
clone.m_translationViewLanguage = null;
return clone;
}
/************************************************************************** /**************************************************************************
* Test * Test

View File

@ -368,7 +368,7 @@ public final class DisplayType
{ {
Language myLanguage = language; Language myLanguage = language;
if (myLanguage == null) if (myLanguage == null)
myLanguage = Language.getLoginLanguage(); myLanguage = Env.getLanguage(Env.getCtx());
// //
if ( pattern != null && pattern.length() > 0) if ( pattern != null && pattern.length() > 0)
{ {

View File

@ -1027,6 +1027,33 @@ public final class Env
return Language.getLoginLanguage(); return Language.getLoginLanguage();
} // getLanguage } // getLanguage
public static ArrayList<String> getSupportedLanguages()
{
ArrayList<String> AD_Languages = new ArrayList<String>();
String sql = "SELECT DISTINCT AD_Language FROM AD_Message_Trl";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
String AD_Language = rs.getString(1);
AD_Languages.add(AD_Language);
}
}
catch (SQLException e)
{
getLogger().log(Level.SEVERE, "", e);
}
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return AD_Languages;
}
/** /**
* Verify Language. * Verify Language.
* Check that language is supported by the system * Check that language is supported by the system