details:   http://code.openbravo.com/erp/devel/pi/rev/da25ccb7bcfb
changeset: 3340:da25ccb7bcfb
user:      Phil Heenan <phillip.heenan <at> openbravo.com>
date:      Fri Mar 06 15:33:21 2009 +0100
summary:   Fix the translation process for forms and manually created reports 
that do not pass through Jasper Reports. Iterate over the DataValue in the 
XMLEngine and check for instances of CharacterComponent in either the headers 
or footers of sections in the report.

diffstat:

2 files changed, 62 insertions(+)
src-core/src/org/openbravo/uiTranslation/TranslationHandler.java |    5 
src-core/src/org/openbravo/xmlEngine/XmlVectorValue.java         |   57 
++++++++++

diffs (96 lines):

diff -r 73c23e7125b7 -r da25ccb7bcfb 
src-core/src/org/openbravo/uiTranslation/TranslationHandler.java
--- a/src-core/src/org/openbravo/uiTranslation/TranslationHandler.java  Fri Mar 
06 12:18:00 2009 +0100
+++ b/src-core/src/org/openbravo/uiTranslation/TranslationHandler.java  Fri Mar 
06 15:33:21 2009 +0100
@@ -198,6 +198,11 @@
       setTabLabels();
     } else if (fileName != null && !fileName.equals("")) {
       String textFileName = fileName.replace(baseDesignPath, "");
+      if (textFileName.contains("?")) {
+        String suffix = textFileName.substring(textFileName.lastIndexOf("."));
+        String prefix = textFileName.substring(0, textFileName.indexOf("?"));
+        textFileName = prefix + suffix;
+      }
       formLabels = TranslationUtils.processFormLabels(conn, textFileName, 
language);
     }
   }
diff -r 73c23e7125b7 -r da25ccb7bcfb 
src-core/src/org/openbravo/xmlEngine/XmlVectorValue.java
--- a/src-core/src/org/openbravo/xmlEngine/XmlVectorValue.java  Fri Mar 06 
12:18:00 2009 +0100
+++ b/src-core/src/org/openbravo/xmlEngine/XmlVectorValue.java  Fri Mar 06 
15:33:21 2009 +0100
@@ -13,6 +13,7 @@
 
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Vector;
 
 import org.apache.log4j.Logger;
@@ -49,6 +50,7 @@
       if (textMap != null) {
         if (xmlComponentValue.print() != null && 
!xmlComponentValue.print().startsWith("<")
             && !xmlComponentValue.print().equals("")) {
+          boolean isTranslated = false;
           result = xmlComponentValue.print();
           log4jXmlVectorValue.debug("printStringBuffer(HashMap<String, String> 
textMap) - result: "
               + result);
@@ -58,6 +60,61 @@
             log4jXmlVectorValue.debug("printStringBuffer() appending 
xmlComponentValue: "
                 + xmlComponentValue.print() + ", translation: " + translation);
             result = translation;
+            isTranslated = true;
+          }
+          if (!isTranslated) {
+            if (DataValue.class.isInstance(xmlComponentValue)) {
+              DataValue dataValue = (DataValue) xmlComponentValue;
+              if (dataValue.dataTemplate != null) {
+                DataTemplate dataTemplate = dataValue.dataTemplate;
+                if (dataTemplate.vecSectionTemplate != null) {
+                  Vector<Object> vecSectionTemplate = 
dataTemplate.vecSectionTemplate;
+                  for (Iterator iterator = vecSectionTemplate.iterator(); 
iterator.hasNext();) {
+                    SectionTemplate sectionTemplate = (SectionTemplate) 
iterator.next();
+                    if (sectionTemplate.vecHeadTemplate != null) {
+                      XmlVectorTemplate xmlTemplate = 
sectionTemplate.vecHeadTemplate;
+                      for (Iterator iterator2 = xmlTemplate.iterator(); 
iterator2.hasNext();) {
+                        Object componentTemplate = (Object) iterator2.next();
+                        if 
(CharacterComponent.class.isInstance(componentTemplate)) {
+                          CharacterComponent charComponent = 
(CharacterComponent) componentTemplate;
+                          if (charComponent.character != null && 
!charComponent.equals("")) {
+                            String original = charComponent.character;
+                            String trl = textMap.get(original);
+                            if (trl != null && !trl.equals(""))
+                              charComponent.character = trl;
+                          }
+                          componentTemplate = charComponent;
+                        }
+                      }
+                      sectionTemplate.vecHeadTemplate = xmlTemplate;
+                    }
+
+                    if (sectionTemplate.vecFootTemplate != null) {
+                      XmlVectorTemplate xmlFootTemplate = 
sectionTemplate.vecFootTemplate;
+                      for (Iterator iterator2 = xmlFootTemplate.iterator(); 
iterator2.hasNext();) {
+                        Object componentTemplate = (Object) iterator2.next();
+                        if 
(CharacterComponent.class.isInstance(componentTemplate)) {
+                          CharacterComponent charComponent = 
(CharacterComponent) componentTemplate;
+                          if (charComponent.character != null && 
!charComponent.equals("")) {
+                            String original = charComponent.character;
+                            String trl = textMap.get(original);
+                            if (trl != null && !trl.equals(""))
+                              charComponent.character = trl;
+                          }
+                          componentTemplate = charComponent;
+                        }
+                      }
+                      sectionTemplate.vecFootTemplate = xmlFootTemplate;
+                    }
+                  }
+                  dataTemplate.vecSectionTemplate = vecSectionTemplate;
+                }
+                dataValue.dataTemplate = dataTemplate;
+              }
+              dataValue.printGenerated();
+              xmlComponentValue = dataValue;
+            }
+            result = xmlComponentValue.print();
           }
         }
       }

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to