Return-Path: Delivered-To: apmail-click-commits-archive@www.apache.org Received: (qmail 20528 invoked from network); 28 Mar 2010 12:26:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Mar 2010 12:26:29 -0000 Received: (qmail 60968 invoked by uid 500); 28 Mar 2010 12:26:29 -0000 Delivered-To: apmail-click-commits-archive@click.apache.org Received: (qmail 60951 invoked by uid 500); 28 Mar 2010 12:26:29 -0000 Mailing-List: contact commits-help@click.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@click.apache.org Delivered-To: mailing list commits@click.apache.org Received: (qmail 60937 invoked by uid 99); 28 Mar 2010 12:26:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Mar 2010 12:26:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Mar 2010 12:26:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BE6E223889DD; Sun, 28 Mar 2010 12:26:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r928386 - in /click/trunk/click/framework/src/org/apache/click/control: Form.java Table.java Date: Sun, 28 Mar 2010 12:26:03 -0000 To: commits@click.apache.org From: sabob@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100328122603.BE6E223889DD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sabob Date: Sun Mar 28 12:26:03 2010 New Revision: 928386 URL: http://svn.apache.org/viewvc?rev=928386&view=rev Log: migrated html imports to head elements Modified: click/trunk/click/framework/src/org/apache/click/control/Form.java click/trunk/click/framework/src/org/apache/click/control/Table.java Modified: click/trunk/click/framework/src/org/apache/click/control/Form.java URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Form.java?rev=928386&r1=928385&r2=928386&view=diff ============================================================================== --- click/trunk/click/framework/src/org/apache/click/control/Form.java (original) +++ click/trunk/click/framework/src/org/apache/click/control/Form.java Sun Mar 28 12:26:03 2010 @@ -30,6 +30,8 @@ import javax.servlet.http.HttpServletRes import org.apache.click.Context; import org.apache.click.Control; import org.apache.click.Page; +import org.apache.click.element.CssImport; +import org.apache.click.element.JsImport; import org.apache.click.service.FileUploadService; import org.apache.click.service.LogService; import org.apache.click.util.ClickUtils; @@ -569,11 +571,6 @@ public class Form extends AbstractContai + "if (field && field.focus && field.type != 'hidden' && field.disabled != true) { field.focus(); };\n" + "//-->\n"; - /** The HTML imports statements. */ - protected static final String HTML_IMPORTS = - "\n" - + "\n"; - // Instance Variables ----------------------------------------------------- /** The form action URL. */ @@ -1122,35 +1119,29 @@ public class Form extends AbstractContai } /** - * Return the Form HTML head imports statements for the following resources: - *

+ * Return the Form HTML HEAD elements for the following resources: + * *

    *
  • click/control.css
  • *
  • click/control.js
  • *
- *

