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 program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or any later version.
11: *
12: * This program 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
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; 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.client.session.ISession;
26: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
27: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.TableTypeExpander;
28: import net.sourceforge.squirrel_sql.plugins.oracle.prefs.OraclePreferenceBean;
29:
30: /**
31: * This class is an expander for Oracle table nodes which could potentially
32: * include flashback recycle bin tables. This will exclude those tables if the
33: * plugin is so configured.
34: *
35: * @author manningr
36: */
37: public class OracleTableParentExpander extends TableTypeExpander {
38:
39: private OraclePreferenceBean _prefs = null;
40:
41: /**
42: * Default ctor.
43: */
44: public OracleTableParentExpander(OraclePreferenceBean prefs) {
45: super ();
46: _prefs = prefs;
47: }
48:
49: /**
50: * Create the child nodes for the passed parent node and return them. Note
51: * that this method should <B>not</B> actually add the child nodes to the
52: * parent node as this is taken care of in the caller.
53: *
54: * @param session Current session.
55: * @param node Node to be expanded.
56: *
57: * @return A list of <TT>ObjectTreeNode</TT> objects representing the child
58: * nodes for the passed node.
59: */
60: public List<ObjectTreeNode> createChildren(ISession session,
61: ObjectTreeNode parentNode) throws SQLException {
62: final List<ObjectTreeNode> childNodes = super .createChildren(
63: session, parentNode);
64: List<ObjectTreeNode> result = new ArrayList<ObjectTreeNode>();
65: for (ObjectTreeNode childNode : childNodes) {
66: if (_prefs.isExcludeRecycleBinTables()) {
67: if (!childNode.getUserObject().toString().startsWith(
68: "BIN$")) {
69: result.add(childNode);
70: }
71: } else {
72: result.add(childNode);
73: }
74: }
75: return result;
76: }
77: }
|