View Javadoc

1   package de.matthias_burbach.mosaique.swing;
2   
3   import java.util.Iterator;
4   import java.util.List;
5   
6   import javax.swing.tree.DefaultTreeModel;
7   
8   import de.matthias_burbach.mosaique.core.model.AbstractFileItem;
9   import de.matthias_burbach.mosaique.core.model.Definition;
10  import de.matthias_burbach.mosaique.core.model.Put;
11  
12  /***
13   * @author Matthias Burbach
14   */
15  public class PutsNode extends AbstractFileItemNode {
16      /***
17       * The Tiles definition whose puts to display.
18       */
19      private Definition definition;
20  
21      /***
22       * The puts dynamically defined on the JSP that inserts the definition
23       * with this Tiles context of put attributes.
24       */
25      private List dynamicPuts;
26  
27      /***
28       * The tree model to delegate change operations to.
29       */
30      private DefaultTreeModel treeModel;
31  
32      /***
33       * @param definition The definition to display.
34       * @param dynamicPuts The puts dynamically defined on the JSP that inserts
35       *                    the definition with this Tiles context of put
36       *                    attributes.
37       * @param treeModel The tree model to delegate change operations to.
38       */
39      public PutsNode(
40              final Definition definition,
41              final List dynamicPuts,
42              final DefaultTreeModel treeModel) {
43          this.definition = definition;
44          this.dynamicPuts = dynamicPuts;
45          this.treeModel = treeModel;
46      }
47  
48      /*
49       * (non-Javadoc)
50       * @see de.matthias_burbach.mosaique.swing.BaseMutableTreeNode
51       *          #initChildren()
52       */
53      /***
54       * {@inheritDoc}
55       */
56      protected void initChildren() {
57          for (Iterator iter =
58                  definition.getTilesContext().getPutsOrderedByLevel().iterator();
59                  iter.hasNext();) {
60              Put put = (Put) iter.next();
61              PutNode putNode = new PutNode(put, treeModel);
62              add(putNode);
63          }
64          if (dynamicPuts != null) {
65              for (Iterator iter = dynamicPuts.iterator(); iter.hasNext();) {
66                  Put put = (Put) iter.next();
67                  PutNode putNode = new PutNode(put, treeModel);
68                  add(putNode);
69              }
70          }
71      }
72  
73      /*
74       * (non-Javadoc)
75       * @see de.matthias_burbach.mosaique.swing.AbstractFileItemNode
76       *          #getFileItem()
77       */
78      /***
79       * {@inheritDoc}
80       */
81      public AbstractFileItem getFileItem() {
82          return definition;
83      }
84  
85      /*(non-Javadoc)
86       * @see java.lang.Object#toString()
87       */
88      /***
89       * {@inheritDoc}
90       */
91      public String toString() {
92          return "puts";
93      }
94  }