KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > tools > templateeditor > tree > TemplateTreeFolder


1 package com.genimen.djeneric.tools.templateeditor.tree;
2
3 import javax.swing.ImageIcon JavaDoc;
4 import javax.swing.JTree JavaDoc;
5 import javax.swing.tree.TreePath JavaDoc;
6
7 import com.genimen.djeneric.structure.ExtentUsage;
8 import com.genimen.djeneric.tools.generator.util.Template;
9 import com.genimen.djeneric.tools.generator.util.TemplateSet;
10 import com.genimen.djeneric.tools.templateeditor.TemplateEditor;
11
12 public class TemplateTreeFolder extends DefaultTemplateTreeNode
13 {
14   private static final long serialVersionUID = 1L;
15
16   public TemplateTreeFolder(TemplateSet templateSet)
17   {
18     super(templateSet);
19   }
20
21   public TemplateTreeFolder(ExtentUsage extentUsage, JTree JavaDoc tree, TemplateSet templateSet)
22   {
23     super(extentUsage, tree, templateSet);
24   }
25
26   public void reload() throws Exception JavaDoc
27   {
28     _alreadyLoaded = false;
29     expandNode();
30   }
31
32   public void expandNode() throws Exception JavaDoc
33   {
34     if (_alreadyLoaded) return;
35
36     boolean isCollapsed = _tree.isCollapsed(new TreePath JavaDoc(this.getPath()));
37     removeAllChildren();
38
39     try
40     {
41       ExtentUsage taus = getExtentUsage();
42
43       for (int i = 0; i < taus.getDetailRelationCount(); i++)
44       {
45         TemplateTreeFolder folder = new TemplateTreeFolder(taus.getDetailRelation(i).getDetail(), _tree,
46             getTemplateSet());
47         insertAsFolder(folder);
48       }
49
50       Template[] templates = getTemplateSet().getTemplatesFor(taus.getExtent().getObjectType());
51       for (int i = 0; i < templates.length; i++)
52       {
53         TemplateTreeNode ttn = new TemplateTreeNode(taus, _tree, getTemplateSet(), templates[i]);
54         insertAsChild(ttn);
55       }
56
57       _alreadyLoaded = true;
58     }
59     finally
60     {
61       getModel().nodeStructureChanged(this);
62       if (!isCollapsed) _tree.expandPath(new TreePath JavaDoc(this.getPath()));
63     }
64   }
65
66   public ImageIcon JavaDoc getImageIcon()
67   {
68     return TemplateEditor.getImageIcon("folder.gif");
69   }
70
71 }
Popular Tags