Author: maksimkaszynski
Date: 2007-07-20 08:07:19 -0400 (Fri, 20 Jul 2007)
New Revision: 1732
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortField.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/config/component/scrollable-grid.xml
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java
Log:
rendering of sort icons moved to server
Modified: trunk/sandbox/ui/scrollable-grid/src/main/config/component/scrollable-grid.xml
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-07-20
12:07:19 UTC (rev 1732)
@@ -199,6 +199,10 @@
<renderer generate="true">
<template>org/richfaces/scrollable-grid-footer-cell.jspx</template>
</renderer>
+
+ <renderer generate="true">
+ <template>org/richfaces/scrollable-grid-header-itself.jspx</template>
+ </renderer>
<converter generate="false">
<classname>org.richfaces.model.selection.ClientSelectionConverter</classname>
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Selectable.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import org.richfaces.model.selection.Selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selectable {
+ public Selection getSelection();
+ public void setSelection (Selection selection);
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/Sortable.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,23 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v
$
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.model.SortOrder;
+
+
+/**
+ * @author Maksim Kaszynski
+ * Base interface for sort capable components
+ */
+public interface Sortable {
+ public SortOrder getSortOrder();
+ public void setSortOrder(SortOrder sortOrder);
+}
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -52,7 +52,10 @@
public static final String SORT_SINGLE = "single";
public static final String SORT_MULTI = "multi";
+ public static String ASC_ICON = "ascIcon";
+ public static String DESC_ICON = "descIcon";
+
private boolean MODEL_RANGE = false;
private final static Log log = LogFactory.getLog(UIScrollableGrid.class);
@@ -385,4 +388,29 @@
public abstract void setSortMode(String mode);
+ public UIComponent getAscIcon() {
+ return getFacet(ASC_ICON);
+ }
+
+ public void setAscIcon(UIComponent component) {
+ if (component == null) {
+ getFacets().remove(ASC_ICON);
+ } else {
+ getFacets().put(ASC_ICON, component);
+ }
+ }
+
+ public UIComponent getDescIcon() {
+ return getFacet(DESC_ICON);
+ }
+
+ public void setDescIcon(UIComponent component) {
+ if (component == null) {
+ getFacets().remove(DESC_ICON);
+ } else {
+ getFacets().put(DESC_ICON, component);
+ }
+ }
+
+
}
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -5,6 +5,8 @@
import java.util.Iterator;
+import javax.faces.component.UIComponent;
+
import org.richfaces.event.sort.SortListener;
import org.richfaces.event.sort.SortSource;
@@ -42,4 +44,40 @@
public abstract void setName(String name);
+ public UIScrollableGrid getGrid() {
+ return (UIScrollableGrid) getParent();
+ }
+
+ public UIComponent getAscIcon() {
+ UIComponent facet = getFacet(UIScrollableGrid.ASC_ICON);
+ if (facet == null) {
+ facet = getGrid().getAscIcon();
+ }
+ return facet;
+ }
+
+ public void setAscIcon(UIComponent component) {
+ if (component == null) {
+ getFacets().remove(UIScrollableGrid.ASC_ICON);
+ } else {
+ getFacets().put(UIScrollableGrid.ASC_ICON, component);
+ }
+ }
+
+ public UIComponent getDescIcon() {
+ UIComponent facet = getFacet(UIScrollableGrid.DESC_ICON);
+ if (facet == null) {
+ facet = getGrid().getDescIcon();
+ }
+ return facet;
+ }
+
+ public void setDescIcon(UIComponent component) {
+ if (component == null) {
+ getFacets().remove(UIScrollableGrid.DESC_ICON);
+ } else {
+ getFacets().put(UIScrollableGrid.DESC_ICON, component);
+ }
+ }
+
}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package org.richfaces.event.scroll;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class ScrollEvent extends FacesEvent {
+
+ private static final long serialVersionUID = 3786221668771853810L;
+
+ private int rows;
+
+ private int first;
+
+ public ScrollEvent(UIComponent component, int rows, int first){
+ super(component);
+ this.rows = rows;
+ this.first = first;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ }
+
+ public int getFirst() {
+ return first;
+ }
+
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public int getRows() {
+ return rows;
+ }
+
+ public void setRows(int rows) {
+ this.rows = rows;
+ }
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/MultiColumnSortListener.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package org.richfaces.event.sort;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class MultiColumnSortListener implements SortListener {
+
+ public static final MultiColumnSortListener INSTANCE = new MultiColumnSortListener();
+
+ private MultiColumnSortListener() {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.event.sort.SortListener#processSort(org.richfaces.event.sort.SortEvent)
+ */
+ public void processSort(SortEvent e) {
+ UIScrollableGrid grid = (UIScrollableGrid) e.getComponent();
+ int columnIndex = e.getSortColumn();
+ UIScrollableGridColumn column =
+ (UIScrollableGridColumn) grid.getChildren().get(columnIndex);
+ String name = column.getName();
+
+ SortOrder sortOrder = grid.getSortOrder();
+ if (sortOrder == null) {
+ sortOrder = new SortOrder();
+ grid.setSortOrder(sortOrder);
+
+ if (grid.getValueBinding("sortOrder") != null) {
+ grid.getValueBinding("sortOrder").setValue(FacesContext.getCurrentInstance(),
sortOrder);
+ }
+
+ }
+
+ SortField[] fields = sortOrder.getFields();
+
+ if (fields == null) {
+ //If no sorting was applied at all, set sorting to current
+ fields = new SortField[] {new SortField(name, columnIndex, Boolean.TRUE)};
+ } else {
+
+ List newFields = new LinkedList(Arrays.asList(fields));
+ SortField newField = null;
+
+ for (Iterator iterator = newFields.iterator(); iterator.hasNext() && newField
== null; ) {
+ SortField sortField = (SortField) iterator.next();
+ if (sortField.getIndex() == columnIndex ||
+ (sortField.getName() != null &&
+ name != null &&
+ name.equals(sortField.getName()))) {
+
+ Boolean asc = sortField.getAscending();
+ asc = Boolean.TRUE.equals(asc) ? Boolean.FALSE : Boolean.TRUE;
+
+ newField = new SortField(name, columnIndex, asc);
+ iterator.remove();
+
+ }
+ }
+
+ if (newField == null) {
+ newField = new SortField(name, columnIndex, Boolean.TRUE);
+ }
+
+ newFields.add(newField);
+ fields = (SortField[]) newFields.toArray(new SortField[newFields.size()]);
+ }
+
+ sortOrder.setFields(fields);
+ }
+
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SingleColumnSortListener.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,71 @@
+/**
+ *
+ */
+package org.richfaces.event.sort;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SingleColumnSortListener implements SortListener {
+
+ public static final SingleColumnSortListener INSTANCE = new SingleColumnSortListener();
+
+ private SingleColumnSortListener() {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.event.sort.SortListener#processSort(org.richfaces.event.sort.SortEvent)
+ */
+ public void processSort(SortEvent e) {
+ UIScrollableGrid grid = (UIScrollableGrid) e.getComponent();
+ int columnIndex = e.getSortColumn();
+ UIScrollableGridColumn column =
+ (UIScrollableGridColumn) grid.getChildren().get(columnIndex);
+ String name = column.getName();
+
+ SortOrder sortOrder = grid.getSortOrder();
+ if (sortOrder == null) {
+ sortOrder = new SortOrder();
+ grid.setSortOrder(sortOrder);
+
+ if (grid.getValueBinding("sortOrder") != null) {
+ grid.getValueBinding("sortOrder").setValue(FacesContext.getCurrentInstance(),
sortOrder);
+ }
+
+ }
+
+ SortField[] fields = sortOrder.getFields();
+
+ SortField newField = new SortField(name, columnIndex, Boolean.TRUE);
+
+ if (fields != null) {
+ for (int i = 0; i < fields.length; i++) {
+ SortField sortField = fields[i];
+ if (sortField.getIndex() == columnIndex ||
+ (sortField.getName() != null &&
+ name != null &&
+ name.equals(sortField.getName()))) {
+
+ Boolean asc = sortField.getAscending();
+ asc = Boolean.TRUE.equals(asc) ? Boolean.FALSE : Boolean.TRUE;
+
+ newField = new SortField(name, columnIndex, asc);
+ break;
+
+ }
+ }
+ }
+
+ sortOrder.setFields(new SortField[] {newField});
+ }
+
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortEvent.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,95 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortEvent.java,v
$
+ * $Revision: 1.2 $
+ */
+
+package org.richfaces.event.sort;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ *
+ */
+public class SortEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -1453867412542792281L;
+
+ private int sortColumn;
+
+ private int startRow;
+
+ private int dataIndex;
+
+ private boolean asc;
+
+
+ public SortEvent(
+ UIComponent component, int sortColumn, int startRow, int dataIndex, boolean asc) {
+
+ super(component);
+ this.asc = asc;
+ this.sortColumn = sortColumn;
+ this.startRow = startRow;
+ this.dataIndex = dataIndex;
+
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return (listener instanceof SortListener);
+ }
+
+ public void processListener(FacesListener listener) {
+ ((SortListener) listener).processSort(this);
+ }
+
+ /**
+ * @return the sortField
+ */
+ public int getSortColumn() {
+ return sortColumn;
+ }
+
+ /**
+ * @see java.util.EventObject#toString()
+ */
+ public String toString() {
+ return "SortEvent: {sortColumn: " + sortColumn + "}";
+ }
+
+ public boolean isAsc() {
+ return asc;
+ }
+
+ public void setAsc(boolean asc) {
+ this.asc = asc;
+ }
+
+ public int getDataIndex() {
+ return dataIndex;
+ }
+
+ public void setDataIndex(int dataIndex) {
+ this.dataIndex = dataIndex;
+ }
+
+ public int getStartRow() {
+ return startRow;
+ }
+
+ public void setStartRow(int startRow) {
+ this.startRow = startRow;
+ }
+
+ public void setSortColumn(int sortColumn) {
+ this.sortColumn = sortColumn;
+ }
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortListener.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,21 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortListener.java,v
$
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.event.sort;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface SortListener extends FacesListener {
+ public void processSort(SortEvent e);
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/event/sort/SortSource.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,21 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/event/sort/SortSource.java,v
$
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.event.sort;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface SortSource {
+ public void addSortListener(SortListener listener);
+ public void removeSortListener(SortListener listener);
+ public SortListener[] getSortListeners();
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,186 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.ajax4jsf.ajax.repeat.SerializableDataModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation stores last loaded data, so no additional requests to db will be
performed
+ * Acts as a proxy between the component and original data model
+ * @author Maksim Kaszynski
+ *
+ */
+public class DataModelCache extends GridDataModel {
+
+ private static Log log = LogFactory.getLog(DataModelCache.class);
+
+ private static class DataRange {
+ private int startRow;
+ private int endRow;
+ private SortOrder sortOrder;
+ private List loadedData;
+
+ public DataRange(int startRow, int endRow, SortOrder sortOrder,
+ List loadedData) {
+ super();
+ this.startRow = startRow;
+ this.endRow = endRow;
+ this.sortOrder = sortOrder;
+ this.loadedData = loadedData;
+ }
+
+ public boolean match(int s, int e, SortOrder sortOrder) {
+ return s == startRow
+ && e == endRow
+ && sortOrdersMatch(sortOrder, this.sortOrder);
+ }
+
+ private boolean sortOrdersMatch(SortOrder sortOrder1, SortOrder sortOrder2) {
+ boolean result = sortOrder1 == sortOrder2;
+
+ if (sortOrder1 != null && sortOrder2 != null) {
+ result = sortOrder1.equals(sortOrder2);
+ }
+
+ return result;
+ }
+
+ }
+
+ private Map secondaryMapping = new HashMap();
+
+ private DataRange dataRange;
+
+ private GridDataModel gridDataModel;
+
+ private int rowCount = Integer.MIN_VALUE;
+
+ public DataModelCache(GridDataModel gridDataModel) {
+ super();
+ this.gridDataModel = gridDataModel;
+
+ if (log.isTraceEnabled()) {
+ log.trace("initializing with " + gridDataModel);
+ }
+ }
+
+ public void addDataModelListener(DataModelListener listener) {
+ gridDataModel.addDataModelListener(listener);
+ }
+
+ public DataModelListener[] getDataModelListeners() {
+ return gridDataModel.getDataModelListeners();
+ }
+
+ public Object getObjectById(Object id) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Trying to get object by id" + id);
+ }
+ //First try to find data in inner cache
+ //If not found - get it from original model
+ Object cached = secondaryMapping.get(id);
+
+ if (cached == null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Cache miss " + id + " falling back to original
model");
+ }
+
+ cached = gridDataModel.getObjectById(id);
+ secondaryMapping.put(id, cached);
+
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("At last found element " + cached);
+ }
+
+ return cached;
+ }
+
+ public int getRowCount() {
+ if (rowCount == Integer.MIN_VALUE) {
+ rowCount = gridDataModel.getRowCount();
+ }
+ return rowCount;
+ }
+
+ public Object getRowData() {
+ Object secondaryMapped = secondaryMapping.get(getRowKey());
+
+ if (secondaryMapped == null) {
+ secondaryMapped = super.getRowData();
+ }
+ return secondaryMapped;
+ }
+
+ public int getRowIndex() {
+ return gridDataModel.getRowIndex();
+ }
+
+ public Object getRowKey() {
+ return gridDataModel.getRowKey();
+ }
+
+ public SerializableDataModel getSerializableModel(Range range) {
+ return gridDataModel.getSerializableModel(range);
+ }
+
+ public Object getWrappedData() {
+ return gridDataModel.getWrappedData();
+ }
+
+ public boolean isRowAvailable() {
+ return secondaryMapping.containsKey(getRowKey()) || super.isRowAvailable();
+ }
+
+ public List loadData(int startRow, int endRow, SortOrder sortOrder) {
+ if (dataRange == null || !dataRange.match(startRow, endRow, sortOrder)) {
+ List data = gridDataModel.loadData(startRow, endRow, sortOrder);
+ dataRange = new DataRange(startRow, endRow, sortOrder, data);
+ }
+ return dataRange.loadedData;
+ }
+
+ public void removeDataModelListener(DataModelListener listener) {
+ gridDataModel.removeDataModelListener(listener);
+ }
+
+ public void setRowIndex(int arg0) {
+ gridDataModel.setRowIndex(arg0);
+ }
+
+ public void setRowKey(Object key) {
+ gridDataModel.setRowKey(key);
+ super.setRowKey(key);
+ }
+
+ public void setWrappedData(Object arg0) {
+ gridDataModel.setWrappedData(arg0);
+ }
+
+ public Object getId(Object o) {
+ return gridDataModel.getId(o);
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ // TODO Auto-generated method stub
+ super.walk(context, visitor, range, argument);
+ }
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,208 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.ajax.repeat.Range;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for data models
+ * Subclasses must implement {@link #loadData(int, int, SortOrder)}
+ * For certain features (like selection and sorting) to work correctly together,
+ * {@link #getId(Object)} and {@link #getObjectById(Object)}
+ * methods need to be overriden
+ *
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class GridDataModel extends ExtendedDataModel {
+
+ /**
+ * Simple implementation - index-based row key
+ * @author Maksim Kaszynski
+ *
+ */
+ private static class SimpleRowKey implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+ private int i;
+
+ public SimpleRowKey(int i) {
+ super();
+ this.i = i;
+ }
+
+ public int intValue() {
+ return i;
+ }
+
+ public String toString() {
+ return String.valueOf(i);
+ }
+ }
+
+
+ private static final Log log = LogFactory.getLog(GridDataModel.class);
+
+ private Object rowKey;
+
+ private Map mapping;
+
+ private SortOrder lastSortOrder;
+
+ /**
+ * Load range of data items from the source.
+ * Starting from startRow, and up to but excluding endRow
+ * @param startRow
+ * @param endRow
+ * @param sortOrder
+ * @return list of ordered data
+ */
+ public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
+
+
+ /**
+ * Load data range, and iterate over it
+ */
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+
+ if (log.isTraceEnabled()) {
+ log.trace("Starting walk");
+ }
+
+ ScrollableGridRange sequenceRange = (ScrollableGridRange) range;
+
+ int startIndex = sequenceRange.getFirst();
+ int last = sequenceRange.getLast();
+
+ lastSortOrder = sequenceRange.getSortOrder();
+
+ List objects = loadData(startIndex, last, lastSortOrder);
+
+ mapping = new HashMap();
+
+ for (int i = 0; i < objects.size(); i++,startIndex++) {
+ Object data = objects.get(i);
+ Object key = getId(data);
+
+ if (key == null) {
+ key = new SimpleRowKey(startIndex);
+ }
+
+ mapping.put(key, data);
+
+ visitor.process(context, key, argument);
+
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("Ending walk");
+ }
+
+ }
+
+
+ /**
+ * This method is the reverse of {@link #getId(Object)}
+ * If you override this method, you need to override {@link #getId(Object)} as well
+ * @param id
+ * @return
+ */
+ public Object getObjectById(Object id) {
+
+ if (id instanceof SimpleRowKey) {
+ int i = ((SimpleRowKey) id).intValue();
+
+ List l = loadData(i, i + 1, lastSortOrder);
+
+ return l.get(0);
+
+ }
+
+ return null;
+ }
+
+ /**
+ * To get rid of Entity interface, method is introduced
+ * Implementations may override it to provide domain-specific searches
+ * Id should be serializable
+ * Default implementation returns <code>null</code> anyway
+ * If you override this method, you need to override {@link #getObjectById(Object)} as
well
+ * @param o
+ * @return
+ */
+ public Object getId(Object o) {
+ return null;
+ }
+
+
+ public Object getRowData() {
+
+ if (mapping != null && mapping.containsKey(rowKey)) {
+ return mapping.get(rowKey);
+ } else {
+ return loadAndMap(rowKey);
+ }
+
+ }
+
+ /**
+ * Row indexes navigation is no longer supported
+ */
+ public int getRowIndex() {
+ throw new UnsupportedOperationException("getRowIndex");
+ }
+
+ /**
+ * Quite simple implementation - data will be cached, so the call will be cheap
+ */
+ public boolean isRowAvailable() {
+ return getRowData() != null;
+ }
+
+ /**
+ * Row indexes navigation is no longer supported
+ */
+ public void setRowIndex(int arg0) {
+ throw new UnsupportedOperationException("setRowIndex");
+ }
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public void setRowKey(Object key) {
+ rowKey = key;
+ }
+
+ private Object loadAndMap(Object id) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("loadAndMap " + id);
+ }
+
+ Object o = getObjectById(id);
+ if (o != null) {
+ if (mapping == null) {
+ mapping = new HashMap();
+ }
+ mapping.put(id, o);
+ }
+ return o;
+ }
+
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,93 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source:
/cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableGridRange.java,v
$
+ * $Revision: 1.7 $
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+import org.ajax4jsf.ajax.repeat.Range;
+
+
+
+/**
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ */
+public class ScrollableGridRange implements Range, Serializable{
+
+ private static final long serialVersionUID = -6675002421400464892L;
+
+ private int first = 0;
+ private int last = 0;
+ private SortOrder sortOrder;
+
+ public ScrollableGridRange(int first, int last, SortOrder sortOrder) {
+ super();
+ this.first = first;
+ this.last = last;
+ this.sortOrder = sortOrder;
+ }
+
+ /**
+ * @return the bufferSize
+ */
+ public int getLast() {
+ return last;
+ }
+ /**
+ * @param bufferSize the bufferSize to set
+ */
+ public void setLast(int lastRow) {
+ this.last = lastRow;
+ }
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return first;
+ }
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ public boolean equals(Object obj) {
+
+ if(!(obj instanceof ScrollableGridRange)){
+ return super.equals(obj);
+ }
+
+ ScrollableGridRange ref = (ScrollableGridRange)obj;
+
+ boolean ret = (this.first == ref.first)&&(this.last == ref.last );
+
+ if(this.sortOrder != null){
+ ret = ret && this.sortOrder.equals(ref.sortOrder);
+ } else {
+ ret = (ret && (ref.sortOrder == null));
+ }
+
+ return ret;
+ }
+
+ public int hashCode() {
+ return super.hashCode();
+ }
+}
Added: trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortField.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/SortField.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,89 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SortField implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String name = null;
+ private int index = -1;
+ private Boolean ascending = null;
+
+
+
+ public SortField(String name, int index, Boolean ascending) {
+ super();
+ this.name = name;
+ this.index = index;
+ this.ascending = ascending;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public Boolean getAscending() {
+ return ascending;
+ }
+
+ public void setAscending(Boolean ascending) {
+ this.ascending = ascending;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((ascending == null) ? 0 : ascending.hashCode());
+ result = prime * result + index;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SortField other = (SortField) obj;
+ if (ascending == null) {
+ if (other.ascending != null)
+ return false;
+ } else if (!ascending.equals(other.ascending))
+ return false;
+ if (index != other.index)
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,129 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ClientSelection implements Serializable{
+
+ private static final long serialVersionUID = 5855157282287053681L;
+
+ public static final String FLAG_RESET = "x";
+
+ public static final String FLAG_ALL = "a";
+
+ private String selectionFlag;
+
+ private List ranges = new ArrayList();
+
+ public ClientSelection() {
+ }
+
+
+ public void addRange(SelectionRange range) {
+ ranges.add(range);
+ }
+
+ public boolean isSelected(int i) {
+ boolean result = false;
+ Iterator iterator = ranges.iterator();
+ while (iterator.hasNext() && !result) {
+ result |= ((SelectionRange) iterator.next()).within(i);
+ }
+ return result;
+ }
+
+ public List getRanges() {
+ return ranges;
+ }
+
+ public void addIndex(int j) {
+ if(this.isSelected(j)) return;
+
+
+
+ SelectionRange firstRange = null;
+
+ int s = ranges.size();
+
+ int insertPosition = 0;
+
+ for(int i = 0; i < s && insertPosition >= 0 ; i++) {
+
+ firstRange = (SelectionRange) ranges.get(i);
+
+ if (firstRange.getStartIndex() == j + 1) {
+
+ firstRange.setStartIndex(j);
+ insertPosition = -1;
+
+ } else if (firstRange.getEndIndex() == j - 1) {
+
+ firstRange.setEndIndex(j);
+
+ if (i + 1 < s) {
+ SelectionRange range2 = (SelectionRange) ranges.get(i + 1);
+
+ if (range2.getStartIndex() == j || range2.getStartIndex() == j + 1) {
+
+ ranges.remove(i + 1);
+
+ firstRange.setEndIndex(range2.getEndIndex());
+ }
+ }
+
+ insertPosition = -1;
+
+ } else if (firstRange.getStartIndex() > j) {
+ insertPosition = i;
+ }
+
+ }
+
+ if (insertPosition >= 0) {
+ firstRange = new SelectionRange(j,j);
+ ranges.add(insertPosition, firstRange);
+
+ return;
+ }
+
+
+ }
+
+ private boolean reset = false;
+ public boolean isReset() {
+ return reset;
+ }
+
+ private boolean selectAll = false;
+ public boolean isSelectAll() {
+ return selectAll;
+ }
+
+
+ public String getSelectionFlag() {
+ return selectionFlag;
+ }
+
+
+ public void setSelectionFlag(String selectionFlag) {
+ this.selectionFlag = selectionFlag;
+
+ reset = false;
+ selectAll = false;
+
+ if (FLAG_ALL.equals(selectionFlag)) {
+ selectAll = true;
+ } else if (FLAG_RESET.equals(selectionFlag)) {
+ reset = true;
+ }
+ }
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/Selection.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selection extends Serializable {
+
+ public Iterator getKeys();
+
+ public int size();
+
+ public boolean isSelected(Object rowKey);
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SelectionRange.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SelectionRange {
+ private int startIndex = -1;;
+ private int endIndex = -1;
+
+ public SelectionRange(int startIndex, int endIndex) {
+ super();
+ this.startIndex = startIndex;
+ this.endIndex = endIndex;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ public void setEndIndex(int endIndex) {
+ this.endIndex = endIndex;
+ }
+
+ public boolean within(int index) {
+ return startIndex <= index && endIndex >= index;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + endIndex;
+ result = prime * result + startIndex;
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SelectionRange other = (SelectionRange) obj;
+ if (endIndex != other.endIndex)
+ return false;
+ if (startIndex != other.startIndex)
+ return false;
+ return true;
+ }
+
+
+}
Added:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
(rev 0)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.richfaces.model.selection;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SimpleSelection implements Selection {
+
+ private static final long serialVersionUID = 1L;
+
+ private Set keys = new HashSet();
+
+ public boolean addKey(Object rowKey) {
+ return keys.add(rowKey);
+ }
+
+ public boolean removeKey(Object rowKey) {
+ return keys.remove(rowKey);
+ }
+
+ public Iterator getKeys() {
+ return keys.iterator();
+ }
+
+ public int size() {
+ return keys.size();
+ }
+
+ public boolean isSelected(Object rowKey) {
+ return keys.contains(rowKey);
+ }
+
+ public void clear() {
+ keys.clear();
+ }
+}
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -5,7 +5,7 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
import org.ajax4jsf.framework.util.javascript.JSReference;
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -32,20 +32,38 @@
return 0;
}
- if(component instanceof UIScrollableGrid){
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
- UIComponent kid = (UIComponent) iter.next();
- if (kid.isRendered()) {
- if (kid instanceof UIScrollableGridColumn){
- UIScrollableGridColumn column = (UIScrollableGridColumn)kid;
- columnsCount += visitor.visit(context, column, writer, state);
- state.nextCell();
+ if (visitor instanceof ContextualColumnVisitor) {
+ ContextualColumnVisitor contextualColumnVisitor =
+ (ContextualColumnVisitor) visitor;
+
+ contextualColumnVisitor.setUp(context, state);
+ }
+ try {
+
+ if(component instanceof UIScrollableGrid){
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
+ UIComponent kid = (UIComponent) iter.next();
+ if (kid.isRendered()) {
+ if (kid instanceof UIScrollableGridColumn){
+ UIScrollableGridColumn column = (UIScrollableGridColumn)kid;
+ columnsCount += visitor.visit(context, column, writer, state);
+ state.nextCell();
+ }
}
}
+ state.setCellIndex(0);
}
- state.setCellIndex(0);
+
+ } finally {
+ if (visitor instanceof ContextualColumnVisitor) {
+ ContextualColumnVisitor contextualColumnVisitor =
+ (ContextualColumnVisitor) visitor;
+
+ contextualColumnVisitor.tearDown(context, state);
+ }
}
+
return columnsCount;
}
}
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -6,6 +6,7 @@
import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -26,6 +27,8 @@
import org.richfaces.component.UIScrollableGridColumn;
import org.richfaces.event.scroll.ScrollEvent;
import org.richfaces.event.sort.SortEvent;
+import org.richfaces.model.SortField;
+import org.richfaces.model.SortOrder;
import org.richfaces.renderkit.CompositeRenderer;
import org.richfaces.renderkit.RendererContributor;
import org.richfaces.renderkit.ScriptOptions;
@@ -51,12 +54,16 @@
private final String COLUMN_NORMAL_TYPE = "normal";
+ private static final String ASC_ICON_CREATED = "ASC_ICON_CREATED";
+ private static final String DESC_ICON_CREATED = "DESC_ICON_CREATED";
private RendererBase cellTemplate = null;
private RendererBase headerCellTemplate = null;
private RendererBase footerCellTemplate = null;
+
+ private RendererBase headerItselfTemplate = null;
private final Log log = LogFactory.getLog(ScrollableGridBaseRenderer.class);
@@ -104,7 +111,8 @@
state.addId(column.getId());
headerCellTemplate = getHeaderCellTemplate();
- ComponentVariables variables =
ComponentsVariableResolver.getVariables(headerCellTemplate, column);
+ ComponentVariables variables =
+ ComponentsVariableResolver.getVariables(headerCellTemplate, column);
String widthPx = (String)column.getAttributes().get("width");
int width = Integer.parseInt(widthPx.substring(0, widthPx.indexOf("px")));
@@ -123,14 +131,76 @@
variables.setVariable("sepOffset", new Integer(sepOffset));
headerCellTemplate.encodeBegin(context, column);
- UIComponent component = column.getFacet(HEADER_PART);
- if(component != null){
- renderChild(context, component);
- }
+ headerRenderer.visit(context, column, writer, state);
headerCellTemplate.encodeEnd(context, column);
}
};
+ private final ColumnVisitor headerRenderer = new ColumnVisitor() {
+
+ public int visit(FacesContext context, UIScrollableGridColumn column,
+ ResponseWriter writer, GridRendererState state)
+ throws IOException {
+
+ ComponentVariables variables =
+ ComponentsVariableResolver.getVariables(getHeaderItselfTemplate(), column);
+
+ int cell_index = state.getCellIndex();
+ String client_id = state.getClientId();
+ Boolean sorting = getColumnSorting(state.getGrid(), cell_index);
+
+ if (sorting != null) {
+ if (sorting.booleanValue()) {
+ variables.setVariable("sortAscending", Boolean.TRUE);
+ } else {
+ variables.setVariable("sortDescending", Boolean.TRUE);
+ }
+ }
+ variables.setVariable("client_id", client_id);
+ variables.setVariable("cell_index", new Integer(cell_index));
+
+ getHeaderItselfTemplate().encodeBegin(context, column);
+
+ UIComponent header = column.getFacet(HEADER_PART);
+
+ if(header != null){
+ renderChild(context, header);
+ }
+ getHeaderItselfTemplate().encodeEnd(context, column);
+
+ return 0;
+ }
+
+
+ private Boolean getColumnSorting(UIScrollableGrid grid, int columnIndex) {
+
+ Boolean sorting = null;
+
+ UIScrollableGridColumn column =
+ (UIScrollableGridColumn) grid.getChildren().get(columnIndex);
+ String name = column.getName();
+ SortOrder sortOrder = grid.getSortOrder();
+
+ if (sortOrder != null) {
+ SortField[] sortFields = sortOrder.getFields();
+
+ if (sortFields != null) {
+ for (int i = 0; i < sortFields.length && sorting == null; i++) {
+ SortField sortField = sortFields[i];
+
+ if ((name != null && name.equals(sortField.getName()))
+ || columnIndex == sortField.getIndex()) {
+ sorting = sortField.getAscending();
+ }
+ }
+ }
+ }
+
+ return sorting;
+ }
+
+ };
+
private final ColumnVisitor footerCellRenderer = new ExtendedColumnVisitor(){
public void renderContent(FacesContext context, UIScrollableGridColumn column,
ResponseWriter writer, GridRendererState state) throws IOException {
@@ -447,6 +517,7 @@
state.setFrozenPart(isFrozen);
state.setClientId(grid.getClientId(context));
state.setSepOffset(new Integer(0));
+
ColumnWalker.iterateOverColumns(context, grid, headerCellRenderer, writer, state);
}
@@ -493,12 +564,36 @@
public void setUpState(FacesContext context, UIScrollableGrid grid) {
GridRendererState.createState(context, grid);
+ Map attrs = grid.getAttributes();
+
+ if (grid.getAscIcon() == null) {
+ attrs.put(ASC_ICON_CREATED, Boolean.TRUE);
+ }
+
+ if (grid.getDescIcon() == null) {
+ attrs.put(DESC_ICON_CREATED, Boolean.TRUE);
+ }
+
}
- public void tearDownState(FacesContext context){
+ public void tearDownState(FacesContext context, UIScrollableGrid grid){
+
+ Map attrs = grid.getAttributes();
+ if (attrs.containsKey(ASC_ICON_CREATED)) {
+ grid.setAscIcon(null);
+ attrs.remove(ASC_ICON_CREATED);
+ }
+
+ if (attrs.containsKey(DESC_ICON_CREATED)) {
+ grid.setDescIcon(null);
+ attrs.remove(DESC_ICON_CREATED);
+ }
+
+
GridRendererState.restoreState(context);
}
+
public String getRowsAjaxUpdate(FacesContext context, UIScrollableGrid grid){
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
@@ -760,6 +855,18 @@
return footerCellTemplate;
}
+
+
+ private RendererBase getHeaderItselfTemplate() {
+
+ if (headerItselfTemplate == null) {
+ headerItselfTemplate =
TemplateLoader.loadTemplate("org.richfaces.renderkit.html.ScrollableGridHeaderItselfRenderer");
+ }
+
+ return headerItselfTemplate;
+ }
+
+
public void renderHiddenScrollInput(FacesContext context, UIScrollableGrid grid) throws
IOException{
ResponseWriter writer = context.getResponseWriter();
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -16,7 +16,7 @@
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.model.selection.ClientSelection;
import org.richfaces.model.selection.Selection;
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/java/org/richfaces/utils/TemplateLoader.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -3,7 +3,7 @@
*/
package org.richfaces.utils;
-import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.framework.renderer.RendererBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-07-20
12:07:19 UTC (rev 1732)
@@ -45,7 +45,7 @@
if(target && src) {
Utils.DOM.Event.removeListeners(target);
- //if (ClientUILib.isIE) {
+ if (ClientUILib.isIE) {
var theDoc = document;
//var createEl = theDoc.createElement;
@@ -55,37 +55,13 @@
var tdSrc, tdNode, subNode;
var childs = src.childNodes;
var ccount = childs.length;
-<<<<<<< .working
var tcount = target.childNodes.length;
for(var k=0; k<tcount; k++) {
tdSrc = k<ccount ? childs[k] : null;
tdNode = theDoc.createElement( "TD" );
- //Utils.DOM.copyAttributes(tdNode, tdSrc);
- tdNode.className = "ClientUI_Grid_BC";
-=======
- var tcount = target.childNodes.length;
- for(var k=0; k<tcount; k++) {
- tdSrc = k<ccount ? childs[k] : null;
- tdNode = theDoc.createElement( "TD" );
tdNode.className = target.childNodes[k].className;
->>>>>>> .merge-right.r1635
-<<<<<<< .working
if(tdSrc) {
- if(tdSrc.innerHTML) {
- tdNode.innerHTML = tdSrc.innerHTML;
- }
- else {
- innerHTML = [];
- innerCount = tdSrc.childNodes.length;
- for(j=0; j<innerCount; j++) {
- subNode = tdSrc.childNodes[j];
- innerHTML.push(subNode.xml);
- }
- tdNode.innerHTML = innerHTML.join("");
- }
-=======
- if(tdSrc) {
innerHTML = [];
innerCount = tdSrc.childNodes.length;
for(j=0; j<innerCount; j++) {
@@ -93,7 +69,6 @@
innerHTML.push(subNode.xml);
}
tdNode.innerHTML = innerHTML.join("");
->>>>>>> .merge-right.r1635
}
row.insertBefore(tdNode, null);
}
@@ -101,7 +76,7 @@
target.parentNode.replaceChild(row, target);
return row;
- /*} else {
+ } else {
var theDoc = document;
Utils.DOM._clearAttributes(target);
@@ -132,7 +107,7 @@
target.innerHTML = innerHTML.join("");
return target;
- }*/
+ }
}
else {
if(!target)
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-07-20
12:07:19 UTC (rev 1732)
@@ -169,8 +169,8 @@
sep.setStyle({cursor: 'auto'});
}
// sort icons
- columns[j].sortDesc = new ClientUI.common.box.Box(details[1], null, true);
- columns[j].sortAsc = new ClientUI.common.box.Box(details[2], null, true);
+ //columns[j].sortDesc = new ClientUI.common.box.Box(details[1], null, true);
+ //columns[j].sortAsc = new ClientUI.common.box.Box(details[2], null, true);
j++;
}
@@ -216,8 +216,8 @@
sep.setStyle({cursor: 'auto'});
}
// sort icons
- columns[j].sortDesc = new ClientUI.common.box.Box(details[1], null, true);
- columns[j].sortAsc = new ClientUI.common.box.Box(details[2], null, true);
+ //columns[j].sortDesc = new ClientUI.common.box.Box(details[1], null, true);
+ //columns[j].sortAsc = new ClientUI.common.box.Box(details[2], null, true);
}
j++;
}
@@ -242,8 +242,8 @@
var details = new Array(3);
var clientId = this.grid.getElement().id;
details[0] = document.getElementById(clientId + ":hsep_" + column);
- details[1] = document.getElementById(clientId + ":hsortd_" + column);
- details[2] = document.getElementById(clientId + ":hsorta_" + column);
+ //details[1] = document.getElementById(clientId + ":hsortd_" + column);
+ //details[2] = document.getElementById(clientId + ":hsorta_" + column);
return details;
},
agjustSeparators: function() {
@@ -399,6 +399,7 @@
if(el) {
var index = parseInt(el.getAttribute("columnIndex"));
if(index>=0) {
+ /*
var dir = this.getColumns()[index].sorted;
dir = (dir == "asc") ? "desc" : "asc";
this.getColumns()[index].sorted = dir;
@@ -417,10 +418,10 @@
}
}
}
-
+ */
this.grid.eventOnSort.fire({
column: index,
- order: dir,
+ /*order: dir,*/
startRow:
this.grid.getBody()._getRowIndex(this.grid.getBody().templFrozen.getElement().rows[0].id),
index: this.grid.getBody().currRange.start
});
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-07-20
12:07:19 UTC (rev 1732)
@@ -24,6 +24,7 @@
this.options = options;
this.client_id = this.options.client_id;
this.rows_count = $(this.client_id + "_rows_input").value;
+ this.scroll_si = $(this.client_id + ":si");
this.columns_count = this.options.columnsCount;
this.splash_id = this.options.splash_id;
this.dataModel = new ClientUI.controls.grid.FakeArrayDataModel(this.rows_count,
this.columns_count, this.client_id);
@@ -33,7 +34,16 @@
{pane: GridLayout_Enum.BODY, ref: this.client_id +"_" +
"GridBodyTemplate"},
{pane: GridLayout_Enum.FOOTER, ref: this.client_id +"_" +
"GridFooterTemplate"}
];
- this.init2 = this.init.bindAsEventListener(this);
+ var grid = this;
+
+ Event.onReady(function(){
+ grid.init();
+ });
+ Utils.execOnLoad(
+ function(){
+ grid.init();
+ },
+ Utils.Condition.ElementPresent(grid.client_id), 100);
this.endInitTime = (new Date()).getTime();
this.rowCallbacks = [];
@@ -45,32 +55,50 @@
// mark that grid control initialized
if(!this.isInitialized) {
this.isInitialized = true;
-
this.startCreateTime = (new Date()).getTime();
ClientUI.controls.grid.ScrollableGrid.parentClass.constructor().call(this,
this.client_id, this.dataModel, this.templates);
-
+
this.endCreateTime = (new Date()).getTime();
-
+
// suspend some processing
setTimeout(function() {
this.startPostProcessTime = (new Date()).getTime();
this.eventOnPostSort = new ClientUI.common.utils.CustomEvent('OnSort');
this.eventOnPostScroll = new ClientUI.common.utils.CustomEvent('OnScroll');
-
- var progress = new ClientUI.common.box.SplashBox(this.splash_id, null, 300, true);
- this.setProgressCtrl(progress);
+
+ //var progress = new ClientUI.common.box.SplashBox(this.splash_id, null, 300, true);
+ //this.setProgressCtrl(progress);
Event.observe(this.eventOnSort, "on sort",
this.onSorted.bindAsEventListener(this));
if (this.options.selectionInput) {
this.selectionManager = new ClientUI.controls.grid.SelectionManager(this);
}
this.endPostProcessTime = (new Date()).getTime();
- }.bind(this), 500);
+ }.bind(this), 500);
+
+ if(this.scroll_si.value !=''){
+ var options = this.scroll_si.value.split(',');
+ this.restoreScrollState(options[0],options[1],options[2]);
+ }
+
+ var form = this.getForm($(this.client_id));
+ Event.observe(form,
"submit",this.restoreScrollPos.bindAsEventListener(this));
}
},
+ getForm: function(element){
+ var node = element;
+ if(node){
+ while(node.tagName.toUpperCase() != 'FORM'){
+ node = node.parentNode;
+ }
+ }
+
+ return node;
+ },
+
onSortComplete : function(request, event, data){
var options = request.getJSON("options");
Utils.AJAX.updateRows(options,request,
@@ -126,7 +154,7 @@
if(index < flength + nlength - 1) {
var frozen = true;
if(index >= flength) {
- index -= fcount;
+ index -= flength;
frozen = false;
}
this.hideColumn(index, frozen);
@@ -140,16 +168,31 @@
this.updateLayout();
},
- restoreScrollState: function(state, start, end) {
- this.getBody().scrollBox.getElement().scrollTop = state.pos;
- this.getBody().currentPos = state.pos;
- this.getBody().setScrollPos(state.pos);
- this.getBody().currRange.start == start;
- this.getBody().currRange.end = end;
+ restoreScrollState: function(scrollPos, start, end) {
+
+ var body = this.getBody();
+ body.scrollBox.getElement().scrollTop = scrollPos;
+ body.currentPos = scrollPos;
+ body.currRange.start = start;
+ body.currRange.end = end;
+ body._onContentVScroll(scrollPos);
+ var visibleRowPos = body.currRange.start * body.defaultRowHeight;
+ //setTimeout(function(){
+ body.templFrozen.moveToY(visibleRowPos);
+ body.templNormal.moveToY(visibleRowPos);
+ //}, 500);
},
getScrollPos: function() {
return this.getBody().currentPos;
+ },
+
+ restoreScrollPos: function(){
+ var body = this.getBody();
+ var start = body.currRange.start;
+ var end = body.currRange.end;
+ var index = this.getScrollPos();
+ this.scroll_si.value = index + "," + start + "," + end;
}
});
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-07-20
12:07:19 UTC (rev 1732)
@@ -86,23 +86,13 @@
border-right: 1px solid #ebeadb;
}
-.ClientUI_Grid_HC .sort-asc {
-/* background-image: url(sort_asc.gif);*/
+.ClientUI_Grid_HC .sort-asc, .ClientUI_Grid_HC .sort-desc {
background-position: right;
background-repeat: no-repeat;
- display: none;
width: 16px !important;;
position: absolute;
}
-.ClientUI_Grid_HC .sort-desc {
-/* background-image: url(sort_desc.gif);*/
- background-position: right;
- background-repeat: no-repeat;
- display: none;
- width: 16px !important;;
- position: absolute;
-}
/**
* Header cells separator
Modified:
trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx 2007-07-20
12:07:19 UTC (rev 1732)
@@ -13,12 +13,9 @@
<td class="ClientUI_Grid_HC Idg-header-cell
#{component.attributes['headerClass']}"
id="#{client_id}:hc_#{cell_index}" columnIndex="#{cell_index}"
sortable="#{component.attributes['sortable']}">
- <div id="#{clientId}:hcb_#{cell_index}"
- class="ClientUI_Grid_HCBody">
- <vcp:body/>
- <div align="right"
id="#{client_id}:hsortd_#{cell_index}" class="sort-desc" />
- <div align="right"
id="#{client_id}:hsorta_#{cell_index}" class="sort-asc" />
- </div>
+
+ <vcp:body/>
+
<jsp:scriptlet>
int offset = ((Integer)variables.getVariable("sepOffset")).intValue() - 3;
Modified:
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/component/html/HtmlScrollableGridComponentTest.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -7,6 +7,7 @@
import java.lang.String ;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase ;
+import org.richfaces.model.SortField;
import org.richfaces.model.SortOrder ;
import java.lang.Object ;
import org.richfaces.model.selection.Selection ;
@@ -183,8 +184,7 @@
assertEquals("oncomplete_oncomplete", component.getOncomplete());
component.setValueBinding("sortOrder", new
MockValueBinding("sortOrder", org.richfaces.model.SortOrder.class));
SortOrder sortOrder = new SortOrder();
- sortOrder.setSortColumn(2);
- sortOrder.setAscending(true);
+ sortOrder.setFields(new SortField[] {new SortField(null, 2, Boolean.TRUE)});
component.setSortOrder(sortOrder);
assertEquals(sortOrder, component.getSortOrder());
component.setValueBinding("footerClass", new
MockValueBinding("footerClass", java.lang.String.class));
Modified:
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java
===================================================================
---
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java 2007-07-20
06:27:17 UTC (rev 1731)
+++
trunk/sandbox/ui/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java 2007-07-20
12:07:19 UTC (rev 1732)
@@ -29,9 +29,9 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
- javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
- javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/scrollable-grid.js");
}
@@ -152,54 +152,83 @@
if(elem.getNodeName().equals("div")){
String elemClassAttr = elem.getAttributeValue("class");
- assertTrue(elemClassAttr.contains("ClientUI_InlineBox"));
- boolean templates = elem.getId().equals(grid.getId()+ "_GridBodyTemplate")
|| elem.getId().equals(grid.getId()+ "_GridFooterTemplate") ||
elem.getId().equals(grid.getId()+ "_GridHeaderTemplate");
- assertTrue(templates);
- Iterator divIter = elem.getChildElementsIterator();
- HtmlElement inDiv = (HtmlElement) divIter.next();
- assertNotNull(inDiv);
- assertEquals("div", inDiv.getNodeName());
+ res = false;
+ if(elemClassAttr.contains("ClientUI_InlineBox")){
+ res = true;
+ }else if(elemClassAttr.contains("ClientUI_Grid_HSplit")){
+ res = true;
+ }
+ assertTrue(res);
- Iterator spanIter = inDiv.getChildElementsIterator();
+ if(!elemClassAttr.contains("ClientUI_Grid_HSplit")){
+
+ boolean templates = elem.getId().equals(grid.getId()+ "_GridBodyTemplate")
|| elem.getId().equals(grid.getId()+ "_GridFooterTemplate") ||
elem.getId().equals(grid.getId()+ "_GridHeaderTemplate");
+ assertTrue(templates);
+
+ Iterator divIter = elem.getChildElementsIterator();
+ HtmlElement inDiv = (HtmlElement) divIter.next();
+ assertNotNull(inDiv);
+ boolean test = false;
+ if(inDiv.getNodeName().equals("div")){
+ test = true;
+ }else if(inDiv.getNodeName().equals("iframe")){
+ test = true;
+ }
+
+ assertTrue(test);
+
+ Iterator spanIter = inDiv.getChildElementsIterator();
- for (;spanIter.hasNext();) {
+ for (;spanIter.hasNext();) {
- HtmlElement span = (HtmlElement) spanIter.next();
- assertNotNull(span);
- assertEquals("span", span.getNodeName());
- elemClassAttr = span.getAttributeValue("class");
- assertNotNull(elemClassAttr);
+ HtmlElement element = (HtmlElement) spanIter.next();
+ assertNotNull(element);
+ res = false;
+ if(element.getNodeName().equals("span")){
+ res = true;
+
+ }else if(element.getNodeName().equals("div")){
+ String divId = element.getAttributeValue("id");
+ assertEquals(id + ":sb", divId);
+ res = true;
+ } else if (element.getNodeName().equals("br")) {
+ res = true;
+ }
+
+ if(!res) {
+ System.out
+ .println("ScrollableGridRendererTest.testRenderingFrozenNormalColumns()");
+ }
+
+ assertTrue(res);
+ elemClassAttr = element.getAttributeValue("class");
+ assertNotNull(elemClassAttr);
- if(span.getId().contains("FrozenBox")){
- assertTrue(elemClassAttr.contains("ClientUI_TmplBox
ClientUI_FrozenBox"));
- }else if(span.getId().contains("NormalBox")){
- assertTrue(elemClassAttr.contains("ClientUI_TmplBox
ClientUI_NormalBox"));
- }
+ if(element.getId().contains("FrozenBox")){
+ assertTrue(elemClassAttr.contains("ClientUI_TmplBox
ClientUI_FrozenBox"));
+ }else if(element.getId().contains("NormalBox")){
+ assertTrue(elemClassAttr.contains("ClientUI_TmplBox
ClientUI_NormalBox"));
+ }
- for (int i = 0; i < columns; i++) {
+ for (int i = 0; i < columns; i++) {
- HtmlElement hcell = page.getHtmlElementById(id + ":hc_" + i);
- assertNotNull(hcell);
- elemClassAttr = hcell.getAttributeValue("class");
- assertTrue(elemClassAttr.contains("ClientUI_Grid_HC Idg-header-cell"));
+ HtmlElement hcell = page.getHtmlElementById(id + ":hc_" + i);
+ assertNotNull(hcell);
+ elemClassAttr = hcell.getAttributeValue("class");
+ assertTrue(elemClassAttr.contains("ClientUI_Grid_HC Idg-header-cell"));
- for (int j = 0; j < grid.getRows(); j++) {
- HtmlElement bcell = page.getHtmlElementById(id + ":c_" + j +
"_" + i);
- assertNotNull(bcell);
- elemClassAttr = bcell.getAttributeValue("class");
- assertTrue(elemClassAttr.contains("ClientUI_Grid_BC Idg-column-cell"));
+ for (int j = 0; j < grid.getRows(); j++) {
+ HtmlElement bcell = page.getHtmlElementById(id + ":c_" + j +
"_" + i);
+ assertNotNull(bcell);
+ elemClassAttr = bcell.getAttributeValue("class");
+ assertTrue(elemClassAttr.contains("ClientUI_Grid_BC
Idg-column-cell"));
+ }
}
-
}
-
}
-
}
-
}
-
}
-
}