Source Code Cross Referenced for XInplaceEditor.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.io.IOException;
017:        import org.wings.SLabel;
018:        import org.wings.event.SDocumentListener;
019:        import org.wings.io.StringBuilderDevice;
020:        import org.wings.plaf.css.Utils;
021:        import org.wings.text.DefaultDocument;
022:        import org.wings.text.SDocument;
023:
024:        /**
025:         * A in place editor is a simple label that becomes editable when activated
026:         * by a mouse click.
027:         * @author Christian Schyma
028:         */
029:        public class XInplaceEditor extends SLabel implements 
030:                XInplaceEditorInterface {
031:
032:            /**
033:             * number of editor columns
034:             */
035:            private int cols = 40;
036:
037:            /**
038:             * numer of editor rows
039:             */
040:            private int rows = 1;
041:
042:            /**
043:             * DWR request timeout in ms
044:             */
045:            private int timeout = 5000;
046:
047:            /**
048:             * intermediate text of a DWR (Ajax) request
049:             */
050:            private SDocument ajaxDocument;
051:
052:            /**
053:             * what to display, when the intermediateDocument gets ""?
054:             */
055:            private String emptyString = "click here to name";
056:
057:            /**
058:             * text to be displayed while hovering with the mouse over the editable text
059:             */
060:            private String clickNotificationText = "click here to edit";
061:
062:            /**
063:             * Creates a new <code>XInplaceEditor</code> instance with the specified text.
064:             *
065:             * @param text The text to be displayed by the label.
066:             */
067:            public XInplaceEditor(String text) {
068:                super (text);
069:                init();
070:            }
071:
072:            /**
073:             * Creates a new <code>XInplaceEditor</code> instance with the specified text
074:             * and number of editor columns.
075:             *
076:             * @param text The text to be displayed by the label.
077:             * @param cols number of editor columns
078:             */
079:            public XInplaceEditor(String text, int cols) {
080:                super (text);
081:                init();
082:                this .cols = cols;
083:            }
084:
085:            /**
086:             * Creates a new <code>XInplaceEditor</code> instance with the specified text,
087:             * numer of editor columns and rows.
088:             *
089:             * @param text The text to be displayed by the label.
090:             * @param cols number of editor columns
091:             * @param rows number of editor rows
092:             */
093:            public XInplaceEditor(String text, int cols, int rows) {
094:                super (text);
095:                init();
096:                this .cols = cols;
097:                this .rows = rows;
098:            }
099:
100:            private void init() {
101:                ajaxDocument = new DefaultDocument(text);
102:                setWordWrap(true);
103:            }
104:
105:            /**
106:             * @return formatted version of the intermediate text. Used by the
107:             * client-side JavaScript.
108:             */
109:            private String getAjaxFormattedText() {
110:                StringBuilderDevice device = new StringBuilderDevice(256);
111:                try {
112:                    Utils.quote(device, ajaxDocument.getText(), true,
113:                            !isWordWrap(), false);
114:                } catch (IOException ex) {
115:                    ex.printStackTrace();
116:                }
117:
118:                return device.toString();
119:            }
120:
121:            public String getAjaxText() {
122:                return ajaxDocument.getText();
123:            }
124:
125:            public String setAjaxText(String text) {
126:                this .ajaxDocument.setText(text);
127:                this .text = text;
128:
129:                // to avoid a invisible label
130:                if (text.compareTo("") == 0) {
131:                    return this .emptyString;
132:                } else {
133:                    return this .getAjaxFormattedText();
134:                }
135:            }
136:
137:            public void setText(String t) {
138:                super .setText(t);
139:                if (this .ajaxDocument != null) {
140:                    setAjaxText(t);
141:                }
142:            }
143:
144:            /**
145:             * set number of columns of the editor
146:             */
147:            public void setCols(int cols) {
148:                int oldValue = this .cols;
149:                this .cols = cols;
150:                reloadIfChange(cols, oldValue);
151:            }
152:
153:            /**
154:             * @see #setCols
155:             */
156:            public int getCols() {
157:                return cols;
158:            }
159:
160:            /**
161:             * set number of rows of the editor
162:             */
163:            public void setRows(int rows) {
164:                int oldValue = this .rows;
165:                this .rows = rows;
166:                reloadIfChange(rows, oldValue);
167:            }
168:
169:            /**
170:             * @see #setRows
171:             */
172:            public int getRows() {
173:                return rows;
174:            }
175:
176:            /**
177:             * Set Ajax request timeout.
178:             * @param timeout in ms
179:             */
180:            public void setTimeout(int timeout) {
181:                int oldValue = this .timeout;
182:                this .timeout = timeout;
183:                reloadIfChange(timeout, oldValue);
184:            }
185:
186:            /**
187:             * @see #setTimeout(int timeout)
188:             */
189:            public int getTimeout() {
190:                return timeout;
191:            }
192:
193:            public SDocumentListener[] getAjaxDocumentListeners() {
194:                return ajaxDocument.getDocumentListeners();
195:            }
196:
197:            public void addAjaxDocumentListener(SDocumentListener listener) {
198:                ajaxDocument.addDocumentListener(listener);
199:            }
200:
201:            public void removeAjaxDocumentListener(SDocumentListener listener) {
202:                ajaxDocument.removeDocumentListener(listener);
203:            }
204:
205:            /**
206:             * @param text to be displayed while hovering with the mouse over
207:             * the editable text
208:             */
209:            public void setClickNotificationText(String text) {
210:                String oldValue = this .clickNotificationText;
211:                this .clickNotificationText = text;
212:                reloadIfChange(text, oldValue);
213:            }
214:
215:            /**
216:             * @return returns the text to be displayed while hovering with the
217:             * mouse over the editable text
218:             */
219:            public String getClickNotificationText() {
220:                return this.clickNotificationText;
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.