Source Code Cross Referenced for PopupUtils.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.acm.seguin.ide.jedit.Navigator;
004:        import org.acm.seguin.completer.Completer;
005:        import java.awt.Point;
006:        import java.awt.event.KeyEvent;
007:        import java.lang.reflect.Field;
008:        import javax.swing.ImageIcon;
009:        import javax.swing.SwingUtilities;
010:        import org.gjt.sp.jedit.View;
011:        import org.gjt.sp.jedit.gui.DefaultInputHandler;
012:        import org.gjt.sp.jedit.gui.InputHandler;
013:        import org.gjt.sp.jedit.jEdit;
014:        import org.gjt.sp.jedit.textarea.JEditTextArea;
015:
016:        /**
017:
018:         * Utility functions for popups
019:
020:         *
021:
022:         * @author    btateyama@yahoo.com
023:
024:         * @created   December 12, 2002
025:
026:         */
027:
028:        public class PopupUtils {
029:            static final Navigator.NavigatorLogger logger = Completer
030:                    .getLogger(PopupUtils.class);
031:            static final ImageIcon ICON_FIELD = new ImageIcon(Navigator.class
032:                    .getResource("icons/field.gif"));
033:            static final ImageIcon ICON_METHOD = new ImageIcon(Navigator.class
034:                    .getResource("icons/method.gif"));
035:            static final ImageIcon ICON_INNER = new ImageIcon(Navigator.class
036:                    .getResource("icons/inner-class.gif"));
037:
038:            static final int ICON_WIDTH = 13;
039:
040:            /**
041:             * Translate a text position to point where popup should appear.
042:             *
043:             * @param argView    Description of the Parameter
044:             * @param argPrefix  Description of the Parameter
045:             * @return           The pointOnTextArea value
046:             */
047:            public static Point getPointOnTextArea(View argView,
048:                    String argPrefix) {
049:
050:                JEditTextArea textArea = argView.getTextArea();
051:                int caretLine = textArea.getCaretLine();
052:                int caret = textArea.getCaretPosition();
053:                textArea.scrollToCaret(false);
054:                Point location = textArea
055:                        .offsetToXY(caret - argPrefix.length());
056:                location.y += textArea.getPainter().getFontMetrics()
057:                        .getHeight();
058:                SwingUtilities.convertPointToScreen(location, textArea
059:                        .getPainter());
060:                return location;
061:            }
062:
063:            public static void requestFocusOnTextArea(JEditTextArea argTextArea) {
064:                SwingUtilities
065:                        .invokeLater(new TextAreaFocusHelper(argTextArea));
066:            }
067:
068:            static class TextAreaFocusHelper implements  Runnable {
069:                JEditTextArea _textArea = null;
070:
071:                TextAreaFocusHelper(JEditTextArea argTextArea) {
072:                    _textArea = argTextArea;
073:                }
074:
075:                public void run() {
076:                    _textArea.requestFocus();
077:                }
078:            }
079:
080:            public static void processJEditCommand(View argView,
081:                    BasePopup argPopup, KeyEvent argEvent) {
082:                if (hasBinding(argView, argEvent)) {
083:                    argPopup.dispose();
084:                    //FIXME: argView.getInputHandler().keyPressed(argEvent);
085:                }
086:
087:                if (!argEvent.isConsumed() && argEvent.isActionKey()) {
088:                    argPopup.dispose();
089:                    argView.processKeyEvent(argEvent);
090:                }
091:            }
092:
093:            private static boolean hasBinding(View argView, KeyEvent argEvent) {
094:                boolean bHasBinding = false;
095:                StringBuffer sbBinding = new StringBuffer();
096:                sbBinding.append(DefaultInputHandler
097:                        .getModifierString(argEvent));
098:                sbBinding.append("+");
099:                String strSym = getSymbolicName(argEvent.getKeyCode());
100:                if (strSym != null) {
101:                    sbBinding.append(strSym);
102:                    DefaultInputHandler inputHandler = (DefaultInputHandler) argView
103:                            .getInputHandler();
104:                    Object obj = inputHandler.getKeyBinding(sbBinding
105:                            .toString());
106:                    bHasBinding = obj != null;
107:                }
108:                return bHasBinding;
109:            }
110:
111:            private static String getSymbolicName(int keyCode) {
112:                // Copied from org.gjt.sp.jedit.gui.GrabKeyDialog
113:                if (keyCode == KeyEvent.VK_UNDEFINED)
114:                    return null;
115:                /* else if(keyCode == KeyEvent.VK_OPEN_BRACKET)
116:                	return "[";
117:                else if(keyCode == KeyEvent.VK_CLOSE_BRACKET)
118:                	return "]"; */
119:
120:                if (keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z)
121:                    return String
122:                            .valueOf(Character.toLowerCase((char) keyCode));
123:
124:                try {
125:                    Field[] fields = KeyEvent.class.getFields();
126:                    for (int i = 0; i < fields.length; i++) {
127:                        Field field = fields[i];
128:                        String name = field.getName();
129:                        if (name.startsWith("VK_")
130:                                && field.getInt(null) == keyCode) {
131:                            return name.substring(3);
132:                        }
133:                    }
134:                } catch (Exception e) {
135:                    logger.error("Error enum fields", e);
136:                }
137:
138:                return null;
139:            } //}}}
140:
141:            public static boolean isCompleteWord(KeyEvent argEvent) {
142:                boolean bIsCompleteWord = false;
143:                StringBuffer sbBinding = new StringBuffer();
144:                sbBinding.append(DefaultInputHandler
145:                        .getModifierString(argEvent));
146:                sbBinding.append("+");
147:                String strSym = getSymbolicName(argEvent.getKeyCode());
148:                if (strSym != null) {
149:                    sbBinding.append(strSym);
150:                    String strB = sbBinding.toString();
151:                    bIsCompleteWord = (strB.equals(jEdit
152:                            .getProperty("complete-word.shortcut")) || strB
153:                            .equals(jEdit
154:                                    .getProperty("complete-word.shortcut2")));
155:                    // hmm..we could also do a cross ref of actions
156:                }
157:                return bIsCompleteWord;
158:            }
159:
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.