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 ValueExpression ve = getValueExpression("currentMarkup"); 147 if (ve != null) { 148 try { 149 Object object = ve.getValue(getFacesContext().getELContext()); 150 return Markup.valueOf(object); 151 } catch (ELException e) { 152 throw new FacesException(e); 153 } 154 } 155 return null; 156 } 157 158 public void setCurrentMarkup(org.apache.myfaces.tobago.context.Markup currentMarkup) { 159 this.currentMarkup = currentMarkup; 160 } 161 162 /** 163 Flag indicating if the subnodes are to be displayed. 164 <br />Default: <code>false</code> 165 */ 166 public boolean isExpanded() { 167 if (expanded != null) { 168 return expanded; 169 } 170 ValueExpression ve = getValueExpression("expanded"); 171 if (ve != null) { 172 try { 173 Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext()); 174 if (bool != null) { 175 return bool; 176 } 177 } catch (ELException e) { 178 throw new FacesException(e); 179 } 180 } 181 return false; 182 } 183 184 public void setExpanded(boolean expanded) { 185 this.expanded = expanded; 186 } 187 188 /** 189 Flag indicating that this element is disabled. 190 <br />Default: <code>false</code> 191 */ 192 public boolean isDisabled() { 193 if (disabled != null) { 194 return disabled; 195 } 196 ValueExpression ve = getValueExpression("disabled"); 197 if (ve != null) { 198 try { 199 Boolean bool = (Boolean) ve.getValue(getFacesContext().getELContext()); 200 if (bool != null) { 201 return bool; 202 } 203 } catch (ELException e) { 204 throw new FacesException(e); 205 } 206 } 207 return false; 208 } 209 210 public void setDisabled(boolean disabled) { 211 this.disabled = disabled; 212 } 213 214 /** 215 Text value to display as tooltip. 216 217 */ 218 public java.lang.String getTip() { 219 if (tip != null) { 220 return tip; 221 } 222 ValueExpression ve = getValueExpression("tip"); 223 if (ve != null) { 224 try { 225 return (java.lang.String) ve.getValue(getFacesContext().getELContext()); 226 } catch (ELException e) { 227 throw new FacesException(e); 228 } 229 } 230 return null; 231 } 232 233 public void setTip(java.lang.String tip) { 234 this.tip = tip; 235 } 236 237 public void restoreState(FacesContext context, Object componentState) { 238 Object[] values = (Object[]) componentState; 239 super.restoreState(context, values[0]); 240 selected = (java.lang.Boolean) values[1]; 241 marked = (java.lang.Boolean) values[2]; 242 markup = (org.apache.myfaces.tobago.context.Markup) values[3]; 243 treeExpansionListener = (javax.faces.el.MethodBinding) restoreAttachedState(context, values[4]); 244 currentMarkup = (org.apache.myfaces.tobago.context.Markup) values[5]; 245 expanded = (java.lang.Boolean) values[6]; 246 disabled = (java.lang.Boolean) values[7]; 247 tip = (java.lang.String) values[8]; 248 } 249 250 public Object saveState(FacesContext context) { 251 Object[] values = new Object[9]; 252 values[0] = super.saveState(context); 253 values[1] = selected; 254 values[2] = marked; 255 values[3] = markup; 256 values[4] = saveAttachedState(context, treeExpansionListener); 257 values[5] = currentMarkup; 258 values[6] = expanded; 259 values[7] = disabled; 260 values[8] = tip; 261 return values; 262 } 263 264 265 }