Author: adrianc
Date: Fri Jun 13 20:01:33 2008 New Revision: 667723 URL: http://svn.apache.org/viewvc?rev=667723&view=rev Log: Screen widget improvements: 1. Better screenlet collapsible implementation. 2. New widget: horizontal-separator. The id attribute is no longer required for collapsible screenlets. Just use collapsible="true". The horizontal-separator widget can be used to divide complicated screens - as an alternative to using screenlets. Modified: ofbiz/trunk/framework/images/webapp/images/maincss.css ofbiz/trunk/framework/images/webapp/images/selectall.js ofbiz/trunk/framework/widget/dtd/widget-screen.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java Modified: ofbiz/trunk/framework/images/webapp/images/maincss.css URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/maincss.css?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/maincss.css (original) +++ ofbiz/trunk/framework/images/webapp/images/maincss.css Fri Jun 13 20:01:33 2008 @@ -1331,15 +1331,15 @@ .screenlet-title-bar ul .collapsed, .screenlet-title-bar ul .collapsed:hover { background: url(/images/expand.gif) no-repeat center center; -min-height: 1em; -min-width: 1em; +min-height: 1.1em; +min-width: 1.1em; } .screenlet-title-bar ul .expanded, .screenlet-title-bar ul .expanded:hover { background: url(/images/collapse.gif) no-repeat center center; -min-height: 1em; -min-width: 1em; +min-height: 1.1em; +min-width: 1.1em; } .screenlet-title-bar ul .collapsed a, Modified: ofbiz/trunk/framework/images/webapp/images/selectall.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/selectall.js?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/images/webapp/images/selectall.js (original) +++ ofbiz/trunk/framework/images/webapp/images/selectall.js Fri Jun 13 20:01:33 2008 @@ -300,33 +300,27 @@ } } -Event.observe(window,'load', function() { - var collapseablePanels = $$('li.collapsed', 'li.expanded'); - collapseablePanels.each( function(e) { - if(e){ - atag = e.down('a'); - atag.observe('click', toggleCollapsablePanel); - } - }); - -}); - -function toggleCollapsablePanel(event){ - var atag = event.element(); - titleDiv = atag.up('div.screenlet-title-bar'); - bodyDiv = titleDiv.next(); - liElement = atag.up('li'); - if(bodyDiv.visible()){ +/** Toggle area visibility on/off. + * @param link The <a> element calling this function + * @param areaId The id of the HTML container to toggle + * @param expandTxt Localized 'Expand' text + * @param collapseTxt Localized 'Collapse' text +*/ +function toggleCollapsiblePanel(link, areaId, expandTxt, collapseTxt){ + var container = $(areaId); + var liElement = $(link).up('li'); + if(container.visible()){ liElement.removeClassName('expanded'); liElement.addClassName('collapsed'); + link.title = expandTxt; } else { liElement.removeClassName('collapsed'); - liElement.addClassName('expanded'); - + liElement.addClassName('expanded'); + link.title = collapseTxt; } - Effect.toggle(bodyDiv, 'appear'); - Event.stop(event); + Effect.toggle(container, 'appear'); } + // ===== End of Ajax Functions ===== // function submitFormDisableSubmits(form) { Modified: ofbiz/trunk/framework/widget/dtd/widget-screen.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-screen.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-screen.xsd Fri Jun 13 20:01:33 2008 @@ -766,6 +766,16 @@ </xs:annotation> </xs:attribute> </xs:attributeGroup> + <xs:element name="horizontal-separator" substitutionGroup="AllWidgets"> + <xs:complexType mixed="true"> + <xs:attributeGroup ref="attlist.horizontal-separator"/> + </xs:complexType> + </xs:element> + <xs:attributeGroup name="attlist.horizontal-separator"> + <xs:attribute type="xs:string" name="id"/> + <xs:attribute type="xs:string" name="name"/> + <xs:attribute type="xs:string" name="style"/> + </xs:attributeGroup> <xs:element name="image" substitutionGroup="AllWidgets"> <xs:complexType mixed="true"> <xs:attributeGroup ref="attlist.image"/> @@ -861,12 +871,8 @@ <xs:attribute type="xs:string" name="title"> <xs:annotation><xs:documentation>Title text to be placed in the screenlet title bar.</xs:documentation></xs:annotation> </xs:attribute> - <xs:attribute type="xs:string" name="id"> - <xs:annotation><xs:documentation>Collapsible screenlets must have a name or ID.</xs:documentation></xs:annotation> - </xs:attribute> - <xs:attribute type="xs:string" name="name"> - <xs:annotation><xs:documentation>Collapsible screenlets must have a name or ID.</xs:documentation></xs:annotation> - </xs:attribute> + <xs:attribute type="xs:string" name="id"/> + <xs:attribute type="xs:string" name="name"/> <xs:attribute name="collapsible" default="false"> <xs:simpleType> <xs:restriction base="xs:token"> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java Fri Jun 13 20:01:33 2008 @@ -91,6 +91,15 @@ appendWhitespace(writer); } + public void renderHorizontalSeparator(Appendable writer, Map<String, Object> context, ModelScreenWidget.HorizontalSeparator separator) throws IOException { + writer.append("<fo:block>"); + appendWhitespace(writer); + writer.append("<fo:leader leader-length=\"100%\" leader-pattern=\"rule\" rule-style=\"solid\" rule-thickness=\"0.1mm\" color=\"black\"/>"); + appendWhitespace(writer); + writer.append("</fo:block>"); + appendWhitespace(writer); + } + public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.Link link) throws IOException { // TODO: not implemented } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Fri Jun 13 20:01:33 2008 @@ -115,9 +115,24 @@ appendWhitespace(writer); } + public void renderHorizontalSeparator(Appendable writer, Map<String, Object> context, ModelScreenWidget.HorizontalSeparator separator) throws IOException { + writer.append("<hr"); + String className = separator.getStyle(context); + if (UtilValidate.isNotEmpty(className)) { + writer.append(" class=\"" + className + "\""); + } + String idName = separator.getId(context); + if (UtilValidate.isNotEmpty(idName)) { + writer.append(" id=\"" + idName + "\""); + } + writer.append("/>"); + appendWhitespace(writer); + } + public void renderScreenletBegin(Appendable writer, Map<String, Object> context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException { HttpServletRequest request = (HttpServletRequest) context.get("request"); HttpServletResponse response = (HttpServletResponse) context.get("response"); + boolean javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request); ModelScreenWidget.Menu tabMenu = screenlet.getTabMenu(); if (tabMenu != null) { tabMenu.renderWidgetString(writer, context, this); @@ -135,6 +150,7 @@ String title = screenlet.getTitle(context); ModelScreenWidget.Menu navMenu = screenlet.getNavigationMenu(); ModelScreenWidget.Form navForm = screenlet.getNavigationForm(); + String collapsibleAreaId = null; if (UtilValidate.isNotEmpty(title) || navMenu != null || navForm != null || screenlet.collapsible()) { writer.append("<div class=\"screenlet-title-bar\">"); appendWhitespace(writer); @@ -147,31 +163,41 @@ appendWhitespace(writer); } if (screenlet.collapsible()) { - String toolTip = null; + collapsibleAreaId = this.getNextElementId(); + String expandToolTip = null; + String collapseToolTip = null; Map<String, Object> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap")); Map<String, Object> paramMap = UtilGenerics.checkMap(context.get("requestParameters")); Map<String, Object> requestParameters = new HashMap<String, Object>(paramMap); + if (uiLabelMap != null) { + expandToolTip = (String) uiLabelMap.get("CommonExpand"); + collapseToolTip = (String) uiLabelMap.get("CommonCollapse"); + } writer.append("<li class=\""); if (collapsed) { - requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "false"); - String queryString = UtilHttp.urlEncodeArgs(requestParameters); - writer.append("collapsed\"><a href=\""); - writer.append(request.getRequestURI() + "?" + queryString); - if (uiLabelMap != null) { - toolTip = (String) uiLabelMap.get("CommonExpand"); + writer.append("collapsed\"><a "); + if (javaScriptEnabled) { + writer.append("onclick=\"javascript:toggleCollapsiblePanel(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\""); + } else { + requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "false"); + String queryString = UtilHttp.urlEncodeArgs(requestParameters); + writer.append("href=\"" + request.getRequestURI() + "?" + queryString + "\""); + } + if (UtilValidate.isNotEmpty(expandToolTip)) { + writer.append(" title=\"" + expandToolTip + "\""); } } else { - requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "true"); - String queryString = UtilHttp.urlEncodeArgs(requestParameters); - writer.append("expanded\"><a href=\""); - writer.append(request.getRequestURI() + "?" + queryString); - if (uiLabelMap != null) { - toolTip = (String) uiLabelMap.get("CommonCollapse"); + writer.append("expanded\"><a "); + if (javaScriptEnabled) { + writer.append("onclick=\"javascript:toggleCollapsiblePanel(this, '" + collapsibleAreaId + "', '" + expandToolTip + "', '" + collapseToolTip + "');\""); + } else { + requestParameters.put(screenlet.getPreferenceKey(context) + "_collapsed", "true"); + String queryString = UtilHttp.urlEncodeArgs(requestParameters); + writer.append("href=\"" + request.getRequestURI() + "?" + queryString + "\""); + } + if (UtilValidate.isNotEmpty(collapseToolTip)) { + writer.append(" title=\"" + collapseToolTip + "\""); } - } - writer.append("\""); - if (UtilValidate.isNotEmpty(toolTip)) { - writer.append(" title=\"" + toolTip + "\""); } writer.append("> </a></li>"); appendWhitespace(writer); @@ -193,10 +219,15 @@ appendWhitespace(writer); writer.append("</div>"); appendWhitespace(writer); + writer.append("<div"); + if (UtilValidate.isNotEmpty(collapsibleAreaId)) { + writer.append(" id=\"" + collapsibleAreaId + "\""); + } if (screenlet.padded()) { - writer.append("<div class=\"screenlet-body\">"); - appendWhitespace(writer); + writer.append(" class=\"screenlet-body\""); } + writer.append(">"); + appendWhitespace(writer); } } @@ -360,10 +391,8 @@ } public void renderScreenletEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Screenlet screenlet) throws IOException { - if (screenlet.padded()) { - writer.append("</div>"); - appendWhitespace(writer); - } + writer.append("</div>"); + appendWhitespace(writer); writer.append("</div>"); appendWhitespace(writer); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Fri Jun 13 20:01:33 2008 @@ -118,6 +118,8 @@ subWidgets.add(new Image(modelScreen, subElement)); } else if ("iterate-section".equals(subElement.getNodeName())) { subWidgets.add(new IterateSectionWidget(modelScreen, subElement)); + } else if ("horizontal-separator".equals(subElement.getNodeName())) { + subWidgets.add(new HorizontalSeparator(modelScreen, subElement)); } else { throw new IllegalArgumentException("Found invalid screen widget element with name: " + subElement.getNodeName()); } @@ -337,6 +339,9 @@ this.idExdr = new FlexibleStringExpander(screenletElement.getAttribute("id")); this.collapsible = "true".equals(screenletElement.getAttribute("collapsible")); this.initiallyCollapsed = "true".equals(screenletElement.getAttribute("initially-collapsed")); + if (this.initiallyCollapsed) { + this.collapsible = true; + } this.padded = !"false".equals(screenletElement.getAttribute("padded")); if (this.collapsible && UtilValidate.isEmpty(this.name) && idExdr.isEmpty()) { throw new IllegalArgumentException("Collapsible screenlets must have a name or id [" + this.modelScreen.getName() + "]"); @@ -420,7 +425,7 @@ public String getPreferenceKey(Map<String, Object> context) { String name = this.idExdr.expandString(context); if (UtilValidate.isEmpty(name)) { - name = this.modelScreen.getName() + "_" + this.name; + name = "screenlet" + "_" + Integer.toHexString(hashCode()); } return name; } @@ -451,6 +456,34 @@ } @SuppressWarnings("serial") + public static class HorizontalSeparator extends ModelScreenWidget { + protected FlexibleStringExpander idExdr; + protected FlexibleStringExpander styleExdr; + + public HorizontalSeparator(ModelScreen modelScreen, Element separatorElement) { + super(modelScreen, separatorElement); + this.idExdr = new FlexibleStringExpander(separatorElement.getAttribute("id")); + this.styleExdr = new FlexibleStringExpander(separatorElement.getAttribute("style")); + } + + public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { + screenStringRenderer.renderHorizontalSeparator(writer, context, this); + } + + public String getId(Map<String, Object> context) { + return this.idExdr.expandString(context); + } + + public String getStyle(Map<String, Object> context) { + return this.styleExdr.expandString(context); + } + + public String rawString() { + return "<horizontal-separator id=\"" + this.idExdr.getOriginal() + "\" name=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\">"; + } + } + + @SuppressWarnings("serial") public static class IncludeScreen extends ModelScreenWidget { protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; @@ -1509,3 +1542,4 @@ + Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java Fri Jun 13 20:01:33 2008 @@ -38,6 +38,7 @@ public void renderSubContentBody(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException; public void renderSubContentEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException; + public void renderHorizontalSeparator(Appendable writer, Map<String, Object> context, ModelScreenWidget.HorizontalSeparator separator) throws IOException; public void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label) throws IOException; public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.Link link) throws IOException; public void renderImage(Appendable writer, Map<String, Object> context, ModelScreenWidget.Image image) throws IOException; @@ -49,3 +50,4 @@ } + Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java?rev=667723&r1=667722&r2=667723&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java Fri Jun 13 20:01:33 2008 @@ -58,6 +58,10 @@ appendWhitespace(writer); } + public void renderHorizontalSeparator(Appendable writer, Map<String, Object> context, ModelScreenWidget.HorizontalSeparator separator) throws IOException { + // TODO: not implemented + } + public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.Link link) throws IOException { // TODO: not implemented } |
Free forum by Nabble | Edit this page |