geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmcma...@apache.org
Subject svn commit: r511659 - in /geronimo/server/trunk/applications/console/geronimo-console-standard/src/main: java/org/apache/geronimo/console/classloaderview/ java/org/apache/geronimo/console/util/ webapp/WEB-INF/view/classloaderview/
Date Sun, 25 Feb 2007 23:36:48 GMT
Author: pmcmahan
Date: Sun Feb 25 15:36:41 2007
New Revision: 511659

URL: http://svn.apache.org/viewvc?view=rev&rev=511659
Log:
GERONIMO-2854 inverse option for classloader view in the admin console

Modified:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/StringTree.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/classloaderview/view.jsp

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java?view=diff&rev=511659&r1=511658&r2=511659
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/classloaderview/ClassLoaderViewPortlet.java
Sun Feb 25 15:36:41 2007
@@ -52,6 +52,7 @@
 
     public void processAction(ActionRequest actionRequest,
             ActionResponse actionResponse) throws PortletException, IOException {
+        actionRequest.getPortletSession().setAttribute("selectedNode", actionRequest.getParameter("snNode"));
     }
 
     protected void doView(RenderRequest renderRequest,
@@ -91,33 +92,68 @@
         super.destroy();
     }
 
-    public String getJSONTrees() {
-        List list = getTrees();
+    public String getJSONTrees(boolean inverse) {
+        List list = getTrees(inverse);
         if (list == null)
             return "[]";
 
         StringBuffer stb = new StringBuffer();
         stb.append("[");
         Hashtable htLinks = new Hashtable();
+        // First level cannot be a link
+        for (int i = 0; i < list.size(); i++) {
+            StringTree node = (StringTree) list.get(i);
+            htLinks.put(node.name, ""+i);
+        }
         for (int i = 0; i < list.size(); i++) {
             StringTree node = (StringTree) list.get(i);
             if (i != 0)
                 stb.append(",");
-            stb.append(node.toJSONObject("" + i, htLinks));
+            stb.append(node.toJSONObject("" + i, htLinks, true));
         }
         stb.append("]");
         list = null;
         return stb.toString();
     }
 
-    public ArrayList getTrees() {
+    public ArrayList getTrees(boolean inverse) {
         ArrayList parentNodes = new ArrayList();
         List list = ClassLoaderRegistry.getList();
         Iterator iter = list.iterator();
         while (iter.hasNext()) {
-            updateTree((ClassLoader) iter.next(), parentNodes);
-        }
+            if(!inverse)
+                updateTree((ClassLoader) iter.next(), parentNodes);
+            else
+                inverseTree((ClassLoader) iter.next(), parentNodes);
+        }            
         return parentNodes;
+    }
+
+    public StringTree inverseTree(ClassLoader classloader, ArrayList parentNodes) {
+        
+        StringTree node = new StringTree(classloader.toString());
+        int index = parentNodes.indexOf(node);
+        if(index != -1)
+            return (StringTree)parentNodes.get(index);
+        
+        node = addClasses(node, classloader);
+        
+        if (classloader instanceof org.apache.geronimo.kernel.config.MultiParentClassLoader)
{
+            org.apache.geronimo.kernel.config.MultiParentClassLoader mpclassloader = (org.apache.geronimo.kernel.config.MultiParentClassLoader)
classloader;
+            ClassLoader[] parents = mpclassloader.getParents();
+            if (parents != null)
+                for (int i = 0; i < parents.length; i++) {
+                    StringTree parentNode = inverseTree(parents[i],parentNodes);
+                    node.addChild(parentNode);
+                }
+        } else if (classloader.getParent() != null) {
+            StringTree parentNode = inverseTree(classloader.getParent(),parentNodes);
+            node.addChild(parentNode);
+        }        
+        if(!parentNodes.contains(node))
+            parentNodes.add(node);
+        
+        return node;
     }
 
     public StringTree updateTree(ClassLoader classloader, ArrayList parentNodes) {

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/StringTree.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/StringTree.java?view=diff&rev=511659&r1=511658&r2=511659
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/StringTree.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/util/StringTree.java
Sun Feb 25 15:36:41 2007
@@ -59,15 +59,23 @@
         }
         return null;
     }
+    public boolean equals(Object node){
+        if(node instanceof StringTree && ((StringTree)node).name.equals(this.name))
+            return true;
+        return false;
+    }
            
     public String toJSONObject(String prependId){
         return toJSONObject(prependId, null);
     }
