Source Code Cross Referenced for DefaultKeyHandler.java in  » UML » jrefactory » org » acm » seguin » completer » popup » 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 » UML » jrefactory » org.acm.seguin.completer.popup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.completer.popup;
002:
003:        import org.gjt.sp.jedit.gui.KeyEventWorkaround;
004:
005:        import java.awt.event.KeyEvent;
006:
007:        import javax.swing.JList;
008:
009:        import org.gjt.sp.jedit.textarea.JEditTextArea;
010:
011:        import org.gjt.sp.jedit.View;
012:
013:        import java.awt.event.KeyAdapter;
014:
015:        /**
016:
017:         * Description of the Class
018:
019:         *
020:
021:         * @author    btateyama@yahoo.com
022:
023:         * @created   December 13, 2002
024:
025:         */
026:
027:        public class DefaultKeyHandler extends KeyAdapter {
028:
029:            boolean _bDisposeOnNextChar = false;
030:
031:            View _view = null;
032:
033:            JEditTextArea _textArea = null;
034:
035:            JList _listMembers = null;
036:
037:            CodePopup _codePopup = null;
038:
039:            DefaultKeyHandler(CodePopup argPopup,
040:
041:            View argView) {
042:
043:                _codePopup = argPopup;
044:
045:                _view = argView;
046:
047:                _textArea = argView.getTextArea();
048:
049:                _listMembers = _codePopup.getListMembers();
050:
051:            }
052:
053:            /**
054:
055:             * Description of the Method
056:
057:             *
058:
059:             * @param evt  Description of the Parameter
060:
061:             */
062:
063:            public void keyPressed(KeyEvent evt) {
064:
065:                // spoof keycodes to extend functionality
066:
067:                int iKeyCode = evt.getKeyCode();
068:
069:                if (evt.isShiftDown() && iKeyCode == KeyEvent.VK_TAB) {
070:
071:                    iKeyCode = KeyEvent.VK_DOWN;
072:
073:                } else if (evt.isControlDown() && iKeyCode == KeyEvent.VK_P) {
074:
075:                    iKeyCode = KeyEvent.VK_UP;
076:
077:                } else if (evt.isControlDown() && iKeyCode == KeyEvent.VK_N) {
078:
079:                    iKeyCode = KeyEvent.VK_DOWN;
080:
081:                } else if (iKeyCode == KeyEvent.VK_TAB) {
082:
083:                    iKeyCode = KeyEvent.VK_ENTER;
084:
085:                }
086:
087:                switch (iKeyCode) {
088:
089:                case KeyEvent.VK_TAB:
090:
091:                case KeyEvent.VK_ENTER:
092:
093:                    _codePopup.insertSelected();
094:
095:                    evt.consume();
096:
097:                    break;
098:
099:                case KeyEvent.VK_ESCAPE:
100:
101:                    _codePopup.dispose();
102:
103:                    evt.consume();
104:
105:                    break;
106:
107:                case KeyEvent.VK_UP:
108:
109:                    int selected = _listMembers.getSelectedIndex();
110:
111:                    if (selected == 0) {
112:
113:                        selected = _listMembers.getModel().getSize() - 1;
114:
115:                    } else if (_codePopup.getFocusOwner() == _listMembers) {
116:
117:                        return;
118:
119:                    } else {
120:
121:                        selected = selected - 1;
122:
123:                    }
124:
125:                    _listMembers.setSelectedIndex(selected);
126:
127:                    _listMembers.ensureIndexIsVisible(selected);
128:
129:                    evt.consume();
130:
131:                    break;
132:
133:                case KeyEvent.VK_DOWN:
134:
135:                    /*
136:
137:                     *  int
138:
139:                     */
140:
141:                    selected = _listMembers.getSelectedIndex();
142:
143:                    if (selected == _listMembers.getModel().getSize() - 1) {
144:
145:                        selected = 0;
146:
147:                    } else if (_codePopup.getFocusOwner() == _listMembers) {
148:
149:                        return;
150:
151:                    } else {
152:
153:                        selected = selected + 1;
154:
155:                    }
156:
157:                    _listMembers.setSelectedIndex(selected);
158:
159:                    _listMembers.ensureIndexIsVisible(selected);
160:
161:                    evt.consume();
162:
163:                    break;
164:
165:                case KeyEvent.VK_BACK_SPACE:
166:
167:                    String strPrefix = _codePopup.getPrefix();
168:
169:                    if (strPrefix.length() <= 1) {
170:
171:                        _textArea.backspace();
172:
173:                        evt.consume();
174:
175:                        _codePopup.dispose();
176:
177:                    } else {
178:
179:                        _codePopup.setPrefix(strPrefix.substring(0, strPrefix
180:                                .length() - 1));
181:
182:                        _textArea.backspace();
183:
184:                        // filter for data on current prefix
185:
186:                        _codePopup.filterData();
187:
188:                        evt.consume();
189:
190:                    }
191:
192:                    break;
193:
194:                default:
195:
196:                    PopupUtils.processJEditCommand(
197:
198:                    _view, _codePopup, evt);
199:
200:                    break;
201:
202:                /*
203:
204:                // we check to see if keystroke is jEdit command...if so, let jEdit do it's thing
205:
206:                if (PopupUtils.processJEditCommand(_view, evt)){
207:
208:                 _codePopup.dispose();
209:
210:                } else if (evt.isActionKey()) {
211:
212:                 _codePopup.dispose();
213:
214:                 _view.processKeyEvent(evt);
215:
216:                }
217:
218:                break;
219:
220:                 */
221:
222:                }
223:
224:            }
225:
226:            /**
227:
228:             * Description of the Method
229:
230:             *
231:
232:             * @param evt  Description of the Parameter
233:
234:             */
235:
236:            public void keyTyped(KeyEvent evt) {
237:
238:                char ch = evt.getKeyChar();
239:
240:                evt = KeyEventWorkaround.processKeyEvent(evt);
241:
242:                if (evt == null) {
243:
244:                    return;
245:
246:                } else if (ch != '\b') {
247:
248:                    // if char is not control character
249:
250:                    if (_bDisposeOnNextChar) {
251:
252:                        _textArea.userInput(ch);
253:
254:                        _codePopup.dispose();
255:
256:                    } else {
257:
258:                        _codePopup.setPrefix(_codePopup.getPrefix() + ch);
259:
260:                        //_strPrefix = _strPrefix + ch;
261:
262:                        _textArea.userInput(ch);
263:
264:                        _codePopup.filterData();
265:
266:                        // setup to close after next char is typed after ( typed
267:
268:                        //_bDisposeOnNextChar = ch == '(';
269:
270:                        if (ch == '(')
271:
272:                            _codePopup.dispose();
273:
274:                    }
275:
276:                }
277:
278:            }
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.