Author: sergeyhalipov
Date: 2007-11-08 14:49:02 -0500 (Thu, 08 Nov 2007)
New Revision: 3835
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBase.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBottom.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconDown.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconTop.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconUp.java
Modified:
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
Icon images added to ordering list.
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBase.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBase.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBase.java 2007-11-08
19:49:02 UTC (rev 3835)
@@ -0,0 +1,129 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+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 Siarhej Chalipau
+ *
+ */
+public abstract class OrderingListIconBase extends Java2Dresource {
+
+ public OrderingListIconBase() {
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ abstract protected void paintImage(ResourceContext context, Graphics2D g2d, Color
textColor);
+
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+
+ int [] data = (int[]) restoreData(context);
+ Color textColor = new Color(data[0]);
+ Color backgroundColor = new Color(data[1]);
+
+ // TODO hans - Cosmetic changes for icons needed.
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_ENABLE);
+
+ Dimension dim = getDimensions(context);
+ g2d.setColor(backgroundColor);
+ g2d.fillRect(0, 0, dim.width, dim.height);
+
+ if (textColor != null && backgroundColor != null && g2d != null) {
+ paintImage(context, g2d, textColor);
+ }
+
+ }
+
+ protected Dimension calculateDimensions(Object data){
+ return new Dimension(16, 16);
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return calculateDimensions(getDataToStore(facesContext, data));
+ }
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return calculateDimensions(restoreData(resourceContext));
+ }
+
+ /**
+ * @param data - pass icon color and background color
+ */
+ protected Object getDataToStore(FacesContext context, Object data) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
+
+ int [] ret = new int[2];
+
+ Color color = null;
+
+ String skinParameter = "headerTextColor";
+ String color1 = (String) skin.getParameter(context, skinParameter);
+ if (null == color1 || "".equals(color1))
+ color1 = (String) defaultSkin.getParameter(context, skinParameter);
+
+ if (color1 == null) {
+ color1 = "#FFFFFF";
+ }
+
+ color = HtmlColor.decode(color1);
+
+ ret[0] = color.getRGB();
+
+ skinParameter = "headerBackgroundColor";
+ String color2 = (String) skin.getParameter(context, skinParameter);
+ if (null == color2 || "".equals(color2))
+ color2 = (String) defaultSkin.getParameter(context, skinParameter);
+
+ if (color2 == null) {
+ color2 = "#000000";
+ }
+
+ color = HtmlColor.decode(color2);
+ ret[1] = color.getRGB();
+
+ return ret;
+ }
+
+ public boolean isCacheable() {
+ return true;
+ }
+
+}
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBottom.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBottom.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconBottom.java 2007-11-08
19:49:02 UTC (rev 3835)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Siarhej Chalipau
+ *
+ */
+public class OrderingListIconBottom extends OrderingListIconBase {
+
+ @Override
+ protected void paintImage(ResourceContext context, Graphics2D g2d,
+ Color textColor) {
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+
+ g2d.setColor(textColor);
+
+ g2d.drawRect(31, 108, 67, 2);
+
+ g2d.translate(31,38);
+ path.moveTo(0,0);
+ path.lineTo(33,33);
+ path.lineTo(34,33);
+ path.lineTo(67,0);
+ path.closePath();
+ g2d.fill(path);
+
+ g2d.translate(0,35);
+ path.moveTo(0,0);
+ path.lineTo(33,33);
+ path.lineTo(34,33);
+ path.lineTo(67,0);
+ path.closePath();
+ g2d.fill(path);
+ }
+
+}
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconDown.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconDown.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconDown.java 2007-11-08
19:49:02 UTC (rev 3835)
@@ -0,0 +1,57 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Siarhej Chalipau
+ *
+ */
+public class OrderingListIconDown extends OrderingListIconBase {
+
+ @Override
+ protected void paintImage(ResourceContext context, Graphics2D g2d,
+ Color textColor) {
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+
+ g2d.translate(31,54);
+ path.moveTo(0,0);
+ path.lineTo(33,33);
+ path.lineTo(34,33);
+ path.lineTo(67,0);
+ path.closePath();
+
+ g2d.setColor(textColor);
+ g2d.fill(path);
+ }
+
+}
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconTop.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconTop.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconTop.java 2007-11-08
19:49:02 UTC (rev 3835)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Siarhej Chalipau
+ *
+ */
+public class OrderingListIconTop extends OrderingListIconBase {
+
+ @Override
+ protected void paintImage(ResourceContext context, Graphics2D g2d,
+ Color textColor) {
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+
+ g2d.setColor(textColor);
+
+ g2d.drawRect(31, 29, 67, 2);
+
+ g2d.translate(31,31);
+ path.moveTo(0,33);
+ path.lineTo(33,0);
+ path.lineTo(34,0);
+ path.lineTo(67,33);
+ path.closePath();
+ g2d.fill(path);
+
+ g2d.translate(0,35);
+ path.moveTo(0,33);
+ path.lineTo(33,0);
+ path.lineTo(34,0);
+ path.lineTo(67,33);
+ path.closePath();
+ g2d.fill(path);
+ }
+
+}
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconUp.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconUp.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/images/OrderingListIconUp.java 2007-11-08
19:49:02 UTC (rev 3835)
@@ -0,0 +1,56 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author Siarhej Chalipau
+ *
+ */
+public class OrderingListIconUp extends OrderingListIconBase {
+
+ @Override
+ protected void paintImage(ResourceContext context, Graphics2D g2d,
+ Color textColor) {
+ GeneralPath path = new GeneralPath();
+
+ Dimension dimension = getDimensions(context);
+ g2d.scale(dimension.getHeight()/128,dimension.getHeight()/128);
+
+ g2d.translate(31,47);
+ path.moveTo(0,33);
+ path.lineTo(33,0);
+ path.lineTo(34,0);
+ path.lineTo(67,33);
+ path.closePath();
+
+ g2d.setColor(textColor);
+ g2d.fill(path);
+ }
+
+}
Modified:
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-08
19:44:02 UTC (rev 3834)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-08
19:49:02 UTC (rev 3835)
@@ -11,11 +11,30 @@
<h:styles>css/orderingList.xcss</h:styles>
- <h:scripts>
- scripts/SelectItem.js,scripts/LayoutManager.js,scripts/OrderingList.js
+ <h:scripts>
+ scripts/SelectItem.js,
+ scripts/OrderingList.js,
+ scripts/LayoutManager.js
</h:scripts>
- <f:clientId var="clientId"/>
+ <f:clientId var="clientId"/>
+
+ <f:resource
+ name="images/spacer.gif"
+ var="spacer" />
+ <f:resource
+ name="org.richfaces.renderkit.html.images.OrderingListIconDown"
+ var="downIcon" />
+ <f:resource
+ name="org.richfaces.renderkit.html.images.OrderingListIconUp"
+ var="upIcon" />
+ <f:resource
+ name="org.richfaces.renderkit.html.images.OrderingListIconTop"
+ var="topIcon" />
+ <f:resource
+ name="org.richfaces.renderkit.html.images.OrderingListIconBottom"
+ var="bottomIcon" />
+
<div id="#{clientId}" x:passThruWithExclusions="id">
<input id="#{clientId}focusKeeper" type="button"
value="" style="position: absolute; left: -32767px;"
name="focusKeeper"/>
<input id="#{clientId}valueKeeper" type="hidden"
name="#{clientId}" value="#{component.submittedValueAsString}"/>
@@ -43,11 +62,23 @@
</tr>
</table>
<f:clientId var="clientId"/>
- <a id="#{clientId}sortLabel"
href="#">Header</a><br/>
- <a id="#{clientId}up" href="#" >up</a><br/>
- <a id="#{clientId}down" href="#" >down</a><br/>
- <a id="#{clientId}first" href="#"
>first</a><br/>
- <a id="#{clientId}last" href="#" >last</a>
+ <a id="#{clientId}sortLabel" href="#">Header</a>
+ <img src="#{spacer}" border="0" width="1"
height="1"/>
+ <a id="#{clientId}up" href="#" >
+ <img src="#{upIcon}" border="0" />
+ </a>
+ <img src="#{spacer}" border="0" width="1"
height="1"/>
+ <a id="#{clientId}down" href="#" >
+ <img src="#{downIcon}" border="0" />
+ </a>
+ <img src="#{spacer}" border="0" width="1"
height="1"/>
+ <a id="#{clientId}first" href="#" >
+ <img src="#{topIcon}" border="0" />
+ </a>
+ <img src="#{spacer}" border="0" width="1"
height="1"/>
+ <a id="#{clientId}last" href="#" >
+ <img src="#{bottomIcon}" border="0" />
+ </a>
</div>
<f:clientId var="cId"/>
<script type="text/javascript">