Source Code Cross Referenced for DefaultSQLEntryPanel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » client » session » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.client.session 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.dnd.DropTarget;
023:        import java.awt.event.MouseListener;
024:
025:        import javax.swing.JTextArea;
026:        import javax.swing.event.CaretListener;
027:        import javax.swing.event.UndoableEditListener;
028:        import javax.swing.text.BadLocationException;
029:        import javax.swing.text.JTextComponent;
030:        import javax.swing.undo.UndoManager;
031:
032:        import net.sourceforge.squirrel_sql.client.gui.dnd.FileEditorDropTargetListener;
033:        import net.sourceforge.squirrel_sql.client.session.properties.SessionProperties;
034:        import net.sourceforge.squirrel_sql.fw.gui.FontInfo;
035:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
036:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
037:
038:        public class DefaultSQLEntryPanel extends BaseSQLEntryPanel {
039:            /** Logger for this class. */
040:            private static ILogger s_log = LoggerController
041:                    .createLogger(DefaultSQLEntryPanel.class);
042:
043:            /** Current session. */
044:            private ISession _session;
045:
046:            /** Text area control. */
047:            private MyTextArea _comp;
048:
049:            @SuppressWarnings("unused")
050:            private DropTarget dt;
051:
052:            public DefaultSQLEntryPanel(ISession session) {
053:                super (session.getApplication());
054:                if (session == null) {
055:                    throw new IllegalArgumentException("ISession == null");
056:                }
057:
058:                _session = session;
059:                _comp = new MyTextArea(session, this );
060:
061:                dt = new DropTarget(_comp, new FileEditorDropTargetListener(
062:                        session));
063:            }
064:
065:            /**
066:             * Retrieve the text area component. Normally this would be a subclass
067:             * of <TT>javax.swing.text.JTextComponent</TT> but a plugin may use a
068:             * class otehr than a Swing text control.
069:             *
070:             * @return	The text area component.
071:             */
072:            public JTextComponent getTextComponent() {
073:                return _comp;
074:            }
075:
076:            /**
077:             * If the component returned by <TT>getTextComponent</TT> contains
078:             * its own scroll bars return <TT>true</TT> other wise this component
079:             * will be wrapped in the scroll pane when added to the SQL panel.
080:             *
081:             * @return	<TT>true</TT> if text component already handles scrolling.
082:             */
083:            public boolean getDoesTextComponentHaveScroller() {
084:                return false;
085:            }
086:
087:            public void addUndoableEditListener(UndoableEditListener lis) {
088:                _comp.getDocument().addUndoableEditListener(lis);
089:            }
090:
091:            public void removeUndoableEditListener(UndoableEditListener lis) {
092:                _comp.getDocument().removeUndoableEditListener(lis);
093:            }
094:
095:            /*
096:             * @see ISQLEntryPanel#hasOwnUndoableManager()
097:             */
098:            public boolean hasOwnUndoableManager() {
099:                return false;
100:            }
101:
102:            /**
103:             * @see ISQLEntryPanel#getText()
104:             */
105:            public String getText() {
106:                return _comp.getText();
107:            }
108:
109:            /**
110:             * @see ISQLEntryPanel#getSelectedText()
111:             */
112:            public String getSelectedText() {
113:                return _comp.getSelectedText();
114:            }
115:
116:            /**
117:             * Replace the contents of the SQL entry area with the passed
118:             * SQL script without selecting it.
119:             *
120:             * @param	sqlScript	The script to be placed in the SQL entry area..
121:             */
122:            public void setText(String sqlScript) {
123:                setText(sqlScript, true);
124:            }
125:
126:            /**
127:             * Replace the contents of the SQL entry area with the passed
128:             * SQL script and specify whether to select it.
129:             *
130:             * @param	sqlScript	The script to be placed in the SQL entry area..
131:             * @param	select		If <TT>true</TT> then select the passed script
132:             * 						in the sql entry area.
133:             */
134:            public void setText(String sqlScript, boolean select) {
135:                _comp.setText(sqlScript);
136:                if (select) {
137:                    setSelectionEnd(getText().length());
138:                    setSelectionStart(0);
139:                }
140:                _comp.setCaretPosition(0);
141:            }
142:
143:            /**
144:             * Append the passed SQL script to the SQL entry area but don't select
145:             * it.
146:             *
147:             * @param	sqlScript	The script to be appended.
148:             */
149:            public void appendText(String sqlScript) {
150:                appendText(sqlScript, false);
151:            }
152:
153:            /**
154:             * Append the passed SQL script to the SQL entry area and specify
155:             * whether it should be selected.
156:             *
157:             * @param	sqlScript	The script to be appended.
158:             * @param	select		If <TT>true</TT> then select the passed script
159:             * 						in the sql entry area.
160:             */
161:            public void appendText(String sqlScript, boolean select) {
162:                final int start = select ? getText().length() : 0;
163:                _comp.append(sqlScript);
164:                if (select) {
165:                    setSelectionEnd(getText().length());
166:                    setSelectionStart(start);
167:                }
168:            }
169:
170:            /**
171:             * Replace the currently selected text in the SQL entry area
172:             * with the passed text.
173:             *
174:             * @param	sqlScript	The script to be placed in the SQL entry area.
175:             */
176:            public void replaceSelection(String sqlScript) {
177:                _comp.replaceSelection(sqlScript);
178:            }
179:
180:            /**
181:             * @see ISQLEntryPanel#getCaretPosition()
182:             */
183:            public int getCaretPosition() {
184:                return _comp.getCaretPosition();
185:            }
186:
187:            /**
188:             * @see ISQLEntryPanel#setTabSize(int)
189:             */
190:            public void setTabSize(int tabSize) {
191:                _comp.setTabSize(tabSize);
192:            }
193:
194:            public void setFont(Font font) {
195:                _comp.setFont(font);
196:            }
197:
198:            /**
199:             * @see ISQLEntryPanel#addMouseListener(MouseListener)
200:             */
201:            public void addMouseListener(MouseListener lis) {
202:                _comp.addMouseListener(lis);
203:            }
204:
205:            /**
206:             * @see ISQLEntryPanel#removeListener(MouseListener)
207:             */
208:            public void removeMouseListener(MouseListener lis) {
209:                _comp.removeMouseListener(lis);
210:            }
211:
212:            /**
213:             * @see ISQLEntryPanel#setCaretPosition(int)
214:             */
215:            public void setCaretPosition(int pos) {
216:                _comp.setCaretPosition(pos);
217:            }
218:
219:            /*
220:             * @see ISQLEntryPanel#getCaretLineNumber()
221:             */
222:            public int getCaretLineNumber() {
223:                try {
224:                    return _comp.getLineOfOffset(_comp.getCaretPosition());
225:                } catch (BadLocationException ex) {
226:                    return 0;
227:                }
228:            }
229:
230:            public int getCaretLinePosition() {
231:                int caretPos = _comp.getCaretPosition();
232:                int caretLineOffset = caretPos;
233:                try {
234:                    caretLineOffset = _comp
235:                            .getLineStartOffset(getCaretLineNumber());
236:                } catch (BadLocationException ex) {
237:                    s_log.error("BadLocationException in getCaretLinePosition",
238:                            ex);
239:                }
240:                return caretPos - caretLineOffset;
241:            }
242:
243:            /**
244:             * @see ISQLEntryPanel#getSelectionStart()
245:             */
246:            public int getSelectionStart() {
247:                return _comp.getSelectionStart();
248:            }
249:
250:            /**
251:             * @see ISQLEntryPanel#setSelectionStart(int)
252:             */
253:            public void setSelectionStart(int pos) {
254:                _comp.setSelectionStart(pos);
255:            }
256:
257:            /**
258:             * @see ISQLEntryPanel#getSelectionEnd()
259:             */
260:            public int getSelectionEnd() {
261:                return _comp.getSelectionEnd();
262:            }
263:
264:            /**
265:             * @see ISQLEntryPanel#setSelectionEnd(int)
266:             */
267:            public void setSelectionEnd(int pos) {
268:                _comp.setSelectionEnd(pos);
269:            }
270:
271:            /**
272:             * @see ISQLEntryPanel#hasFocus()
273:             */
274:            public boolean hasFocus() {
275:                return _comp.hasFocus();
276:            }
277:
278:            /**
279:             * @see ISQLEntryPanel#requestFocus()
280:             */
281:            public void requestFocus() {
282:                _comp.requestFocus();
283:            }
284:
285:            /*
286:             * @see ISQLEntryPanel#addCaretListener(CaretListener)
287:             */
288:            public void addCaretListener(CaretListener lis) {
289:                _comp.addCaretListener(lis);
290:            }
291:
292:            /*
293:             * @see ISQLEntryPanel#removeCaretListener(CaretListener)
294:             */
295:            public void removeCaretListener(CaretListener lis) {
296:                _comp.removeCaretListener(lis);
297:            }
298:
299:            public void addSQLTokenListener(SQLTokenListener tl) {
300:                // Not implemented
301:            }
302:
303:            public void removeSQLTokenListener(SQLTokenListener tl) {
304:                // Not implemented
305:            }
306:
307:            public ISession getSession() {
308:                return _session;
309:            }
310:
311:            private static class MyTextArea extends JTextArea {
312:                private DefaultSQLEntryPanel _pnl;
313:
314:                private MyTextArea(ISession session, DefaultSQLEntryPanel pnl) {
315:                    super ();
316:                    _pnl = pnl;
317:                    SessionProperties props = session.getProperties();
318:                    final FontInfo fi = props.getFontInfo();
319:                    if (fi != null) {
320:                        this .setFont(props.getFontInfo().createFont());
321:                    }
322:                }
323:
324:                //		public void addNotify()
325:                //		{
326:                //			super.addNotify();
327:                //			_pnl.addMouseListener(_pnl._sqlEntryMouseListener);
328:                //		}
329:                //
330:                //		public void removeNotify()
331:                //		{
332:                //			super.removeNotify();
333:                //			_pnl.removeMouseListener(_pnl._sqlEntryMouseListener);
334:                //		}
335:            }
336:
337:            /* (non-Javadoc)
338:             * @see net.sourceforge.squirrel_sql.client.session.ISQLEntryPanel#setUndoManager(javax.swing.undo.UndoManager)
339:             */
340:            public void setUndoManager(UndoManager manager) {
341:                // no support for undo
342:            }
343:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.