portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r225348 - in /portals/jetspeed-2/trunk/components/portal-site/src: java/org/apache/jetspeed/om/folder/impl/ java/org/apache/jetspeed/portalsite/menu/ test/org/apache/jetspeed/portalsite/
Date Tue, 26 Jul 2005 17:05:18 GMT
Author: rwatler
Date: Tue Jul 26 10:05:14 2005
New Revision: 225348

URL: http://svn.apache.org/viewcvs?rev=225348&view=rev
Log:
cleanup short title defaulting for standard menus

Modified:
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/impl/StandardMenuDefinitionImpl.java
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBreadcrumbsMenuDefinition.java
    portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/impl/StandardMenuDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/impl/StandardMenuDefinitionImpl.java?rev=225348&r1=225347&r2=225348&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/impl/StandardMenuDefinitionImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/om/folder/impl/StandardMenuDefinitionImpl.java
Tue Jul 26 10:05:14 2005
@@ -250,7 +250,25 @@
     public String getTitle(Locale locale)
     {
         // fallback to getTitle()
-        return getTitle();
+        return getTitle(locale, true);
+    }
+
+    /**
+     * getTitle - get locale specific title for menu from metadata
+     *            protocol, with or without falback enabled
+     *
+     * @param locale preferred locale
+     * @param fallback whether to return default title
+     * @return title text
+     */
+    protected String getTitle(Locale locale, boolean fallback)
+    {
+        // fallback to getTitle() if enabled
+        if (fallback)
+        {
+            return getTitle();
+        }
+        return null;
     }
 
     /**
@@ -262,10 +280,10 @@
     public String getShortTitle(Locale locale)
     {
         // fallback to getTitle(Locale)
-        String title = getTitle(locale);
+        String title = getTitle(locale, false);
 
-        // fallback to getShortTitle() over getTitle()
-        if ((title == null) || (title == getTitle()))
+        // fallback to getShortTitle()
+        if (title == null)
         {
             title = getShortTitle();
         }

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java?rev=225348&r1=225347&r2=225348&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBackMenuDefinition.java
Tue Jul 26 10:05:14 2005
@@ -79,19 +79,36 @@
     public String getTitle()
     {
         // use locale defaults
-        return getMenuTitleText(null, "menu.title.back");
+        return getMenuTitleText(null, getTitleResourceKey());
     }
 
     /**
      * getTitle - get locale specific title for menu from metadata
+     *            protocol, with or without falback enabled
      *
      * @param locale preferred locale
+     * @param fallback whether to return default title
      * @return title text
      */
-    public String getTitle(Locale locale)
+    protected String getTitle(Locale locale, boolean fallback)
     {
-        // use specified locale
-        return getMenuTitleText(locale, "menu.title.back");
+        // use specified locale or fallback if locale specific title not defined
+        String title = getMenuTitleText(locale, getTitleResourceKey());
+        if (title != null)
+        {
+            return title;
+        }
+        return super.getTitle(locale, fallback);
+    }
+
+    /**
+     * getTitleResourceKey - get resource key used to lookup menu titles
+     *
+     * @return resource key
+     */
+    protected String getTitleResourceKey()
+    {
+        return "menu.title.back";
     }
 
     /**

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBreadcrumbsMenuDefinition.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBreadcrumbsMenuDefinition.java?rev=225348&r1=225347&r2=225348&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBreadcrumbsMenuDefinition.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/menu/StandardBreadcrumbsMenuDefinition.java
Tue Jul 26 10:05:14 2005
@@ -68,25 +68,12 @@
     }
     
     /**
-     * getTitle - get default title for menu
+     * getTitleResourceKey - get resource key used to lookup menu titles
      *
-     * @return title text
+     * @return resource key
      */
-    public String getTitle()
+    protected String getTitleResourceKey()
     {
-        // use locale defaults
-        return getMenuTitleText(null, "menu.title.breadcrumbs");
-    }
-
-    /**
-     * getTitle - get locale specific title for menu from metadata
-     *
-     * @param locale preferred locale
-     * @return title text
-     */
-    public String getTitle(Locale locale)
-    {
-        // use specified locale
-        return getMenuTitleText(locale, "menu.title.breadcrumbs");
+        return "menu.title.breadcrumbs";
     }
 }

Modified: portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java?rev=225348&r1=225347&r2=225348&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/test/org/apache/jetspeed/portalsite/TestPortalSite.java
Tue Jul 26 10:05:14 2005
@@ -707,9 +707,22 @@
         assertNotNull(topMenu3);
         assertTrue(topMenu == topMenu3);
         Menu backMenu = requestContext.getMenu("back");
+        assertNotNull(backMenu);
         assertTrue(backMenu.isEmpty());
         assertNull(backMenu.getElements());
         assertTrue(((MenuImpl)backMenu).isElementRelative());
+        assertEquals("back", backMenu.getName());
+        assertEquals("Back to", backMenu.getTitle());
+        assertEquals("Back to", backMenu.getShortTitle());
+        assertEquals("\u00bb", backMenu.getTitle(Locale.JAPANESE));
+        assertEquals("\u00bb", backMenu.getShortTitle(Locale.JAPANESE));
+        assertEquals("Back to", backMenu.getTitle(new Locale("xx")));
+        assertEquals("Back to", backMenu.getShortTitle(new Locale("xx")));
+        Menu breadcrumbsMenu = requestContext.getMenu("breadcrumbs");
+        assertNotNull(breadcrumbsMenu);
+        assertFalse(breadcrumbsMenu.isEmpty());
+        assertEquals("You are here:", breadcrumbsMenu.getTitle());
+        assertEquals("\u00bb", breadcrumbsMenu.getTitle(Locale.JAPANESE));
         Menu navigationsMenu = requestContext.getMenu("navigations");
         assertNotNull(navigationsMenu);
         assertFalse(navigationsMenu.isEmpty());
@@ -806,6 +819,9 @@
         locators.put("group", locator);
         requestContext = sessionContext.newRequestContext(locators);
         assertNotNull(requestContext);
+        Menu backMenu2 = requestContext.getMenu("back");
+        assertNotNull(backMenu2);
+        assertFalse(backMenu2.isEmpty());
         Menu topMenu4 = requestContext.getMenu("top");
         assertNotNull(topMenu4);
         assertTrue(topMenu != topMenu4);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message