portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r929443 - /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
Date Wed, 31 Mar 2010 09:30:42 GMT
Author: woonsan
Date: Wed Mar 31 09:30:42 2010
New Revision: 929443

URL: http://svn.apache.org/viewvc?rev=929443&view=rev
Log:
JS2-1168: Select the root node automatically when any node has not been selected during adding
sub nodes.
Also, keeping node selection even when a user clicks a node to collapse a node. (By default,
it unselects the node during collapsing, but it doesn't make sense to portal site manager.)

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java?rev=929443&r1=929442&r2=929443&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/site/PortalSiteManager.java
Wed Mar 31 09:30:42 2010
@@ -312,16 +312,15 @@ public class PortalSiteManager extends A
                 protected void onNodeLinkClicked(Object node, BaseTree tree,
                         AjaxRequestTarget target)
                 {
-                    super.onNodeLinkClicked(node, tree, target);
                     DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
                     SiteTreeNode siteNode = (SiteTreeNode) treeNode.getUserObject();
                     
                     populateDocument(siteNode);
+                    
                     if (siteNode.getDocType() == SiteTreeNode.FileType.Folder &&
!siteNode.isLoaded())
                     {
                         retrieveFolders(siteNode.getNodePath(), treeNode);
                         siteNode.setLoaded(true);
-                        tree.updateTree();
                     }
                     
                     if (!tree.getTreeState().isNodeExpanded(treeNode))
@@ -336,6 +335,9 @@ public class PortalSiteManager extends A
                     controlTabs();
                     
                     target.addComponent(tabPanel);
+                    
+                    tree.getTreeState().selectNode(node, true);
+                    tree.updateTree(target);
                 }
 
                 @Override
@@ -3845,6 +3847,7 @@ public class PortalSiteManager extends A
         PortalTree tree = (PortalTree) getPage().get("siteTree");
         Collection selectedNodes = tree.getTreeState().getSelectedNodes();
         DefaultMutableTreeNode treeNode = null;
+        
         if (selectedNodes != null)
         {
             Iterator selectedNode = selectedNodes.iterator();
@@ -3853,15 +3856,26 @@ public class PortalSiteManager extends A
                 treeNode = (DefaultMutableTreeNode) selectedNode.next();
                 break;
             }
-            if (treeNode == null)
+        }
+        
+        if (treeNode == null)
+        {
+            TreeModel treeModel = tree.getModelObject();
+            
+            if (treeModel != null && treeModel.getRoot() != null)
             {
-                treeNode = new DefaultMutableTreeNode(new SiteTreeNode("root",
-                        "/", FileType.Folder));
+                treeNode = (DefaultMutableTreeNode) treeModel.getRoot();
             }
         }
+
+        if (treeNode == null)
+        {
+            treeNode = new DefaultMutableTreeNode(new SiteTreeNode("root", "/", FileType.Folder));
+        }
+        
         return treeNode;
     }
-
+    
     private DefaultMutableTreeNode getMenuSelectedNode()
     {
         Collection selectedNodes = menuTree.getTreeState().getSelectedNodes();
@@ -3881,38 +3895,12 @@ public class PortalSiteManager extends A
         }
         return treeNode;
     }
-
+    
     private SiteTreeNode getUserSelectedNode()
     {
-        SiteTreeNode nodeTree = null;
-        PortalTree tree = (PortalTree) getPage().get("siteTree");
-        Collection selectedNodes = tree.getTreeState().getSelectedNodes();
-        DefaultMutableTreeNode treeNode = null;
-        
-        if (selectedNodes != null)
-        {
-            Iterator selectedNode = selectedNodes.iterator();
-            
-            while (selectedNode.hasNext())
-            {
-                treeNode = (DefaultMutableTreeNode) selectedNode.next();
-                break;
-            }
-        }
-        
-        if (treeNode != null)
-        {
-            nodeTree = (SiteTreeNode) treeNode.getUserObject();
-        }
-        else
-        {
-            DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) treeRoot.getRoot();
-            nodeTree = (SiteTreeNode) rootTreeNode.getUserObject();
-        }
-        
-        return nodeTree;
+        return (SiteTreeNode) getSelectedNode().getUserObject();
     }
-
+    
     private void getSubFoldersPage(JetspeedDocument document)
     {
         List<String> pageFolder = new ArrayList<String>();



---------------------------------------------------------------------
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