Source Code Cross Referenced for XSuggest.java in  » Swing-Library » wings3 » org » wingx » 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 » wings3 » org.wingx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:
014:        package org.wingx;
015:
016:        import java.util.List;
017:        import java.util.Map;
018:
019:        import org.wings.SDimension;
020:        import org.wings.SResourceIcon;
021:        import org.wings.STextField;
022:        import org.wingx.plaf.SuggestCG;
023:
024:        /**
025:         * Enhanced STextField that supports the user input by displaying suggestions.
026:         * @author Christian Schyma
027:         */
028:        public class XSuggest extends STextField implements  XSuggestDataSource {
029:
030:            /**
031:             * data source from which suggestions are generated
032:             */
033:            private XSuggestDataSource dataSource = null;
034:
035:            /**
036:             * Ajax request timeout in ms
037:             */
038:            private int timeout = 10000;
039:
040:            /**
041:             * @see org.wingx.XSuggest#setInputDelay(int delay)
042:             */
043:            private int inputDelay = 500;
044:
045:            /**
046:             * an icon to indicate the Ajax activity
047:             */
048:            private SResourceIcon activityIcon = new SResourceIcon(
049:                    "org/wings/icons/AjaxActivityIndicatorSmall.gif");
050:
051:            /**
052:             * @see org.wingx.XSuggest#setSuggestBoxWidth(SDimension dim)
053:             */
054:            private SDimension suggestBoxWidth = new SDimension(
055:                    SDimension.AUTO, SDimension.AUTO);
056:
057:            {
058:                activityIcon.getId(); // hack to externalize
059:            }
060:
061:            /**
062:             * Creates a text field that can display suggestions.
063:             */
064:            public XSuggest() {
065:            }
066:
067:            /**
068:             * Creates a text field that can display suggestions.
069:             * @param text initial content of the text field
070:             */
071:            public XSuggest(String text) {
072:                super (text);
073:            }
074:
075:            /**
076:             * set a new data source from which suggestions are generated
077:             * @param source
078:             */
079:            public void setDataSource(XSuggestDataSource source) {
080:                this .dataSource = source;
081:            }
082:
083:            /**
084:             * returns the currently used data source
085:             * @see #setDataSource(XSuggestDataSource source)
086:             */
087:            public XSuggestDataSource getDataSource() {
088:                return this .dataSource;
089:            }
090:
091:            /**
092:             * Set Ajax request timeout.
093:             * @param timeout in ms
094:             */
095:            public void setTimeout(int timeout) {
096:                int oldTimeout = this .timeout;
097:                this .timeout = timeout;
098:                reloadIfChange(oldTimeout, timeout);
099:            }
100:
101:            /**
102:             * @see org.wingx.XSuggest#setTimeout(int timeout)
103:             */
104:            public int getTimeout() {
105:                return timeout;
106:            }
107:
108:            /**
109:             * Fast typists can produce a lot of requests in a short time; this delay
110:             * limits the requests to a certain time.
111:             * @param delay in ms
112:             */
113:            public void setInputDelay(int delay) {
114:                int oldDelay = this .inputDelay;
115:                this .inputDelay = delay;
116:                reloadIfChange(oldDelay, delay);
117:            }
118:
119:            /**
120:             * @see org.wingx.XSuggest#setInputDelay(int delay)
121:             */
122:            public int getInputDelay() {
123:                return inputDelay;
124:            }
125:
126:            /**
127:             * Configures the width of the suggest box.  There are three possibilites:<br>
128:             * - <code>SDimension.AUTO</code> automatically set the size in accordance to the content (default)<br>
129:             * - <code>SDimension.INHERIT</code> inherits width from the suggest input box<br>
130:             * - integer value
131:             * @param dim width of suggest box, height is ignored
132:             */
133:            public void setSuggestBoxWidth(SDimension dim) { // setSuggestBoxWidth inherit, auto, pixel width
134:                SDimension oldSuggestBoxWidth = this .suggestBoxWidth;
135:                this .suggestBoxWidth = dim;
136:                reloadIfChange(oldSuggestBoxWidth, dim);
137:            }
138:
139:            public SDimension getSuggestBoxWidth() {
140:                return this .suggestBoxWidth;
141:            }
142:
143:            /**
144:             * Obtaines the list of suggestions from the data source, if there is one.
145:             * @see {org.wingx.XSuggestDataSource.generateSugestions()}
146:             * @param lookupText
147:             * @return suggestions list with map entries or null, if there is no data source
148:             */
149:            public List<Map.Entry<String, String>> generateSuggestions(
150:                    String lookupText) {
151:                if (getDataSource() != null) {
152:                    return getDataSource().generateSuggestions(lookupText);
153:                } else {
154:                    return null;
155:                }
156:            }
157:
158:            @Override
159:            public void processLowLevelEvent(String action, String[] values) {
160:                String value = values[0];
161:                if (value.startsWith("q:")) {
162:                    String query = value.substring(2);
163:                    List<Map.Entry<String, String>> suggestions = generateSuggestions(query);
164:                    update(((SuggestCG) getCG()).getSuggestionsUpdate(this,
165:                            query, suggestions));
166:                } else
167:                    super.processLowLevelEvent(action, values);
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.