001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.ext.renderkit;
035:
036: import com.icesoft.faces.component.CSS_DEFAULT;
037: import com.icesoft.faces.component.ext.taglib.Util;
038:
039: import org.w3c.dom.Element;
040:
041: import javax.faces.component.UIComponent;
042:
043: public class GridRenderer extends
044: com.icesoft.faces.renderkit.dom_html_basic.GridRenderer {
045:
046: // row styles are returned by reference
047: public String[] getRowStyles(UIComponent uiComponent) {
048: if (((String[]) getRowStyleClasses(uiComponent)).length <= 0) {
049: String[] rowStyles = new String[2];
050: rowStyles[0] = Util.getQualifiedStyleClass(uiComponent,
051: CSS_DEFAULT.TABLE_ROW_CLASS1);
052: rowStyles[1] = Util.getQualifiedStyleClass(uiComponent,
053: CSS_DEFAULT.TABLE_ROW_CLASS2);
054: return rowStyles;
055: } else {
056: return getRowStyleClasses(uiComponent);
057: }
058: }
059:
060: public String[] getRowStyleClasses(UIComponent uiComponent) {
061: String[] rowClasses = super .getRowStyleClasses(uiComponent);
062: for (int i = 0; i < rowClasses.length; i++) {
063: rowClasses[i] = Util.getQualifiedStyleClass(uiComponent,
064: rowClasses[i], CSS_DEFAULT.TABLE_ROW_CLASS,
065: "rowClasses");
066: }
067: return rowClasses;
068: }
069:
070: public void writeColStyles(String[] columnStyles,
071: int columnStylesMaxIndex, int columnStyleIndex, Element td,
072: int colNumber, UIComponent uiComponent) {
073: if (columnStyles.length > 0) {
074: if (columnStylesMaxIndex >= 0) {
075: td
076: .setAttribute("class",
077: columnStyles[columnStyleIndex]);
078: }
079: } else {
080: td.setAttribute("class", getColumnStyle(uiComponent,
081: CSS_DEFAULT.COLUMN + colNumber++));
082: }
083: }
084:
085: protected String getRowStyle(UIComponent uiComponent, String style) {
086: return Util.getQualifiedStyleClass(uiComponent, style,
087: CSS_DEFAULT.TABLE_ROW_CLASS, "rowClasses");
088: }
089:
090: protected String getColumnStyle(UIComponent uiComponent,
091: String style) {
092: return Util.getQualifiedStyleClass(uiComponent, style);
093: }
094:
095: protected String[] getColumnStyleClasses(UIComponent uiComponent) {
096: String[] columnStyles = super
097: .getColumnStyleClasses(uiComponent);
098: if (columnStyles.length == 0) {
099: columnStyles = new String[2];
100: columnStyles[0] = Util.getQualifiedStyleClass(uiComponent,
101: CSS_DEFAULT.TABLE_COLUMN_CLASS1);
102: columnStyles[1] = Util.getQualifiedStyleClass(uiComponent,
103: CSS_DEFAULT.TABLE_COLUMN_CLASS2);
104: } else {
105: for (int i = 0; i < columnStyles.length; i++) {
106: columnStyles[i] = Util
107: .getQualifiedStyleClass(uiComponent,
108: columnStyles[i],
109: CSS_DEFAULT.TABLE_COLUMN_CLASS,
110: "columnClasses");
111: }
112: }
113: return columnStyles;
114: }
115: }
|