001: package net.sourceforge.squirrel_sql.client.session;
002:
003: /*
004: * Copyright (C) 2002-2004 Colin Bell and Johan Compagner
005: * colbell@users.sourceforge.net
006: * jcompagner@j-com.nl
007: *
008: * Modifications Copyright (C) 2003-2004 Jason Height
009: *
010: * This library is free software; you can redistribute it and/or
011: * modify it under the terms of the GNU Lesser General Public
012: * License as published by the Free Software Foundation; either
013: * version 2.1 of the License, or (at your option) any later version.
014: *
015: * This library is distributed in the hope that it will be useful,
016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018: * Lesser General Public License for more details.
019: *
020: * You should have received a copy of the GNU Lesser General Public
021: * License along with this library; if not, write to the Free Software
022: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
023: */
024: import java.util.List;
025:
026: import javax.swing.Action;
027: import javax.swing.JMenu;
028: import javax.swing.event.TreeModelListener;
029: import javax.swing.event.TreeSelectionListener;
030:
031: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
032: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.IObjectTreeListener;
033: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
034: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.IObjectTab;
035: import net.sourceforge.squirrel_sql.fw.datasetviewer.DataSetException;
036: import net.sourceforge.squirrel_sql.fw.id.IHasIdentifier;
037: import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
038: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
039: import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
040:
041: /**
042: * This interface defines the API through which plugins can work with the object
043: * tree.
044: *
045: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
046: */
047: public interface IObjectTreeAPI extends IHasIdentifier {
048: /**
049: * Retrieves the session of associated with the tree.
050: *
051: * @return Session associated with the tree.
052: */
053: ISession getSession();
054:
055: /**
056: * Add an expander for the specified object tree node type.
057: *
058: * @param dboType Database object type.
059: * @param expander Expander called to add children to a parent node.
060: *
061: * @throws IllegalArgumentException
062: * Thrown if a <TT>null</TT> <TT>DatabaseObjectType</TT> or
063: * <TT>INodeExpander</TT> thrown.
064: */
065: void addExpander(DatabaseObjectType dboType, INodeExpander expander);
066:
067: /**
068: * Add a tab to be displayed in the detail panel for the passed
069: * database object type.
070: *
071: * @param dboType Database object type.
072: * @param tab Tab to be displayed.
073: *
074: * @throws IllegalArgumentException
075: * Thrown when a <TT>null</TT> <TT>DatabaseObjectType</TT> or
076: * <TT>IObjectTab</TT> passed.
077: */
078: void addDetailTab(DatabaseObjectType dboType, IObjectTab tab);
079:
080: /**
081: * Add a listener to the object tree for structure changes. I.E nodes
082: * added/removed.
083: *
084: * @param lis The <TT>TreeModelListener</TT> you want added.
085: *
086: * @throws IllegalArgumentException
087: * Thrown if <TT>null</TT> <TT>TreeModelListener</TT> passed.
088: */
089: void addTreeModelListener(TreeModelListener lis);
090:
091: /**
092: * Remove a structure changes listener from the object tree.
093: *
094: * @param lis The <TT>TreeModelListener</TT> you want removed.
095: *
096: * @throws IllegalArgumentException
097: * Thrown if <TT>null</TT> <TT>TreeModelListener</TT> passed.
098: */
099: void removeTreeModelListener(TreeModelListener lis);
100:
101: /**
102: * Add a listener to the object tree for selection changes.
103: *
104: * @param lis The <TT>TreeSelectionListener</TT> you want added.
105: *
106: * @throws IllegalArgumentException
107: * Thrown if <TT>null</TT> <TT>TreeSelectionListener</TT> passed.
108: */
109: void addTreeSelectionListener(TreeSelectionListener lis);
110:
111: /**
112: * Remove a listener from the object tree for selection changes.
113: *
114: * @param lis The <TT>TreeSelectionListener</TT> you want removed.
115: *
116: * @throws IllegalArgumentException
117: * Thrown if <TT>null</TT> <TT>TreeSelectionListener</TT> passed.
118: */
119: void removeTreeSelectionListener(TreeSelectionListener lis);
120:
121: /**
122: * Add a listener to the object tree.
123: *
124: * @param lis The <TT>ObjectTreeListener</TT> you want added.
125: *
126: * @throws IllegalArgumentException
127: * Thrown if <TT>null</TT> <TT>ObjectTreeListener</TT> passed.
128: */
129: void addObjectTreeListener(IObjectTreeListener lis);
130:
131: /**
132: * Remove a listener from the object tree.
133: *
134: * @param lis The <TT>ObjectTreeListener</TT> you want removed.
135: *
136: * @throws IllegalArgumentException
137: * Thrown if <TT>null</TT> <TT>ObjectTreeListener</TT> passed.
138: */
139: void removeObjectTreeListener(IObjectTreeListener lis);
140:
141: /**
142: * Add an <TT>Action</TT> to the popup menu for the specified database
143: * object type.
144: *
145: * @param dboType Database object type.
146: * @param action Action to add to menu.
147: *
148: * @throws IllegalArgumentException
149: * Thrown if a <TT>null</TT> <TT>DatabaseObjectType</TT> or
150: * <TT>Action</TT> thrown.
151: */
152: void addToPopup(DatabaseObjectType dboType, Action action);
153:
154: /**
155: * Add an <TT>Action</TT> to the popup menu for all node types.
156: *
157: * @param action Action to add to menu.
158: *
159: * @throws IllegalArgumentException
160: * Thrown if a <TT>null</TT> <TT>Action</TT> thrown.
161: */
162: void addToPopup(Action action);
163:
164: /**
165: * Add an hierarchical menu to the popup menu for the specified database
166: * object type.
167: *
168: * @param dboType Database object type.
169: * @param menu <TT>JMenu</TT> to add to menu.
170: *
171: * @throws IllegalArgumentException
172: * Thrown if a <TT>null</TT> <TT>DatabaseObjectType</TT> or
173: * <TT>JMenu</TT> thrown.
174: */
175: void addToPopup(DatabaseObjectType dboType, JMenu menu);
176:
177: /**
178: * Add an hierarchical menu to the popup menu for all node types.
179: *
180: * @param menu <TT>JMenu</TT> to add to menu.
181: *
182: * @throws IllegalArgumentException
183: * Thrown if a <TT>null</TT> <TT>JMenu</TT> thrown.
184: */
185: void addToPopup(JMenu menu);
186:
187: /**
188: * Return an array of the selected nodes in the tree. This is guaranteed
189: * to be non-null.
190: *
191: * @return Array of nodes in the tree.
192: */
193: ObjectTreeNode[] getSelectedNodes();
194:
195: /**
196: * Return an array of the currently selected database
197: * objects. This is guaranteed to be non-null.
198: *
199: * @return array of <TT>ObjectTreeNode</TT> objects.
200: */
201: IDatabaseObjectInfo[] getSelectedDatabaseObjects();
202:
203: /**
204: * Return a type-safe list of the currently selected database tables
205: *
206: * @return list of <TT>ITableInfo</TT> objects.
207: */
208: List<ITableInfo> getSelectedTables();
209:
210: /**
211: * Refresh the object tree.
212: */
213: void refreshTree();
214:
215: /**
216: * Refresh the object tree.
217: */
218: void refreshTree(boolean reloadSchemaInfo);
219:
220: /**
221: * Refresh the nodes currently selected in the object tree.
222: */
223: void refreshSelectedNodes();
224:
225: /**
226: * Remove one or more nodes from the tree.
227: *
228: * @param nodes Array of nodes to be removed.
229: *
230: * @throws IllegalArgumentException
231: * Thrown if a <TT>null</TT> <TT>ObjectTreeNode[]</TT> thrown.
232: */
233: void removeNodes(ObjectTreeNode[] nodes);
234:
235: /**
236: * Retrieve details about all object types that can be in this
237: * tree.
238: *
239: * @return DatabaseObjectType[] Array of object type info objects.
240: */
241: DatabaseObjectType[] getDatabaseObjectTypes();
242:
243: /**
244: * Add a known database object type to the object tree.
245: *
246: * @param dboType The new database object type.
247: */
248: void addKnownDatabaseObjectType(DatabaseObjectType dboType);
249:
250: IObjectTab getTabbedPaneIfSelected(DatabaseObjectType dbObjectType,
251: String title);
252:
253: /**
254: * Tries to locate the object given by the paramteres in the Object tree.
255: * The first matching object found is selected.
256: *
257: * @param catalog null means any catalog
258: * @param schema null means any schema
259: * @param table, view, ... but not a table or view column
260: * @return true if the Object was found and selected.
261: */
262: boolean selectInObjectTree(String catalog, String schema,
263: String object);
264:
265: /**
266: * Selects the root node of the tree.
267: */
268: void selectRoot();
269:
270: /**
271: * Expands the specified tree node.
272: *
273: * @param node the tree node to expand
274: */
275: void expandNode(ObjectTreeNode node);
276:
277: /**
278: * Calls refreshComponent on the selected tab in the current
279: * ObjectTreeTabbedPane, if the selected tab happens to be a BaseDataSetTab
280: * type.
281: *
282: * @throws DataSetException if there was a problem refreshing the component.
283: */
284: void refreshSelectedTab() throws DataSetException;
285:
286: }
|