001 // ---------- Attention: Generated code, please do not modify! ----------- 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020 package org.apache.myfaces.tobago.component; 021 022 import javax.faces.context.FacesContext; 023 import javax.faces.el.MethodBinding; 024 import org.apache.myfaces.tobago.context.Markup; 025 import org.apache.myfaces.tobago.internal.component.AbstractUITreeNode; 026 import org.apache.commons.lang.ArrayUtils; 027 import org.apache.commons.lang.StringUtils; 028 import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression; 029 import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding; 030 import org.apache.myfaces.tobago.internal.util.Deprecation; 031 import org.apache.myfaces.tobago.renderkit.MarginValues; 032 import org.apache.myfaces.tobago.renderkit.SpacingValues; 033 import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer; 034 import javax.el.ELException; 035 import javax.faces.FacesException; 036 import java.util.ArrayList; 037 import java.util.List; 038 import javax.el.MethodExpression; 039 import javax.el.ValueExpression; 040 041 /** 042 Creates a tree node. This component represents a single node inside a tree structure. 043 For interating over tree node use tc:treeData. 044 * UIComponent class, generated from template {@code component1.2.stg} with class 045 * {@link org.apache.myfaces.tobago.internal.taglib.component.TreeNodeTagDeclaration}. 046 */ 047 public class UITreeNode 048 extends AbstractUITreeNode implements SupportsMarkup { 049 050 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.TreeNode"; 051 052 private java.lang.Boolean selected; 053 private java.lang.Boolean marked; 054 private org.apache.myfaces.tobago.context.Markup markup; 055 private javax.faces.el.MethodBinding treeExpansionListener; 056 private org.apache.myfaces.tobago.context.Markup currentMarkup; 057 private java.lang.Boolean expanded; 058 private java.lang.Boolean disabled; 059 private java.lang.String tip; 060 061 062 /** 063 Flag indicating if the node is selected (only possible, when the tree component allows it). 064 <br />Default: <code>false</code> 065 */ 066 public boolean isSelected() { 067 if (selected != null) { 068 return selected; 069 } 070 ValueExpression ve = getValueExpression("selected"); 071 if (ve != null) { 072 try { 073 Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext()); 074 if (bool != null) { 075 return bool; 076 } 077 } catch (ELException e) { 078 throw new FacesException(e); 079 } 080 } 081 return false; 082 } 083 084 public void setSelected(boolean selected) { 085 this.selected = selected; 086 } 087 088 /** 089 Flag indicating if the node is marked, and should be displayed in a special way. 090 <br />Default: <code>false</code> 091 */ 092 public boolean isMarked() { 093 if (marked != null) { 094 return marked; 095 } 096 ValueExpression ve = getValueExpression("marked"); 097 if (ve != null) { 098 try { 099 Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext()); 100 if (bool != null) { 101 return bool; 102 } 103 } catch (ELException e) { 104 throw new FacesException(e); 105 } 106 } 107 return false; 108 } 109 110 public void setMarked(boolean marked) { 111 this.marked = marked; 112 } 113 114 public org.apache.myfaces.tobago.context.Markup getMarkup() { 115 if (markup != null) { 116 return markup; 117 } 118 ValueExpression ve = getValueExpression("markup"); 119 if (ve != null) { 120 try { 121 Object object = ve.getValue(getFacesContext().getELContext()); 122 return Markup.valueOf(object); 123 } catch (ELException e) { 124 throw new FacesException(e); 125 } 126 } 127 return null; 128 } 129 130 public void setMarkup(org.apache.myfaces.tobago.context.Markup markup) { 131 this.markup = markup; 132 } 133 134 public javax.faces.el.MethodBinding getTreeExpansionListener() { 135 return treeExpansionListener; 136 } 137 138 public void setTreeExpansionListener(javax.faces.el.MethodBinding treeExpansionListener) { 139 this.treeExpansionListener = treeExpansionListener; 140 } 141 142 public org.apache.myfaces.tobago.context.Markup getCurrentMarkup() { 143 if (currentMarkup != null) { 144 return currentMarkup; 145 } 146 return null; 147 } 148 149 public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) { 150 this.currentMarkup = currentMarkup; 151 } 152 153 /** 154 Flag indicating if the subnodes are to be displayed. 155 <br />Default: <code>false</code> 156 */ 157 public boolean isExpanded() { 158 if (expanded != null) { 159 return expanded; 160 } 161 ValueExpression ve = getValueExpression("expanded"); 162 if (ve != null) { 163 try { 164 Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext()); 165 if (bool != null) { 166 return bool; 167 } 168 } catch (ELException e) { 169 throw new FacesException(e); 170 } 171 } 172 return false; 173 } 174 175 public void setExpanded(boolean expanded) { 176 this.expanded = expanded; 177 } 178 179 /** 180 Flag indicating that this element is disabled. 181 <br />Default: <code>false</code> 182 */ 183 public boolean isDisabled() { 184 if (disabled != null) { 185 return disabled; 186 } 187 ValueExpression ve = getValueExpression("disabled"); 188 if (ve != null) { 189 try { 190 Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext()); 191 if (bool != null) { 192 return bool; 193 } 194 } catch (ELException e) { 195 throw new FacesException(e); 196 } 197 } 198 return false; 199 } 200 201 public void setDisabled(boolean disabled) { 202 this.disabled = disabled; 203 } 204 205 /** 206 Text value to display as tooltip. 207 208 */ 209 public java.lang.String getTip() { 210 if (tip != null) { 211 return tip; 212 } 213 ValueExpression ve = getValueExpression("tip"); 214 if (ve != null) { 215 try { 216 return (java.lang.String) ve.getValue(getFacesContext().getELContext()); 217 } catch (ELException e) { 218 throw new FacesException(e); 219 } 220 } 221 return null; 222 } 223 224 public void setTip(java.lang.String tip) { 225 this.tip = tip; 226 } 227 228 public void restoreState(FacesContext context, Object componentState) { 229 Object[] values = (Object[]) componentState; 230 super.restoreState(context, values[0]); 231 selected = (java.lang.Boolean) values[1]; 232 marked = (java.lang.Boolean) values[2]; 233 markup = (org.apache.myfaces.tobago.context.Markup) values[3]; 234 treeExpansionListener = (javax.faces.el.MethodBinding) restoreAttachedState(context, values[4]); 235 expanded = (java.lang.Boolean) values[5]; 236 disabled = (java.lang.Boolean) values[6]; 237 tip = (java.lang.String) values[7]; 238 } 239 240 public Object saveState(FacesContext context) { 241 Object[] values = new Object[8]; 242 values[0] = super.saveState(context); 243 values[1] = selected; 244 values[2] = marked; 245 values[3] = markup; 246 values[4] = saveAttachedState(context, treeExpansionListener); 247 values[5] = expanded; 248 values[6] = disabled; 249 values[7] = tip; 250 currentMarkup = null; 251 return values; 252 } 253 254 255 }