-           
     public String toJSONObject(String prependId, Hashtable htLinks){
+        return toJSONObject(prependId, htLinks, false);
+    }
+           
+    public String toJSONObject(String prependId, Hashtable htLinks, boolean level1){
         StringBuffer stb = new StringBuffer();
         if(htLinks != null){
-            if(!name.startsWith("class ") && !name.startsWith("interface ") &&
!name.equals("Classes") && !name.equals("Interfaces") && htLinks.containsKey(name)){
+            if(!name.startsWith("class ") && !name.startsWith("interface ") &&
!name.equals("Classes") && !name.equals("Interfaces") && htLinks.containsKey(name)
&& !level1){
                 stb.append("{title:'link::");
                 stb.append(htLinks.get(name));
                 stb.append("',widgetId:'");

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/classloaderview/view.jsp?view=diff&rev=511659&r1=511658&r2=511659
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
Sun Feb 25 15:36:41 2007
@@ -21,11 +21,20 @@
 <portlet:defineObjects />
 
 <%
+    boolean inverse = false;
+    if(renderRequest.getPortletSession().getAttribute("inverse") != null){
+        inverse = ((Boolean)renderRequest.getPortletSession().getAttribute("inverse")).booleanValue();
       
+    }
+    renderRequest.getPortletSession().setAttribute("inverse",new Boolean(!inverse));
+    String selectedNode = (String)renderRequest.getPortletSession().getAttribute("selectedNode");
+    if(selectedNode != null){
+        renderRequest.getPortletSession().removeAttribute("selectedNode");
+    }
 
 
     ClassLoaderViewPortlet cp = (ClassLoaderViewPortlet) renderRequest.getPortletSession().getAttribute("classloaderTree");
     renderRequest.getPortletSession().removeAttribute("classloaderTree");
-    String childs = cp.getJSONTrees();
+    String childs = cp.getJSONTrees(inverse);
 %>
 
 <script>
@@ -39,7 +48,7 @@
         
         dojo.hostenv.writeIncludes();
 
-    dojo.addOnLoad(function(){
+        dojo.addOnLoad(function(){
 
         var tree = dojo.widget.manager.getWidgetById('tree');
 
@@ -60,7 +69,14 @@
                 }
             }
         );
-
+        <%
+    if(selectedNode != null && !selectedNode.equals("")) {
+    %>
+        findPrevious('<%= selectedNode %>');
+    <%
+    }
+    %>
+    
         });
 
 
@@ -104,7 +120,7 @@
                         else {
                                 if(children[child].widgetId == lastFound)doCheck = false;
             }
-                }
+        }
         if(children[child].title.indexOf("link::") == 0) {
             var node = children[child].title.substring(6);
             load(node);
@@ -143,15 +159,23 @@
                 if(curr == "")curr=curr+nodes[nod];
                 else curr=curr+"."+nodes[nod];
                 if(dojo.widget.byId(curr).state != "LOADED" && dojo.widget.byId(curr).children.length
!= 0)
-                        dojo.widget.byId(curr).setChildren(dojo.widget.byId(curr).children);
-        }
-        dojo.widget.byId('selector').select(dojo.widget.byId(node));
+                    dojo.widget.byId(curr).setChildren(dojo.widget.byId(curr).children);
+        }        
 }
 
 function select(node)
 {
-    load(node);
-    dojo.widget.byId('selector').select(dojo.widget.byId(node));
+        var nodes = node.split(".");
+        var curr ="";
+        for(nod in nodes)
+        {
+                if(curr == "")curr=curr+nodes[nod];
+                else curr=curr+"."+nodes[nod];
+                if(dojo.widget.byId(curr).state != "LOADED" && dojo.widget.byId(curr).children.length
!= 0)
+                    dojo.widget.byId(curr).setChildren(dojo.widget.byId(curr).children);
+                dojo.widget.byId('controller').expandToLevel(dojo.widget.byId(curr),1);
+        }        
+        dojo.widget.byId('selector').select(dojo.widget.byId(node));
 }
 
 function findInSelected(selectedNodes)
@@ -172,7 +196,7 @@
                 lastFound =  v;
                 doCheck = true;
         }
-        else{
+        else {
                 debug.innerHTML = "<br/>Failure in search: No more matching result
found";
                 alert('Failure in search: No more matching result found');
                 lastFound =  '';
@@ -213,6 +237,18 @@
         }
         document.body.style.cursor = '';
 }
+function findPrevious(search)
+{
+        var selectNodes = dojo.widget.byId('tree').children;
+        var v= findNext(selectNodes,search);
+        if(v)
+        {
+                dojo.widget.byId('selector').deselectAll();
+                select(v);
+                lastFound =  '';
+                doCheck = false;
+        }
+}
 
 function searchContinue() {
         debug.innerHTML = "";
@@ -220,6 +256,17 @@
         findInSelected(lastSearchOn);
         document.body.style.cursor = '';
 }
+function getAction(){
+    var nodes= dojo.widget.manager.getWidgetById('selector').selectedNodes[0];
+    if(nodes != undefined){
+        if(nodes.title == 'Classes' || nodes.title == 'Interfaces')
+            document.clform.snNode.value = nodes.parent.title;
+        else
+            document.clform.snNode.value = nodes.title;
+    }
+    document.clform.action = '<portlet:actionURL><portlet:param name="action" value="invert"/></portlet:actionURL>'
+    return true;
+}
 
 </script>
 
@@ -228,17 +275,19 @@
                     .getConsoleFrameworkServletPath(request);
             String iconCSS = consoleFrameworkContext + "/../TreeDocIcon.css";
 %>
-
+<form name="clform" onSubmit="return getAction()">
+<input type="hidden" name="snNode" value=""/>
 <TABLE cellpadding="1" cellspacing="1" border="1">
  <tr>
-  <td><b>Search Text:</b> <input type="text" id="searchText"
-   onChange="javascript:textChange()" /> <input type="button"
+  <td><b>Search Text:</b> <input type="text" name="searchText" id="searchText"
+   onChange="javascript:textChange()"/> <input type="button"
    value="Find" onClick="javascript:search()" /> <input type="button"
    id="findNext" value="Find Next" onClick="javascript:searchContinue()"
    disabled=true /> Search only selected:<input type="checkbox"
    id="inSelected" onChange="javascript:textChange()" /></td>
  </tr>
 </table>
+<input type="submit" value="Invert Tree" />
 <br />
 
 <div dojoType="TreeBasicControllerV3" widgetId="controller"></div>
@@ -252,3 +301,4 @@
  widgetId='tree' allowedMulti='false'></div>
 
 <div id="debug"></div>
+</form>



Mime
View raw message