View Javadoc

1   package de.matthias_burbach.mosaique.swing;
2   
3   import java.util.List;
4   
5   import javax.swing.tree.DefaultTreeModel;
6   
7   import de.matthias_burbach.mosaique.core.model.AbstractFileItem;
8   import de.matthias_burbach.mosaique.core.model.Definition;
9   import de.matthias_burbach.mosaique.core.model.Jsp;
10  import de.matthias_burbach.mosaique.core.model.TilesContext;
11  
12  /***
13   * @author Matthias Burbach
14   */
15  public class DefinitionNode extends AbstractFileItemNode {
16      /***
17       * The Tiles definition to display.
18       */
19      private Definition definition;
20  
21      /***
22       * The puts defined by the insert element inserting this definition.
23       * Can be null.
24       */
25      private List insertPuts;
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 insertPuts The puts defined by the insert element inserting this
35       *                   definition. Can be null.
36       * @param treeModel The tree model to delegate change operations to.
37       */
38      public DefinitionNode(
39              final Definition definition,
40              final List insertPuts,
41              final DefaultTreeModel treeModel) {
42          this.definition = definition;
43          this.insertPuts = insertPuts;
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          Jsp jsp = definition.getJsp();
57          TilesContext tilesContext = definition.getTilesContext();
58          if (jsp != null) {
59              JspNode jspNode = new JspNode(jsp, tilesContext, treeModel);
60              add(jspNode);
61          }
62          PutsNode putsNode = new PutsNode(definition, insertPuts, treeModel);
63          add(putsNode);
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 definition;
76      }
77  
78      /*(non-Javadoc)
79       * @see java.lang.Object#toString()
80       */
81      /***
82       * {@inheritDoc}
83       */
84      public String toString() {
85          return definition.getName();
86      }
87  }