- * Additionally all {@link #getControls() controls} import statements are - * also returned. * - * @see org.apache.click.Control#getHtmlImports() + * @see org.apache.click.Control#getHeadElements() * - * @return the HTML head import statements for the control stylesheet and - * JavaScript files + * @return the form list of HEAD elements to be included in the page */ @Override - public String getHtmlImports() { - HtmlStringBuffer buffer = new HtmlStringBuffer(512); + public List getHeadElements() { + if (headElements == null) { + headElements = super.getHeadElements(); - buffer.append(ClickUtils.createHtmlImport(HTML_IMPORTS, getContext())); + Context context = getContext(); + String versionIndicator = ClickUtils.getResourceVersionIndicator(context); - for (Control control : getControls()) { - String htmlImports = control.getHtmlImports(); - if (htmlImports != null) { - buffer.append(htmlImports); - } + headElements.add(new CssImport("/click/control.css", versionIndicator)); + headElements.add(new JsImport("/click/control.js", versionIndicator)); } - - return buffer.toString(); + return headElements; } /** Modified: click/trunk/click/framework/src/org/apache/click/control/Table.java URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/Table.java?rev=928386&r1=928385&r2=928386&view=diff ============================================================================== --- click/trunk/click/framework/src/org/apache/click/control/Table.java (original) +++ click/trunk/click/framework/src/org/apache/click/control/Table.java Sun Mar 28 12:26:03 2010 @@ -26,8 +26,11 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; +import org.apache.click.Context; import org.apache.click.Control; +import org.apache.click.element.CssImport; +import org.apache.click.element.CssStyle; import org.apache.click.element.Element; import org.apache.click.util.ClickUtils; import org.apache.click.util.DataProvider; @@ -276,20 +279,6 @@ public class Table extends AbstractContr DARK_STYLES.add("report"); } - /** - * The table.css style sheet import link with a light contract sortable icon. - */ - public static final String TABLE_IMPORTS_LIGHT = - "\n" - + "\n"; - - /** - * The table.css style sheet import link with a dark contract sortable icon. - */ - public static final String TABLE_IMPORTS_DARK = - "\n" - + "\n"; - /** The attached style pagination banner position. */ public static final int PAGINATOR_ATTACHED = 1; @@ -818,77 +807,83 @@ public class Table extends AbstractContr *

      * hover:hover { color: navy } 
* - * @param hoverRows specify whether class 'hover' rows attribute is rendered (default false). + * @param hoverRows specify whether class 'hover' rows attribute is rendered + * (default false). */ public void setHoverRows(boolean hoverRows) { this.hoverRows = hoverRows; } /** - * Return the Table HTML head import statements for the following resources: - *

+ * Return the Table HTML HEAD elements for the following resource: + * *

    *
  • click/table.css
  • *
- *

- * Additionally all {@link #getControls() controls} import statements are - * also returned. * - * @return the HTML head import statements for the control stylesheet + * Additionally, the HEAD elements of the {@link #getControlLink()} will + * also be returned. + * + * @return the list of HEAD elements for the Table */ @Override - @SuppressWarnings("deprecation") - public String getHtmlImports() { - HtmlStringBuffer buffer = new HtmlStringBuffer(512); + public List getHeadElements() { + if (headElements == null) { + headElements = super.getHeadElements(); - // Flag indicating which import style to return - boolean useDarkStyle = false; - if (hasAttribute("class")) { + boolean isDarkStyle = isDarkStyle(); - String styleClasses = getAttribute("class"); - - StringTokenizer tokens = new StringTokenizer(styleClasses, " "); - while (tokens.hasMoreTokens()) { - String token = tokens.nextToken(); - if (DARK_STYLES.contains(token)) { - useDarkStyle = true; - break; + Context context = getContext(); + String versionIndicator = ClickUtils.getResourceVersionIndicator(context); + headElements.add(new CssImport("/click/table.css", versionIndicator)); + + String tableId = getId(); + CssStyle cssStyle = new CssStyle(); + cssStyle.setId(tableId + "_css_setup"); + + if (!headElements.contains(cssStyle)) { + String contextPath = context.getRequest().getContextPath(); + HtmlStringBuffer buffer = new HtmlStringBuffer(100); + buffer.append("th.sortable a {\n"); + buffer.append("background: url("); + buffer.append(contextPath); + buffer.append("/click/column-sortable-"); + if (isDarkStyle) { + buffer.append("dark"); + } else { + buffer.append("light"); } - } - } - - if (useDarkStyle) { - buffer.append(ClickUtils.createHtmlImport(TABLE_IMPORTS_DARK, getContext())); - - } else { - buffer.append(ClickUtils.createHtmlImport(TABLE_IMPORTS_LIGHT, getContext())); - } - - if (hasControls()) { - for (int i = 0, size = getControls().size(); i < size; i++) { - Control control = (Control) getControls().get(i); - String htmlImports = control.getHtmlImports(); - if (htmlImports != null) { - buffer.append(htmlImports); + buffer.append(versionIndicator); + buffer.append(".gif)"); + buffer.append(" center right no-repeat;}\n"); + buffer.append("th.ascending a {\n"); + buffer.append("background: url("); + buffer.append(contextPath); + buffer.append("/click/column-ascending-"); + if (isDarkStyle) { + buffer.append("dark"); + } else { + buffer.append("light"); } + buffer.append(versionIndicator); + buffer.append(".gif)"); + buffer.append(" center right no-repeat;}\n"); + buffer.append("th.descending a {\n"); + buffer.append("background: url("); + buffer.append(contextPath); + buffer.append("/click/column-descending-"); + if (isDarkStyle) { + buffer.append("dark"); + } else { + buffer.append("light"); + } + buffer.append(versionIndicator); + buffer.append(".gif)"); + buffer.append(" center right no-repeat;}"); + cssStyle.setContent(buffer.toString()); + headElements.add(cssStyle); } - } - - return buffer.toString(); - } - /** - * Return the HEAD elements for the Table. The HEAD elements of the - * {@link #getControlLink()} will also be included. - * - * @see org.apache.click.Control#getHtmlImports() - * - * @return the list of HEAD elements for the Table - */ - @Override - public List getHeadElements() { - if (headElements == null) { - headElements = super.getHeadElements(); headElements.addAll(getControlLink().getHeadElements()); } return headElements; @@ -1916,4 +1911,30 @@ public class Table extends AbstractContr } } + // Private Methods -------------------------------------------------------- + + /** + * Return true if a dark table style is selected, false otherwise. + * + * @return true if a dark table style is selectd, false otherwise + */ + private boolean isDarkStyle() { + + // Flag indicating which import style to return + boolean isDarkStyle = false; + if (hasAttribute("class")) { + + String styleClasses = getAttribute("class"); + + StringTokenizer tokens = new StringTokenizer(styleClasses, " "); + while (tokens.hasMoreTokens()) { + String token = tokens.nextToken(); + if (DARK_STYLES.contains(token)) { + isDarkStyle = true; + break; + } + } + } + return isDarkStyle; + } }