Author: andrei_exadel
Date: 2009-03-25 12:27:11 -0400 (Wed, 25 Mar 2009)
New Revision: 13185
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_left_dis.png
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_right_dis.png
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/imageScroller.xhtml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_left.png
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_right.png
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageInfo.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld.css
Log:
scroller for image list
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java 2009-03-25
16:27:11 UTC (rev 13185)
@@ -0,0 +1,112 @@
+/**
+ *
+ */
+package org.richfaces.realworld.tags;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.component.UIDatascroller;
+import org.richfaces.renderkit.html.DatascrollerTemplate;
+
+/**
+ * @author Andrey Markavtsov
+ *
+ */
+public class RealworldImageScrollerRenderer extends DatascrollerTemplate {
+
+ @Override
+ public void renderPager(FacesContext context, UIComponent component,
+ int pageIndex, int count) throws IOException {
+ ResponseWriter out = context.getResponseWriter();
+ UIDatascroller scroller = (UIDatascroller) component;
+ int currentPage = pageIndex;
+
+ int maxPages = scroller.getMaxPages();
+ if (maxPages <= 1) {
+ maxPages = 1;
+ }
+
+ int pageCount = count;
+ if (pageCount <= 1) {
+ return;
+ }
+
+ int delta = maxPages / 2;
+
+ int pages;
+ int start;
+ if (pageCount > maxPages && currentPage > delta) {
+ pages = maxPages;
+ start = currentPage - pages / 2 - 1;
+ if (start + pages > pageCount) {
+ start = pageCount - pages;
+ }
+ } else {
+ pages = pageCount < maxPages ? pageCount : maxPages;
+ start = 0;
+ }
+
+ for (int i = start, size = start + pages; i < size; i++) {
+
+ boolean isCurrentPage = (i + 1 == currentPage);
+ String styleClass;
+ String style;
+ if (isCurrentPage) {
+ styleClass = scroller.getSelectedStyleClass();
+ style = scroller.getSelectedStyle();
+ } else {
+ styleClass = scroller.getInactiveStyleClass();
+ style = scroller.getInactiveStyle();
+ }
+ if (styleClass==null){
+ styleClass="";
+ }
+
+ out.startElement("td", component);
+ out.startElement("div", component);
+
+ if (!isCurrentPage) {
+ out.writeAttribute("onclick", getOnClick(Integer.toString(i +
1)), null);
+ }
+
+ renderPageVar(context, component, i);
+
+ if (isCurrentPage) {
+ out.writeAttribute("class", styleClass, null);
+ UIComponent facet = component.getFacet("activePage");
+ if (facet != null) {
+ renderChild(context, facet);
+ }
+ } else {
+ out.writeAttribute("class", styleClass, null);
+ UIComponent facet = component.getFacet("inactivePage");
+ if (facet != null) {
+ renderChild(context, facet);
+ }
+ }
+ if (null != style) out.writeAttribute("style", style, null);
+ //out.writeText(Integer.toString(i + 1), null);
+ //renderChild(context, link);
+ out.endElement("div");
+ out.endElement("td");
+ }
+ }
+
+ void renderPageVar(FacesContext context, UIComponent component, int i) {
+ String varName = (String) component.getAttributes().get("pageVar");
+ if (varName != null && varName.length() > 0) {
+ context.getExternalContext()
+ .getRequestMap().put(varName, new Integer(i));
+ }
+ }
+
+ @Override
+ protected Class getComponentClass() {
+ return super.getComponentClass();
+ }
+
+}
Modified: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml 2009-03-25
16:26:45 UTC (rev 13184)
+++
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml 2009-03-25
16:27:11 UTC (rev 13185)
@@ -21,5 +21,10 @@
<renderer-type>org.ajax4jsf.components.RealworldAjaxCommandButtonRenderer</renderer-type>
<renderer-class>org.richfaces.realworld.tags.RealworldCommandButtonRenderer</renderer-class>
</renderer>
+ <renderer>
+ <component-family>org.richfaces.Datascroller</component-family>
+ <renderer-type>org.ajax4jsf.components.RealworldImageDataScroller</renderer-type>
+ <renderer-class>org.richfaces.realworld.tags.RealworldImageScrollerRenderer</renderer-class>
+ </renderer>
</render-kit>
</faces-config>
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml 2009-03-25
16:26:45 UTC (rev 13184)
+++
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml 2009-03-25
16:27:11 UTC (rev 13185)
@@ -27,4 +27,11 @@
<renderer-type>org.ajax4jsf.components.RealworldAjaxCommandButtonRenderer</renderer-type>
</component>
</tag>
+ <tag>
+ <tag-name>imageDataScroller</tag-name>
+ <component>
+ <component-type>org.richfaces.Datascroller</component-type>
+
<renderer-type>org.ajax4jsf.components.RealworldImageDataScroller</renderer-type>
+ </component>
+ </tag>
</facelet-taglib>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_left.png
===================================================================
(Binary files differ)
Added: trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_left_dis.png
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_left_dis.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_right.png
===================================================================
(Binary files differ)
Added: trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_right_dis.png
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/arr_right_dis.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageInfo.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/imageScroller.xhtml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/imageScroller.xhtml
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/imageScroller.xhtml 2009-03-25
16:27:11 UTC (rev 13185)
@@ -0,0 +1,74 @@
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:richx="http://richfaces.org/richx">
+
+<style>
+.rich-datascr-button {
+ background-color: #CECECE;
+}
+</style>
+
+<richx:imageDataScroller reRender="tree"
+ scrollerListener="#{controller.scroll}" id="imageScroller"
+ fastControls="hide"
+ boundaryControls="hide"
+ pageVar="pageVar"
+ styleClass="imageScroller"
+ inactiveStyleClass="imageScroller-inactive"
+ tableStyleClass="imageScroller-table"
+ maxPages="5"
+ for="mainImage" align="left"
page="#{model.selectedImageIndex}">
+ <f:facet name="activePage">
+ <h:panelGroup layout="block" styleClass="preview_box_photo_80"
style="margin: 0px; margin-right: 3px">
+ <h:graphicImage style="border: 2px solid red"
styleClass="pr_photo_bg" value="/img/shell/frame_photo_80.png" />
+ <h:panelGrid cellpadding="0">
+ <h:panelGroup>
+ <a4j:mediaOutput element="img"
+ createContent="#{imageLoader.paintImage}"
+ style="border : 2px solid #FFFFFF;"
+ value="#{fileManager.transformPath(model.selectedAlbum.images[pageVar].path,
'_small80')}">
+ <f:param value="#{imageSizeHelper.currentDimension.x}"
name="x" />
+ </a4j:mediaOutput>
+ <br/>
+ </h:panelGroup>
+ </h:panelGrid>
+ <h:panelGroup layout="block"
styleClass="photo_name">#{model.selectedAlbum.images[pageVar].name}</h:panelGroup>
+ <h:panelGroup layout="block"
styleClass="photo_data">#{pageVar+1}</h:panelGroup>
+ </h:panelGroup>
+ </f:facet>
+ <f:facet name="inactivePage">
+ <h:panelGroup layout="block" styleClass="preview_box_photo_80"
style="margin: 0px">
+ <h:graphicImage styleClass="pr_photo_bg"
value="/img/shell/frame_photo_80.png" />
+ <h:panelGrid cellpadding="0">
+ <h:panelGroup>
+ <a4j:mediaOutput element="img"
+ createContent="#{imageLoader.paintImage}"
+ style="border : 2px solid #FFFFFF;"
+ value="#{fileManager.transformPath(model.selectedAlbum.images[pageVar].path,
'_small80')}">
+ <f:param value="#{imageSizeHelper.currentDimension.x}"
name="x" />
+ </a4j:mediaOutput>
+ <br/>
+ </h:panelGroup>
+ </h:panelGrid>
+ <h:panelGroup layout="block"
styleClass="photo_name">#{model.selectedAlbum.images[pageVar].name}</h:panelGroup>
+ <h:panelGroup layout="block"
styleClass="photo_data">#{pageVar+1}</h:panelGroup>
+ </h:panelGroup>
+ </f:facet>
+ <f:facet name="previous">
+ <h:graphicImage styleClass="imageScroller-leftArr"
value="img/shell/arr_left.png"></h:graphicImage>
+ </f:facet>
+ <f:facet name="previous_disabled">
+ <h:graphicImage styleClass="imageScroller-leftArr"
value="img/shell/arr_left_dis.png"></h:graphicImage>
+ </f:facet>
+ <f:facet name="next">
+ <h:graphicImage styleClass="imageScroller-rightArr"
value="img/shell/arr_right.png"></h:graphicImage>
+ </f:facet>
+ <f:facet name="next_disabled">
+ <h:graphicImage styleClass="imageScroller-rightArr"
value="img/shell/arr_right_dis.png"></h:graphicImage>
+ </f:facet>
+ </richx:imageDataScroller>
+</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld.css
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld.css 2009-03-25
16:26:45 UTC (rev 13184)
+++
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld.css 2009-03-25
16:27:11 UTC (rev 13185)
@@ -876,4 +876,40 @@
width : 155px;
padding: 5px;
font-weight: bold;
-}
\ No newline at end of file
+}
+
+.imageScroller {
+ border: none;
+ position: relative;
+ float: left;
+ background-color: #CECECE;
+}
+
+.imageScroller-inactive table {
+ border: none;
+ cursor: pointer;
+}
+
+.imageScroller-table {
+ border: none;
+ background-color: #CECECE;
+}
+
+.imageScroller-table td {
+ border: none;
+}
+
+.imageScroller-leftArr {
+ position: absolute;
+ left: -10px;
+ bottom: 5px;
+ z-index: 2;
+}
+
+.imageScroller-rightArr {
+ position: absolute;
+ right: -10px;
+ bottom: 5px;
+ z-index: 2;
+}
+