01: package net.sourceforge.squirrel_sql.plugins.oracle.expander;
02:
03: /*
04: * Copyright (C) 2002-2003 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.sql.SQLException;
22: import java.util.ArrayList;
23: import java.util.List;
24:
25: import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
26: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
27: import net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData;
28:
29: import net.sourceforge.squirrel_sql.client.session.ISession;
30: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
31: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
32:
33: import net.sourceforge.squirrel_sql.plugins.oracle.IObjectTypes;
34:
35: /**
36: * This class handles the expanding of the "Package Type" or "Package Heading"
37: * node. It will give a list of all the packages available in the schema.
38: *
39: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
40: */
41: public class PackageParentExpander implements INodeExpander {
42: /**
43: * Default ctor.
44: *
45: * @throws IllegalArgumentException
46: * Thrown if <TT>null</TT> <TT>OraclePlugin</TT> passed.
47: */
48: PackageParentExpander() {
49: super ();
50: }
51:
52: /**
53: * Create the child nodes for the passed parent node and return them. Note
54: * that this method should <B>not</B> actually add the child nodes to the
55: * parent node as this is taken care of in the caller.
56: *
57: * @param session Current session.
58: * @param node Node to be expanded.
59: *
60: * @return A list of <TT>ObjectTreeNode</TT> objects representing the child
61: * nodes for the passed node.
62: */
63: public List<ObjectTreeNode> createChildren(ISession session,
64: ObjectTreeNode parentNode) throws SQLException {
65: final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
66: final IDatabaseObjectInfo parentDbinfo = parentNode
67: .getDatabaseObjectInfo();
68: final SQLDatabaseMetaData md = session.getSQLConnection()
69: .getSQLMetaData();
70: final String schemaName = parentDbinfo.getSchemaName();
71:
72: // Add package node to contain standalone procedures.
73: IDatabaseObjectInfo dbinfo = new DatabaseObjectInfo(null,
74: schemaName, "", IObjectTypes.PACKAGE, md);
75: ObjectTreeNode child = new ObjectTreeNode(session, dbinfo);
76: child.setUserObject("Standalone");
77: childNodes.add(child);
78:
79: // Add packages.
80: ObjectType objType = new ObjectType(IObjectTypes.PACKAGE,
81: "PACKAGE", IObjectTypes.PACKAGE);
82: INodeExpander exp = new ObjectTypeExpander(objType);
83: childNodes.addAll(exp.createChildren(session, parentNode));
84:
85: return childNodes;
86: }
87: }
|