[portal-commits] JBoss Portal SVN: r9079 - branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/common.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Nov 23 04:05:27 EST 2007


Author: emuckenhuber
Date: 2007-11-23 04:05:27 -0500 (Fri, 23 Nov 2007)
New Revision: 9079

Modified:
   branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
Log:
improved generated window name

Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java	2007-11-22 23:45:10 UTC (rev 9078)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java	2007-11-23 09:05:27 UTC (rev 9079)
@@ -22,10 +22,12 @@
  ******************************************************************************/
 package org.jboss.portal.core.admin.ui.common;
 
+import org.jboss.portal.Mode;
 import org.jboss.portal.core.admin.ui.actions.WindowComparator;
 import org.jboss.portal.core.impl.model.content.ContentProviderRegistryService;
 import org.jboss.portal.core.model.content.Content;
 import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentProvider;
 import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
 import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
 import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
@@ -166,9 +168,45 @@
       }
    }
 
-   protected String createWindowName()
+   protected String createWindowName(String contentType, String contentURI, boolean appendNumber)
    {
-      return "" + (int)(100 * Math.random());
+      String windowName = null;
+      ContentProvider contentProvider = ContentProviderRegistryService.getInstance().getContentProvider(ContentType.create(contentType));
+      String instanceName = contentProvider.getPortletInfo().getPortletName(Mode.VIEW);
+
+      if(instanceName == null)
+      {
+         // Content type portlet: use URI (PortletInstance) 
+         windowName = contentURI; 
+      }
+      else
+      {
+         windowName = instanceName;
+      }
+      
+      //
+      if(windowName.indexOf("Instance") != -1)
+      {
+         // Replace the instance with window
+         windowName = windowName.replace("Instance", "Window");
+      }
+      else
+      {
+         // Or just append window
+         windowName = windowName + "Window";
+      }
+      
+      //
+      if (appendNumber)
+      {
+         // if the window already exists add a random number 
+         return windowName + "_" + (int)(100 * Math.random());
+      }
+      else
+      {
+         // Just the window without any number 
+         return windowName;
+      }
    }
 
    public void assignWindows(ActionEvent event)
@@ -176,7 +214,7 @@
       String id = event.getComponent().getId();
       char direction = id.charAt(0);
       String regionName = id.substring(2);
-
+      
       // Contains the names selected window in the UI
       List selectedWindows = (List)assignedWindows.values.get(regionName);
 
@@ -228,10 +266,10 @@
             String windowName = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("blah");
             if (windowName.trim().length() == 0)
             {
-               windowName = createWindowName();
+               windowName = createWindowName(selectedContentType.toString(), selectedContentURI, false);
                while (page.getWindow(windowName) != null)
                {
-                  windowName = "" + createWindowName();
+                  windowName = createWindowName(selectedContentType.toString(), selectedContentURI, true);
                }
             }
 




More information about the portal-commits mailing list