1 package de.matthias_burbach.mosaique.swing;
2
3 import java.util.Iterator;
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.LogicalPage;
9 import de.matthias_burbach.mosaique.core.model.StrutsConfig;
10
11 /***
12 * @author Matthias Burbach
13 */
14 public class StrutsConfigNode
15 extends AbstractFileItemNode {
16
17 /***
18 * The Struts config to display.
19 */
20 private StrutsConfig strutsConfig;
21
22 /***
23 * The tree model to delegate change operations to.
24 */
25 private DefaultTreeModel treeModel;
26
27 /***
28 * @param strutsConfig The Struts config to display.
29 * @param treeModel The tree model to delegate change operations to.
30 */
31 public StrutsConfigNode(
32 final StrutsConfig strutsConfig,
33 final DefaultTreeModel treeModel) {
34 this.strutsConfig = strutsConfig;
35 this.treeModel = treeModel;
36 }
37
38
39
40
41
42
43 /***
44 * {@inheritDoc}
45 */
46 protected void initChildren() {
47 if (strutsConfig.getLogicalPages() != null) {
48 for (Iterator iter = strutsConfig.getLogicalPages().iterator();
49 iter.hasNext();) {
50 LogicalPage logicalPage = (LogicalPage) iter.next();
51 LogicalPageNode logicalPageNode =
52 new LogicalPageNode(logicalPage, treeModel);
53 add(logicalPageNode);
54 }
55 }
56 }
57
58 /***
59 * @return The Struts config file item being displayed by this node.
60 */
61 public AbstractFileItem getFileItem() {
62 return strutsConfig;
63 }
64
65
66
67
68 /***
69 * {@inheritDoc}
70 */
71 public String toString() {
72 return strutsConfig.getName();
73 }
74 }