geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r897782 - in /geronimo/server/branches/2.2/plugins/console/console-portal-driver: pom.xml src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java src/main/webapp/WEB-INF/themes/navigation.jsp
Date Mon, 11 Jan 2010 08:02:20 GMT
Author: genspring
Date: Mon Jan 11 08:02:19 2010
New Revision: 897782

URL: http://svn.apache.org/viewvc?rev=897782&view=rev
Log:
GERONIMO-4994 adding g11n support for the new navigation tree.

Modified:
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/pom.xml
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
    geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp

Modified: geronimo/server/branches/2.2/plugins/console/console-portal-driver/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-portal-driver/pom.xml?rev=897782&r1=897781&r2=897782&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-portal-driver/pom.xml (original)
+++ geronimo/server/branches/2.2/plugins/console/console-portal-driver/pom.xml Mon Jan 11
08:02:19 2010
@@ -38,6 +38,13 @@
             <artifactId>console-filter</artifactId>
             <version>${version}</version>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.plugins</groupId>
+            <artifactId>console-core</artifactId>
+            <version>${version}</version>
+            <scope>test</scope>
+        </dependency>
 
         <!-- for jspc maven plugin -->
         <dependency>

Modified: geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java?rev=897782&r1=897781&r2=897782&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
Mon Jan 11 08:02:19 2010
@@ -17,7 +17,9 @@
 package org.apache.geronimo.console.navigation;
 
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.ResourceBundle;
 import java.util.TreeMap;
 
 import org.apache.geronimo.pluto.impl.PageConfig;
@@ -45,9 +47,20 @@
  */
 
 public class NavigationJsonGenerator {
-     
+      
+    private ResourceBundle navigationResourcebundle;
+         
     private static final Logger log = LoggerFactory.getLogger(NavigationJsonGenerator.class);
     
+    public NavigationJsonGenerator(Locale locale) {
+
+        if (locale == null) {
+            navigationResourcebundle = ResourceBundle.getBundle("org.apache.geronimo.console.i18n.ConsoleResource");
+        } else {
+            navigationResourcebundle = ResourceBundle.getBundle("org.apache.geronimo.console.i18n.ConsoleResource",locale);
+        }
+    }
+    
     public String generateTreeJSON(List<PageConfig> pageConfigList, String contextPath,
String DefaultIcon) {
        
         Map<String, TreeNode> navigationTree = new TreeMap<String, TreeNode>();
@@ -87,11 +100,11 @@
         
 
         if (!node.isLeafNode()) {
-            sb.append("label: \'"+node.getLabel() + "\'");
+            sb.append("label: \'"+getLocalizedString(node.getLabel()) + "\'");
         } else {
             sb.append("label: \'<img src=\"" + contextPath + node.getIcon() + "\" alt=\"\"
border=\"0\">&nbsp;");
             sb.append("<a href=\"" + contextPath + "/portal/" + node.getId() + "/" + node.getPath()
+ "\">"
-                    + node.getLabel() + "</a>\'");
+                    + getLocalizedString(node.getLabel()) + "</a>\'");
         }
 
         sb.append(",");
@@ -150,9 +163,9 @@
         if (node.isLeafNode()) {
             sb.append("\n{");
             sb.append("label: \'<img src=\"").append(contextPath).append(node.getIcon()).append("\">&nbsp;");
-            sb.append("<span>").append(node.getLabel()).append("</span>\'");
+            sb.append("<span>").append(getLocalizedString(node.getLabel())).append("</span>\'");
             sb.append(",");
-            sb.append("name: \'").append(node.getLabel()).append("\'");
+            sb.append("name: \'").append(getLocalizedString(node.getLabel())).append("\'");
             sb.append("},");
         }
         
@@ -203,7 +216,7 @@
         if (node.isLeafNode()) {
             sb.append("<li>");
             sb.append("<a href=\"" + contextPath + "/portal/" + node.getId() + "/" + node.getPath()
+ "\">"
-                    + node.getLabel() + "</a>");
+                    + getLocalizedString(node.getLabel()) + "</a>");
             sb.append("</li>\n");
         }
         
@@ -218,5 +231,22 @@
 
 
     }
+    
+    private String getLocalizedString(String key) {
+
+        try {
+            
+            return navigationResourcebundle.getString(key);
+
+        } catch (Exception e) {
+
+            log.debug("error when get localized string by key:" + key
+                    + ", fallbacking to the key as the string returned", e);
+
+        }
+
+        return key;
+
+    }
 
 }

Modified: geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp?rev=897782&r1=897781&r2=897782&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp
Mon Jan 11 08:02:19 2010
@@ -38,7 +38,7 @@
 </c:forEach>
 
 <%
-    NavigationJsonGenerator generator = new NavigationJsonGenerator();
+    NavigationJsonGenerator generator = new NavigationJsonGenerator(request.getLocale());
     String treeJson = generator.generateTreeJSON(pageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif");
     String listJson = generator.generateQuickLauncherJSON(pageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif");
 %>



Mime
View raw message