Author: abelevich
Date: 2008-01-03 05:43:47 -0500 (Thu, 03 Jan 2008)
New Revision: 5121
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListArrowImageBase.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonGradient.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonLightGradient.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonPressGradient.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListLeftArrowImage.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListRightArrowImage.java
Modified:
trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
Log:
add Button Arrows, Gradient
Modified: trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
===================================================================
--- trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2008-01-03 09:55:42
UTC (rev 5120)
+++ trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2008-01-03 10:43:47
UTC (rev 5121)
@@ -108,14 +108,7 @@
<name>onStart</name>
<classname>java.lang.String</classname>
</property>
-
- <property>
- <name>width</name>
- <classname>java.lang.String</classname>
- <defaultvalue>"70px"</defaultvalue>
- </property>
-
-
+
</properties>
</component>
Modified:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-01-03
09:55:42 UTC (rev 5120)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -36,12 +36,15 @@
private static final String FUNCTION_ADD_TO_SELECTED =
"myfaces_picklist_addToSelected";
private static final String FUNCTION_REMOVE_FROM_SELECTED =
"myfaces_picklist_removeFromSelected";
private final InternetResource[] scripts =
{getResource("/org/richfaces/renderkit/html/scripts/picklist.js")};
-
+ private final InternetResource[] styles =
{getResource("/org/richfaces/renderkit/html/css/picklist.xcss")};
protected InternetResource[] getScripts() {
return scripts;
}
+ protected InternetResource[] getStyles() {
+ return styles;
+ }
protected List selectItemsForSelectedList(FacesContext facesContext,UIComponent
uiComponent, List selectItemList, Converter converter, Set lookupSet) {
List selectItemForSelectedValues = new ArrayList(lookupSet.size());
for (Iterator i = selectItemList.iterator(); i.hasNext();) {
@@ -136,7 +139,7 @@
writer.startElement("table", picklist);
writer.startElement(HTML.TR_ELEMENT, picklist);
writer.startElement(HTML.td_ELEM, picklist);
-
+
encodeSelect(context, picklist, availableListClientId, picklist.isDisabled(),
picklist.getSize(), selectItemsForAvailableList, converter, writer);
writer.endElement(HTML.td_ELEM);
@@ -151,20 +154,19 @@
+ "('" + availableListClientId +
"','" + selectedListClientId
+ "','" + hiddenFieldCliendId
+ "')";
- encodeSwapButton(context, picklist, javascriptAddToSelected,">",writer);
+ encodeSwapButton(context, picklist, javascriptAddToSelected,true,writer);
writer.startElement("br", picklist);
writer.endElement("br");
- encodeSwapButton(context, picklist, javascriptRemoveFromSelected, "<",
writer);
+ encodeSwapButton(context, picklist, javascriptRemoveFromSelected, false, writer);
writer.endElement(HTML.td_ELEM);
// encode selected list
writer.startElement(HTML.td_ELEM, picklist);
-
encodeSelect(context, picklist, selectedListClientId, picklist.isDisabled(),
picklist.getSize(),
- selectItemsForSelectedValues, converter, writer);
+ selectItemsForSelectedValues, converter, writer);
// hidden field with the selected values
encodeHiddenField(context, picklist, hiddenFieldCliendId, lookupSet,writer);
@@ -181,11 +183,12 @@
writer.writeAttribute("id", clientId, "id");
writer.writeAttribute("name", clientId, null);
writer.writeAttribute("multiple", "true", null);
- String width = (String) component.getAttributes().get("width");
- if(width != null) {
- writer.writeAttribute("style", "width: " + width + ";",
null);
- }
-
+ writer.writeAttribute("class", "rich-pick-list
rich-pick-list-outputlist", null);
+ String outputStyle =
(String)component.getAttributes().get("outputStyle");
+ String outputStyleClass =
(String)component.getAttributes().get("outputStyleClass");
+ writer.writeAttribute(HTML.style_ATTRIBUTE, outputStyle, null);
+ writer.writeAttribute(HTML.STYLE_CLASS_ATTR, outputStyleClass, null);
+
if (size == 0) {
writer.writeAttribute("size", Integer.toString(selectItemsToDisplay.size()),
null);
} else {
@@ -256,17 +259,42 @@
}
}
- private void encodeSwapButton(FacesContext facesContext, UIComponent uiComponent,
String javaScriptFunction,
- String text,ResponseWriter writer) throws IOException {
+ private void encodeSwapButton(FacesContext context, UIComponent component, String
javaScriptFunction,
+ boolean isRight,ResponseWriter writer) throws IOException {
- writer.startElement(HTML.INPUT_ELEM, uiComponent);
- writer.writeAttribute(HTML.TYPE_ATTR,"button","type");
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, javaScriptFunction, null);
- writer.writeAttribute(HTML.value_ATTRIBUTE, text, null);
- writer.endElement(HTML.INPUT_ELEM);
+ writer.startElement(HTML.BUTTON, component);
+ String buttonStyle = (String)component.getAttributes().get("buttonStyle");
+ String buttonStyleClass =
(String)component.getAttributes().get("buttonStyleClass");
+
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "rich-pick-button" , null);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, buttonStyle, null);
+ writer.writeAttribute(HTML.STYLE_CLASS_ATTR, buttonStyleClass, null);
+
+ writer.writeAttribute("onmouseout",
"this.className='rich-pick-button'", null);
+ writer.writeAttribute("onmouseup",
"this.className='rich-pick-button'", null);
+ writer.writeAttribute("onmousedown",
"this.className='rich-pick-button-press'", null);
+ writer.writeAttribute("onmouseover",
"this.className='rich-pick-button-light'", null);
+
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, javaScriptFunction + "; return
false;", null);
+ writer.startElement(HTML.IMG_ELEMENT, component);
+ String arrowURI = null;
+
+ if(isRight) {
+ arrowURI =
getResource("org.richfaces.renderkit.images.PickListRightArrowImage").getUri(context,
component);
+ } else {
+ arrowURI =
getResource("org.richfaces.renderkit.images.PickListLeftArrowImage").getUri(context,
component);
+ }
+
+ writer.writeAttribute(HTML.src_ATTRIBUTE, arrowURI, null);
+ writer.writeAttribute(HTML.width_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.height_ATTRIBUTE, "15", null);
+ writer.writeAttribute(HTML.alt_ATTRIBUTE, "", null);
+ writer.writeAttribute(HTML.border_ATTRIBUTE, "0", null);
+ writer.endElement(HTML.IMG_ELEMENT);
+ writer.endElement(HTML.BUTTON);
}
- private void encodeHiddenField(FacesContext facesContext, UIComponent component,
+ private void encodeHiddenField(FacesContext context, UIComponent component,
String hiddenFieldCliendId, Set lookupSet, ResponseWriter writer) throws IOException
{
writer.startElement(HTML.INPUT_ELEM, component);
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListArrowImageBase.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListArrowImageBase.java
(rev 0)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListArrowImageBase.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -0,0 +1,63 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.images;
+
+import java.awt.Dimension;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.Zipper2;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PickListArrowImageBase extends Java2Dresource {
+
+ private static final Dimension dimensions = new Dimension(15, 15);
+
+ public PickListArrowImageBase() {
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimensions;
+ }
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimensions;
+ }
+
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray == null) {
+ return null;
+ }
+ return new Integer(new Zipper2(objectArray).nextIntColor());
+ }
+
+ protected Object getDataToStore(FacesContext context, Object data) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ String skinParameter = "headerTextColor";
+ String headerTextColor = (String) skin.getParameter(context, skinParameter);
+ if (null == headerTextColor || "".equals(headerTextColor)) {
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+ headerTextColor = (String) defaultSkin.getParameter(context, skinParameter);
+ }
+
+ int intValue = HtmlColor.decode( headerTextColor == null ?
"#000000":headerTextColor ).getRGB();
+ byte[] ret = new byte[3];
+ new Zipper2(ret).addColor(intValue);
+
+ return ret;
+ }
+
+}
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonGradient.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonGradient.java
(rev 0)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonGradient.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.images;
+
+import org.richfaces.renderkit.html.BaseGradient;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PickListButtonGradient extends BaseGradient {
+ public PickListButtonGradient() {
+ super(30,50,20,"additionalBackgroundColor", "trimColor");
+ }
+}
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonLightGradient.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonLightGradient.java
(rev 0)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonLightGradient.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.images;
+
+import org.richfaces.renderkit.html.BaseGradient;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PickListButtonLightGradient extends BaseGradient {
+ public PickListButtonLightGradient() {
+ super(30,50,20,"additionalBackgroundColor",
"headerGradientColor");
+ }
+}
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonPressGradient.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonPressGradient.java
(rev 0)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListButtonPressGradient.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -0,0 +1,18 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.images;
+
+import org.richfaces.renderkit.html.BaseGradient;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PickListButtonPressGradient extends BaseGradient {
+ public PickListButtonPressGradient() {
+ super(30,50,20,"additionalBackgroundColor", "trimColor");
+
+ }
+
+}
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListLeftArrowImage.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListLeftArrowImage.java
(rev 0)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListLeftArrowImage.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -0,0 +1,25 @@
+package org.richfaces.renderkit.images;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PickListLeftArrowImage extends PickListArrowImageBase{
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ Integer color = (Integer) restoreData(context);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setColor(new Color(color.intValue()));
+ g2d.drawLine(9,5,9,11);
+ g2d.drawLine(8,6,8,10);
+ g2d.drawLine(7,7,7,9);
+ g2d.drawLine(6,8,6,8);
+ }
+
+}
Added:
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListRightArrowImage.java
===================================================================
---
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListRightArrowImage.java
(rev 0)
+++
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/images/PickListRightArrowImage.java 2008-01-03
10:43:47 UTC (rev 5121)
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.images;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class PickListRightArrowImage extends PickListArrowImageBase {
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ Integer color = (Integer) restoreData(context);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setColor(new Color(color.intValue()));
+ g2d.drawLine(9,8,9,8);
+ g2d.drawLine(8,7,8,9);
+ g2d.drawLine(7,6,7,10);
+ g2d.drawLine(6,5,6,11);
+ }
+}