[pal-cvs 2549] [281] display layout and portlet in tree.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2007年 7月 17日 (火) 15:07:12 JST


Revision: 281
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=281
Author:   shinsuke
Date:     2007-07-17 15:07:11 +0900 (Tue, 17 Jul 2007)

Log Message:
-----------
display layout and portlet in tree.

Modified Paths:
--------------
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java
    pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html


-------------- next part --------------
Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java	2007-07-17 04:09:29 UTC (rev 280)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java	2007-07-17 06:07:11 UTC (rev 281)
@@ -16,37 +16,44 @@
  */
 package jp.sf.pal.admin;
 
-public class PALAdminConstants
-{
+public class PALAdminConstants {
     public static final boolean DEBUG = false;
 
     public static final String PREFIX = "jp.sf.pal.admin.";
 
     public static final String CPS_SECURITY_PROVIDER_COMPONENT = "cps:SecurityProvider";
 
-    public static final String SECURITY_PROVIDER_COMPONENT = PREFIX + "SecurityProvider";
+    public static final String SECURITY_PROVIDER_COMPONENT = PREFIX
+            + "SecurityProvider";
 
-    public static final String PORTAL_ADMINISTRATION_COMPONENT = PREFIX + "PortalAdministration";
+    public static final String PORTAL_ADMINISTRATION_COMPONENT = PREFIX
+            + "PortalAdministration";
 
     public static final String USER_MANAGER_COMPONENT = PREFIX + "UserManager";
 
     public static final String ROLE_MANAGER_COMPONENT = PREFIX + "RoleManager";
 
-    public static final String GROUP_MANAGER_COMPONENT = PREFIX + "GroupManager";
+    public static final String GROUP_MANAGER_COMPONENT = PREFIX
+            + "GroupManager";
 
     public static final String PROFILER_COMPONENT = PREFIX + "Profiler";
 
     public static final String PAGE_MANAGER_COMPONENT = PREFIX + "PageManager";
 
-    public static final String APPLICATION_SERVER_MANAGER_COMPONENT = PREFIX + "ApplicationServerManager";
+    public static final String APPLICATION_SERVER_MANAGER_COMPONENT = PREFIX
+            + "ApplicationServerManager";
 
-    public static final String PORTLET_REGISTRY_COMPONENT = PREFIX + "PortletRegistry";
+    public static final String PORTLET_REGISTRY_COMPONENT = PREFIX
+            + "PortletRegistry";
 
-    public static final String PORTLET_FACTORY_COMPONENT = PREFIX + "PortletFactory";
+    public static final String PORTLET_FACTORY_COMPONENT = PREFIX
+            + "PortletFactory";
 
-    public static final String DEPLOYMENT_MANAGER_COMPONENT = PREFIX + "DeploymentManager";
+    public static final String DEPLOYMENT_MANAGER_COMPONENT = PREFIX
+            + "DeploymentManager";
 
-    public static final String DECORATION_FACTORY_COMPONENT = PREFIX + "DecorationFactory";
+    public static final String DECORATION_FACTORY_COMPONENT = PREFIX
+            + "DecorationFactory";
 
     public static final String PREVIOUS_PAGE_NUMBER = "previousPageNumber";
 
@@ -63,7 +70,8 @@
 
     public static final String USER_CREDENTIAL_EXTEND = PREFIX + "Extend";
 
-    public static final String USER_CREDENTIAL_EXTEND_UNLIMITED = PREFIX + "ExtendUnlimited";
+    public static final String USER_CREDENTIAL_EXTEND_UNLIMITED = PREFIX
+            + "ExtendUnlimited";
 
     //TODO move to portlet.xml file
     public static final String LOCATOR_PAGE = "page";
@@ -105,27 +113,34 @@
 
     public static final String RULE_VALUES = PREFIX + "RuleValues";
 
-    public static final String EMAIL_TEMPLATE_LOCATION = PREFIX + "EmailTemplateLocation";
+    public static final String EMAIL_TEMPLATE_LOCATION = PREFIX
+            + "EmailTemplateLocation";
 
-    public static final String EMAIL_TEMPLATE_NAME = PREFIX + "EmailTemplateName";
+    public static final String EMAIL_TEMPLATE_NAME = PREFIX
+            + "EmailTemplateName";
 
     public static final String TEMPLATE_LOCATOR = PREFIX + "TemplateLocator";
 
     public static final String FORCE_UNIQUE_EMAIL = PREFIX + "ForceUniqueEmail";
 
-    public static final String FORCE_GENERATED_PASSWORD = PREFIX + "ForceGeneratedPassword";
+    public static final String FORCE_GENERATED_PASSWORD = PREFIX
+            + "ForceGeneratedPassword";
 
-    public static final String FORCE_USE_EMAIL_AS_USERNAME = PREFIX + "ForceUseEmailAsUsername";
+    public static final String FORCE_USE_EMAIL_AS_USERNAME = PREFIX
+            + "ForceUseEmailAsUsername";
 
     public static final String SEND_MAIL = PREFIX + "SendMail";
 
     public static final String RETURN_PATH = PREFIX + "ReturnPath";
 
-    public static final String USER_REGISTRATION_PARAMS = PREFIX + "UserRegistrationParams";
+    public static final String USER_REGISTRATION_PARAMS = PREFIX
+            + "UserRegistrationParams";
 
     public static final String DEFAULT_TEMPLATE_LOCATION = "/WEB-INF/template/userreg/";
 
     public static final String DEFAULT_TEMPLATE_NAME = "userRegistrationEmail.vm";
 
     public static final String CTX_RETURN_URL = "returnURL";
+
+    public static final String SEPARATOR = "::";
 }

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java	2007-07-17 04:09:29 UTC (rev 280)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java	2007-07-17 06:07:11 UTC (rev 281)
@@ -9,6 +9,7 @@
 
 import javax.faces.context.FacesContext;
 
+import jp.sf.pal.admin.PALAdminConstants;
 import jp.sf.pal.admin.entity.NodeInfo;
 import jp.sf.pal.admin.util.PortalComponentUtil;
 import jp.sf.pal.common.CommonException;
@@ -18,6 +19,7 @@
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.folder.InvalidFolderException;
+import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageNotFoundException;
@@ -121,7 +123,7 @@
     public List<NodeInfo> getTreeNode(String path, String returnPath)
             throws CommonException {
         List<NodeInfo> treeList = new ArrayList<NodeInfo>();
-        treeList.add(new NodeInfo(NodeInfo.FOLDER, "/", path, returnPath, 0,
+        treeList.add(new NodeInfo(NodeInfo.FOLDER, "/", "/", returnPath, 0,
                 true, true));
 
         try {
@@ -151,9 +153,10 @@
     protected List<NodeInfo> constructTreeNode(Folder parent, String path,
             String returnPath, int depth) throws CommonException {
         String targetPathName = "";
+        String folderOrPagePath = getFolderOrPagePath(path);
         int parentPathLength = parent.getPath().length();
-        if (parentPathLength < path.length()) {
-            targetPathName = path.substring(parentPathLength);
+        if (parentPathLength < folderOrPagePath.length()) {
+            targetPathName = folderOrPagePath.substring(parentPathLength);
             int startIndex = targetPathName.indexOf("/");
             if (startIndex == 0 && targetPathName.length() != 1) {
                 targetPathName = targetPathName.substring(1);
@@ -173,8 +176,7 @@
                         .hasNext();) {
                     Folder child = ite.next();
                     treeList.add(new NodeInfo(NodeInfo.FOLDER, child.getName(),
-                            child.getPath(), returnPath, depth + 1, false,
-                            false));
+                            child.getPath(), returnPath, depth, false, false));
                     if (targetPathName.equals(child.getName())) {
                         List<NodeInfo> childTreeList = constructTreeNode(child,
                                 path, returnPath, depth + 1);
@@ -194,13 +196,23 @@
                     Page child = ite.next();
                     if (targetPathName.equals(child.getName())) {
                         treeList.add(new NodeInfo(NodeInfo.PAGE, child
-                                .getName(), child.getPath(), returnPath,
-                                depth + 1, true, true));
-                        //TODO layout and portlet
+                                .getName(), child.getPath(), returnPath, depth,
+                                true, true));
+                        // layout and portlet
+                        Fragment rootFragment = child.getRootFragment();
+                        if (rootFragment != null) {
+                            treeList.add(new NodeInfo(NodeInfo.LAYOUT,
+                                    getLayoutOrPortletName(rootFragment
+                                            .getName()), createPath(child
+                                            .getPath(), rootFragment.getId()),
+                                    returnPath, depth + 1, true, true));
+                            treeList.addAll(constructTreeNode(rootFragment,
+                                    path, returnPath, depth + 2));
+                        }
                     } else {
                         treeList.add(new NodeInfo(NodeInfo.PAGE, child
-                                .getName(), child.getPath(), returnPath,
-                                depth + 1, false, false));
+                                .getName(), child.getPath(), returnPath, depth,
+                                false, false));
                     }
                 }
             } catch (NodeException e) {
@@ -222,17 +234,17 @@
                         if (childTreeList != null) {
                             treeList.add(new NodeInfo(NodeInfo.FOLDER, child
                                     .getName(), child.getPath(), returnPath,
-                                    depth + 1, true, false));
+                                    depth, true, false));
                             treeList.addAll(childTreeList);
                         } else {
                             treeList.add(new NodeInfo(NodeInfo.FOLDER, child
                                     .getName(), child.getPath(), returnPath,
-                                    depth + 1, true, true));
+                                    depth, true, true));
                         }
                     } else {
                         treeList.add(new NodeInfo(NodeInfo.FOLDER, child
-                                .getName(), child.getPath(), returnPath,
-                                depth + 1, false, false));
+                                .getName(), child.getPath(), returnPath, depth,
+                                false, false));
                     }
                 }
             } catch (DocumentException e) {
@@ -245,8 +257,7 @@
                         .hasNext();) {
                     Page child = ite.next();
                     treeList.add(new NodeInfo(NodeInfo.PAGE, child.getName(),
-                            child.getPath(), returnPath, depth + 1, false,
-                            false));
+                            child.getPath(), returnPath, depth, false, false));
                 }
             } catch (NodeException e) {
                 logger.warn("Could not get pages: " + path, e);
@@ -255,6 +266,85 @@
         }
     }
 
