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


001:        /*
002:         * $Id: STextComponent.java 3423 2007-07-05 09:47:56Z hengels $
003:         * Copyright 2000,2005 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:        package org.wings;
015:
016:        import org.wings.event.SDocumentEvent;
017:        import org.wings.event.SDocumentListener;
018:        import org.wings.plaf.TextAreaCG;
019:        import org.wings.plaf.TextFieldCG;
020:        import org.wings.text.DefaultDocument;
021:        import org.wings.text.SDocument;
022:
023:        import javax.swing.text.BadLocationException;
024:
025:        /**
026:         * Abstract base class of input text components like {@link STextArea} and {@link STextField}.
027:         * Requires a surrounding {@link SForm} element!
028:         *
029:         * @author <a href="mailto:armin.haaf@mercatis.de">Armin Haaf</a>
030:         * @version $Revision: 3423 $
031:         */
032:        public abstract class STextComponent extends SComponent implements 
033:                LowLevelEventListener, SDocumentListener {
034:
035:            private boolean editable = true;
036:
037:            private SDocument document;
038:
039:            /**
040:             * @see LowLevelEventListener#isEpochCheckEnabled()
041:             */
042:            private boolean epochCheckEnabled = true;
043:
044:            public STextComponent() {
045:                this (new DefaultDocument(), true);
046:            }
047:
048:            public STextComponent(String text) {
049:                this (new DefaultDocument(text), true);
050:            }
051:
052:            public STextComponent(SDocument document) {
053:                this (document, true);
054:            }
055:
056:            public STextComponent(SDocument document, boolean editable) {
057:                setDocument(document);
058:                setEditable(editable);
059:            }
060:
061:            public SDocument getDocument() {
062:                return document;
063:            }
064:
065:            public void setDocument(SDocument document) {
066:                if (document == null)
067:                    throw new IllegalArgumentException("null");
068:
069:                SDocument oldDocument = this .document;
070:                this .document = document;
071:                if (oldDocument != null)
072:                    oldDocument.removeDocumentListener(this );
073:                document.addDocumentListener(this );
074:                reloadIfChange(oldDocument, document);
075:            }
076:
077:            /**
078:             * Defines if the textcomponent is editable or not.
079:             * @see #isEditable()
080:             * @param ed true if the text component is to be editable false if not.
081:             */
082:            public void setEditable(boolean ed) {
083:                boolean oldEditable = editable;
084:                editable = ed;
085:                if (editable != oldEditable)
086:                    reload();
087:            }
088:
089:            public boolean isEditable() {
090:                return editable;
091:            }
092:
093:            /**
094:             * Sets the text of the component to the specified text.
095:             * @see #getText()
096:             * @param text the new text for the component.
097:             */
098:            public void setText(String text) {
099:                document.setText(text);
100:            }
101:
102:            public String getText() {
103:                return document.getText();
104:            }
105:
106:            /**
107:             * Appends the given text to the end of the document. Does nothing
108:             * if the string is null or empty.
109:             *
110:             * @param text the text to append.
111:             */
112:            public void append(String text) {
113:                try {
114:                    document.insert(document.getLength(), text);
115:                } catch (BadLocationException e) {
116:                }
117:            }
118:
119:            public void processLowLevelEvent(String action, String[] values) {
120:                processKeyEvents(values);
121:                if (action.endsWith("_keystroke"))
122:                    return;
123:
124:                if (isEditable() && isEnabled()) {
125:                    String newValue = values[0];
126:                    if (newValue != null && newValue.length() == 0) {
127:                        newValue = null;
128:                    }
129:                    String text = getText();
130:                    if (text != null && text.length() == 0) {
131:                        text = null;
132:                    }
133:
134:                    if (isDifferent(newValue, text)) {
135:                        getDocument().setDelayEvents(true);
136:                        setText(newValue);
137:                        getDocument().setDelayEvents(false);
138:                        SForm.addArmedComponent(this );
139:                    }
140:                }
141:            }
142:
143:            public SDocumentListener[] getDocumentListeners() {
144:                return getDocument().getDocumentListeners();
145:            }
146:
147:            public void addDocumentListener(SDocumentListener listener) {
148:                getDocument().addDocumentListener(listener);
149:            }
150:
151:            public void removeDocumentListener(SDocumentListener listener) {
152:                getDocument().removeDocumentListener(listener);
153:            }
154:
155:            public void fireIntermediateEvents() {
156:                getDocument().fireDelayedIntermediateEvents();
157:            }
158:
159:            public void fireFinalEvents() {
160:                super .fireFinalEvents();
161:                getDocument().fireDelayedFinalEvents();
162:            }
163:
164:            /**
165:             * @see LowLevelEventListener#isEpochCheckEnabled()
166:             */
167:            public boolean isEpochCheckEnabled() {
168:                return epochCheckEnabled;
169:            }
170:
171:            /**
172:             * @see LowLevelEventListener#isEpochCheckEnabled()
173:             */
174:            public void setEpochCheckEnabled(boolean epochCheckEnabled) {
175:                this .epochCheckEnabled = epochCheckEnabled;
176:            }
177:
178:            public void insertUpdate(SDocumentEvent e) {
179:                //reload();
180:            }
181:
182:            public void removeUpdate(SDocumentEvent e) {
183:                //reload();
184:            }
185:
186:            public void changedUpdate(SDocumentEvent e) {
187:                if (isUpdatePossible()) {
188:                    if (STextField.class.isAssignableFrom(getClass())
189:                            && !SPasswordField.class
190:                                    .isAssignableFrom(getClass()))
191:                        update(((TextFieldCG) getCG()).getTextUpdate(
192:                                (STextField) this , getText()));
193:                    else if (STextArea.class.isAssignableFrom(getClass()))
194:                        update(((TextAreaCG) getCG()).getTextUpdate(
195:                                (STextArea) this, getText()));
196:                    else
197:                        reload();
198:                } else {
199:                    reload();
200:                }
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.