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


001:        /*
002:         * $Id: TextComponentExample.java 2750 2006-08-02 08:10:54Z hengels $
003:         * Copyright 2006 wingS development team.
004:         *
005:         * This file is part of wingS (http://wingsframework.org).
006:         *
007:         * wingS is free software; you can redistribute it and/or modify
008:         * it under the terms of the GNU Lesser General Public License
009:         * as published by the Free Software Foundation; either version 2.1
010:         * of the License, or (at your option) any later version.
011:         *
012:         * Please see COPYING for the complete licence.
013:         */
014:
015:        package wingset;
016:
017:        import java.util.*;
018:
019:        import org.wings.SBorderLayout;
020:        import org.wings.SComponent;
021:        import org.wings.SDimension;
022:        import org.wings.SGridLayout;
023:        import org.wings.SLabel;
024:        import org.wings.SPanel;
025:        import org.wings.STextField;
026:        import org.wingx.XSuggest;
027:        import org.wingx.XSuggestDataSource;
028:
029:        /**
030:         * Example demonstrating the use of component XSuggest.
031:         * @author Christian Schyma
032:         */
033:        public class XSuggestExample extends WingSetPane {
034:
035:            XSuggest birthCountryField = null;
036:            XSuggest currentCountryField = null;
037:
038:            protected SComponent createExample() {
039:                SPanel panel = new SPanel();
040:                panel.add(createXSuggestPanel(), SBorderLayout.CENTER);
041:                return panel;
042:            }
043:
044:            private SPanel createXSuggestPanel() {
045:                SGridLayout gridLayout = new SGridLayout(2);
046:                gridLayout.setHgap(10);
047:                gridLayout.setVgap(4);
048:                SPanel panel = new SPanel(gridLayout);
049:
050:                panel.add(new SLabel("Surname:"));
051:                STextField surname = new STextField();
052:                surname.setToolTipText("enter your surname");
053:                panel.add(surname);
054:
055:                panel.add(new SLabel("Name:"));
056:                STextField name = new STextField();
057:                name.setToolTipText("enter your name");
058:                panel.add(name);
059:
060:                panel.add(new SLabel("Birth Country:"));
061:                birthCountryField = new XSuggest();
062:                birthCountryField.setDataSource(new CountriesOfTheWorld());
063:                birthCountryField.setToolTipText("where have you been born?");
064:                birthCountryField.setSuggestBoxWidth(new SDimension(
065:                        SDimension.INHERIT, SDimension.INHERIT));
066:                panel.add(birthCountryField);
067:
068:                panel.add(new SLabel("Current Country:"));
069:                currentCountryField = new XSuggest();
070:                currentCountryField.setDataSource(new CountriesOfTheWorld());
071:                currentCountryField.setToolTipText("where are you living?");
072:                currentCountryField.setSuggestBoxWidth(new SDimension(
073:                        SDimension.INHERIT, SDimension.INHERIT));
074:                panel.add(currentCountryField);
075:
076:                panel.add(new SLabel("State (only German: try 'b'): "));
077:                XSuggest stateSuggestionField = new XSuggest();
078:                stateSuggestionField.setDataSource(new StatesOfGermany());
079:                panel.add(stateSuggestionField);
080:
081:                panel.add(new SLabel("auto correct: "));
082:                XSuggest autoCorrect = new XSuggest();
083:                panel.add(autoCorrect);
084:
085:                // set width of text fields
086:                for (int i = 0; i < panel.getComponentCount(); i++) {
087:                    SComponent component = panel.getComponent(i);
088:                    if ((component instanceof  XSuggest)
089:                            || (component instanceof  STextField)) {
090:                        ((STextField) component).setColumns(20);
091:                    }
092:                }
093:
094:                return panel;
095:            }
096:
097:            protected SComponent createControls() {
098:                return null;
099:            }
100:
101:            /**     
102:             * a model for XSuggest
103:             * @author Roman R&auml;dle
104:             * @version $Revision$
105:             */
106:            public class CountriesOfTheWorld implements  XSuggestDataSource {
107:
108:                private List completion;
109:
110:                public CountriesOfTheWorld() {
111:                    completion = new ArrayList();
112:                    initCompletion();
113:                }
114:
115:                private String ajaxText;
116:
117:                public String getAjaxText() {
118:                    return ajaxText;
119:                }
120:
121:                public void setAjaxText(String ajaxText) {
122:                    this .ajaxText = ajaxText;
123:                }
124:
125:                private void initCompletion() {
126:                    completion.add("Afghanistan");
127:                    completion.add("Albania");
128:                    completion.add("Algeria");
129:                    completion.add("American Samoa");
130:                    completion.add("Andorra");
131:                    completion.add("Angola");
132:                    completion.add("Anguilla");
133:                    completion.add("Antarctica");
134:                    completion.add("Antigua & Barbuda");
135:                    completion.add("Antilles, Netherlands");
136:                    completion.add("Arabia, Saudi");
137:                    completion.add("Argentina");
138:                    completion.add("Armenia");
139:                    completion.add("Aruba");
140:                    completion.add("Asia Pacific");
141:                    completion.add("Australia");
142:                    completion.add("Austria");
143:                    completion.add("Azerbaijan");
144:                    completion.add("Bahamas, The");
145:                    completion.add("Bahrain");
146:                    completion.add("Bangladesh");
147:                    completion.add("Barbados");
148:                    completion.add("Belarus");
149:                    completion.add("Belgium");
150:                    completion.add("Belize");
151:                    completion.add("Benin");
152:                    completion.add("Bermuda");
153:                    completion.add("Bhutan");
154:                    completion.add("Bolivia");
155:                    completion.add("Bosnia and Herzegovina");
156:                    completion.add("Botswana");
157:                    completion.add("Bouvet Island");
158:                    completion.add("Brazil");
159:                    completion.add("British Indian Ocean Territory");
160:                    completion.add("British Virgin Islands");
161:                    completion.add("Brunei Darussalam");
162:                    completion.add("Bulgaria");
163:                    completion.add("Burkina Faso");
164:                    completion.add("Burundi");
165:                    completion.add("Cambodia");
166:                    completion.add("Cameroon");
167:                    completion.add("Canada");
168:                    completion.add("Cape Verde");
169:                    completion.add("Cayman Islands");
170:                    completion.add("Central African Republic");
171:                    completion.add("Chad");
172:                    completion.add("Chile");
173:                    completion.add("China");
174:                    completion.add("Christmas Island");
175:                    completion.add("Cocos (Keeling) Islands");
176:                    completion.add("Colombia");
177:                    completion.add("Comoros");
178:                    completion.add("Congo");
179:                    completion.add("Congo, Democratic Rep. of the");
180:                    completion.add("Cook Islands");
181:                    completion.add("Costa Rica");
182:                    completion.add("Cote D'Ivoire");
183:                    completion.add("Croatia");
184:                    completion.add("Cuba");
185:                    completion.add("Cyprus");
186:                    completion.add("Czech Republic");
187:                    completion.add("Czechoslovakia (Former)");
188:                    completion.add("Denmark");
189:                    completion.add("Djibouti");
190:                    completion.add("Dominica");
191:                    completion.add("Dominican Republic");
192:                    completion.add("East Timor (Timor-Leste)");
193:                    completion.add("Ecuador");
194:                    completion.add("Egypt");
195:                    completion.add("El Salvador");
196:                    completion.add("Equatorial Guinea");
197:                    completion.add("Eritrea");
198:                    completion.add("Estonia");
199:                    completion.add("Ethiopia");
200:                    completion.add("European Union");
201:                    completion.add("Falkland Islands (Malvinas)");
202:                    completion.add("Faroe Islands");
203:                    completion.add("Fiji");
204:                    completion.add("Finland");
205:                    completion.add("France");
206:                    completion.add("French Guiana");
207:                    completion.add("French Polynesia");
208:                    completion.add("French Southern Territories - TF");
209:                    completion.add("Gabon");
210:                    completion.add("Gambia, the");
211:                    completion.add("Georgia");
212:                    completion.add("Germany");
213:                    completion.add("Ghana");
214:                    completion.add("Gibraltar");
215:                    completion.add("Greece");
216:                    completion.add("Greenland");
217:                    completion.add("Grenada");
218:                    completion.add("Guadeloupe");
219:                    completion.add("Guam");
220:                    completion.add("Guatemala");
221:                    completion.add("Guerney");
222:                    completion.add("Guinea");
223:                    completion.add("Guinea-Bissau");
224:                    completion.add("Guinea, Equatorial");
225:                    completion.add("Guiana, French");
226:                    completion.add("Guyana");
227:                    completion.add("Haiti");
228:                    completion.add("Heard and McDonald Islands");
229:                    completion.add("Holy See (Vatican City State)");
230:                    completion.add("Holland (see Netherlands)");
231:                    completion.add("Honduras");
232:                    completion.add("Hong Kong, (China)");
233:                    completion.add("Hungary");
234:                    completion.add("Iceland");
235:                    completion.add("India");
236:                    completion.add("Indonesia");
237:                    completion.add("Iran, Islamic Republic of");
238:                    completion.add("Iraq");
239:                    completion.add("Ireland");
240:                    completion.add("Israel");
241:                    completion.add("Ivory Coast (see Cote d'Ivoire)");
242:                    completion.add("Italy");
243:                    completion.add("Jamaica");
244:                    completion.add("Japan");
245:                    completion.add("Jersey");
246:                    completion.add("Jordan");
247:                    completion.add("Kazakhstan");
248:                    completion.add("Kenya");
249:                    completion.add("Kiribati");
250:                    completion.add("Korea, Demo. People's Rep. of");
251:                    completion.add("Korea, (South) Republic of");
252:                    completion.add("Kuwait");
253:                    completion.add("Kyrgyzstan");
254:                    completion.add("Lao People's Democratic Republic");
255:                    completion.add("Latvia");
256:                    completion.add("Lebanon");
257:                    completion.add("Lesotho");
258:                    completion.add("Liberia");
259:                    completion.add("Libyan Arab Jamahiriya");
260:                    completion.add("Liechtenstein");
261:                    completion.add("Lithuania");
262:                    completion.add("Luxembourg");
263:                    completion.add("Macao, (China)");
264:                    completion.add("Macedonia, TFYR");
265:                    completion.add("Madagascar");
266:                    completion.add("Malawi");
267:                    completion.add("Malaysia");
268:                    completion.add("Maldives");
269:                    completion.add("Mali");
270:                    completion.add("Malta");
271:                    completion.add("Marshall Islands");
272:                    completion.add("Martinique");
273:                    completion.add("Mauritania");
274:                    completion.add("Mauritius");
275:                    completion.add("Mayotte");
276:                    completion.add("Mexico");
277:                    completion.add("Micronesia, Federated States of");
278:                    completion.add("Moldova, Republic of");
279:                    completion.add("Monaco");
280:                    completion.add("Mongolia");
281:                    completion.add("Montserrat");
282:                    completion.add("Morocco");
283:                    completion.add("Mozambique");
284:                    completion.add("Myanmar (ex-Burma)");
285:                    completion.add("Namibia");
286:                    completion.add("Nauru");
287:                    completion.add("Nepal");
288:                    completion.add("Netherlands");
289:                    completion.add("Netherlands Antilles");
290:                    completion.add("New Caledonia");
291:                    completion.add("New Zealand");
292:                    completion.add("Nicaragua");
293:                    completion.add("Niger");
294:                    completion.add("Nigeria");
295:                    completion.add("Niue");
296:                    completion.add("Norfolk Island");
297:                    completion.add("Northern Mariana Islands");
298:                    completion.add("Norway");
299:                    completion.add("Oman");
300:                    completion.add("Pakistan");
301:                    completion.add("Palau");
302:                    completion.add("Palestinian Territory");
303:                    completion.add("Panama");
304:                    completion.add("Papua New Guinea");
305:                    completion.add("Paraguay");
306:                    completion.add("Peru");
307:                    completion.add("Philippines");
308:                    completion.add("Pitcairn Island");
309:                    completion.add("Poland");
310:                    completion.add("Portugal");
311:                    completion.add("Puerto Rico");
312:                    completion.add("Qatar");
313:                    completion.add("Reunion");
314:                    completion.add("Romania");
315:                    completion.add("Russia (Russian Federation)");
316:                    completion.add("Rwanda");
317:                    completion.add("Sahara");
318:                    completion.add("Saint Helena");
319:                    completion.add("Saint Kitts and Nevis");
320:                    completion.add("Saint Lucia");
321:                    completion.add("Saint Pierre and Miquelon");
322:                    completion.add("Saint Vincent and the Grenadines");
323:                    completion.add("Samoa");
324:                    completion.add("San Marino");
325:                    completion.add("Sao Tome and Principe");
326:                    completion.add("Saudi Arabia");
327:                    completion.add("Senegal");
328:                    completion.add("Serbia & Montenegro");
329:                    completion.add("Seychelles");
330:                    completion.add("Sierra Leone");
331:                    completion.add("Singapore");
332:                    completion.add("Slovakia");
333:                    completion.add("Slovenia");
334:                    completion.add("Solomon Islands");
335:                    completion.add("Somalia");
336:                    completion.add("South Africa");
337:                    completion.add("S. Georgia and S. Sandwich Is.");
338:                    completion.add("Spain");
339:                    completion.add("Sri Lanka (ex-Ceilan)");
340:                    completion.add("Sudan");
341:                    completion.add("Suriname");
342:                    completion.add("Svalbard and Jan Mayen Islands");
343:                    completion.add("Swaziland");
344:                    completion.add("Sweden");
345:                    completion.add("Switzerland");
346:                    completion.add("Syrian Arab Republic");
347:                    completion.add("Taiwan");
348:                    completion.add("Tajikistan");
349:                    completion.add("Tanzania, United Republic of");
350:                    completion.add("Thailand");
351:                    completion.add("Timor-Leste (East Timor)");
352:                    completion.add("Togo");
353:                    completion.add("Tokelau");
354:                    completion.add("Tonga");
355:                    completion.add("Trinidad & Tobago");
356:                    completion.add("Tunisia");
357:                    completion.add("Turkey");
358:                    completion.add("Turkmenistan");
359:                    completion.add("Turks and Caicos Islands");
360:                    completion.add("Tuvalu");
361:                    completion.add("Uganda");
362:                    completion.add("Ukraine");
363:                    completion.add("United Arab Emirates");
364:                    completion.add("United Kingdom");
365:                    completion.add("United States");
366:                    completion.add("US Minor Outlying Islands");
367:                    completion.add("Uruguay");
368:                    completion.add("Uzbekistan");
369:                    completion.add("Vanuatu");
370:                    completion.add("Vatican City State (Holy See)");
371:                    completion.add("Venezuela");
372:                    completion.add("Viet Nam");
373:                    completion.add("Virgin Islands, British");
374:                    completion.add("Virgin Islands, U.S.");
375:                    completion.add("Wallis and Futuna");
376:                    completion.add("Western Sahara");
377:                    completion.add("Yemen");
378:                    completion.add("Zambia");
379:                    completion.add("Zimbabwe");
380:                }
381:
382:                public List<Map.Entry<String, String>> generateSuggestions(
383:                        String part) {
384:                    List<Map.Entry<String, String>> returning = new ArrayList<Map.Entry<String, String>>();
385:                    for (Iterator iter = completion.iterator(); iter.hasNext();) {
386:                        Object o = iter.next();
387:                        if (o instanceof  String) {
388:                            String s = (String) o;
389:                            if (s.toLowerCase().startsWith(part.toLowerCase())) {
390:                                returning.add(new Entry(s, s));
391:                            }
392:                        }
393:                    }
394:
395:                    return returning;
396:                }
397:
398:            }
399:
400:            /**     
401:             * another model for XSuggest 
402:             * @author Christian Schyma
403:             * @version $Revision$
404:             */
405:            public class StatesOfGermany implements  XSuggestDataSource {
406:
407:                private String ajaxText;
408:
409:                public String getAjaxText() {
410:                    return ajaxText;
411:                }
412:
413:                public void setAjaxText(String ajaxText) {
414:                    this .ajaxText = ajaxText;
415:                }
416:
417:                class State {
418:                    public String name;
419:                    public String iso;
420:
421:                    State(String name, String iso) {
422:                        this .name = name;
423:                        this .iso = iso;
424:                    }
425:                }
426:
427:                private List states = new ArrayList();
428:
429:                private void init() {
430:                    states.add(new State("Berlin", "DE-BE"));
431:                    states.add(new State("Brandenburg", "DE-BR"));
432:                    states.add(new State("Baden-Württemberg", "DE-BW"));
433:                    states.add(new State("Bayern", "DE-BY"));
434:                    states.add(new State("Bremen", "DE-HB"));
435:                    states.add(new State("Hessen", "DE-HE"));
436:                    states.add(new State("Hamburg", "DE-HH"));
437:                    states.add(new State("Mecklenburg-Vorpommern", "DE-MV"));
438:                    states.add(new State("Niedersachsen", "DE-NI"));
439:                    states.add(new State("Nordrhein-Westfalen", "DE-NW"));
440:                    states.add(new State("Rheinland-Pfalz", "DE-RP"));
441:                    states.add(new State("Schleswig-Holstein", "DE-SH"));
442:                    states.add(new State("Saarland", "DE-SL"));
443:                    states.add(new State("Sachsen", "DE-SN"));
444:                    states.add(new State("Sachsen-Anhalt", "DE-ST"));
445:                    states.add(new State("Thüringen", "DE-TH"));
446:                }
447:
448:                public List<Map.Entry<String, String>> generateSuggestions(
449:                        String part) {
450:                    List<Map.Entry<String, String>> returning = new ArrayList<Map.Entry<String, String>>();
451:                    for (Iterator iter = states.iterator(); iter.hasNext();) {
452:                        Object o = iter.next();
453:                        if (o instanceof  State) {
454:                            State state = (State) o;
455:                            if (state.name.toLowerCase().startsWith(
456:                                    part.toLowerCase())) {
457:                                returning.add(new Entry(state.name, state.iso
458:                                        + " " + state.name));
459:                            }
460:                        }
461:                    }
462:
463:                    return returning;
464:                }
465:
466:                /** Creates a new instance of StatesOfGermany */
467:                public StatesOfGermany() {
468:                    init();
469:                }
470:            }
471:
472:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.