/* * Copyright (c) Blue Fish Development Group 1996-2004. All rights reserved. * * This version: * $Author: jduke $ * $Date: 2005/01/04 18:27:10 $ * $Id: ColorInputTag.java,v 1.1 2005/01/04 18:27:10 jduke Exp $ */ package com.bluefishgroup.bedrock.wdk.control; import java.io.IOException; import javax.servlet.jsp.JspWriter; import com.documentum.web.form.Control; import com.documentum.web.form.ControlTag; import com.documentum.web.form.Util; import com.documentum.web.util.SafeHTMLString; /** * Tag class for the ColorInput control. * * @author Jason Duke * @version $Revision: 1.1 $ */ public class ColorInputTag extends ControlTag { /** CSS Class to use by default for the amount textbox and the currency dropdown */ private static final String DEFAULT_CLASS = "defaultTextStyle"; /** Size for the HTML text element containing the amount. */ private String _size = null; /** Whether or not enter while on textbox should submit the form */ private Boolean _defaultOnEnter = null; /** The red component */ private String _red = null; /** The green component */ private String _green = null; /** The blue component */ private String _blue = null; /** The size to use for each color component's textbox */ public static final char DEFAULT_SIZE = 5; /* * (non-Javadoc) * * @see com.documentum.web.form.ControlTag#getControlClass() */ protected Class getControlClass() { return ColorInput.class; } /* * (non-Javadoc) * * @see com.documentum.web.form.ControlTag#release() */ public void release() { super.release(); _size = null; _defaultOnEnter = null; _red = null; _green = null; _blue = null; } /** * Sets the default on enter property * * @param defaultOnEnter the default on enter property */ public void setDefaultonenter(String strDefaultOnEnter) { _defaultOnEnter = new Boolean(strDefaultOnEnter); } /** * Gets the default on enter property * * @return the default on enter property */ public Boolean isDefaultOnEnter() { return _defaultOnEnter; } /** * Sets the size property * * @param strSize the size property */ public void setSize(String size) { _size = size; } /** * Gets the size property * * @return the size property */ public String getSize() { return _size; } /** * Returns the blue. * * @return the blue */ public String getBlue() { return _blue; } /** * Sets the blue. * * @param blue the blue */ public void setBlue(String blue) { _blue = blue; } /** * Returns the green. * * @return the green */ public String getGreen() { return _green; } /** * Sets the green. * * @param green the green */ public void setGreen(String green) { _green = green; } /** * Returns the red. * * @return the red */ public String getRed() { return _red; } /** * Sets the red. * * @param red the red */ public void setRed(String red) { _red = red; } /** * Render the control HTML. * * @param out The JspWriter to write output to. */ protected void renderEnd(JspWriter out) throws IOException { ColorInput colorInput = (ColorInput) getControl(); if (colorInput.isVisible()) { StringBuffer buf = new StringBuffer(128); renderComponentInputs(colorInput, buf); out.print(buf.toString()); } } /** * Renders the HTML for a single color component (red, green, or blue) to the given * StringBuffer. * * @param colorInput the ColorInput control object * @param propertyName property name, used to give the generated HTML form element a unique name * @param value the value of the color component being rendered * @param buf the StringBuffer to use for output */ protected void renderComponentInput(ColorInput colorInput, String propertyName, Float value, StringBuffer buf) { String size = colorInput.getSize(); String cssClass = colorInput.getCssClass(); String cssStyle = colorInput.getCssStyle(); buf.append("'); } /** * Renders all three component color HTML input elements, using an HTML table to format them. * * @param colorInput the control * @param buf the StringBuffer to use for output */ protected void renderComponentInputs(ColorInput colorInput, StringBuffer buf) { Float red = colorInput.getRed(); Float green = colorInput.getGreen(); Float blue = colorInput.getBlue(); buf.append(""); // Render color bars over each textbox. // TODO: Make this optional using a tag attribute. buf.append(""); buf.append(""); buf.append(""); // TODO: Implement optional tag attributes with NLS strings to label each color component. buf.append(""); buf.append(""); buf.append(""); buf.append(""); buf.append(""); buf.append(""); buf.append(""); buf.append("
"); buf.append(""); buf.append(""); buf.append(""); buf.append(""); buf.append(""); buf.append("
 "); renderComponentInput(colorInput, ColorInput.PROPERTY_RED, red, buf); buf.append(" "); renderComponentInput(colorInput, ColorInput.PROPERTY_GREEN, green, buf); buf.append(" "); renderComponentInput(colorInput, ColorInput.PROPERTY_BLUE, blue, buf); buf.append("
"); } /* * (non-Javadoc) * * @see com.documentum.web.form.ControlTag#setControlProperties(com.documentum.web.form.Control) */ protected void setControlProperties(Control control) { // Let the super do its thing. super.setControlProperties(control); // Get the control as a ColorInput. ColorInput colorInput = (ColorInput) control; // Set control properties from the tag arguments if (isDefaultOnEnter() != null) { colorInput.setDefaultOnEnter(_defaultOnEnter.booleanValue()); } if (getSize() != null) { colorInput.setSize(getSize()); } if (getRed() != null) { colorInput.setRed(getRed()); } if (getGreen() != null) { colorInput.setGreen(getGreen()); } if (getBlue() != null) { colorInput.setBlue(getBlue()); } } } /* * $Log: ColorInputTag.java,v $ * Revision 1.1 2005/01/04 18:27:10 jduke * Initial checkin of article "Creating Simple WDK Controls", along with associated resources. Article is incomplete. * */