Author: vmolotkov
Date: 2007-11-02 11:42:09 -0400 (Fri, 02 Nov 2007)
New Revision: 3724
Added:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
layoutManager for OrderingList was added, fixed table header,
css styles for header and content tables
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-02
15:27:22 UTC (rev 3723)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-02
15:42:09 UTC (rev 3724)
@@ -3,12 +3,16 @@
import java.util.Iterator;
import java.util.List;
+import javax.faces.component.UIColumn;
+
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.RepeatState;
import org.ajax4jsf.model.SequenceDataModel;
+import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.EmptyIterator;
+import org.apache.commons.collections.iterators.FilterIterator;
public abstract class UIOrderingList extends UIDataAdaptor {
@@ -18,6 +22,14 @@
private Object activeItem;
+ public static final Predicate isColumn = new ColumnPredicate();
+
+ private static final class ColumnPredicate implements Predicate {
+ public boolean evaluate(Object input) {
+ return (input instanceof UIColumn || input instanceof Column);
+ }
+ }
+
@Override
protected DataComponentState createComponentState() {
return new RepeatState();
@@ -69,4 +81,8 @@
public void setActiveItem(Object activeItem) {
this.activeItem = activeItem;
}
+
+ public Iterator columns() {
+ return new FilterIterator(getChildren().iterator(), isColumn);
+ }
}
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-02
15:27:22 UTC (rev 3723)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-02
15:42:09 UTC (rev 3724)
@@ -12,8 +12,14 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.component.SequenceDataAdaptor;
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.iterators.FilterIterator;
+import org.richfaces.component.Column;
+import org.richfaces.component.Row;
+import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIOrderingList;
public abstract class OrderingListRendererBase extends AbstractRowsRenderer {
@@ -34,6 +40,75 @@
return true;
}
+ public void encodeOrderingListStructure(FacesContext context, UIOrderingList
orderingList)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ //encodeCaption(context, orderingList);
+ encodeHeader(context, orderingList);
+ //encodeFooter(context, orderingList);
+
+ }
+
+ protected Iterator columnFacets(UIOrderingList orderingList, final String name){
+ return new FilterIterator(orderingList.columns(), new Predicate() {
+
+ public boolean evaluate(Object input) {
+ UIComponent component = (UIComponent) input;
+ // accept only columns with corresponding facets.
+ if (component instanceof Column || component instanceof UIColumn) {
+ return component.isRendered()&&(component.getFacet(name) != null);
+ }
+ else{
+ return false;
+ }
+ }});
+ }
+
+ public void encodeHeader(FacesContext context, UIOrderingList orderingList)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ //UIComponent header = orderingList.getHeader();
+ Iterator headers = columnFacets(orderingList,"header");
+
+ if (headers.hasNext()) {
+ writer.startElement("thead", orderingList);
+ String headerClass = (String)
orderingList.getAttributes().get("headerClass");
+
+ writer.startElement("tr", orderingList);
+ encodeStyleClass(writer, null, "dr-table-subheader rich-table-subheader",
null, headerClass);
+ encodeHeaderFacets(context, writer, headers, "ol_col
rich-table-subheadercell", headerClass, "header", "th");
+
+ writer.endElement("tr");
+ }
+ writer.endElement("thead");
+ }
+
+ protected void encodeHeaderFacets(FacesContext context,
+ ResponseWriter writer, Iterator headers, String skinCellClass,
+ String headerClass, String facetName, String element)
+ throws IOException {
+ while (headers.hasNext()) {
+ UIComponent column = (UIComponent) headers.next();
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
+
+ writer.startElement(element, column);
+ if (!headers.hasNext()) {
+ skinCellClass = "ol_endcol rich-table-subheadercell";
+ }
+ encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null) {
+ renderChild(context, facet);
+ }
+
+ writer.endElement(element);
+ }
+ }
+
@Override
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
Modified:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-02
15:27:22 UTC (rev 3723)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-02
15:42:09 UTC (rev 3724)
@@ -21,7 +21,6 @@
}
.ol_list {
- overflow : auto;
width : 200px;
height : 150px;
background : #FFFFFF;
@@ -29,6 +28,18 @@
margin : 0px 8px 8px 8px;
}
+.ol_list_content {
+ overflow : auto;
+ width: 200px;
+ height: 132px;
+}
+
+.ol_list_header {
+ overflow: hidden;
+ width: 200px;
+ height: 18px;
+}
+
.ol_button_layout {
padding : 15px 8px 15px 0px;
vertical-align : top;
@@ -56,6 +67,26 @@
padding : 2px 0px 0px 2px;
}
+#internal_header_tab {
+ width : 100%;
+}
+
+#internal_header_tab th {
+ background : #4A75B5;
+ color : #FFFFFF;
+
+ font-family : Arial;
+ font-size :11px;
+ font-weight : normal;
+ border-bottom : 1px solid #bfbfc0;
+ border-right : 1px solid #bfbfc0;
+ padding : 2px;
+}
+
+#internal_header_tab .ol_endcol {
+ border-right : 0px;
+}
+
#internal_tab {
width : 100%;
}
@@ -73,17 +104,6 @@
padding : 2px;
}
-#internal_tab th {
- background : #4A75B5;
- color : #FFFFFF;
-
- font-family : Arial;
- font-size :11px;
- font-weight : normal;
- border-bottom : 1px solid #bfbfc0;
- border-right : 1px solid #bfbfc0;
- padding : 2px;
-}
#internal_tab tr.ol_select {
background : #EAF0F8;
Added:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js 2007-11-02
15:42:09 UTC (rev 3724)
@@ -0,0 +1,18 @@
+LayoutManager = function(headerId, contentId) {
+ this.headerTable = document.getElementById(headerId);
+ this.contentTable = document.getElementById(contentId);
+}
+
+LayoutManager.scrollWidth = 17;
+
+LayoutManager.prototype.widthSynchronization = function() {
+ var contentCells = this.contentTable.tBodies[0].rows[0].cells;
+ var headerCells = this.headerTable.tHead.rows[0].cells;
+ for (var i = 0; i < contentCells.length; i++) {
+ if (i == contentCells.length - 1) {
+ headerCells[i].style.width = contentCells[i].offsetWidth + LayoutManager.scrollWidth;
+ } else {
+ headerCells[i].style.width = contentCells[i].offsetWidth;
+ }
+ }
+}
\ No newline at end of file
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-02
15:27:22 UTC (rev 3723)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-02
15:42:09 UTC (rev 3724)
@@ -12,13 +12,15 @@
<h:styles>css/orderingList.xcss</h:styles>
<h:scripts>
- scripts/SelectItem.js,scripts/OrderingList.js
+ scripts/SelectItem.js,scripts/OrderingList.js,scripts/LayoutManager.js
</h:scripts>
<f:clientid var="clientId"/>
<script type="text/javascript">
function init() {
var shuttle = new Shuttle('#{clientId}', 'internal_tab',
'#{clientId}focusKeeper', '#{clientId}valueKeeper');
+ var layoutManager = new LayoutManager('internal_header_tab',
'internal_tab');
+ layoutManager.widthSynchronization();
Shuttle.setFocus('#{clientId}focusKeeper');
document.getElementById('up').onclick = function()
{shuttle.moveSelectedItems('up');};
document.getElementById('down').onclick = function()
{shuttle.moveSelectedItems('down');};
@@ -36,13 +38,20 @@
<tr>
<td>
<div class="ol_list">
- <table id="internal_tab" cellpadding="0"
cellspacing="0" class="">
- <tbody id="#{clientId}tbody">
- <vcp:body>
- <f:call name="renderChildren" />
- </vcp:body>
- </tbody>
- </table>
+ <div class="ol_list_header">
+ <table id="internal_header_tab" cellpadding="0"
cellspacing="0">
+ <f:call name="encodeOrderingListStructure"/>
+ </table>
+ </div>
+ <div class="ol_list_content">
+ <table id="internal_tab" cellpadding="0"
cellspacing="0">
+ <tbody id="#{clientId}tbody">
+ <vcp:body>
+ <f:call name="renderChildren" />
+ </vcp:body>
+ </tbody>
+ </table>
+ </div>
</div>
</td>
</tr>