diff --git a/org.adempiere.base/src/org/compiere/util/Msg.java b/org.adempiere.base/src/org/compiere/util/Msg.java index 17fb61c572..7cc7f1f1f9 100644 --- a/org.adempiere.base/src/org/compiere/util/Msg.java +++ b/org.adempiere.base/src/org/compiere/util/Msg.java @@ -68,7 +68,10 @@ public final class Msg /** The Map */ private CCache> m_languages - = new CCache>(null, "msg_lang", 2, 0, false); + = new CCache>(null, "msg_lang", 2, 0, false); + + private CCache> m_elementCache + = new CCache>(null, "msg_element", 2, 0, false); /** * Get Language specific Message Map @@ -93,7 +96,22 @@ public final class Msg return retValue; } return retValue; - } // getMsgMap + } // getMsgMap + + private CCache getElementMap (String ad_language) + { + String AD_Language = ad_language; + if (AD_Language == null || AD_Language.length() == 0) + AD_Language = Language.getBaseAD_Language(); + // Do we have the language ? + CCache retValue = (CCache)m_elementCache.get(AD_Language); + if (retValue != null && retValue.size() > 0) + return retValue; + + retValue = new CCache("element", 100); + m_elementCache.put(AD_Language, retValue); + return retValue; + } /** @@ -464,34 +482,30 @@ public final class Msg return ""; String AD_Language = ad_language; if (AD_Language == null || AD_Language.length() == 0) - AD_Language = Language.getBaseAD_Language(); + AD_Language = Language.getBaseAD_Language(); + + Msg msg = get(); + CCache cache = msg.getElementMap(AD_Language); + String key = ColumnName+"|"+isSOTrx; + String retStr = cache.get(key); + if (retStr != null) + return retStr; - // Check AD_Element - String retStr = ""; + // Check AD_Element PreparedStatement pstmt = null; ResultSet rs = null; try { - try + if (AD_Language == null || AD_Language.length() == 0 || Env.isBaseLanguage(AD_Language, "AD_Element")) + pstmt = DB.prepareStatement("SELECT Name, PO_Name FROM AD_Element WHERE UPPER(ColumnName)=?", null); + else { - if (AD_Language == null || AD_Language.length() == 0 || Env.isBaseLanguage(AD_Language, "AD_Element")) - pstmt = DB.prepareStatement("SELECT Name, PO_Name FROM AD_Element WHERE UPPER(ColumnName)=?", null); - else - { - pstmt = DB.prepareStatement("SELECT t.Name, t.PO_Name FROM AD_Element_Trl t, AD_Element e " - + "WHERE t.AD_Element_ID=e.AD_Element_ID AND UPPER(e.ColumnName)=? " - + "AND t.AD_Language=?", null); - pstmt.setString(2, AD_Language); - } + pstmt = DB.prepareStatement("SELECT t.Name, t.PO_Name FROM AD_Element_Trl t, AD_Element e " + + "WHERE t.AD_Element_ID=e.AD_Element_ID AND UPPER(e.ColumnName)=? " + + "AND t.AD_Language=?", null); + pstmt.setString(2, AD_Language); } - catch (Exception e) - { - return ColumnName; - } - finally { - DB.close(rs); - rs = null; - } + pstmt.setString(1, ColumnName.toUpperCase()); rs = pstmt.executeQuery(); if (rs.next()) @@ -515,8 +529,11 @@ public final class Msg DB.close(rs, pstmt); rs = null; pstmt = null; } - if (retStr != null) - return retStr.trim(); + if (retStr != null) { + retStr = retStr.trim(); + cache.put(key, retStr); + return retStr; + } return retStr; } // getElement diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java index ae968b4670..876df630fe 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java @@ -243,7 +243,8 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree MTreeNode mNode = (MTreeNode) sNode.getData(); treeValues[i] = mNode.getName(); treeDescription[i] = mNode.getDescription(); - treeImages[i] = mNode.getImagePath(); + String imagePath = mNode.getImagePath(); + treeImages[i] = imagePath != null ? imagePath.intern() : null; } } @@ -287,7 +288,7 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree image = element.getImage(); } } - return image; + return image != null ? image.intern() : null; } /**