View Javadoc

1   package de.matthias_burbach.mosaique.swing;
2   
3   
4   import javax.swing.tree.DefaultTreeModel;
5   
6   import de.matthias_burbach.mosaique.core.model.AbstractFileItem;
7   import de.matthias_burbach.mosaique.core.model.Definition;
8   import de.matthias_burbach.mosaique.core.model.LogicalPage;
9   
10  /***
11   * @author Matthias Burbach
12   */
13  public class LogicalPageNode
14      extends AbstractFileItemNode {
15  
16      /***
17       * The logical page to display.
18       */
19      private LogicalPage logicalPage;
20  
21      /***
22       * The tree model to delegate change operations to.
23       */
24      private DefaultTreeModel treeModel;
25  
26      /***
27       * @param logicalPage The logical page to display.
28       * @param treeModel The tree model to delegate change operations to.
29       */
30      public LogicalPageNode(
31              final LogicalPage logicalPage,
32              final DefaultTreeModel treeModel) {
33          this.logicalPage = logicalPage;
34          this.treeModel = treeModel;
35      }
36  
37      /*
38       * (non-Javadoc)
39       * @see de.matthias_burbach.mosaique.swing.BaseMutableTreeNode
40       *          #initChildren()
41       */
42      /***
43       * {@inheritDoc}
44       */
45      protected void initChildren() {
46          Definition definition = logicalPage.getDefinition();
47          if (definition != null) {
48              DefinitionNode child =
49                  new DefinitionNode(definition, null, treeModel);
50              add(child);
51          }
52      }
53  
54      /*
55       * (non-Javadoc)
56       * @see de.matthias_burbach.mosaique.swing.AbstractFileItemNode
57       *          #getFileItem()
58       */
59      /***
60       * {@inheritDoc}
61       */
62      public AbstractFileItem getFileItem() {
63          return logicalPage;
64      }
65  
66      /*(non-Javadoc)
67       * @see java.lang.Object#toString()
68       */
69      /***
70       * {@inheritDoc}
71       */
72      public String toString() {
73          return logicalPage.getName();
74      }
75  }