Source Code Cross Referenced for Behavior.java in  » Internationalization-Localization » icu4j » com » ibm » richtext » textpanel » 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 » Internationalization Localization » icu4j » com.ibm.richtext.textpanel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.
003:         *
004:         * The program is provided "as is" without any warranty express or
005:         * implied, including the warranty of non-infringement and the implied
006:         * warranties of merchantibility and fitness for a particular purpose.
007:         * IBM will not be liable for any damages suffered by you as a result
008:         * of using the Program. In no event will IBM be liable for any
009:         * special, indirect or consequential damages or lost profits even if
010:         * IBM has been advised of the possibility of their occurrence. IBM
011:         * will not be liable for any third party claims against you.
012:         */
013:        package com.ibm.richtext.textpanel;
014:
015:        import java.awt.Graphics;
016:        import java.awt.Rectangle;
017:
018:        import java.awt.event.FocusEvent;
019:        import java.awt.event.KeyEvent;
020:        import java.awt.event.MouseEvent;
021:
022:        /** A class that handles events for a BehaviorOwner.
023:         * A behavior enacpsulates some piece of the event-handling logic for a component.
024:         * This allows the client to separate event-handling logic out into separate classes
025:         * according to function, or to dynamically change the way a component handles
026:         * events without adding a lot of special-case code to the panel itself.
027:         * Behaviors are stored in a linked list, and all behaviors get a crack at an event before
028:         * the owner gets a crack at them (right now, we rely on objects that implement
029:         * BehaviorOwner to support these semantics).
030:         * Behavior provides all the same event-handling functions that Component provides, and
031:         * they all have exactly the same syntax and semantics. */
032:        abstract class Behavior {
033:
034:            static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
035:            private Behavior fNextBehavior = null;
036:            private BehaviorOwner fOwner = null;
037:
038:            static class EventType {
039:
040:                EventType() {
041:                }
042:            }
043:
044:            // events - should these be in TextPanel (or elsewhere)?
045:
046:            // This event's WHAT parameter is a TextRange instance
047:            static final EventType SELECT = new EventType();
048:
049:            // No WHAT param for these:
050:            static final EventType CUT = new EventType();
051:            static final EventType COPY = new EventType();
052:            static final EventType PASTE = new EventType();
053:            static final EventType CLEAR = new EventType();
054:            static final EventType UNDO = new EventType();
055:            static final EventType REDO = new EventType();
056:            static final EventType CLEAR_COMMAND_LOG = new EventType();
057:
058:            // WHAT param is a StyleModifier
059:            static final EventType CHARACTER_STYLE_MOD = new EventType();
060:            static final EventType PARAGRAPH_STYLE_MOD = new EventType();
061:
062:            // With this event, values of the WHAT parameter are
063:            // either Boolean.TRUE or Boolean.FALSE
064:            static final EventType SET_MODIFIED = new EventType();
065:
066:            // WHAT param is a TextReplacement
067:            static final EventType REPLACE = new EventType();
068:
069:            // WHAT param is an Integer
070:            static final EventType SET_COMMAND_LOG_SIZE = new EventType();
071:
072:            public Behavior() {
073:            }
074:
075:            public void addToOwner(BehaviorOwner owner) {
076:                removeFromOwner();
077:                fOwner = owner;
078:                setNextBehavior(owner.getBehavior());
079:                owner.setBehavior(this );
080:            }
081:
082:            public boolean focusGained(FocusEvent e) {
083:                if (fNextBehavior != null)
084:                    return fNextBehavior.focusGained(e);
085:                else
086:                    return false;
087:            }
088:
089:            public boolean focusLost(FocusEvent e) {
090:                if (fNextBehavior != null)
091:                    return fNextBehavior.focusLost(e);
092:                else
093:                    return false;
094:            }
095:
096:            public boolean keyPressed(KeyEvent e) {
097:                if (fNextBehavior != null)
098:                    return fNextBehavior.keyPressed(e);
099:                else
100:                    return false;
101:            }
102:
103:            public boolean keyTyped(KeyEvent e) {
104:
105:                if (fNextBehavior != null) {
106:                    return fNextBehavior.keyTyped(e);
107:                } else {
108:                    return false;
109:                }
110:            }
111:
112:            public boolean keyReleased(KeyEvent e) {
113:                if (fNextBehavior != null)
114:                    return fNextBehavior.keyReleased(e);
115:                else
116:                    return false;
117:            }
118:
119:            public boolean mouseDragged(MouseEvent e) {
120:                if (fNextBehavior != null)
121:                    return fNextBehavior.mouseDragged(e);
122:                else
123:                    return false;
124:            }
125:
126:            public boolean mouseEntered(MouseEvent e) {
127:                if (fNextBehavior != null)
128:                    return fNextBehavior.mouseEntered(e);
129:                else
130:                    return false;
131:            }
132:
133:            public boolean mouseExited(MouseEvent e) {
134:                if (fNextBehavior != null)
135:                    return fNextBehavior.mouseExited(e);
136:                else
137:                    return false;
138:            }
139:
140:            public boolean mouseMoved(MouseEvent e) {
141:                if (fNextBehavior != null)
142:                    return fNextBehavior.mouseMoved(e);
143:                else
144:                    return false;
145:            }
146:
147:            public boolean mousePressed(MouseEvent e) {
148:                if (fNextBehavior != null)
149:                    return fNextBehavior.mousePressed(e);
150:                else
151:                    return false;
152:            }
153:
154:            public boolean mouseReleased(MouseEvent e) {
155:                if (fNextBehavior != null)
156:                    return fNextBehavior.mouseReleased(e);
157:                else
158:                    return false;
159:            }
160:
161:            public final Behavior nextBehavior() {
162:                return fNextBehavior;
163:            }
164:
165:            public boolean paint(Graphics g, Rectangle drawRect) {
166:                if (fNextBehavior != null)
167:                    return fNextBehavior.paint(g, drawRect);
168:                else
169:                    return false;
170:            }
171:
172:            public void removeFromOwner() {
173:                if (fOwner != null) {
174:                    if (fOwner.getBehavior() == this )
175:                        fOwner.setBehavior(nextBehavior());
176:                    else {
177:                        Behavior current = fOwner.getBehavior();
178:
179:                        while (current != null
180:                                && current.nextBehavior() != this )
181:                            current = current.nextBehavior();
182:                        if (current != null)
183:                            current.setNextBehavior(nextBehavior());
184:                    }
185:                    setNextBehavior(null);
186:                    fOwner = null;
187:                }
188:            }
189:
190:            public final void setNextBehavior(Behavior next) {
191:                fNextBehavior = next;
192:            }
193:
194:            public boolean textControlEventOccurred(EventType event, Object data) {
195:                if (fNextBehavior != null)
196:                    return fNextBehavior.textControlEventOccurred(event, data);
197:                else
198:                    return false;
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.