From: <jt...@hy...> - 2008-03-14 01:50:57
|
Author: jtravis Date: 2008-03-13 18:50:54 -0700 (Thu, 13 Mar 2008) New Revision: 8248 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=8248 Added: trunk/src/org/hyperic/hq/hqu/rendit_sys/html/HQUWebUtil.groovy trunk/src/org/hyperic/hq/hqu/rendit_sys/html/TwoPanedFilterBuilder.groovy Modified: trunk/src/org/hyperic/hq/hqu/rendit_sys/render/RenderFrame.groovy Log: Merge from 3.2: Introduce HQUWebUtil which will allow DSL-style creation of web-widgets in the view. Currently it abstracts out our 2-paned filter, which is used in the event center (and alert center) Added: trunk/src/org/hyperic/hq/hqu/rendit_sys/html/HQUWebUtil.groovy =================================================================== --- trunk/src/org/hyperic/hq/hqu/rendit_sys/html/HQUWebUtil.groovy (rev 0) +++ trunk/src/org/hyperic/hq/hqu/rendit_sys/html/HQUWebUtil.groovy 2008-03-14 01:50:54 UTC (rev 8248) @@ -0,0 +1,35 @@ +/** + * This utility class provides methods for creating web-widgets programatically. + * The primary goal is to share functionality between views. + */ + +package org.hyperic.hq.hqu.rendit.html + +class HQUWebUtil { + /** + * Create a TwoPanedFilterBuilder. + * + * In myView.gsp: + * <% hquTwoPanedFilter { w -> + w.filter('My Filter Box') { + w.filterElement('First Filter') { + %> some HTML <% + } + w.filterElement('Second Filter') { + %> more HTML <% + } + } + w.pane { + %> right-side-of-the-window stuff <% + } + } %> + * + */ + static hquTwoPanedFilter(Binding b, Closure yield) { + def output = b.PAGE.getOutput() + def builder = new TwoPanedFilterBuilder(output:output) + builder.filterAndPane { + yield(builder) + } + } +} \ No newline at end of file Added: trunk/src/org/hyperic/hq/hqu/rendit_sys/html/TwoPanedFilterBuilder.groovy =================================================================== --- trunk/src/org/hyperic/hq/hqu/rendit_sys/html/TwoPanedFilterBuilder.groovy (rev 0) +++ trunk/src/org/hyperic/hq/hqu/rendit_sys/html/TwoPanedFilterBuilder.groovy 2008-03-14 01:50:54 UTC (rev 8248) @@ -0,0 +1,93 @@ +package org.hyperic.hq.hqu.rendit.html + +/** + * A TwoPanedFilter is a builder which allows for a filter, + * filter-elements, and a content pane. + * + * It contains a small left-column (where filters are) and a large + * right column (the content pane) + * + * To use it: + * def x = new TwoPanedFilterBuilder(output) + * x.filterAndPane { + x.filters('Filter Box') { + x.filterElement('Element one') { + output.write('Body of one') + } + x.filterElement('Element two') { + output.write('Body of two') + } + } + x.pane { + output.write('Body of pane') + } + } + * + * + */ +class TwoPanedFilterBuilder extends BuilderSupport { + def output + + def createNode(name, value) { + def res = [nodeType: name, name: value] + if (name == 'filterAndPane') { + output.write(""" + <div style="margin-top:10px;margin-left:10px;margin-bottom:5px;padding-right:10px;">""") + res.finish = { """ + </div> +""" } + } else if (name == 'filter') { + output.write(""" + <div style="float:left;width:18%;margin-right:10px;"> + <div class="filters"> + <div class="BlockTitle">${res.name}</div> + <div class="filterBox">""") + res.finish= { """ + </div> + </div> + </div> +""" } + } else if (name == 'filterElement') { + output.write(""" + <div class="fieldSetStacked" style="margin-bottom:8px;"> + <span><strong>${res.name}</strong></span> + <div>""") + res.finish = { """ + </div> + </div> +""" } + } else if (name == 'pane') { + output.write(""" + <div style="float:right;width:78%;display:inline;height: 445px;overflow-x: hidden; overflow-y: auto;" + id="logsCont"> + <div>""") + res.finish = { """ + </div> + </div> +""" } + } else { + throw new RuntimeException("Unknown type: [$name]") + } + res + } + + def createNode(name) { + createNode(name, 'unspecified') + } + + def createNode(name, Map attributes) { + createNode(name) + } + + def createNode(name, Map Attributes, value) { + createNode(name) + } + + void setParent(parent, child) { + child.parent = parent + } + + void nodeCompleted(parent, node) { + output.write(node.finish()) + } +} Modified: trunk/src/org/hyperic/hq/hqu/rendit_sys/render/RenderFrame.groovy =================================================================== --- trunk/src/org/hyperic/hq/hqu/rendit_sys/render/RenderFrame.groovy 2008-03-14 01:50:40 UTC (rev 8247) +++ trunk/src/org/hyperic/hq/hqu/rendit_sys/render/RenderFrame.groovy 2008-03-14 01:50:54 UTC (rev 8248) @@ -3,6 +3,7 @@ import org.codehaus.groovy.runtime.MethodClosure import java.lang.reflect.Modifier import org.hyperic.hq.hqu.rendit.html.DojoUtil +import org.hyperic.hq.hqu.rendit.html.HQUWebUtil import org.hyperic.hq.hqu.rendit.html.HtmlUtil import org.hyperic.hq.hqu.rendit.html.FormGenerator import org.apache.commons.logging.Log @@ -107,6 +108,7 @@ res += staticMethodsToMap(varMap, DojoUtil) res += staticMethodsToMap(varMap, HtmlUtil) + res += staticMethodsToMap(varMap, HQUWebUtil) // Override general methods which generate links so that URLs can // be re-written |