View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package guessNumber;
    18
    19  import java.io.Serializable;
    20
    21  import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
    22  import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
    23
    24  /***
    25   * <p>
    26   * Bean holding the tree hierarchy.
    27   * </p>
    28   *
    29   * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
    30   */
    31  public class TreeTable implements Serializable
    32  {
    33      private DefaultTreeModel treeModel;
    34
    35      /***
    36       * @param treeModel The treeModel.
    37       */
    38      public TreeTable(DefaultTreeModel treeModel)
    39      {
    40          this.treeModel = treeModel;
    41      }
    42
    43      /***
    44       * <p>
    45       * Default constructor.
    46       * </p>
    47       */
    48      public TreeTable()
    49      {
    50          DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeItem(1, "XY", "9001", "XY 9001"));
    51          DefaultMutableTreeNode a = new DefaultMutableTreeNode(new TreeItem(2, "A", "9001", "A 9001"));
    52          root.insert(a);
    53          DefaultMutableTreeNode b = new DefaultMutableTreeNode(new TreeItem(3, "B", "9001", "B 9001"));
    54          root.insert(b);
    55          DefaultMutableTreeNode c = new DefaultMutableTreeNode(new TreeItem(4, "C", "9001", "C 9001"));
    56          root.insert(c);
    57
    58          DefaultMutableTreeNode node = new DefaultMutableTreeNode(new TreeItem(5, "a1", "9002", "a1 9002"));
    59          a.insert(node);
    60          node = new DefaultMutableTreeNode(new TreeItem(6, "a2", "9002", "a2 9002"));
    61          a.insert(node);
    62          node = new DefaultMutableTreeNode(new TreeItem(7, "a3", "9002", "a3 9002"));
    63          a.insert(node);
    64          node = new DefaultMutableTreeNode(new TreeItem(8, "b", "9002", "b 9002"));
    65          b.insert(node);
    66
    67          a = node;
    68          node = new DefaultMutableTreeNode(new TreeItem(9, "x1", "9003", "x1 9003"));
    69          a.insert(node);
    70          node = new DefaultMutableTreeNode(new TreeItem(9, "x2", "9003", "x2 9003"));
    71          a.insert(node);
    72
    73          this.treeModel = new DefaultTreeModel(root);
    74      }
    75
    76      /***
    77       * @return Returns the treeModel.
    78       */
    79      public DefaultTreeModel getTreeModel()
    80      {
    81          return treeModel;
    82      }
    83
    84      /***
    85       * @param treeModel The treeModel to set.
    86       */
    87      public void setTreeModel(DefaultTreeModel treeModel)
    88      {
    89          this.treeModel = treeModel;
    90      }
    91  }