01: package org.firebirdsql.squirrel.exp;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.firebirdsql.squirrel.FirebirdPlugin;
07: import org.firebirdsql.squirrel.IObjectTypes;
08: import org.firebirdsql.squirrel.util.IndexParentInfo;
09:
10: import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
11: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
12: import net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData;
13:
14: import net.sourceforge.squirrel_sql.client.session.ISession;
15: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
16: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
17:
18: public class DatabaseExpander implements INodeExpander {
19: /** Logger for this class. */
20: // private static ILogger s_log =
21: // LoggerController.createLogger(DatabaseExpander.class);
22: private FirebirdPlugin _plugin;
23:
24: public DatabaseExpander(FirebirdPlugin plugin) {
25: this ._plugin = plugin;
26: }
27:
28: /**
29: * Create the child nodes for the passed parent node and return them. Note
30: * that this method should <B>not</B> actually add the child nodes to the
31: * parent node as this is taken care of in the caller.
32: *
33: * @param session Current session.
34: * @param node Node to be expanded.
35: *
36: * @return A list of <TT>ObjectTreeNode</TT> objects representing the child
37: * nodes for the passed node.
38: */
39: public List<ObjectTreeNode> createChildren(ISession session,
40: ObjectTreeNode parentNode) {
41: final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
42: final SQLDatabaseMetaData md = session.getSQLConnection()
43: .getSQLMetaData();
44:
45: final IDatabaseObjectInfo parentDbinfo = parentNode
46: .getDatabaseObjectInfo();
47: final String catalogName = parentDbinfo.getCatalogName();
48: final String schemaName = parentDbinfo.getSimpleName();
49: ObjectTreeNode node;
50: IDatabaseObjectInfo seqInfo = new DatabaseObjectInfo(
51: catalogName, schemaName, "GENERATORS",
52: IObjectTypes.GENERATOR_PARENT, md);
53: node = new ObjectTreeNode(session, seqInfo);
54: node.addExpander(new GeneratorParentExpander(_plugin));
55: childNodes.add(node);
56:
57: seqInfo = new DatabaseObjectInfo(catalogName, schemaName,
58: "DOMAINS", IObjectTypes.DOMAIN_PARENT, md);
59: node = new ObjectTreeNode(session, seqInfo);
60: node.addExpander(new DomainParentExpander(_plugin));
61: childNodes.add(node);
62:
63: seqInfo = new IndexParentInfo(null, md);
64: node = new ObjectTreeNode(session, seqInfo);
65: childNodes.add(node);
66:
67: return childNodes;
68: }
69:
70: }
|