View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.example.demo;
21  
22  import org.apache.myfaces.tobago.context.Markup;
23  import org.apache.myfaces.tobago.event.TreeExpansionEvent;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  import java.lang.invoke.MethodHandles;
28  
29  public class Node {
30  
31    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
32  
33    private String name;
34  
35    private String id;
36  
37    private String tip;
38  
39    private Markup markup;
40  
41    private boolean expanded = true;
42  
43    private boolean disabled;
44  
45    private boolean selected;
46  
47    public Node(final String name) {
48      this.name = name;
49    }
50  
51    public Node(final String name, final String id) {
52      this.name = name;
53      this.id = id;
54    }
55  
56    public Node(final String name, final Markup markup) {
57      this.name = name;
58      this.markup = markup;
59    }
60  
61    public Node(final String name, final boolean disabled) {
62      this.name = name;
63      this.disabled = disabled;
64    }
65  
66    public String action() {
67      LOG.info("action: name='" + name + "'");
68      return null;
69    }
70  
71    public void expansionListener(final TreeExpansionEvent event) {
72      LOG.info("event='" + event + "'");
73      expanded = event.isNewExpanded();
74    }
75  
76    public String getName() {
77      return name;
78    }
79  
80    public void setName(final String name) {
81      this.name = name;
82    }
83  
84    public String getId() {
85      return id;
86    }
87  
88    public void setId(final String id) {
89      this.id = id;
90    }
91  
92    public boolean isExpanded() {
93      return expanded;
94    }
95  
96    public void setExpanded(final boolean expanded) {
97      this.expanded = expanded;
98    }
99  
100   public Markup getMarkup() {
101     return markup;
102   }
103 
104   public void setMarkup(final Markup markup) {
105     this.markup = markup;
106   }
107 
108   public String getTip() {
109     return tip;
110   }
111 
112   public void setTip(final String tip) {
113     this.tip = tip;
114   }
115 
116   public boolean isDisabled() {
117     return disabled;
118   }
119 
120   public void setDisabled(final boolean disabled) {
121     this.disabled = disabled;
122   }
123 
124   public boolean isSelected() {
125     return selected;
126   }
127 
128   public void setSelected(final boolean selected) {
129     this.selected = selected;
130   }
131 
132   public String toString() {
133     return "Node name=" + name + " id=" + id;
134   }
135 }