svn commit: r1095037 - in /ofbiz/trunk/framework: example/config/ExampleEntityLabels.xml example/entitydef/entitymodel.xml webtools/src/org/ofbiz/webtools/WebToolsServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1095037 - in /ofbiz/trunk/framework: example/config/ExampleEntityLabels.xml example/entitydef/entitymodel.xml webtools/src/org/ofbiz/webtools/WebToolsServices.java

adrianc
Author: adrianc
Date: Tue Apr 19 11:23:07 2011
New Revision: 1095037

URL: http://svn.apache.org/viewvc?rev=1095037&view=rev
Log:
New feature: i18n entity descriptions in Web Tools. New feature demonstrated in Example component.

Modified:
    ofbiz/trunk/framework/example/config/ExampleEntityLabels.xml
    ofbiz/trunk/framework/example/entitydef/entitymodel.xml
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java

Modified: ofbiz/trunk/framework/example/config/ExampleEntityLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleEntityLabels.xml?rev=1095037&r1=1095036&r2=1095037&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/config/ExampleEntityLabels.xml (original)
+++ ofbiz/trunk/framework/example/config/ExampleEntityLabels.xml Tue Apr 19 11:23:07 2011
@@ -69,6 +69,22 @@
         <value xml:lang="th">สภาพที่เป็นจริง</value>
         <value xml:lang="zh">真实世界</value>
     </property>
+
+    <!-- Entity descriptions. The Web Tools component will use these properties
+        for online documentation. Entity description property keys have the form:
+        EntityDescription.[entityname].
+    -->
+    <property key="EntityDescription.Example">
+        <value xml:lang="en">Example Entity</value>
+    </property>
+
+    <!-- Entity field descriptions. The Web Tools component will use these properties
+        for online documentation. Field description property keys have two forms:
+        FieldDescription.[fieldname] - will be used for all fields of that name
+        FieldDescription.[entityname].[fieldname] - will be used for the specified
+        entity field
+    -->
+
     <property key="FieldDescription.Example.exampleId">
         <value xml:lang="en">A unique Example ID. If you don't assign an ID, one will be generated automatically</value>
         <value xml:lang="fr">Une réf. unique d'exemple. Si vous n'entrez pas de réf., elle sera générée automatiquement</value>
@@ -134,12 +150,6 @@
         <value xml:lang="th">ตัวอย่างวันที่</value>
         <value xml:lang="zh">样例日期</value>
     </property>
-    <!-- Entity field descriptions. The Webtools component will use these properties
-        for online documentation. Field description properties have two forms:
-        FieldDescription.[fieldname] - will be used for all fields of that name
-        FieldDescription.[entityname].[fieldname] - will be used for the specified
-        entity field
-    -->
     <property key="FieldDescription.exampleId">
         <value xml:lang="en">Example ID</value>
         <value xml:lang="fr">Réf. d'exemple</value>

Modified: ofbiz/trunk/framework/example/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/entitydef/entitymodel.xml?rev=1095037&r1=1095036&r2=1095037&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/framework/example/entitydef/entitymodel.xml Tue Apr 19 11:23:07 2011
@@ -39,11 +39,7 @@ under the License.
     <!-- org.ofbiz.example.example -->
     <!-- ========================================================= -->
 
-    <entity entity-name="Example"
-            package-name="org.ofbiz.example.example"
-            title="Example Entity"
-            default-resource-name="ExampleEntityLabels"
-            >
+    <entity entity-name="Example" package-name="org.ofbiz.example.example" title="Example Entity">
         <field name="exampleId" type="id-ne"><description>primary sequenced ID</description></field>
         <field name="exampleTypeId" type="id-ne"></field>
         <field name="statusId" type="id-ne"></field>

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=1095037&r1=1095036&r2=1095037&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Tue Apr 19 11:23:07 2011
@@ -663,6 +663,15 @@ public class WebToolsServices {
                                 Debug.logInfo(exception.getMessage(), module);
                             }
                         }
+                        String entityDescription = null;
+                        if (bundle != null) {
+                            try {
+                                entityDescription = bundle.getString("EntityDescription." + entity.getEntityName());
+                            } catch (Exception exception) {}
+                        }
+                        if (UtilValidate.isEmpty(entityDescription)) {
+                            entityDescription = entity.getDescription();
+                        }
 
                         // fields list
                         List<Map<String, Object>> javaNameList = FastList.newInstance();
@@ -754,7 +763,7 @@ public class WebToolsServices {
                         entityMap.put("groupName", groupName);
                         entityMap.put("plainTableName", entity.getPlainTableName());
                         entityMap.put("title", entity.getTitle());
-                        entityMap.put("description", entity.getDescription());
+                        entityMap.put("description", entityDescription);
                         String entityLocation = entity.getLocation();
                         entityLocation = entityLocation.replaceFirst(System.getProperty("ofbiz.home") + "/", "");
                         entityMap.put("location", entityLocation);