+    protected List<NodeInfo> constructTreeNode(Fragment parent, String path,
+            String returnPath, int depth) throws CommonException {
+        List<NodeInfo> treeList = new ArrayList<NodeInfo>();
+        String folderOrPagePath = getFolderOrPagePath(path);
+        String fragmentId = getFragmentId(path);
+        for (Iterator<Fragment> itr = parent.getFragments().iterator(); itr
+                .hasNext();) {
+            Fragment child = itr.next();
+            String id = child.getId();
+            if ("layout".equals(child.getType())) {
+                // layout
+                if (id.equals(fragmentId)) {
+                    treeList.add(new NodeInfo(NodeInfo.LAYOUT,
+                            getLayoutOrPortletName(child.getName()),
+                            createPath(folderOrPagePath, id), returnPath,
+                            depth, false, true));
+                } else {
+                    treeList.add(new NodeInfo(NodeInfo.LAYOUT,
+                            getLayoutOrPortletName(child.getName()),
+                            createPath(folderOrPagePath, id), returnPath,
+                            depth, false, false));
+                }
+                treeList.addAll(constructTreeNode(child, path, returnPath,
+                        depth + 1));
+            } else {
+                // portlet
+                if (id.equals(fragmentId)) {
+                    treeList.add(new NodeInfo(NodeInfo.PORTLET,
+                            getLayoutOrPortletName(child.getName()),
+                            createPath(folderOrPagePath, id), returnPath,
+                            depth, false, true));
+                } else {
+                    treeList.add(new NodeInfo(NodeInfo.PORTLET,
+                            getLayoutOrPortletName(child.getName()),
+                            createPath(folderOrPagePath, id), returnPath,
+                            depth, false, false));
+                }
+            }
+        }
+        return treeList;
+    }
+
+    protected String createPath(String folderOrPagePath, String fragmentId) {
+        if (fragmentId != null) {
+            return folderOrPagePath + PALAdminConstants.SEPARATOR + fragmentId;
+        }
+        return folderOrPagePath;
+    }
+
+    protected String getFolderOrPagePath(String path) {
+        if (path == null) {
+            return "/";
+        }
+        int index = path.indexOf(PALAdminConstants.SEPARATOR);
+        if (index < 0) {
+            return path;
+        }
+        return path.substring(0, index);
+    }
+
+    protected String getFragmentId(String path) {
+        if (path == null) {
+            return null;
+        }
+        int index = path.indexOf(PALAdminConstants.SEPARATOR);
+        if (index < 0) {
+            return null;
+        }
+        return path.substring(index);
+    }
+
+    protected String getLayoutOrPortletName(String name) {
+        int index = name.indexOf(PALAdminConstants.SEPARATOR);
+        if (index < 0) {
+            return name;
+        }
+        return name.substring(index + 2);
+    }
+
     public List<Map<String, String>> createPageDecorationsList() {
         List<Map<String, String>> list = new ArrayList<Map<String, String>>();
         for (Iterator<String> itr = getDecorationFactory().getPageDecorations(

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java	2007-07-17 04:09:29 UTC (rev 280)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/web/site/AbstractSiteEditorPage.java	2007-07-17 06:07:11 UTC (rev 281)
@@ -116,6 +116,14 @@
         return getJumpEditorStyle();
     }
 
+    public String getJumpLayoutInfoEditorStyle() {
+        return getJumpEditorStyle();
+    }
+
+    public String getJumpPortletInfoEditorStyle() {
+        return getJumpEditorStyle();
+    }
+
     protected String getJumpEditorStyle() {
         StringBuffer buf = new StringBuffer(
                 "text-decoration: none;margin-left:");
@@ -133,6 +141,14 @@
         return getIconSrc();
     }
 
+    public String getLayoutIconSrc() {
+        return getIconSrc();
+    }
+
+    public String getPortletIconSrc() {
+        return getIconSrc();
+    }
+
     public String getIconSrc() {
         FacesContext facesContext = FacesContext.getCurrentInstance();
         StringBuffer buf = new StringBuffer(facesContext.getExternalContext()
@@ -144,6 +160,10 @@
             buf.append("folder");
         } else if (entity.getType() == NodeInfo.PAGE) {
             buf.append("page");
+        } else if (entity.getType() == NodeInfo.LAYOUT) {
+            buf.append("layout");
+        } else if (entity.getType() == NodeInfo.PORTLET) {
+            buf.append("portlet");
         } else {
             buf.append("none");
         }
@@ -160,4 +180,15 @@
         NodeInfo entity = getNodeItems().get(getNodeIndex());
         return entity.getType() == NodeInfo.PAGE;
     }
+
+    public boolean isPageLayout() {
+        // cannot use isLayout
+        NodeInfo entity = getNodeItems().get(getNodeIndex());
+        return entity.getType() == NodeInfo.LAYOUT;
+    }
+
+    public boolean isPortlet() {
+        NodeInfo entity = getNodeItems().get(getNodeIndex());
+        return entity.getType() == NodeInfo.PORTLET;
+    }
 }
\ No newline at end of file

Modified: pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html
===================================================================
--- pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html	2007-07-17 04:09:29 UTC (rev 280)
+++ pal-admin/trunk/src/main/webapp/view/site/pageInfoEditor.html	2007-07-17 06:07:11 UTC (rev 281)
@@ -27,6 +27,18 @@
               <span id="name-page">Name</span>
             </a>
           </div>
+          <div id="isPageLayout" style="white-space: nowrap;">
+            <a id="jumpLayoutInfoEditor" href="layoutInfoEditor.html?path=a&returnPath=b" style="">
+              <img id="layoutIcon" src="" border="0" style="vertical-align:middle;" />
+              <span id="name-layout">Name</span>
+            </a>
+          </div>
+          <div id="isPortlet" style="white-space: nowrap;">
+            <a id="jumpPortletInfoEditor" href="portletInfoEditor.html?path=a&returnPath=b" style="">
+              <img id="portletIcon" src="" border="0" style="vertical-align:middle;" />
+              <span id="name-portlet">Name</span>
+            </a>
+          </div>
         </div>
       </div>
 <!-- tree: END -->


pal-cvs メーリングリストの案内
Back to archive index