/*
* xulfaces : bring XUL power to Java
*
* Copyright (C) 2005 Olivier SCHMITT
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.xulfaces.component.tree;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import org.xulfaces.IconProvider;
import org.xulfaces.LabelProvider;
import org.xulfaces.annotation.faces.ATTRIBUTE;
import org.xulfaces.annotation.faces.COMPONENT;
import org.xulfaces.component.XULColumn;
import org.xulfaces.renderkit.KitConstants;
/**
*
* @author kito31
* @version $Id: TreeCellComponent.java,v 1.13 2007/04/09 13:21:41 kito31 Exp $
*/
@COMPONENT(type="xul.component.TreeCell")
public class TreeCellComponent extends XULColumn {
@ATTRIBUTE(description="Indicates whether the tree is editable or not. (Firefox 1.5)")
private Boolean editable;
@ATTRIBUTE(automateRendering=false,description = "The label to appear on the cell.")
private String label;
@ATTRIBUTE(description = "For columns that are progress meters, this determines the type of progress meter to use.")
private String mode;
@ATTRIBUTE(description = "Sets the properties of the treecell, which can be used to style the cell.")
private String properties;
@ATTRIBUTE(description = "Points to the treecol the cell is in.")
private String ref;
@ATTRIBUTE(automateRendering=false,description = " The URL of the image to appear on the treecell. If this attribute is left out, no image appears.")
private String src;
@ATTRIBUTE(description = "A percentage value that specifies the amount of the progress meter that is filled in or value of a checkbox.")
private Object value;
private IconProvider iconProvider;
private LabelProvider labelProvider;
private String nodeId;
public void encodeBegin(FacesContext facesContext) throws IOException {
ValueBinding valueBinding = getValueBinding("iconProvider");
if(valueBinding != null){
setIconProvider((IconProvider) valueBinding.getValue(facesContext));
}
valueBinding = getValueBinding("labelProvider");
if(valueBinding != null){
setLabelProvider((LabelProvider) valueBinding.getValue(facesContext));
}
super.encodeBegin(facesContext);
}
public void setIconProvider(IconProvider iconProvider) {
this.iconProvider = iconProvider;
}
public LabelProvider getLabelProvider() {
return labelProvider;
}
public void setLabelProvider(LabelProvider labelProvider) {
this.labelProvider = labelProvider;
}
public IconProvider getIconProvider() {
return iconProvider;
}
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getVar(){
TreeRowComponent treeRowComponent = (TreeRowComponent) getParent();
TreeItemComponent treeItemComponent = (TreeItemComponent) treeRowComponent.getParent();
TreeChildrenComponent treeChildrenComponent = (TreeChildrenComponent) treeItemComponent.getParent();
TreeComponent treeComponent = (TreeComponent) treeChildrenComponent.getParent();
return treeComponent.getVar();
}
// @StartGeneration
public java.lang.Boolean getEditable(){
java.lang.Boolean value = null;
ValueBinding vb = getValueBinding("editable");
if (vb != null) {
return (java.lang.Boolean)(vb.getValue(getFacesContext()));
}
else {
value = this.editable;
}
return value;
}
public void setEditable(java.lang.Boolean value){
this.editable = value;
}
public java.lang.String getLabel(){
java.lang.String value = null;
ValueBinding vb = getValueBinding("label");
if (vb != null) {
return (java.lang.String)(vb.getValue(getFacesContext()));
}
else {
value = this.label;
}
return value;
}
public void setLabel(java.lang.String value){
this.label = value;
}
public java.lang.String getMode(){
java.lang.String value = null;
ValueBinding vb = getValueBinding("mode");
if (vb != null) {
return (java.lang.String)(vb.getValue(getFacesContext()));
}
else {
value = this.mode;
}
return value;
}
public void setMode(java.lang.String value){
this.mode = value;
}
public java.lang.String getProperties(){
java.lang.String value = null;
ValueBinding vb = getValueBinding("properties");
if (vb != null) {
return (java.lang.String)(vb.getValue(getFacesContext()));
}
else {
value = this.properties;
}
return value;
}
public void setProperties(java.lang.String value){
this.properties = value;
}
public java.lang.String getRef(){
java.lang.String value = null;
ValueBinding vb = getValueBinding("ref");
if (vb != null) {
return (java.lang.String)(vb.getValue(getFacesContext()));
}
else {
value = this.ref;
}
return value;
}
public void setRef(java.lang.String value){
this.ref = value;
}
public java.lang.String getSrc(){
java.lang.String value = null;
ValueBinding vb = getValueBinding("src");
if (vb != null) {
return (java.lang.String)(vb.getValue(getFacesContext()));
}
else {
value = this.src;
}
return value;
}
public void setSrc(java.lang.String value){
this.src = value;
}
public java.lang.Object getValue(){
java.lang.Object value = null;
ValueBinding vb = getValueBinding("value");
if (vb != null) {
return (java.lang.Object)(vb.getValue(getFacesContext()));
}
else {
value = this.value;
}
return value;
}
public void setValue(java.lang.Object value){
this.value = value;
}
public Object saveState(FacesContext context) {
Object values[] = new Object[8];
values[0] = super.saveState(context);
values[1] = this.editable;
values[2] = this.label;
values[3] = this.mode;
values[4] = this.properties;
values[5] = this.ref;
values[6] = this.src;
values[7] = this.value;
return ((Object) (values));
}
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
this.editable = (java.lang.Boolean) values[1];
this.label = (java.lang.String) values[2];
this.mode = (java.lang.String) values[3];
this.properties = (java.lang.String) values[4];
this.ref = (java.lang.String) values[5];
this.src = (java.lang.String) values[6];
this.value = (java.lang.Object) values[7];
}
// @EndGeneration
}