View Javadoc

1   package de.matthias_burbach.mosaique.swing;
2   
3   
4   import java.util.Iterator;
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.Insert;
10  import de.matthias_burbach.mosaique.core.model.Jsp;
11  import de.matthias_burbach.mosaique.core.model.TilesContext;
12  
13  /***
14   * @author Matthias Burbach
15   */
16  public class JspNode extends AbstractFileItemNode {
17      /***
18       * The JSP to display.
19       */
20      private Jsp jsp;
21  
22      /***
23       * The tiles context of this Jsp if activated by the defining definition.
24       */
25      private TilesContext tilesContext;
26  
27      /***
28       * The tree model to delegate change operations to.
29       */
30      private DefaultTreeModel treeModel;
31  
32      /***
33       * @param jsp The JSP to display.
34       * @param tilesContext The Tiles context used when the displayed JSP is
35       *                     rendered.
36       * @param treeModel The tree model to delegate change operations to.
37       */
38      public JspNode(
39              final Jsp jsp,
40              final TilesContext tilesContext,
41              final DefaultTreeModel treeModel) {
42          this.jsp = jsp;
43          this.tilesContext = tilesContext;
44          this.treeModel = treeModel;
45      }
46  
47      /*
48       * (non-Javadoc)
49       * @see de.matthias_burbach.mosaique.swing.BaseMutableTreeNode
50       *          #initChildren()
51       */
52      /***
53       * {@inheritDoc}
54       */
55      protected void initChildren() {
56          if (jsp.getInserts() != null) {
57              for (Iterator iter = jsp.getInserts().iterator(); iter.hasNext();) {
58                  Insert insert = (Insert) iter.next();
59                  InsertNode insertNode =
60                      new InsertNode(insert, tilesContext, treeModel);
61                  add(insertNode);
62              }
63          }
64      }
65  
66      /*
67       * (non-Javadoc)
68       * @see de.matthias_burbach.mosaique.swing.AbstractFileItemNode
69       *          #getFileItem()
70       */
71      /***
72       * {@inheritDoc}
73       */
74      public AbstractFileItem getFileItem() {
75          return jsp;
76      }
77  
78      /*(non-Javadoc)
79       * @see java.lang.Object#toString()
80       */
81      /***
82       * {@inheritDoc}
83       */
84      public String toString() {
85          return jsp.getName();
86      }
87  }