geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r814983 [3/5] - in /geronimo/server/trunk/plugins: ./ console/console-core/src/main/java/org/apache/geronimo/console/util/ debugviews/debugviews-console-jetty/ debugviews/debugviews-console-jetty/src/main/history/ debugviews/debugviews-cons...
Date Tue, 15 Sep 2009 03:31:08 GMT
Modified: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/classloaderview/view.jsp?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
(original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/classloaderview/view.jsp
Tue Sep 15 03:31:07 2009
@@ -17,373 +17,201 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@ page import="javax.portlet.RenderRequest,org.apache.geronimo.console.classloaderview.ClassLoaderViewPortlet"%>
 <fmt:setBundle basename="debugviews"/>
 <portlet:defineObjects />
 
-<%
-    // retrieve and set attributes
-    boolean inverse = ((Boolean)renderRequest.getPortletSession().getAttribute("inverse")).booleanValue();
-    
-    String selectedNode = (String)renderRequest.getPortletSession().getAttribute("selectedNode");
+<% String dwrForwarderServlet = "/console/dwr2"; %>
+<script type='text/javascript' src='<%= dwrForwarderServlet %>/interface/ClassLoaderViewHelper.js'></script>
+<script type='text/javascript' src='<%= dwrForwarderServlet %>/engine.js'></script>
+<script type='text/javascript' src='<%= dwrForwarderServlet %>/util.js'></script>
+<style type="text/css">
+    @import "/dojo/dojo/resources/dojo.css";
+    @import "/dojo/dijit/themes/soria/soria.css";
+</style>
+<script type="text/javascript" src="/dojo/dojo/dojo.js.uncompressed.js" djConfig="parseOnLoad:true"></script>
+<script type="text/javascript">
+    //style class
+    document.body.className="soria";
+
+    //import dojo lib
+    dojo.require("dojo.data.ItemFileWriteStore");
+    dojo.require("dijit.tree.ForestStoreModel");
+    dojo.require("dijit.Tree");
+    dojo.require("dijit.TitlePane");
+    dojo.require("dijit.form.Button");
 
-    if (selectedNode != null) {
-        renderRequest.getPortletSession().removeAttribute("selectedNode");
-    }
+</script>
 
-    ClassLoaderViewPortlet cp = (ClassLoaderViewPortlet) renderRequest.getPortletSession().getAttribute("classloaderTree");
-    renderRequest.getPortletSession().removeAttribute("classloaderTree");
-    String childs = cp.getJSONTrees(inverse);
-%>
-
-    <script type="text/javascript" src="/dojo/0.4/dojo.js"></script>
-
-    <script type="text/javascript">
-        dojo.require("dojo.lang.*");
-        dojo.require("dojo.widget.*");
-        // Pane includes
-        dojo.require("dojo.widget.ContentPane");
-        dojo.require("dojo.widget.LayoutContainer"); // Before: LayoutPane
-        dojo.require("dojo.widget.SplitContainer"); // Before: SplitPane
-        // Tree includes
-        dojo.require("dojo.widget.Tree");
-        dojo.require("dojo.widget.TreeBasicController");
-        dojo.require("dojo.widget.TreeContextMenu");
-        dojo.require("dojo.widget.TreeSelector");
-        // Tab includes
-        dojo.require("dojo.widget.TabContainer");
-        // Etc includes
-        dojo.require("dojo.widget.SortableTable");
-        dojo.require("dojo.widget.ComboBox");
-        dojo.require("dojo.widget.Tooltip");
-        dojo.require("dojo.widget.validate");
-        // Includes Dojo source for debugging
-        // dojo.hostenv.writeIncludes();
-    </script>
 
-<script>
-    dojo.require("dojo.widget.*");
-    dojo.require("dojo.widget.TreeV3");
-    dojo.require("dojo.widget.TreeNodeV3");
-    dojo.require("dojo.widget.TreeBasicControllerV3");
-    dojo.require("dojo.widget.TreeSelectorV3");
-    dojo.require("dojo.widget.TreeEmphasizeOnSelect");
-    dojo.require("dojo.widget.TreeToggleOnSelect");
+<!------------------------>
+<!--     Page Stuff     -->
+<!------------------------>
+<script type="text/javascript">
+    var debugStore = null;
+    var debugModel = null;
+    var debugTree = null;
+    var inverse = true; 
+    dojo.addOnLoad(function (){
+        dwr.util.useLoadingMessage();
+        invertTree();
+    });
+    function invertTree ()
+    {
+        document.body.style.cursor = "wait";
+        invertButton.attr("disabled", true);
+        findButton.attr("disabled", true);
+        searchReset();
+        inverse = !inverse;
+        ClassLoaderViewHelper.getTrees(inverse, createTree);
         
-    dojo.hostenv.writeIncludes();
-
-    dojo.addOnLoad(function() {
-        var tree = dojo.widget.manager.getWidgetById('tree');
-
-        var treeNodes = <%= childs %>;          
-
-        tree.setChildren(treeNodes);
-
-        dojo.event.topic.subscribe('tree/afterExpand',
-            function(source) { 
-                for (i in source['source'].children)
-                    if (source['source'].children[i].title.indexOf('link::') == 0) {
-                        var node = source['source'].children[i].title.substring(6);
-
-                        load(node);
-
-                        var curr = dojo.widget.byId(node);
-                        var chil = replace(curr.children, curr.widgetId, source['source'].children[i].widgetId);
-
-                        source['source'].children[i].setTitle(curr.title);
-                        source['source'].children[i].setChildren(chil);  
-                    }
-            }
-        );
-<%
-    if (selectedNode != null && ! selectedNode.equals("")) {
-%>
-        findPrevious('<%= selectedNode %>');
-<%
     }
-%>
-    }); // end of addOnLoad
-
-    var lastFound = '';
-    var doCheck = false;
-
-    function replace(children, from, to) {
-        var child = [];
-
-        for (name in children) {
-            var chds = [];
-            var newname = '';
-            var currTitle = children[name].title;
-
-            if (children[name].widgetId.indexOf(from) == 0)
-                newname = to+children[name].widgetId.substring(from.length);
-
-            if (children[name].children)
-                chds = replace(children[name].children, from , to);
-
-            child.push({title:currTitle,widgetId:newname,children:chds});
-        }
-
-        return child;
-    }
-
-    function check(curr,last) {
-        var cr = curr.split(".");
-        var ls = last.split(".");
-
-        for (var i = 0; i < cr.length; i++)
-            if(parseInt(cr[i]) < parseInt(ls[i]))
-                return false;
-
-        return true;
-    }
-
-    function findNext(children, str) {
-        for (var child = 0; child < children.length; child++) {
-            if (doCheck) {
-                if (! check(children[child].widgetId, lastFound))
-                    continue;
-                else
-                    if(children[child].widgetId == lastFound)doCheck = false;
-
-            }
-
-            if (children[child].title.indexOf("link::") == 0) {
-                var node = children[child].title.substring(6);
-
-                load(node);
-
-                var curr = dojo.widget.byId(node);
-                var ret = findNext([curr],str)
-
-                if (ret) {
-                    var chil = replace(curr.children, curr.widgetId, children[child].widgetId);

-
-                    children[child].setTitle(curr.title);
-                    children[child].setChildren(chil);
-                    ret = findNext([children[child]],str);
-
-                    if (ret)
-                        return ret;
-                }
-            } else {
-                if (children[child].title.indexOf(str) != -1 && children[child].widgetId
!= lastFound && !doCheck) {
-                    return children[child].widgetId;
-                }
-
-                if (children[child].children) {
-                    var ret = findNext(children[child].children, str);
-
-                    if (ret) {
-                        return ret;
-                    }
-                }
+    function createTree(json){
+        
+        debugStore = null;
+        if(debugModel){
+            debugModel.destroy();
+            debugModel = null;
+        }
+        if(debugTree){
+            debugTree.destroyRecursive(false);
+            debugTree = null;
+        }
+        var rootNodes = document.createElement("div");
+        rootNodes.id = "treeRootNodes";
+        document.getElementById("dojotree").appendChild(rootNodes);
+        
+        var treeData = dojo.fromJson(json);
+        debugStore = new dojo.data.ItemFileWriteStore({data:treeData});
+        debugModel = new dijit.tree.ForestStoreModel({
+              store:debugStore, rootId:"ClassLoaders", rootLabel:"ClassLoaders", 
+            query:{type:"root"}, childrenAttrs:["children"]});
+        debugTree = new dijit.Tree(
+            {model:debugModel, showRoot:false, openOnClick:true},
+            "treeRootNodes");
+
+        document.body.style.cursor = "";
+        invertButton.attr("disabled", false);
+        findButton.attr("disabled", false);
+      }
+
+    var lastFoundId = -1;
+    var SearchOn = []; //For ignore the fake root it better be a array
+
+    function findRecur(items, str, path) 
+    {
+        for (var child = 0; child < items.length; child++) {
+
+            path.push(items[child]);
+            var label = debugStore.getLabel(items[child]);
+            if (label && label.indexOf(str) != -1 && parseInt(debugStore.getIdentity(items[child]))
> lastFoundId)
+                return true;
+
+            if (items[child].children && findRecur(items[child].children, str, path))
+                return true;
+            path.pop();
+        }
+        return false;
+    }
+    function select(path)
+    {
+        var i;
+        function expandParent(node)
+        {
+            if(node && !node.isExpanded)
+            {
+                expandParent(node.getParent());
+                debugTree._expandNode(node);
             }
         }
-
-        return ;
-    }
-
-    function load(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);
-        }
-    }
-
-    function select(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);
+        //make sure the ancestor node expanded before
+        expandParent(debugTree._itemNodeMap[debugStore.getIdentity(path[0])].getParent());
+        for (i = 0;;i++) {
+            node  = debugTree._itemNodeMap[debugStore.getIdentity(path[i])];
+            if(i < path.length-1)
+                debugTree._expandNode(node);
+            else 
+            {
+                debugTree.focusNode(node);
+                return node;
+            }
         }
-
-        dojo.widget.byId('selector').select(dojo.widget.byId(node));
     }
-
-    function findInSelected(selectedNodes) {
-        var search = document.getElementById("searchText").value;
-
-        if (search == "") {
-            debug.innerHTML = "<br/>Failure in search: No text to search";
-            alert('Failure in search: No text to search');
-            return;
-        }
-
-        var v= findNext(selectedNodes, search);
-
-        if (v) {
-            dojo.widget.byId('selector').deselectAll();
-            select(v);
-            document.getElementById("findNext").disabled = false;
-            lastFound = v;
-            doCheck = true;
+    function findAndSelect(key, scope)
+    {
+        var path = [], node, res = false;
+        document.body.style.cursor = "wait";
+        if(!findRecur(scope, key, path))
+        {
+            lastFoundId = -1;
         } else {
-            debug.innerHTML = "<br/>Failure in search: No more matching result found";
-            alert('Failure in search: No more matching result found');
-            lastFound = '';
-            doCheck = false;
+            node = select(path);
+            lastFoundId = parseInt(debugStore.getIdentity(node.item));
+            res = true;
         }
+        document.body.style.cursor = "";
+        return res;
     }
-
-    function textChange() {
-        document.getElementById("findNext").disabled=true;
-        lastFound = '';
-        doCheck = false;
-    }
-
-    var lastSearchOn = '';
-
     function search() {
-        debug.innerHTML = "";
-        document.body.style.cursor = "wait";
-        lastFound = '';
-        doCheck = false;
-        lastSearchOn = [];
-
-        var nodes;
-
+        lastFoundId = -1;
+        
+        var key = document.getElementById("searchText").value;
+        if (key == "")
+        {
+            alert('<fmt:message key="debugviews.common.noText"/>');
+            return;
+        }
+        
         if (document.getElementById("inSelected").checked) {
-            nodes = dojo.widget.byId('selector').selectedNodes;
-
-            if (nodes == '') {
-                debug.innerHTML = "<br/>Failure in search: No node selected to search.";
-                alert('Failure in search: No node selected to search');
-            } else {
-                for (obj in nodes)
-                    lastSearchOn.push(nodes[obj]);  
-
-                findInSelected(nodes);
+            node = debugTree.lastFocused;
+            if (node == '' || node == debugTree.rootNode) {
+                alert('<fmt:message key="debugviews.common.pleaseSelect"/>');
+                return;
             }
+            SearchOn = [node.item];
         } else {
-            nodes = dojo.widget.byId('tree').children;
-            lastSearchOn = dojo.widget.byId('tree').children;
-            findInSelected(nodes);
-        }
-
-        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;
+            SearchOn = debugTree.rootNode.item.children;
         }
+        if(!findAndSelect(key, SearchOn))
+            alert('<fmt:message key="debugviews.common.notFound"/> ' + key);
+        else 
+            findNext.attr("disabled", false);
     }
 
     function searchContinue() {
-        debug.innerHTML = "";
-        document.body.style.cursor = "wait";
-        findInSelected(lastSearchOn);
-        document.body.style.cursor = '';
+        var key = document.getElementById("searchText").value;
+        if(!findAndSelect(key, SearchOn))
+            alert('<fmt:message key="debugviews.common.notFound"/> ' + key);
     }
 
-    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;
-    }
+    function searchReset() {
+        findNext.attr("disabled", true);
+        lastFoundId = -1;
+        //The only way to enable "findNext" button is to search() 
+    }    
 </script>
-
-<form name="clform" onSubmit="return getAction()" method="POST">
-<input type="hidden" name="snNode" value=""/>
-<input type="hidden" name="inverse" value="${inverse}"/>
-<TABLE cellpadding="1" cellspacing="1" border="1">
- <tr>
-  <td><b><label for="searchText"><fmt:message key="classloaderview.view.searchText"/></label>:</b>
<input type="text" name="searchText" id="searchText"
-   onChange="javascript:textChange()"/> <input type="button"
-   value='<fmt:message key="debugviews.common.find"/>' onClick="javascript:search()"
/> <input type="button"
-   id="findNext" value='<fmt:message key="debugviews.common.findNext"/>' onClick="javascript:searchContinue()"
-   disabled=true /> <label for="inSelected"><fmt:message key="classloaderview.view.searchOnlySelected"/></label>:<input
type="checkbox"
-   id="inSelected" onChange="javascript:textChange()" /></td>
- </tr>
-</table>
-<input type="submit" value='<fmt:message key="classloaderview.view.invertTree"/>'
/>
+<div dojoType="dijit.TitlePane" title="<fmt:message key="debugviews.common.find"/>"
>
+    <b><label for="searchText"><fmt:message key="classloaderview.view.searchText"/></label>:</b>
+    <input type="text" name="searchText" id="searchText" onChange="javascript:searchReset()"/>

+    <button dojoType="dijit.form.Button" jsId="findButton" ><fmt:message key="debugviews.common.find"/>
+        <script type="dojo/method" event="onClick" args="btn">
+            search();
+        </script>
+    </button>
+    <button dojoType="dijit.form.Button" jsId="findNext" disabled="true"><fmt:message
key="debugviews.common.findNext"/>
+        <script type="dojo/method" event="onClick" args="btn">
+            searchContinue();
+        </script>
+    </button>
+    <label for="inSelected"><fmt:message key="classloaderview.view.searchOnlySelected"/></label>:
+    <input type="checkbox" id="inSelected" onChange="javascript:searchReset()" />
+
+</div>
+<br/>
+<button dojoType="dijit.form.Button" jsId="invertButton" ><fmt:message key="classloaderview.view.invertTree"/>
+    <script type="dojo/method" event="onClick" args="btn">
+        invertTree();
+    </script>
+</button>
 <br />
-<div dojoType="TreeBasicControllerV3" widgetId="controller"></div>
-<div dojoType="TreeSelectorV3" widgetId="selector"></div>
-<div dojoType="TreeEmphasizeOnSelect" selector="selector"></div>
-<div dojoType="TreeToggleOnSelect" selector="selector" controller="controller"></div>
-<div dojoType="TreeDocIconExtension" widgetId="iconcontroller" templateCssString="
-.TreeStateChildrenYes-ExpandOpen .TreeIconContent {
-    background-image : url('../templates/images/TreeV3/i_long.gif');
-    background-repeat : no-repeat;
-    background-position: 18px 9px;
-}
-
-.TreeStateChildrenYes-ExpandClosed .TreeIconContent {
-    background-image : url();
-}
-
-.TreeStateChildrenNo-ExpandLeaf .TreeIconContent {
-    background-image : url();
-}
-
-.TreeStateChildrenNo-ExpandClosed .TreeIconContent {
-    background-image : url();
-}
-
-.TreeStateChildrenNo-ExpandOpen .TreeIconContent {
-    background-image : url();
-}
-
-.TreeIconDocument {
-    background-image: url(<%= renderResponse.encodeURL(renderRequest.getContextPath()
+ "/ico_filetree_16x16.gif") %>);
-}
-
-.TreeExpandOpen .TreeIconFolder {
-    background-image: url(<%= renderResponse.encodeURL(renderRequest.getContextPath()
+ "/ico_filetree_16x16.gif") %>);
-}
-
-.TreeExpandClosed .TreeIconFolder {
-    background-image: url(<%= renderResponse.encodeURL(renderRequest.getContextPath()
+ "/ico_filetree_16x16.gif") %>);
-}
-
-/* generic class for docIcon */
-.TreeIcon {
-    width: 18px;
-    height: 18px;
-    float: left;
-    display: inline;
-    background-repeat : no-repeat;
-}
-
-div.TreeContent {
-    margin-left: 36px;
-}"></div>
-<div dojoType="TreeV3" listeners="controller;selector;iconcontroller" widgetId='tree'
allowedMulti='false'></div>
-
-<div id="debug"></div>
-</form>
+<div id = "dojotree">
+</div>

Modified: geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/dependencyview/view.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/dependencyview/view.jsp?rev=814983&r1=814982&r2=814983&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/dependencyview/view.jsp
(original)
+++ geronimo/server/trunk/plugins/debugviews/debugviews-portlets/src/main/webapp/WEB-INF/view/dependencyview/view.jsp
Tue Sep 15 03:31:07 2009
@@ -17,267 +17,202 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@ page import="javax.portlet.RenderRequest"%>
 <fmt:setBundle basename="debugviews"/>
 <portlet:defineObjects/>
 
-<%
-    String childs = (String)renderRequest.getPortletSession().getAttribute("dependencyTree");
   
-    renderRequest.getPortletSession().removeAttribute("dependencyTree");
-%>
-
-    <script type="text/javascript" src="/dojo/0.4/dojo.js"></script>
-
-    <script type="text/javascript">
-        dojo.require("dojo.lang.*");
-        dojo.require("dojo.widget.*");
-        // Pane includes
-        dojo.require("dojo.widget.ContentPane");
-        dojo.require("dojo.widget.LayoutContainer"); // Before: LayoutPane
-        dojo.require("dojo.widget.SplitContainer"); // Before: SplitPane
-        // Tree includes
-        dojo.require("dojo.widget.Tree");
-        dojo.require("dojo.widget.TreeBasicController");
-        dojo.require("dojo.widget.TreeContextMenu");
-        dojo.require("dojo.widget.TreeSelector");
-        // Tab includes
-        dojo.require("dojo.widget.TabContainer");
-        // Etc includes
-        dojo.require("dojo.widget.SortableTable");
-        dojo.require("dojo.widget.ComboBox");
-        dojo.require("dojo.widget.Tooltip");
-        dojo.require("dojo.widget.validate");
-        // Includes Dojo source for debugging
-        // dojo.hostenv.writeIncludes();
-    </script>
-
-<script>
-    dojo.require("dojo.widget.*");
-    dojo.require("dojo.widget.TreeV3");
-    dojo.require("dojo.widget.TreeNodeV3");
-    dojo.require("dojo.widget.TreeBasicControllerV3");
-    dojo.require("dojo.widget.TreeSelectorV3");
-    dojo.require("dojo.widget.TreeEmphasizeOnSelect");
-    dojo.require("dojo.widget.TreeToggleOnSelect");
-    
-    dojo.hostenv.writeIncludes();
+<% String dwrForwarderServlet = "/console/dwr2"; %>
+<script type='text/javascript' src='<%= dwrForwarderServlet %>/interface/DependencyViewHelper.js'></script>
+<script type='text/javascript' src='<%= dwrForwarderServlet %>/engine.js'></script>
+<script type='text/javascript' src='<%= dwrForwarderServlet %>/util.js'></script>
+<style type="text/css">
+    @import "/dojo/dojo/resources/dojo.css";
+    @import "/dojo/dijit/themes/soria/soria.css";
+</style>
+<script type="text/javascript" src="/dojo/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
+<script type="text/javascript">
+    //style class
+    document.body.className="soria";
+
+    //import dojo lib
+    dojo.require("dojo.data.ItemFileWriteStore");
+    dojo.require("dijit.tree.ForestStoreModel");
+    dojo.require("dijit.Tree");
+    dojo.require("dijit.TitlePane");
+    dojo.require("dijit.form.Button");
 
-    dojo.addOnLoad(function(){
-        var tree = dojo.widget.manager.getWidgetById('tree');
-
-        dojo.event.topic.subscribe("nodeSelected",
-             function(message) { 
-                if (message.node.parent.title == "dependencies") {
-                    for (var i = 0; i < tree.children.length; i++) {
-                        var node = findOnlyInSelected(tree.children[i],message.node.title);
-
-                        if (node) {
-                            select(node);
-                            break;
-                        }
-                    }
-                }
-             }
-        );
-        
-        var treeNodes = <%= childs %>;        
-
-        tree.setChildren(treeNodes);
-    });
-
-    function findOnlyInSelected(selectedNodes, search) {
-        var children = selectedNodes.children;
-
-        for (var child = 0; child < children.length; child++) {
-            if (children[child].title == search)
-                return children[child].widgetId;
-        }
-
-        return ;
-    }
-
-    var lastFound = '';
-    var doCheck = false;;
-
-    function check(curr,last) {
-        var cr = curr.split(".");
-        var ls = last.split(".");
-
-        for (var i = 0; i < cr.length; i++)
-            if (parseInt(cr[i]) < parseInt(ls[i]))
-                return false;
+</script>
 
-        return true;
-    }
 
-    function findNext(children, str) {
-        for (var child = 0; child < children.length; child++) {
-            if (doCheck) {
-                if (! check(children[child].widgetId,lastFound))
-                    continue;
-                else
-                    if (children[child].widgetId == lastFound)
-                        doCheck = false;
+<!------------------------>
+<!--     Page Stuff     -->
+<!------------------------>
+<script type="text/javascript">
+
+    var debugStore = null; 
+    DependencyViewHelper.getTrees({callback:createStore,async:false});
+    function createStore(treeData){    
+    //      var treeData = dojo.fromJson(json);                    
+          debugStore=new dojo.data.ItemFileReadStore({data:treeData});       
+      }
+    var debugModel = new dijit.tree.ForestStoreModel({
+        store:debugStore, rootId:"Dependencies", rootLabel:"Dependencis", childrenAttrs:["children"]});
+
+    var lastFoundId = -1;
+    var SearchOn = []; //For ignore the fake root it better be a array
+
+    function findRecur(items, str, path) 
+    {
+        for (var child = 0; child < items.length; child++) {
+
+            path.push(items[child]);
+            var label = debugStore.getLabel(items[child]);
+            if (label && label.indexOf(str) != -1 && debugStore.getIdentity(items[child])
> lastFoundId)
+                return true;
+
+            if (items[child].children && findRecur(items[child].children, str, path))
+                return true;
+            path.pop();
+        }
+        return false;
+    }
+    function select(path)
+    {
+        var i;
+        function expandParent(node)
+        {
+            if(node && !node.isExpanded)
+            {
+                expandParent(node.getParent());
+                debugTree._expandNode(node);
             }
-
-            if (children[child].title.indexOf(str) != -1 && children[child].widgetId
!= lastFound && !doCheck)
-                return children[child].widgetId;
-
-            if (children[child].children) {
-                var ret = findNext(children[child].children,str);
-
-                if (ret)
-                    return ret;
+        }
+        //make sure the ancestor node expanded before
+        expandParent(debugTree._itemNodeMap[debugStore.getIdentity(path[0])].getParent());
+        for (i = 0;;i++) {
+            node  = debugTree._itemNodeMap[debugStore.getIdentity(path[i])];
+            if(i < path.length-1)
+                debugTree._expandNode(node);
+            else 
+            {
+                debugTree.focusNode(node);
+                return node;
             }
         }
-
-        return ;
     }
-
-    function select(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);
+    function findAndSelect(key, scope)
+    {
+        var path = [], node, res = false;
+        document.body.style.cursor = "wait";
+        if(!findRecur(scope, key, path))
+        {
+            lastFoundId = -1;
+        } else {
+            node = select(path);
+            lastFoundId = debugStore.getIdentity(node.item);
+            res = true;
         }
-
-        dojo.widget.byId('selector').select(dojo.widget.byId(node));
+        document.body.style.cursor = '';
+        return res;
     }
-
-    function findInSelected(selectedNodes) {
-        var search = document.getElementById("searchText").value;
-
-        if (search == "") {
-            alert('No Text to search');
+    function search() {
+        lastFoundId = -1;
+        
+        var key = document.getElementById("searchText").value;
+        if (key == "")
+        {
+            alert('<fmt:message key="debugviews.common.noText"/>');
             return;
         }
-
-        var v= findNext(selectedNodes, search);
-
-        if (v) {
-            dojo.widget.byId('selector').deselectAll();
-            select(v);
-            document.getElementById("findNext").disabled = false;
-            lastFound = v;
-            doCheck = true;
+        
+        if (document.getElementById("inSelected").checked) {
+            node = debugTree.lastFocused;
+            if (node == '' || node == debugTree.rootNode) {
+                alert('<fmt:message key="debugviews.common.pleaseSelect"/>');
+                return;
+            }
+            SearchOn = [node.item];
         } else {
-            alert('Nothing found');
-            lastFound = '';
-            doCheck = false;
+            SearchOn = debugTree.rootNode.item.children;
         }
+        if(!findAndSelect(key, SearchOn))
+            alert('<fmt:message key="debugviews.common.notFound"/> ' + key);
+        else 
+            findNext.attr("disabled", false);
     }
 
-    function textChange() {
-        document.getElementById("findNext").disabled=true;
-        lastFound = '';
-        doCheck = false;
+    function searchContinue() {
+        var key = document.getElementById("searchText").value;
+        if(!findAndSelect(key, SearchOn))
+            alert('<fmt:message key="debugviews.common.notFound"/> ' + key);
     }
 
-    var lastSearchOn = '';
-
-    function search() {
-        document.body.style.cursor = "wait";
-        lastFound = '';
-        doCheck = false;
-        lastSearchOn = [];
-
-        var nodes;
-
-        if (document.getElementById("inSelected").checked) {
-            nodes = dojo.widget.byId('selector').selectedNodes;
+    function searchReset() {
+        findNext.attr("disabled", true);
+        lastFoundId = -1;
+        //The only way to enable "findNext" button is to search() 
+    }
+    function markModule(node)
+    {
+        if(node.getParent().label != "dependencies")
+            return;
 
-            if (nodes == '') {
-                alert('No Node selected to search');
-            } else {
-                for (obj in nodes)
-                    lastSearchOn.push(nodes[obj]);
+        //select the module
+        var i, j, toparray, children;
+        var name = node.label;
+    out:for(i=0, toparray=debugStore._arrayOfTopLevelItems;i < toparray.length;i++)
+            for(j=0, children=toparray[i].children;j<children.length;j++)
+                if(name == debugStore.getLabel(children[j]))break out;
+        if(i < toparray.length)
+            select([toparray[i], children[j]]); //keep in silence if not found
+    }
+    //modified the Tree._onDblClick in dijit/Tree.js to meet out need
+    function _onDblClick(e)
+    {
+        // summary:
+        //        Translates double-click events into commands for the controller to process
+        var domElement = e.target;
+
+        // find node
+        var nodeWidget = dijit.getEnclosingWidget(domElement);    
+        if(!nodeWidget || !nodeWidget.isTreeNode){
+            return;
+        }
 
-                findInSelected(nodes);
+        if( (this.openOnDblClick && nodeWidget.isExpandable) ||
+            (domElement == nodeWidget.expandoNode || domElement == nodeWidget.expandoNodeText)
){
+            // expando node was clicked, or label of a folder node was clicked; open it
+            if(nodeWidget.isExpandable){
+                this._onExpandoClick({node:nodeWidget});
             }
-        } else {
-            nodes = dojo.widget.byId('tree').children;
-            lastSearchOn = dojo.widget.byId('tree').children;
-            findInSelected(nodes);
+        }else{
+            this._publish("execute", { item: nodeWidget.item, node: nodeWidget} );
+            markModule(nodeWidget);
         }
-
-        document.body.style.cursor = '';
-    }
-
-    function searchContinue() {
-        document.body.style.cursor = "wait";
-        findInSelected(lastSearchOn);
-        document.body.style.cursor = '';
+        dojo.stopEvent(e);
     }
+    dojo.addOnLoad(function(){
+        debugTree._onDblClick = _onDblClick;
+    });
 </script>
-<TABLE cellpadding="1" cellspacing="1" border="1">
-<tr><td>
-<b><label for="searchText"><fmt:message key="dependencyview.view.searchText"/></label>:</b>
<input type="text" id="searchText" onChange="javascript:textChange()"/>
-<input type="button" value='<fmt:message key="debugviews.common.find"/>' onClick="javascript:search()"/>
-<input type="button" id="findNext" value='<fmt:message key="debugviews.common.findNext"/>'
onClick="javascript:searchContinue()" disabled=true />
-<label for="inSelected"><fmt:message key="dependencyview.view.searchOnlySelected"/></label>:<input
type="checkbox" id="inSelected" onChange="javascript:textChange()"/>
-</td></tr>
-</table>
-<br/>
-<div dojoType="TreeBasicControllerV3" widgetId="controller"></div>    
-<div dojoType="TreeSelectorV3" widgetId="selector" eventNames="select:nodeSelected"></div>
   
-<div dojoType="TreeEmphasizeOnSelect" selector="selector"></div>
-<div dojoType="TreeToggleOnSelect" selector="selector" controller="controller"></div>
-<div dojoType="TreeDocIconExtension"  widgetId="iconcontroller" templateCssString="
-.TreeStateChildrenYes-ExpandOpen .TreeIconContent {
-    background-image : url('../templates/images/TreeV3/i_long.gif');
-    background-repeat : no-repeat;
-    background-position: 18px 9px;
-}
-
-.TreeStateChildrenYes-ExpandClosed .TreeIconContent {
-    background-image : url();
-}
-
-.TreeStateChildrenNo-ExpandLeaf .TreeIconContent {
-    background-image : url();
-}
-
-.TreeStateChildrenNo-ExpandClosed .TreeIconContent {
-    background-image : url();
-}
-
-.TreeStateChildrenNo-ExpandOpen .TreeIconContent {
-    background-image : url();
-}
-
-.TreeIconDocument {
-    background-image: url(<%= renderResponse.encodeURL(renderRequest.getContextPath()
+ "/ico_filetree_16x16.gif") %>);
-}
-
-.TreeExpandOpen .TreeIconFolder {
-    background-image: url(<%= renderResponse.encodeURL(renderRequest.getContextPath()
+ "/ico_filetree_16x16.gif") %>);
-}
-
-.TreeExpandClosed .TreeIconFolder {
-    background-image: url(<%= renderResponse.encodeURL(renderRequest.getContextPath()
+ "/ico_filetree_16x16.gif") %>);
-}
-
-/* generic class for docIcon */
-.TreeIcon {
-    width: 18px;
-    height: 18px;
-    float: left;
-    display: inline;
-    background-repeat : no-repeat;
-}
-
-div.TreeContent {
-    margin-left: 36px;
-}"></div>
-<div dojoType="TreeV3" listeners="controller;selector;iconcontroller" widgetId='tree'
allowedMulti='false'></div>
+<div dojoType="dijit.TitlePane" title="<fmt:message key="debugviews.common.find"/>"
>
+    <b><label for="searchText"><fmt:message key="dependencyview.view.searchText"
/></label>: </b>
+    <input type="text" id="searchText" onChange="javascript:searchReset()" /> 
+    <button dojoType="dijit.form.Button" jsId="findButton" ><fmt:message key="debugviews.common.find"/>
+        <script type="dojo/method" event="onClick" args="btn">
+            search();
+        </script>
+    </button>
+    <button dojoType="dijit.form.Button" jsId="findNext" disabled="true"><fmt:message
key="debugviews.common.findNext"/>
+        <script type="dojo/method" event="onClick" args="btn">
+            searchContinue();
+        </script>
+    </button>
+    <label for="inSelected"><fmt:message key="dependencyview.view.searchOnlySelected"
/></label>: 
+    <input type="checkbox" id="inSelected" onChange="javascript:searchReset()" />
+</div>
+<br />
+<div dojoType="dijit.Tree" jsId="debugTree" class="soria" showRoot="false"
+      model="debugModel" openOnClick="true" >
+</div>
 
 



Mime
View raw message