click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r928397 - in /click/trunk/click/extras/src/org/apache/click/extras/control: AbstractContainerField.java ColorPicker.java
Date Sun, 28 Mar 2010 13:25:42 GMT
Author: sabob
Date: Sun Mar 28 13:25:41 2010
New Revision: 928397

URL: http://svn.apache.org/viewvc?rev=928397&view=rev
Log:
migrated html imports to head elements

Modified:
    click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
    click/trunk/click/extras/src/org/apache/click/extras/control/ColorPicker.java

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java?rev=928397&r1=928396&r2=928397&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
(original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/AbstractContainerField.java
Sun Mar 28 13:25:41 2010
@@ -196,6 +196,7 @@ public abstract class AbstractContainerF
      * @throws IllegalArgumentException if the given parent instance is
      * referencing <tt>this</tt> object: <tt>if (parent == this)</tt>
      */
+    @Override
     public void setParent(Object parent) {
         if (parent == this) {
             throw new IllegalArgumentException("Cannot set parent to itself");
@@ -211,6 +212,7 @@ public abstract class AbstractContainerF
      * @return the HTML includes statements for the contained control stylesheet
      * and JavaScript files
      */
+    @Override
     @SuppressWarnings("deprecation")
     public String getHtmlImports() {
         if (hasControls()) {
@@ -247,6 +249,7 @@ public abstract class AbstractContainerF
      *
      * @see org.apache.click.control.Field#getRequestValue()
      */
+    @Override
     public void bindRequestValue() {
     }
 
@@ -255,6 +258,7 @@ public abstract class AbstractContainerF
      *
      * @return true to continue Page event processing or false otherwise
      */
+    @Override
     public boolean onProcess() {
         boolean continueProcessing = super.onProcess();
 
@@ -271,6 +275,7 @@ public abstract class AbstractContainerF
     /**
      * @see org.apache.click.Control#onDestroy()
      */
+    @Override
     public void onDestroy() {
         if (hasControls()) {
             for (int i = 0, size = getControls().size(); i < size; i++) {
@@ -287,6 +292,7 @@ public abstract class AbstractContainerF
     /**
      * @see org.apache.click.Control#onInit()
      */
+    @Override
     public void onInit() {
         super.onInit();
         if (hasControls()) {
@@ -300,6 +306,7 @@ public abstract class AbstractContainerF
     /**
      * @see org.apache.click.Control#onRender()
      */
+    @Override
     public void onRender() {
         if (hasControls()) {
             for (int i = 0, size = getControls().size(); i < size; i++) {
@@ -320,6 +327,7 @@ public abstract class AbstractContainerF
      *
      * @param buffer the specified buffer to render the control's output to
      */
+    @Override
     public void render(HtmlStringBuffer buffer) {
 
         //If tag is set, render it
@@ -351,6 +359,7 @@ public abstract class AbstractContainerF
      *
      * @return the HTML representation of this control
      */
+    @Override
     public String toString() {
         HtmlStringBuffer buffer = new HtmlStringBuffer(getControlSizeEst());
         render(buffer);
@@ -365,6 +374,7 @@ public abstract class AbstractContainerF
      * @param tagName the name of the tag to close
      * @param buffer the buffer to append the output to
      */
+    @Override
     protected void renderTagEnd(String tagName, HtmlStringBuffer buffer) {
         buffer.elementEnd(tagName);
     }
@@ -422,6 +432,7 @@ public abstract class AbstractContainerF
      *
      * @return the estimated rendered control size in characters
      */
+    @Override
     protected int getControlSizeEst() {
         int size = 20;
 

Modified: click/trunk/click/extras/src/org/apache/click/extras/control/ColorPicker.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/control/ColorPicker.java?rev=928397&r1=928396&r2=928397&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/control/ColorPicker.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/control/ColorPicker.java Sun Mar
28 13:25:41 2010
@@ -20,12 +20,15 @@ package org.apache.click.extras.control;
 
 import java.text.MessageFormat;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.click.Context;
 import org.apache.click.control.Field;
+import org.apache.click.element.CssImport;
+import org.apache.click.element.JsImport;
 import org.apache.click.util.ClickUtils;
 import org.apache.click.util.HtmlStringBuffer;
 
@@ -90,16 +93,10 @@ import org.apache.click.util.HtmlStringB
  */
 public class ColorPicker extends Field {
 
-    // -------------------------------------------------------------- Constants
+    // Constants --------------------------------------------------------------
 
     private static final long serialVersionUID = 1L;
 
-    /** The ColorPicker imports statements. */
-    static final String HTML_IMPORTS =
-        "<link type=\"text/css\" rel=\"stylesheet\" href=\"{0}/click/colorpicker/colorpicker{1}.css\"/>\n"
-        + "<script type=\"text/javascript\" src=\"{0}/click/prototype/prototype{1}.js\"></script>\n"
-        + "<script type=\"text/javascript\" src=\"{0}/click/colorpicker/colorpicker{1}.js\"></script>\n";
-
     /** The color validation hexadecimal pattern. */
     static final Pattern HEX_PATTERN =
         Pattern.compile("#[a-fA-F0-9]{3}([a-fA-F0-9]{3})?");
@@ -124,7 +121,7 @@ public class ColorPicker extends Field {
         + "   '}'\n"
         + "'}'\n";
 
-    // ----------------------------------------------------- Instance Variables
+    // Instance Variables -----------------------------------------------------
 
     /**
      * The show text field option for entering a color hex value. The default
@@ -135,7 +132,7 @@ public class ColorPicker extends Field {
     /** The text field size attribute. The default size is 7. */
     protected int size = 7;
 
-    // ----------------------------------------------------------- Constructors
+    // Constructors -----------------------------------------------------------
 
     /**
      * Construct a ColorPicker with the given name. The color picker will show
@@ -190,10 +187,10 @@ public class ColorPicker extends Field {
         super();
     }
 
-    // ------------------------------------------------------ Public Attributes
+    // Public Attributes ------------------------------------------------------
 
     /**
-     * Return the ColorPicker HTML head imports statements for the following
+     * Return the ColorPicker HTML HEAD elements for the following
      * resources:
      * <p/>
      * <ul>
@@ -202,12 +199,23 @@ public class ColorPicker extends Field {
      * <li><tt>click/colorpicker/colorpicker.js</tt></li>
      * </ul>
      *
-     * @see org.apache.click.Control#getHtmlImports()
+     * @see org.apache.click.Control#getHeadElements()
      *
-     * @return the HTML head import statements for the control
+     * @return the HTML HEAD elements for the control
      */
-    public String getHtmlImports() {
-        return ClickUtils.createHtmlImport(HTML_IMPORTS, getContext());
+    @Override
+    public List getHeadElements() {
+        if (headElements == null) {
+            headElements = super.getHeadElements();
+
+            Context context = getContext();
+            String versionIndicator = ClickUtils.getResourceVersionIndicator(context);
+
+            headElements.add(new CssImport("/click/colorpicker/colorpicker.css", versionIndicator));
+            headElements.add(new JsImport("/click/prototype/prototype.js", versionIndicator));
+            headElements.add(new JsImport("/click/colorpicker/colorpicker.js", versionIndicator));
+        }
+        return headElements;
     }
 
     /**
@@ -258,6 +266,7 @@ public class ColorPicker extends Field {
      *
      * @return the field JavaScript client side validation function
      */
+    @Override
     public String getValidationJavaScript() {
         Object[] args = new Object[9];
         args[0] = getId();
@@ -267,13 +276,14 @@ public class ColorPicker extends Field {
         return MessageFormat.format(VALIDATE_COLORPICKER_FUNCTION, args);
     }
 
-    // --------------------------------------------------------- Public Methods
+    // Public Methods ---------------------------------------------------------
 
     /**
      * @see org.apache.click.control.AbstractControl#getControlSizeEst()
      *
      * @return the estimated rendered control size in characters
      */
+    @Override
     public int getControlSizeEst() {
         return 96;
     }
@@ -285,6 +295,7 @@ public class ColorPicker extends Field {
      *
      * @param buffer the specified buffer to render the control's output to
      */
+    @Override
     public void render(HtmlStringBuffer buffer) {
         Context context = getContext();
         Map values = new HashMap();
@@ -342,6 +353,7 @@ public class ColorPicker extends Field {
      *
      * @return a HTML rendered ColorPicker string
      */
+    @Override
     public String toString() {
         HtmlStringBuffer buffer = new HtmlStringBuffer(getControlSizeEst());
         render(buffer);
@@ -354,6 +366,7 @@ public class ColorPicker extends Field {
      *
      * @see org.apache.click.control.TextField#validate()
      */
+    @Override
     public void validate() {
         setError(null);
 
@@ -372,7 +385,7 @@ public class ColorPicker extends Field {
         }
     }
 
-    // -------------------------------------------------------- Protected Methods
+    // Protected Methods ------------------------------------------------------
 
     /**
      * Render a Velocity template for the given data model.
@@ -384,7 +397,7 @@ public class ColorPicker extends Field {
         buffer.append(getContext().renderTemplate(ColorPicker.class, model));
     }
 
-    // -------------------------------------------------------- Private Methods
+    // Private Methods --------------------------------------------------------
 
     private boolean isColor(String value) {
         if (value == null) {



Mime
View raw message