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: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: */
022: import javax.swing.Action;
023: import javax.swing.JMenu;
024: import javax.swing.JMenuItem;
025:
026: import net.sourceforge.squirrel_sql.client.session.event.IResultTabListener;
027: import net.sourceforge.squirrel_sql.client.session.event.ISQLExecutionListener;
028: import net.sourceforge.squirrel_sql.client.session.event.ISQLPanelListener;
029: import net.sourceforge.squirrel_sql.client.session.event.ISQLResultExecuterTabListener;
030: import net.sourceforge.squirrel_sql.client.session.mainpanel.ISQLResultExecuter;
031: import net.sourceforge.squirrel_sql.client.session.mainpanel.SqlPanelListener;
032: import net.sourceforge.squirrel_sql.client.session.mainpanel.SQLHistoryItem;
033:
034: import java.io.File;
035: import java.util.ArrayList;
036:
037: /**
038: * This interface defines the API through which plugins can work with the SQL
039: * panel.
040: *
041: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
042: */
043: public interface ISQLPanelAPI {
044: void addExecutor(ISQLResultExecuter exec);
045:
046: void removeExecutor(ISQLResultExecuter exec);
047:
048: /**
049: * Add a listener listening for SQL Execution.
050: *
051: * @param lis Listener
052: *
053: * @throws IllegalArgumentException
054: * If a null <TT>ISQLExecutionListener</TT> passed.
055: */
056: void addSQLExecutionListener(ISQLExecutionListener lis);
057:
058: /**
059: * Remove an SQL execution listener.
060: *
061: * @param lis Listener
062: *
063: * @throws IllegalArgumentException
064: * If a null <TT>ISQLExecutionListener</TT> passed.
065: */
066: void removeSQLExecutionListener(ISQLExecutionListener lis);
067:
068: /**
069: * Add a listener for events in this sessions result tabs.
070: *
071: * @param lis The listener.
072: */
073: void addResultTabListener(IResultTabListener lis);
074:
075: /**
076: * Remove a listener for events in this sessions result tabs.
077: *
078: * @param lis The listener.
079: */
080: void removeResultTabListener(IResultTabListener lis);
081:
082: /**
083: * Add a listener for events in this SQL Panel.
084: *
085: * @param lis Listener
086: *
087: * @throws IllegalArgumentException
088: * If a null <TT>ISQLPanelListener</TT> passed.
089: */
090: void addSQLPanelListener(ISQLPanelListener lis);
091:
092: /**
093: * Remove a listener.
094: *
095: * @param lis Listener
096: *
097: * @throws IllegalArgumentException
098: * If a null <TT>ISQLPanelListener</TT> passed.
099: */
100: void removeSQLPanelListener(ISQLPanelListener lis);
101:
102: /**
103: * Add a listener for events in this sql panel executer tabs.
104: *
105: * @param lis The listener.
106: */
107: void addExecuterTabListener(ISQLResultExecuterTabListener lis);
108:
109: /**
110: * Remove a listener for events in this sql panel executer tabs.
111: *
112: * @param lis The listener.
113: */
114: void removeExecuterTabListener(ISQLResultExecuterTabListener lis);
115:
116: ISQLEntryPanel getSQLEntryPanel();
117:
118: /**
119: * Returns the result execution panel that stores such things as IResultTabs
120: *
121: * @return an implementation of ISQLResultExecuter
122: */
123: ISQLResultExecuter getSQLResultExecuter();
124:
125: /**
126: * Return the entire contents of the SQL entry area.
127: *
128: * @return the entire contents of the SQL entry area.
129: */
130: String getEntireSQLScript();
131:
132: /**
133: * Return the selected contents of the SQL entry area.
134: *
135: * @return the selected contents of the SQL entry area.
136: */
137: String getSelectedSQLScript();
138:
139: /**
140: * Return the SQL script to be executed.
141: *
142: * @return the SQL script to be executed.
143: */
144: String getSQLScriptToBeExecuted();
145:
146: /**
147: * Append the passed SQL script to the SQL entry area but don't select
148: * it.
149: *
150: * @param sqlScript The script to be appended.
151: */
152: void appendSQLScript(String sqlScript);
153:
154: /**
155: * Append the passed SQL script to the SQL entry area and specify
156: * whether it should be selected.
157: *
158: * @param sqlScript The script to be appended.
159: * @param select If <TT>true</TT> then select the passed script
160: * in the sql entry area.
161: */
162: void appendSQLScript(String sqlScript, boolean select);
163:
164: /**
165: * Replace the contents of the SQL entry area with the passed
166: * SQL script without selecting it.
167: *
168: * @param sqlScript The script to be placed in the SQL entry area.
169: */
170: void setEntireSQLScript(String sqlScript);
171:
172: /**
173: * Replace the contents of the SQL entry area with the passed
174: * SQL script and specify whether to select it.
175: *
176: * @param sqlScript The script to be placed in the SQL entry area.
177: * @param select If <TT>true</TT> then select the passed script
178: * in the sql entry area.
179: */
180: void setEntireSQLScript(String sqlScript, boolean select);
181:
182: /**
183: * Replace the currently selected text in the SQL entry area
184: * with the passed text.
185: *
186: * @param sqlScript The script to be placed in the SQL entry area.
187: * @param select If <TT>true</TT> then select the passed script
188: * in the sql entry area.
189: */
190: void replaceSelectedSQLScript(String sqlScript, boolean select);
191:
192: /**
193: * Return the offset into the SQL entry area where the current select
194: * starts.
195: *
196: * @return the current selections start position.
197: */
198: int getSQLScriptSelectionStart();
199:
200: /**
201: * Return the offset into the SQL entry area where the current select
202: * ends.
203: *
204: * @return the current selections end position.
205: */
206: int getSQLScriptSelectionEnd();
207:
208: /**
209: * Set the offset into the SQL entry area where the current select
210: * starts.
211: *
212: * param start the new selections start position.
213: */
214: void setSQLScriptSelectionStart(int start);
215:
216: /**
217: * Set the offset into the SQL entry area where the current select
218: * ends.
219: *
220: * param start the new selections start position.
221: */
222: void setSQLScriptSelectionEnd(int end);
223:
224: /**
225: * Execute the passed SQL.
226: *
227: * @param sql SQL to be executed.
228: */
229: void executeSQL(String sql);
230:
231: /**
232: * Execute the current SQL.
233: */
234: void executeCurrentSQL();
235:
236: /**
237: * Close all the SQL result tabs.
238: */
239: void closeAllSQLResultTabs();
240:
241: /**
242: * Close all the SQL result tabs except from the selected.
243: */
244: void closeAllButCurrentResultTabs();
245:
246: /**
247: * Close the selected result tab.
248: */
249: void closeCurrentResultTab();
250:
251: /**
252: * Toggle if all further SQL resutls should go to the current tab.
253: */
254: void toggleCurrentSQLResultTabSticky();
255:
256: /**
257: * Close all the "torn off" SQL result frames.
258: */
259: void closeAllSQLResultFrames();
260:
261: /**
262: * Display the next tab in the SQL results.
263: */
264: void gotoNextResultsTab();
265:
266: /**
267: * Display the previous tab in the SQL results.
268: */
269: void gotoPreviousResultsTab();
270:
271: /**
272: * The passed SQL should be added to the SQL history.
273: *
274: * @param sql SQL to be added to history.
275: *
276: * @throws IllegalArgumentException
277: * Thrown if <TT>null</TT> <TT>sql</TT> passed.
278: */
279: void addSQLToHistory(String sql);
280:
281: /**
282: * Add a hierarchical menu to the SQL Entry Area popup menu.
283: *
284: * @param menu The menu that will be added.
285: */
286: void addToSQLEntryAreaMenu(JMenu menu);
287:
288: /**
289: * Add an <TT>Action</TT> to the SQL Entry Area popup menu.
290: *
291: * @param action The action to be added.
292: */
293: JMenuItem addToSQLEntryAreaMenu(Action action);
294:
295: ISession getSession();
296:
297: boolean isInMainSessionWindow();
298:
299: void addToToolsPopUp(String selectionString, Action action);
300:
301: boolean fileSave();
302:
303: void fileSaveAs();
304:
305: void fileOpen();
306:
307: void fileOpen(File f);
308:
309: void fileAppend();
310:
311: void fileClose();
312:
313: void fileNew();
314:
315: void filePrint();
316:
317: void showToolsPopup();
318:
319: boolean confirmClose();
320:
321: void addSqlPanelListener(SqlPanelListener sqlPanelListener);
322:
323: ArrayList<SQLHistoryItem> getSQLHistoryItems();
324: }
|