Source Code Cross Referenced for AbstractInputHandler.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » input » 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 » Swing Library » jEdit » org.gjt.sp.jedit.input 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * AbstractInputHandler.java - Manages key bindings and executes actions
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2006 Matthieu Casanova
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program 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
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:        package org.gjt.sp.jedit.input;
023:
024:        import org.gjt.sp.jedit.gui.KeyEventTranslator;
025:        import org.gjt.sp.jedit.Debug;
026:        import org.gjt.sp.util.Log;
027:
028:        import java.awt.event.KeyListener;
029:        import java.awt.event.KeyEvent;
030:
031:        /**
032:         * The abstract input handler manage the keyboard handling.
033:         * The entry point is
034:         * {@link #processKeyEvent(java.awt.event.KeyEvent, int, boolean)}
035:         * 
036:         * @author Matthieu Casanova
037:         * @version $Id: FoldHandler.java 5568 2006-07-10 20:52:23Z kpouer $
038:         */
039:        public abstract class AbstractInputHandler {
040:            protected int lastActionCount;
041:            /** This listener will receive keyboard events if it is not null. */
042:            protected KeyListener keyEventInterceptor;
043:            protected String readNextChar;
044:            protected int repeatCount;
045:
046:            protected static final int REPEAT_COUNT_THRESHOLD = 20;
047:
048:            //{{{ AbstractInputHandler constructor
049:            public AbstractInputHandler() {
050:                repeatCount = 1;
051:            } //}}}
052:
053:            //{{{ getLastActionCount() method
054:            /**
055:             * Returns the number of times the last action was executed.
056:             * It can be used with smartHome and smartEnd
057:             * @return the number of times the last action was executed
058:             * @since jEdit 2.5pre5
059:             */
060:            public int getLastActionCount() {
061:                return lastActionCount;
062:            } //}}}
063:
064:            //{{{ resetLastActionCount() method
065:            /**
066:             * Resets the last action count. This should be called when an
067:             * editing operation that is not an action is invoked, for example
068:             * a mouse click.
069:             * @since jEdit 4.0pre1
070:             */
071:            public void resetLastActionCount() {
072:                lastActionCount = 0;
073:            } //}}}
074:
075:            //{{{ getKeyEventInterceptor() method
076:            public KeyListener getKeyEventInterceptor() {
077:                return keyEventInterceptor;
078:            } //}}}
079:
080:            //{{{ setKeyEventInterceptor() method
081:            /**
082:             * Sets the listener that will handle all key events in this
083:             * view. For example, the complete word command uses this so
084:             * that all key events are passed to the word list popup while
085:             * it is visible.
086:             * @param keyEventInterceptor the KeyListener that will receive the events
087:             */
088:            public void setKeyEventInterceptor(KeyListener keyEventInterceptor) {
089:                this .keyEventInterceptor = keyEventInterceptor;
090:            } //}}}
091:
092:            //{{{ isPrefixActive() method
093:            /**
094:             * Returns if a prefix key has been pressed.
095:             */
096:            public boolean isPrefixActive() {
097:                return readNextChar != null;
098:            } //}}}
099:
100:            //{{{ handleKey() method
101:            /**
102:             * Handles a keystroke.
103:             * @param keyStroke The key stroke.
104:             * @param dryRun only calculate the return value, do not have any other effect
105:             * @return true if the input could be handled.
106:             * @since jEdit 4.3pre7
107:             */
108:            public abstract boolean handleKey(KeyEventTranslator.Key keyStroke,
109:                    boolean dryRun);
110:
111:            //}}}
112:
113:            //{{{ processKeyEvent() method
114:
115:            /**
116:             * Process a keyboard event.
117:             * This is the entry point of the keyboard handling
118:             *
119:             * @param evt the keyboard event
120:             * @param from the source, it can be {@link org.gjt.sp.jedit.View#VIEW},
121:             * {@link org.gjt.sp.jedit.View#ACTION_BAR} or {@link org.gjt.sp.jedit.View#TEXT_AREA}
122:             * @param global tell if the event comes from the DefaultKeyboardFocusManager or not
123:             */
124:            public abstract void processKeyEvent(KeyEvent evt, int from,
125:                    boolean global);
126:
127:            //}}}
128:
129:            //{{{ processKeyEventKeyStrokeHandling() method
130:
131:            /**
132:             *
133:             * @param evt the keyboard event
134:             * @param from the source, it can be {@link org.gjt.sp.jedit.View#VIEW},
135:             * {@link org.gjt.sp.jedit.View#ACTION_BAR} or {@link org.gjt.sp.jedit.View#TEXT_AREA}
136:             * @param mode the mode is "press" or "type" and is used for debug only  
137:             * @param global tell if the event comes from the DefaultKeyboardFocusManager or not
138:             */
139:            protected void processKeyEventKeyStrokeHandling(KeyEvent evt,
140:                    int from, String mode, boolean global) {
141:                KeyEventTranslator.Key keyStroke = KeyEventTranslator
142:                        .translateKeyEvent2(evt);
143:
144:                if (keyStroke != null) {
145:                    keyStroke.setIsFromGlobalContext(global);
146:                    if (Debug.DUMP_KEY_EVENTS) {
147:                        Log.log(Log.DEBUG, this , "Translated (key " + mode
148:                                + "): " + keyStroke + " from " + from);
149:                    }
150:                    boolean consumed = false;
151:                    if (handleKey(keyStroke, keyStroke.isPhantom())) {
152:                        evt.consume();
153:
154:                        consumed = true;
155:                    }
156:                    if (Debug.DUMP_KEY_EVENTS) {
157:                        Log.log(Log.DEBUG, this , "Translated (key " + mode
158:                                + "): " + keyStroke + " from " + from
159:                                + ": consumed=" + consumed + '.');
160:                    }
161:                }
162:            } //}}}
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.