Source Code Cross Referenced for EventTrackers.java in  » IDE-Eclipse » jface » org » eclipse » jface » tests » databinding » 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 » IDE Eclipse » jface » org.eclipse.jface.tests.databinding 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         ******************************************************************************/package org.eclipse.jface.tests.databinding;
011:
012:        import java.util.List;
013:
014:        import org.eclipse.core.databinding.observable.ChangeEvent;
015:        import org.eclipse.core.databinding.observable.IChangeListener;
016:        import org.eclipse.core.databinding.observable.IObservable;
017:        import org.eclipse.core.databinding.observable.list.IListChangeListener;
018:        import org.eclipse.core.databinding.observable.list.ListChangeEvent;
019:        import org.eclipse.core.databinding.observable.map.IMapChangeListener;
020:        import org.eclipse.core.databinding.observable.map.MapChangeEvent;
021:        import org.eclipse.core.databinding.observable.set.ISetChangeListener;
022:        import org.eclipse.core.databinding.observable.set.SetChangeEvent;
023:        import org.eclipse.core.databinding.observable.value.IObservableValue;
024:        import org.eclipse.core.databinding.observable.value.IValueChangeListener;
025:        import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
026:
027:        /**
028:         * Implementations of change listeners that keep track of the number of times an
029:         * event fires.
030:         * 
031:         * @since 1.1
032:         */
033:        public class EventTrackers {
034:            public static class ChangeEventTracker implements  IChangeListener {
035:                public int count;
036:
037:                public ChangeEvent event;
038:
039:                /**
040:                 * Queue that the listener will add itself too when it is notified of an
041:                 * event. Used to determine order of notifications of listeners.
042:                 */
043:                public final List notificationQueue;
044:
045:                public ChangeEventTracker() {
046:                    notificationQueue = null;
047:                }
048:
049:                public ChangeEventTracker(List notificationQueue) {
050:                    this .notificationQueue = notificationQueue;
051:                }
052:
053:                public void handleChange(ChangeEvent event) {
054:                    count++;
055:                    this .event = event;
056:                    if (notificationQueue != null) {
057:                        notificationQueue.add(this );
058:                    }
059:                }
060:
061:                /**
062:                 * Convenience method to register the listener on an observable allowing for one line setup.
063:                 * <pre><code>
064:                 * ChangeEventTracker listener = new ChangeEventTracker().register(observable);
065:                 * </code></pre>
066:                 * 
067:                 * @param observable
068:                 * @return
069:                 */
070:                public ChangeEventTracker register(IObservable observable) {
071:                    observable.addChangeListener(this );
072:                    return this ;
073:                }
074:            }
075:
076:            public static class ValueChangeEventTracker implements 
077:                    IValueChangeListener {
078:                public int count;
079:
080:                public ValueChangeEvent event;
081:
082:                public ValueChangeEventTracker() {
083:                }
084:
085:                public void handleValueChange(ValueChangeEvent event) {
086:                    count++;
087:                    this .event = event;
088:                }
089:
090:                /**
091:                 * Convenience method to register the listener on an observable allowing for one line setup.
092:                 * <pre><code>
093:                 * ValueChangeEventTracker listener = new ValueChangeEventTracker().register(observable);
094:                 * </code></pre>
095:                 * 
096:                 * @param observable
097:                 * @return
098:                 */
099:                public ValueChangeEventTracker register(
100:                        IObservableValue observable) {
101:                    observable.addValueChangeListener(this );
102:                    return this ;
103:                }
104:            }
105:
106:            public static class MapChangeEventTracker implements 
107:                    IMapChangeListener {
108:                public int count;
109:
110:                public MapChangeEvent event;
111:
112:                public MapChangeEventTracker() {
113:                }
114:
115:                public void handleMapChange(MapChangeEvent event) {
116:                    count++;
117:                    this .event = event;
118:                }
119:            }
120:
121:            public static class ListChangeEventTracker implements 
122:                    IListChangeListener {
123:                public int count;
124:
125:                public ListChangeEvent event;
126:
127:                /**
128:                 * Queue that the listener will add itself too when it is notified of an
129:                 * event. Used to determine order of notifications of listeners.
130:                 */
131:                public final List notificationQueue;
132:
133:                public ListChangeEventTracker() {
134:                    notificationQueue = null;
135:                }
136:
137:                public ListChangeEventTracker(List notificationQueue) {
138:                    this .notificationQueue = notificationQueue;
139:                }
140:
141:                public void handleListChange(ListChangeEvent event) {
142:                    count++;
143:                    this .event = event;
144:                    if (notificationQueue != null) {
145:                        notificationQueue.add(this );
146:                    }
147:                }
148:            }
149:
150:            public static class SetChangeEventTracker implements 
151:                    ISetChangeListener {
152:                public int count;
153:
154:                public SetChangeEvent event;
155:
156:                /**
157:                 * Queue that the listener will add itself too when it is notified of an
158:                 * event. Used to determine order of notifications of listeners.
159:                 */
160:                public final List notificationQueue;
161:
162:                public SetChangeEventTracker() {
163:                    notificationQueue = null;
164:                }
165:
166:                public SetChangeEventTracker(List notificationQueue) {
167:                    this .notificationQueue = notificationQueue;
168:                }
169:
170:                public void handleSetChange(SetChangeEvent event) {
171:                    count++;
172:                    this.event = event;
173:                    if (notificationQueue != null) {
174:                        notificationQueue.add(this);
175:                    }
176:                }
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.