001: package net.sourceforge.squirrel_sql.client.session;
002:
003: /*
004: * Copyright (C) 2001-2003 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: import java.awt.Font;
022: import java.awt.event.MouseListener;
023:
024: import javax.swing.Action;
025: import javax.swing.JComponent;
026: import javax.swing.JMenu;
027: import javax.swing.JMenuItem;
028: import javax.swing.text.JTextComponent;
029: import javax.swing.event.CaretListener;
030: import javax.swing.event.UndoableEditListener;
031: import javax.swing.undo.UndoManager;
032:
033: import net.sourceforge.squirrel_sql.fw.id.IHasIdentifier;
034:
035: public interface ISQLEntryPanel extends IHasIdentifier {
036: /**
037: * Retrieve the text area component. Normally this would be a subclass
038: * of <TT>javax.swing.text.JTextComponent</TT> but a plugin may use a
039: * class other than a Swing text control.
040: *
041: * @return The text area component.
042: */
043: JTextComponent getTextComponent();
044:
045: /**
046: * If the component returned by <TT>getTextComponent</TT> contains
047: * its own scroll bars return <TT>true</TT> other wise this component
048: * will be wrapped in the scroll pane when added to the SQL panel.
049: *
050: * @return <TT>true</TT> if text component already handles scrolling.
051: */
052: boolean getDoesTextComponentHaveScroller();
053:
054: String getText();
055:
056: String getSelectedText();
057:
058: /**
059: * Replace the contents of the SQL entry area with the passed
060: * SQL script without selecting it.
061: *
062: * @param sqlScript The script to be placed in the SQL entry area..
063: */
064: void setText(String sqlScript);
065:
066: /**
067: * Replace the contents of the SQL entry area with the passed
068: * SQL script and specify whether to select it.
069: *
070: * @param sqlScript The script to be placed in the SQL entry area..
071: * @param select If <TT>true</TT> then select the passed script
072: * in the sql entry area.
073: */
074: void setText(String sqlScript, boolean select);
075:
076: /**
077: * Append the passed SQL script to the SQL entry area but don't select
078: * it.
079: *
080: * @param sqlScript The script to be appended.
081: */
082: void appendText(String text);
083:
084: /**
085: * Append the passed SQL script to the SQL entry area and specify
086: * whether it should be selected.
087: *
088: * @param sqlScript The script to be appended.
089: * @param select If <TT>true</TT> then select the passed script
090: * in the sql entry area.
091: */
092: void appendText(String sqlScript, boolean select);
093:
094: /**
095: * Replace the currently selected text in the SQL entry area
096: * with the passed text.
097: *
098: * @param sqlScript The script to be placed in the SQL entry area.
099: */
100: void replaceSelection(String sqlScript);
101:
102: String getSQLToBeExecuted();
103:
104: int[] getBoundsOfSQLToBeExecuted();
105:
106: void moveCaretToPreviousSQLBegin();
107:
108: void moveCaretToNextSQLBegin();
109:
110: void selectCurrentSql();
111:
112: int getSelectionStart();
113:
114: void setSelectionStart(int pos);
115:
116: int getSelectionEnd();
117:
118: void setSelectionEnd(int pos);
119:
120: int getCaretPosition();
121:
122: void setCaretPosition(int pos);
123:
124: /**
125: * Return the zero-based line number that the caret is currently on.
126: *
127: * @return the zero-based line number that the caret is currently on.
128: */
129: int getCaretLineNumber();
130:
131: int getCaretLinePosition();
132:
133: boolean hasFocus();
134:
135: void requestFocus();
136:
137: void setFont(Font font);
138:
139: void setTabSize(int tabSize);
140:
141: /**
142: * Add a hierarchical menu to the SQL Entry Area popup menu.
143: *
144: * @param menu The menu that will be added.
145: */
146: void addToSQLEntryAreaMenu(JMenu menu);
147:
148: /**
149: * Add an <TT>Action</TT> to the SQL Entry Area popup menu.
150: *
151: * @param action The action to be added.
152: *
153: * @return The newly created menu item.
154: */
155: JMenuItem addToSQLEntryAreaMenu(Action action);
156:
157: void addMouseListener(MouseListener lis);
158:
159: void removeMouseListener(MouseListener lis);
160:
161: boolean hasOwnUndoableManager();
162:
163: void setUndoManager(UndoManager manager);
164:
165: void addUndoableEditListener(UndoableEditListener listener);
166:
167: void removeUndoableEditListener(UndoableEditListener listener);
168:
169: void setUndoActions(Action undo, Action redo);
170:
171: void addCaretListener(CaretListener lis);
172:
173: void removeCaretListener(CaretListener lis);
174:
175: void addSQLTokenListener(SQLTokenListener tl);
176:
177: void removeSQLTokenListener(SQLTokenListener tl);
178:
179: void dispose();
180:
181: ISession getSession();
182: }
|