Package org.xulfaces.component.tree

Source Code of org.xulfaces.component.tree.TreeChildrenComponent

/*
*   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 javax.faces.component.NamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

import org.xulfaces.annotation.faces.ATTRIBUTE;
import org.xulfaces.annotation.faces.COMPONENT;
import org.xulfaces.component.XULComponentBase;

/**
*
* @author kito31
* @version $Id: TreeChildrenComponent.java,v 1.10 2006/12/01 18:28:51 kito31 Exp $
*/
@COMPONENT(type="xul.component.TreeChildren")
public class TreeChildrenComponent extends XULComponentBase implements NamingContainer {

   
  @ATTRIBUTE(description="If true, the background of the tree's rows will alternate between two colors.")
  private Boolean alternatingbackground;
 
  private String nodeId;
   
  private TreePath[] selectionPath;
 
  private String var;
 


  public TreeModel getTreeModel() {
    ValueBinding valueBinding = getValueBinding("value");
    if(valueBinding != null){
      TreeModel treeModel = (TreeModel) valueBinding.getValue(getFacesContext());
      return treeModel;
    }
    return null;
  }

  public String getVar() {
    return var;
  }

 

  public void setVar(String var) {
    this.var = var;
  }

  public Object saveState(FacesContext facesContext) {
    Object values[] = new Object[4];
    values[0] = super.saveState(facesContext);
    values[1] = var;
    values[2] = selectionPath;
    values[3] = alternatingbackground;
    return ((Object) (values));
  }

  public void restoreState(FacesContext facesContext, Object state) {
    Object values[] = (Object[]) state;
    super.restoreState(facesContext, values[0]);
    var = (String) values[1];
    selectionPath = (TreePath[]) values[2];
    alternatingbackground = (Boolean) values[3];
  }

  public TreePath[] getSelectionPath() {
    return selectionPath;
  }

  public void setSelectionPath(TreePath[] selectionPath) {
    this.selectionPath = selectionPath;
  }

  public String getNodeId() {
    return nodeId;
  }

  public void setNodeId(String nodeId) {
    this.nodeId = nodeId;
  }

 
  public Boolean getAlternatingbackground() {
    java.lang.Boolean value = null;
    ValueBinding vb = getValueBinding("alternatingbackground");
        if (vb != null) {
      return (java.lang.Boolean)(vb.getValue(getFacesContext()));
        }
    else {
      value = this.alternatingbackground;
    }
    return value;
  }

  public void setAlternatingbackground(Boolean alternatingbackground) {
    this.alternatingbackground = alternatingbackground;
 
}
TOP

Related Classes of org.xulfaces.component.tree.TreeChildrenComponent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.