diff --git a/core/pom.xml b/core/pom.xml index 68cbbca187f52874671c9a37726471fdeb151722..7e0f3d8c7cde6e9103b59aa3434fd91d3948da90 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -231,7 +231,7 @@ org.kohsuke.stapler stapler - 1.91 + 1.92 org.jvnet.localizer diff --git a/core/src/main/java/hudson/model/TreeView.java b/core/src/main/java/hudson/model/TreeView.java index 6d58dbe8e722ab0134b66a192529bd6dc9a7279f..c21566cc76e23128cabe16158fcc48c758fd3cf4 100644 --- a/core/src/main/java/hudson/model/TreeView.java +++ b/core/src/main/java/hudson/model/TreeView.java @@ -2,6 +2,7 @@ package hudson.model; import hudson.model.Descriptor.FormException; import hudson.util.CaseInsensitiveComparator; +import hudson.Indenter; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -45,6 +46,17 @@ public class TreeView extends View implements ViewGroup { super(name); } + /** + * Returns {@link Indenter} that has the fixed indentation width. + * Used for assisting view rendering. + */ + public Indenter createFixedIndenter(String d) { + final int depth = Integer.parseInt(d); + return new Indenter() { + protected int getNestLevel(Job job) { return depth; } + }; + } + /** * Returns a read-only view of all {@link Job}s in this view. * diff --git a/core/src/main/resources/hudson/model/TreeView/ajaxRows.jelly b/core/src/main/resources/hudson/model/TreeView/ajaxRows.jelly new file mode 100644 index 0000000000000000000000000000000000000000..6480369f209635f586431e895fdef96111167bd3 --- /dev/null +++ b/core/src/main/resources/hudson/model/TreeView/ajaxRows.jelly @@ -0,0 +1,17 @@ + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/core/src/main/resources/lib/hudson/projectView.jelly b/core/src/main/resources/lib/hudson/projectView.jelly index 0be22b0cfc390621639c6788043fc2b06a0137dc..b073f9984a92573387cac0699bd4b7260982caea 100644 --- a/core/src/main/resources/lib/hudson/projectView.jelly +++ b/core/src/main/resources/lib/hudson/projectView.jelly @@ -37,16 +37,7 @@ - - - - - - - ${v.viewName} - - - + diff --git a/core/src/main/resources/lib/hudson/projectViewNested.jelly b/core/src/main/resources/lib/hudson/projectViewNested.jelly new file mode 100644 index 0000000000000000000000000000000000000000..696ec6ffb6796db455ab9009992be2981e3d2ca4 --- /dev/null +++ b/core/src/main/resources/lib/hudson/projectViewNested.jelly @@ -0,0 +1,20 @@ + + + + + + + + + + + + + ${v.viewName} + + + + diff --git a/core/src/main/resources/lib/hudson/projectViewNested.js b/core/src/main/resources/lib/hudson/projectViewNested.js new file mode 100644 index 0000000000000000000000000000000000000000..1501a2d7e10b0603d18d0c1029c59cad45f0e136 --- /dev/null +++ b/core/src/main/resources/lib/hudson/projectViewNested.js @@ -0,0 +1,28 @@ +hudsonRules["IMG.treeview-fold-control"] = function(e) { + e.onexpanded = function() { + var img = this; + var tr = findAncestor(this, "TR"); + var tail = tr.nextSibling; + + img.oncollapsed = function() { + while(tr.nextSibling!=tail) + tr.nextSibling.remove(); + }; + + new Ajax.Request( + this.getAttribute("url"), + { + method : 'post', + onComplete : function(x) { + var cont = document.createElement("div"); + cont.innerHTML = x.responseText; + var rows = $A(cont.firstChild.rows); + rows.reverse().each(function(r) { + YAHOO.util.Dom.insertAfter(r, tr); + Behaviour.applySubtree(r); + }); + } + }); + }; + e = null; +}; diff --git a/war/resources/scripts/hudson-behavior.js b/war/resources/scripts/hudson-behavior.js index 3874f21cc484a45a528743421b412e5ea58ee141..a37b2a3e0e23a097d9fc5e46d762cf18d3d9f867 100644 --- a/war/resources/scripts/hudson-behavior.js +++ b/war/resources/scripts/hudson-behavior.js @@ -437,6 +437,36 @@ var hudsonRules = { "INPUT.yui-button" : function(e) { makeButton(e); + }, + + // image that shows [+] or [-], with hover effect. + // oncollapsed and onexpanded will be called when the button is triggered. + "IMG.fold-control" : function(e) { + function changeTo(e,img) { + var src = e.src; + e.src = src.substring(0,src.lastIndexOf('/'))+"/"+e.getAttribute("state")+img; + } + e.onmouseover = function() { + changeTo(this,"-hover.png"); + }; + e.onmouseout = function() { + changeTo(this,".png"); + }; + e.parentNode.onclick = function(event) { + var e = this.firstChild; + var s = e.getAttribute("state"); + if(s=="plus") { + e.setAttribute("state","minus"); + if(e.onexpanded) e.onexpanded(); + } else { + e.setAttribute("state","plus"); + if(e.oncollapsed) e.oncollapsed(); + } + changeTo(e,"-hover.png"); + YAHOO.util.Event.stopEvent(event); + return false; + }; + e = null; // memory leak prevention } };