1 30 package com.genimen.djeneric.tools.console.nodes; 31 32 import javax.swing.ImageIcon ; 33 import javax.swing.JTree ; 34 import javax.swing.tree.DefaultTreeModel ; 35 import javax.swing.tree.TreePath ; 36 37 import com.genimen.djeneric.repository.DjExtent; 38 import com.genimen.djeneric.repository.DjSession; 39 import com.genimen.djeneric.util.DjLogger; 40 41 public class RootNode extends CustomTreeNode 42 { 43 private static final long serialVersionUID = 1L; 44 DjSession _session; 45 46 public RootNode() 47 { 48 } 49 50 public void setTree(JTree tree) 51 { 52 _tree = tree; 53 } 54 55 public void setModel(DefaultTreeModel model) 56 { 57 _treeModel = model; 58 } 59 60 public void setSession(DjSession session) 61 { 62 _session = session; 63 } 64 65 public ImageIcon getImageIcon() 66 { 67 return (getImageIcon("images/schema.gif")); 68 } 69 70 public String toString() 71 { 72 return "Schema"; 73 } 74 75 public void expandNode() throws Exception 76 { 77 if (_alreadyLoaded) return; 78 79 boolean isCollapsed = _tree.isCollapsed(new TreePath (this.getPath())); 80 removeAllChildren(); 81 _treeModel.nodeStructureChanged(this); 82 83 try 84 { 85 DjExtent[] tables = _session.getPersistenceManager().getExtentsSorted(); 86 for (int i = 0; i < tables.length; i++) 87 { 88 insertAsFolder(new ExtentNode(getTree(), getModel(), tables[i])); 89 } 90 _alreadyLoaded = true; 91 } 92 catch (Exception x) 93 { 94 DjLogger.log(x); 95 } 96 if (!isCollapsed) _tree.expandPath(new TreePath (this.getPath())); 97 } 98 99 } | Popular Tags |