Source Code Cross Referenced for ContextModelListenerAdapter.java in  » GIS » udig-1.1 » net » refractions » udig » project » internal » 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 » GIS » udig 1.1 » net.refractions.udig.project.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003:         * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004:         * under the terms of the GNU Lesser General Public License as published by the Free Software
005:         * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006:         * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007:         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008:         */
009:        package net.refractions.udig.project.internal;
010:
011:        import org.eclipse.emf.common.notify.Notification;
012:        import org.eclipse.emf.common.notify.impl.AdapterImpl;
013:
014:        /**
015:         * An Adapter for ContextModels that allow other objects to listen to state changes that occur in
016:         * the ContextModel and its Layers.
017:         * <p>
018:         * See the example for how to use an this class as a listener.
019:         * </p>
020:         * <p>
021:         * Responsibilities:
022:         * <ul>
023:         * <li>Listener for ContextModel state events</li>
024:         * <li>Call methods when an event occurs that can be mapped to one of the methods.
025:         * <p>
026:         * For example if a layer is added the layerAdded method is called.
027:         * </p>
028:         * </li>
029:         * </ul>
030:         * </p>
031:         * <p>
032:         * The following example adds an observer/listener that only reacts to single layer added events...
033:         * <b>Note that multiple layers being added are ignored </b>. Example Use:
034:         * 
035:         * <pre><code>
036:         * contextModel.eAdapters().add(new ContextModelListenerAdapter(){
037:         *     protected void layerAdded( Notification msg ) {
038:         *         //Enter behaviour
039:         *     }
040:         * });
041:         * </code></pre>
042:         * 
043:         * </p>
044:         * <p>
045:         * The following example adds an observer/listener that is notified of style change events that
046:         * occur in the layers contained by the ContextModel.
047:         * </p>
048:         * <p>
049:         * Note: getDeepAdapters() adds the listener/adapter/observer to the context model and all of the
050:         * children. Children that are later added or removed automatically have the deep adapter added or
051:         * removed.
052:         * </p>
053:         * <p>
054:         * Example Use:
055:         * 
056:         * <pre><code>
057:         * contextModel.getDeepAdapters().add(new ContextModelListenerAdapter(){
058:         *     protected void styleChanged( Notification msg ) {
059:         *         //Enter behaviour
060:         *     }
061:         * });
062:         * </code></pre>
063:         * 
064:         * </p>
065:         * 
066:         * @author jeichar
067:         * @since 0.3
068:         */
069:
070:        public class ContextModelListenerAdapter extends AdapterImpl {
071:
072:            /**
073:             * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
074:             */
075:            public void notifyChanged(Notification msg) {
076:                if (msg.getNotifier() instanceof  ContextModel) {
077:                    switch (msg.getFeatureID(ContextModel.class)) {
078:                    case ProjectPackage.CONTEXT_MODEL__LAYERS: {
079:                        switch (msg.getEventType()) {
080:                        case Notification.ADD: {
081:                            layerAdded(msg);
082:                            break;
083:                        }// case
084:                        case Notification.ADD_MANY: {
085:                            manyLayersAdded(msg);
086:                            break;
087:                        }// case
088:                        case Notification.REMOVE: {
089:                            layerRemoved(msg);
090:                            break;
091:                        }// case
092:                        case Notification.REMOVE_MANY: {
093:                            manyLayersRemoved(msg);
094:                            break;
095:                        }// case
096:                        case Notification.MOVE: {
097:                            zorderChanged(msg);
098:                            break;
099:                        }// case
100:                        }// switch
101:                        break;
102:                    }// case
103:                    }// switch
104:                }// if
105:                else if (msg.getNotifier() instanceof  Layer) {
106:                    switch (msg.getFeatureID(Layer.class)) {
107:                    case ProjectPackage.LAYER__GLYPH: {
108:                        glyphChanged(msg);
109:                        break;
110:                    }// case
111:                    case ProjectPackage.LAYER__STYLE_BLACKBOARD: { // FIXME: Changed from LAYER__STYLE
112:                        styleChanged(msg);
113:                        break;
114:                    }// case
115:                    case ProjectPackage.LAYER__VISIBLE: {
116:                        visibilityChanged(msg);
117:                        break;
118:                    }// case
119:                    }// switch
120:
121:                }// else
122:            }
123:
124:            /**
125:             * This method is called when a single layer has been added.
126:             * <p>
127:             * msg.getNewValue() will return the layer added
128:             * </p>
129:             * 
130:             * @param msg The Notification object with all the information about the event.
131:             */
132:            protected void layerAdded(Notification msg) {
133:                // do nothing
134:            }
135:
136:            /**
137:             * This method is called when more than on layer has been added.
138:             * <li>msg.getNewValue() will return a list of the layers added</li>
139:             * <li>msg.getNotifier() will return the ContextModel</li>
140:             * </ul>
141:             * </p>
142:             * 
143:             * @param msg The Notification object with all the information about the event.
144:             */
145:            protected void manyLayersAdded(Notification msg) {
146:                // do nothing
147:            }
148:
149:            /**
150:             * This method is called when a single layer has been removed.
151:             * <p>
152:             * <ul>
153:             * <li>msg.getOldValue() will return the layer removed</li>
154:             * <li>msg.getNotifier() will return the ContextModel</li>
155:             * </ul>
156:             * </p>
157:             * 
158:             * @param msg The Notification object with all the information about the event.
159:             */
160:            protected void layerRemoved(Notification msg) {
161:                // do nothing
162:            }
163:
164:            /**
165:             * This method is called when a multiple layers have been removed.
166:             * <p>
167:             * <ul>
168:             * <li>msg.getOldValue() will return a list with the layers removed</li>
169:             * <li>msg.getNotifier() will return the ContextModel</li>
170:             * </ul>
171:             * </p>
172:             * 
173:             * @param msg The Notification object with all the information about the event.
174:             */
175:            protected void manyLayersRemoved(Notification msg) {
176:                // do nothing
177:            }
178:
179:            /**
180:             * The order of the layer in the list has been changed. Therefore the zorder of the layer has
181:             * been changed.
182:             * <p>
183:             * The closer to the beginning of the list the later the object will be rendered. In other words
184:             * the list is in reverse zorder
185:             * </p>
186:             * <p>
187:             * <ul>
188:             * <li>msg.getNewIntValue() will return the new position of the layer</li>
189:             * <li>msg.getOldIntValue() will return the old position of the layer</li>
190:             * <li>msg.getNotifier() will return the ContextModel</li>
191:             * </ul>
192:             * </p>
193:             * 
194:             * @param msg The Notification object with all the information about the event.
195:             */
196:            protected void zorderChanged(Notification msg) {
197:                // do nothing
198:            }
199:
200:            /**
201:             * Called when the Glyph of a layer has been changed.
202:             * <p>
203:             * <ul>
204:             * <li>msg.getNewValue() will return the new Glyph</li>
205:             * <li>msg.getOldValue() will return the old Glyph</li>
206:             * <li>msg.getNotifier() will return the Layer</li>
207:             * </ul>
208:             * </p>
209:             * 
210:             * @param msg The Notification object with all the information about the event.
211:             */
212:            protected void glyphChanged(Notification msg) {
213:                // do nothing
214:            }
215:
216:            /**
217:             * Called when the Style of a layer has been changed.
218:             * <p>
219:             * <ul>
220:             * <li>msg.getNewValue() will return the new Style</li>
221:             * <li>msg.getOldValue() will return the old Style</li>
222:             * <li>msg.getNotifier() will return the Layer</li>
223:             * </ul>
224:             * </p>
225:             * 
226:             * @param msg The Notification object with all the information about the event.
227:             */
228:            protected void styleChanged(Notification msg) {
229:                // do nothing
230:            }
231:
232:            /**
233:             * Called when the Visibility of a layer has been changed.
234:             * <p>
235:             * <ul>
236:             * <li>msg.getNewValue() will return the new Visibility</li>
237:             * <li>msg.getOldValue() will return the old Visibility</li>
238:             * <li>msg.getNotifier() will return the Layer</li>
239:             * </ul>
240:             * </p>
241:             * 
242:             * @param msg The Notification object with all the information about the event.
243:             */
244:            protected void visibilityChanged(Notification msg) {
245:                // do nothing
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.