puremvc-as3 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/2.0.4/asdoc/all-classes.html +81 -0
  2. data/2.0.4/asdoc/all-index-A.html +59 -0
  3. data/2.0.4/asdoc/all-index-B.html +52 -0
  4. data/2.0.4/asdoc/all-index-C.html +92 -0
  5. data/2.0.4/asdoc/all-index-D.html +58 -0
  6. data/2.0.4/asdoc/all-index-E.html +89 -0
  7. data/2.0.4/asdoc/all-index-F.html +72 -0
  8. data/2.0.4/asdoc/all-index-G.html +190 -0
  9. data/2.0.4/asdoc/all-index-H.html +174 -0
  10. data/2.0.4/asdoc/all-index-I.html +202 -0
  11. data/2.0.4/asdoc/all-index-J.html +52 -0
  12. data/2.0.4/asdoc/all-index-K.html +52 -0
  13. data/2.0.4/asdoc/all-index-L.html +67 -0
  14. data/2.0.4/asdoc/all-index-M.html +112 -0
  15. data/2.0.4/asdoc/all-index-N.html +128 -0
  16. data/2.0.4/asdoc/all-index-O.html +178 -0
  17. data/2.0.4/asdoc/all-index-P.html +79 -0
  18. data/2.0.4/asdoc/all-index-Q.html +52 -0
  19. data/2.0.4/asdoc/all-index-R.html +308 -0
  20. data/2.0.4/asdoc/all-index-S.html +193 -0
  21. data/2.0.4/asdoc/all-index-T.html +67 -0
  22. data/2.0.4/asdoc/all-index-U.html +52 -0
  23. data/2.0.4/asdoc/all-index-V.html +84 -0
  24. data/2.0.4/asdoc/all-index-W.html +52 -0
  25. data/2.0.4/asdoc/all-index-X.html +52 -0
  26. data/2.0.4/asdoc/all-index-Y.html +52 -0
  27. data/2.0.4/asdoc/all-index-Z.html +52 -0
  28. data/2.0.4/asdoc/appendixes.html +47 -0
  29. data/2.0.4/asdoc/asdoc.js +273 -0
  30. data/2.0.4/asdoc/class-summary.html +174 -0
  31. data/2.0.4/asdoc/cookies.js +84 -0
  32. data/2.0.4/asdoc/images/collapsed.gif +0 -0
  33. data/2.0.4/asdoc/images/detailHeaderRule.jpg +0 -0
  34. data/2.0.4/asdoc/images/detailSectionHeader.jpg +0 -0
  35. data/2.0.4/asdoc/images/expanded.gif +0 -0
  36. data/2.0.4/asdoc/images/inherit-arrow.gif +0 -0
  37. data/2.0.4/asdoc/images/inheritedSummary.gif +0 -0
  38. data/2.0.4/asdoc/images/logo.jpg +0 -0
  39. data/2.0.4/asdoc/images/titleTableBottom.jpg +0 -0
  40. data/2.0.4/asdoc/images/titleTableMiddle.jpg +0 -0
  41. data/2.0.4/asdoc/images/titleTableTop.jpg +0 -0
  42. data/2.0.4/asdoc/index-list.html +121 -0
  43. data/2.0.4/asdoc/index.html +63 -0
  44. data/2.0.4/asdoc/mxml-tags.html +45 -0
  45. data/2.0.4/asdoc/org/puremvc/as3/core/Controller.html +433 -0
  46. data/2.0.4/asdoc/org/puremvc/as3/core/Model.html +405 -0
  47. data/2.0.4/asdoc/org/puremvc/as3/core/View.html +524 -0
  48. data/2.0.4/asdoc/org/puremvc/as3/core/class-list.html +30 -0
  49. data/2.0.4/asdoc/org/puremvc/as3/core/package-detail.html +65 -0
  50. data/2.0.4/asdoc/org/puremvc/as3/interfaces/ICommand.html +110 -0
  51. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IController.html +226 -0
  52. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IFacade.html +520 -0
  53. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IMediator.html +345 -0
  54. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IModel.html +226 -0
  55. data/2.0.4/asdoc/org/puremvc/as3/interfaces/INotification.html +269 -0
  56. data/2.0.4/asdoc/org/puremvc/as3/interfaces/INotifier.html +151 -0
  57. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IObserver.html +234 -0
  58. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IProxy.html +217 -0
  59. data/2.0.4/asdoc/org/puremvc/as3/interfaces/IView.html +350 -0
  60. data/2.0.4/asdoc/org/puremvc/as3/interfaces/class-list.html +54 -0
  61. data/2.0.4/asdoc/org/puremvc/as3/interfaces/package-detail.html +93 -0
  62. data/2.0.4/asdoc/org/puremvc/as3/patterns/command/MacroCommand.html +284 -0
  63. data/2.0.4/asdoc/org/puremvc/as3/patterns/command/SimpleCommand.html +164 -0
  64. data/2.0.4/asdoc/org/puremvc/as3/patterns/command/class-list.html +27 -0
  65. data/2.0.4/asdoc/org/puremvc/as3/patterns/command/package-detail.html +61 -0
  66. data/2.0.4/asdoc/org/puremvc/as3/patterns/facade/Facade.html +940 -0
  67. data/2.0.4/asdoc/org/puremvc/as3/patterns/facade/class-list.html +24 -0
  68. data/2.0.4/asdoc/org/puremvc/as3/patterns/facade/package-detail.html +57 -0
  69. data/2.0.4/asdoc/org/puremvc/as3/patterns/mediator/Mediator.html +402 -0
  70. data/2.0.4/asdoc/org/puremvc/as3/patterns/mediator/class-list.html +24 -0
  71. data/2.0.4/asdoc/org/puremvc/as3/patterns/mediator/package-detail.html +57 -0
  72. data/2.0.4/asdoc/org/puremvc/as3/patterns/observer/Notification.html +312 -0
  73. data/2.0.4/asdoc/org/puremvc/as3/patterns/observer/Notifier.html +180 -0
  74. data/2.0.4/asdoc/org/puremvc/as3/patterns/observer/Observer.html +253 -0
  75. data/2.0.4/asdoc/org/puremvc/as3/patterns/observer/class-list.html +30 -0
  76. data/2.0.4/asdoc/org/puremvc/as3/patterns/observer/package-detail.html +65 -0
  77. data/2.0.4/asdoc/org/puremvc/as3/patterns/proxy/Proxy.html +338 -0
  78. data/2.0.4/asdoc/org/puremvc/as3/patterns/proxy/class-list.html +24 -0
  79. data/2.0.4/asdoc/org/puremvc/as3/patterns/proxy/package-detail.html +57 -0
  80. data/2.0.4/asdoc/package-frame.html +36 -0
  81. data/2.0.4/asdoc/package-list.html +52 -0
  82. data/2.0.4/asdoc/package-summary.html +68 -0
  83. data/2.0.4/asdoc/print.css +110 -0
  84. data/2.0.4/asdoc/style.css +565 -0
  85. data/2.0.4/asdoc/title-bar.html +55 -0
  86. data/2.0.4/bin/PureMVC_AS3_2_0_4.swc +0 -0
  87. data/2.0.4/license.txt +61 -0
  88. data/2.0.4/src/org/puremvc/as3/core/Controller.as +183 -0
  89. data/2.0.4/src/org/puremvc/as3/core/Model.as +144 -0
  90. data/2.0.4/src/org/puremvc/as3/core/View.as +271 -0
  91. data/2.0.4/src/org/puremvc/as3/interfaces/ICommand.as +21 -0
  92. data/2.0.4/src/org/puremvc/as3/interfaces/IController.as +64 -0
  93. data/2.0.4/src/org/puremvc/as3/interfaces/IFacade.as +131 -0
  94. data/2.0.4/src/org/puremvc/as3/interfaces/IMediator.as +150 -0
  95. data/2.0.4/src/org/puremvc/as3/interfaces/IModel.as +57 -0
  96. data/2.0.4/src/org/puremvc/as3/interfaces/INotification.as +76 -0
  97. data/2.0.4/src/org/puremvc/as3/interfaces/INotifier.as +46 -0
  98. data/2.0.4/src/org/puremvc/as3/interfaces/IObserver.as +81 -0
  99. data/2.0.4/src/org/puremvc/as3/interfaces/IProxy.as +61 -0
  100. data/2.0.4/src/org/puremvc/as3/interfaces/IView.as +106 -0
  101. data/2.0.4/src/org/puremvc/as3/patterns/command/MacroCommand.as +121 -0
  102. data/2.0.4/src/org/puremvc/as3/patterns/command/SimpleCommand.as +42 -0
  103. data/2.0.4/src/org/puremvc/as3/patterns/facade/Facade.as +419 -0
  104. data/2.0.4/src/org/puremvc/as3/patterns/mediator/Mediator.as +115 -0
  105. data/2.0.4/src/org/puremvc/as3/patterns/observer/Notification.as +128 -0
  106. data/2.0.4/src/org/puremvc/as3/patterns/observer/Notifier.as +55 -0
  107. data/2.0.4/src/org/puremvc/as3/patterns/observer/Observer.as +114 -0
  108. data/2.0.4/src/org/puremvc/as3/patterns/proxy/Proxy.as +88 -0
  109. data/2.0.4/src/puremvc-manifest.xml +20 -0
  110. data/2.0.4/version.txt +117 -0
  111. data/Gemfile +4 -0
  112. data/README.textile +107 -0
  113. data/Rakefile +24 -0
  114. data/lib/puremvc-as3.rb +29 -0
  115. data/lib/rake/rename.rb +34 -0
  116. metadata +198 -0
@@ -0,0 +1,419 @@
1
+ /*
2
+ PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved.
3
+ Your reuse is governed by the Creative Commons Attribution 3.0 United States License
4
+ */
5
+ package org.puremvc.as3.patterns.facade
6
+ {
7
+
8
+ import org.puremvc.as3.core.*;
9
+ import org.puremvc.as3.interfaces.*;
10
+ import org.puremvc.as3.patterns.observer.Notification;
11
+
12
+ /**
13
+ * A base Singleton <code>IFacade</code> implementation.
14
+ *
15
+ * <P>
16
+ * In PureMVC, the <code>Facade</code> class assumes these
17
+ * responsibilities:
18
+ * <UL>
19
+ * <LI>Initializing the <code>Model</code>, <code>View</code>
20
+ * and <code>Controller</code> Singletons.</LI>
21
+ * <LI>Providing all the methods defined by the <code>IModel,
22
+ * IView, & IController</code> interfaces.</LI>
23
+ * <LI>Providing the ability to override the specific <code>Model</code>,
24
+ * <code>View</code> and <code>Controller</code> Singletons created.</LI>
25
+ * <LI>Providing a single point of contact to the application for
26
+ * registering <code>Commands</code> and notifying <code>Observers</code></LI>
27
+ * </UL>
28
+ * <P>
29
+ * Example usage:
30
+ * <listing>
31
+ * import org.puremvc.as3.patterns.facade.&lowast;;
32
+ *
33
+ * import com.me.myapp.model.~~;
34
+ * import com.me.myapp.view.~~;
35
+ * import com.me.myapp.controller.~~;
36
+ *
37
+ * public class MyFacade extends Facade
38
+ * {
39
+ * // Notification constants. The Facade is the ideal
40
+ * // location for these constants, since any part
41
+ * // of the application participating in PureMVC
42
+ * // Observer Notification will know the Facade.
43
+ * public static const GO_COMMAND:String = "go";
44
+ *
45
+ * // Override Singleton Factory method
46
+ * public static function getInstance() : MyFacade {
47
+ * if (instance == null) instance = new MyFacade();
48
+ * return instance as MyFacade;
49
+ * }
50
+ *
51
+ * // optional initialization hook for Facade
52
+ * override public function initializeFacade() : void {
53
+ * super.initializeFacade();
54
+ * // do any special subclass initialization here
55
+ * }
56
+ *
57
+ * // optional initialization hook for Controller
58
+ * override public function initializeController() : void {
59
+ * // call super to use the PureMVC Controller Singleton.
60
+ * super.initializeController();
61
+ *
62
+ * // Otherwise, if you're implmenting your own
63
+ * // IController, then instead do:
64
+ * // if ( controller != null ) return;
65
+ * // controller = MyAppController.getInstance();
66
+ *
67
+ * // do any special subclass initialization here
68
+ * // such as registering Commands
69
+ * registerCommand( GO_COMMAND, com.me.myapp.controller.GoCommand )
70
+ * }
71
+ *
72
+ * // optional initialization hook for Model
73
+ * override public function initializeModel() : void {
74
+ * // call super to use the PureMVC Model Singleton.
75
+ * super.initializeModel();
76
+ *
77
+ * // Otherwise, if you're implmenting your own
78
+ * // IModel, then instead do:
79
+ * // if ( model != null ) return;
80
+ * // model = MyAppModel.getInstance();
81
+ *
82
+ * // do any special subclass initialization here
83
+ * // such as creating and registering Model proxys
84
+ * // that don't require a facade reference at
85
+ * // construction time, such as fixed type lists
86
+ * // that never need to send Notifications.
87
+ * regsiterProxy( new USStateNamesProxy() );
88
+ *
89
+ * // CAREFUL: Can't reference Facade instance in constructor
90
+ * // of new Proxys from here, since this step is part of
91
+ * // Facade construction! Usually, Proxys needing to send
92
+ * // notifications are registered elsewhere in the app
93
+ * // for this reason.
94
+ * }
95
+ *
96
+ * // optional initialization hook for View
97
+ * override public function initializeView() : void {
98
+ * // call super to use the PureMVC View Singleton.
99
+ * super.initializeView();
100
+ *
101
+ * // Otherwise, if you're implmenting your own
102
+ * // IView, then instead do:
103
+ * // if ( view != null ) return;
104
+ * // view = MyAppView.getInstance();
105
+ *
106
+ * // do any special subclass initialization here
107
+ * // such as creating and registering Mediators
108
+ * // that do not need a Facade reference at construction
109
+ * // time.
110
+ * registerMediator( new LoginMediator() );
111
+ *
112
+ * // CAREFUL: Can't reference Facade instance in constructor
113
+ * // of new Mediators from here, since this is a step
114
+ * // in Facade construction! Usually, all Mediators need
115
+ * // receive notifications, and are registered elsewhere in
116
+ * // the app for this reason.
117
+ * }
118
+ * }
119
+ * </listing>
120
+ *
121
+ * @see org.puremvc.as3.core.model.Model Model
122
+ * @see org.puremvc.as3.core.view.View View
123
+ * @see org.puremvc.as3.core.controller.Controller Controller
124
+ * @see org.puremvc.as3.patterns.observer.Notification Notification
125
+ * @see org.puremvc.as3.patterns.mediator.Mediator Mediator
126
+ * @see org.puremvc.as3.patterns.proxy.Proxy Proxy
127
+ * @see org.puremvc.as3.patterns.command.SimpleCommand SimpleCommand
128
+ * @see org.puremvc.as3.patterns.command.MacroCommand MacroCommand
129
+ */
130
+ public class Facade implements IFacade
131
+ {
132
+ /**
133
+ * Constructor.
134
+ *
135
+ * <P>
136
+ * This <code>IFacade</code> implementation is a Singleton,
137
+ * so you should not call the constructor
138
+ * directly, but instead call the static Singleton
139
+ * Factory method <code>Facade.getInstance()</code>
140
+ *
141
+ * @throws Error Error if Singleton instance has already been constructed
142
+ *
143
+ */
144
+ public function Facade( ) {
145
+ if (instance != null) throw Error(SINGLETON_MSG);
146
+ instance = this;
147
+ initializeFacade();
148
+ }
149
+
150
+ /**
151
+ * Initialize the Singleton <code>Facade</code> instance.
152
+ *
153
+ * <P>
154
+ * Called automatically by the constructor. Override in your
155
+ * subclass to do any subclass specific initializations. Be
156
+ * sure to call <code>super.initializeFacade()</code>, though.</P>
157
+ */
158
+ protected function initializeFacade( ):void {
159
+ initializeModel();
160
+ initializeController();
161
+ initializeView();
162
+ }
163
+
164
+ /**
165
+ * Facade Singleton Factory method
166
+ *
167
+ * @return the Singleton instance of the Facade
168
+ */
169
+ public static function getInstance():IFacade {
170
+ if (instance == null) instance = new Facade( );
171
+ return instance;
172
+ }
173
+
174
+ /**
175
+ * Initialize the <code>Controller</code>.
176
+ *
177
+ * <P>
178
+ * Called by the <code>initializeFacade</code> method.
179
+ * Override this method in your subclass of <code>Facade</code>
180
+ * if one or both of the following are true:
181
+ * <UL>
182
+ * <LI> You wish to initialize a different <code>IController</code>.</LI>
183
+ * <LI> You have <code>Commands</code> to register with the <code>Controller</code> at startup.</code>. </LI>
184
+ * </UL>
185
+ * If you don't want to initialize a different <code>IController</code>,
186
+ * call <code>super.initializeController()</code> at the beginning of your
187
+ * method, then register <code>Command</code>s.
188
+ * </P>
189
+ */
190
+ protected function initializeController( ):void {
191
+ if ( controller != null ) return;
192
+ controller = Controller.getInstance();
193
+ }
194
+
195
+ /**
196
+ * Initialize the <code>Model</code>.
197
+ *
198
+ * <P>
199
+ * Called by the <code>initializeFacade</code> method.
200
+ * Override this method in your subclass of <code>Facade</code>
201
+ * if one or both of the following are true:
202
+ * <UL>
203
+ * <LI> You wish to initialize a different <code>IModel</code>.</LI>
204
+ * <LI> You have <code>Proxy</code>s to register with the Model that do not
205
+ * retrieve a reference to the Facade at construction time.</code></LI>
206
+ * </UL>
207
+ * If you don't want to initialize a different <code>IModel</code>,
208
+ * call <code>super.initializeModel()</code> at the beginning of your
209
+ * method, then register <code>Proxy</code>s.
210
+ * <P>
211
+ * Note: This method is <i>rarely</i> overridden; in practice you are more
212
+ * likely to use a <code>Command</code> to create and register <code>Proxy</code>s
213
+ * with the <code>Model</code>, since <code>Proxy</code>s with mutable data will likely
214
+ * need to send <code>INotification</code>s and thus will likely want to fetch a reference to
215
+ * the <code>Facade</code> during their construction.
216
+ * </P>
217
+ */
218
+ protected function initializeModel( ):void {
219
+ if ( model != null ) return;
220
+ model = Model.getInstance();
221
+ }
222
+
223
+
224
+ /**
225
+ * Initialize the <code>View</code>.
226
+ *
227
+ * <P>
228
+ * Called by the <code>initializeFacade</code> method.
229
+ * Override this method in your subclass of <code>Facade</code>
230
+ * if one or both of the following are true:
231
+ * <UL>
232
+ * <LI> You wish to initialize a different <code>IView</code>.</LI>
233
+ * <LI> You have <code>Observers</code> to register with the <code>View</code></LI>
234
+ * </UL>
235
+ * If you don't want to initialize a different <code>IView</code>,
236
+ * call <code>super.initializeView()</code> at the beginning of your
237
+ * method, then register <code>IMediator</code> instances.
238
+ * <P>
239
+ * Note: This method is <i>rarely</i> overridden; in practice you are more
240
+ * likely to use a <code>Command</code> to create and register <code>Mediator</code>s
241
+ * with the <code>View</code>, since <code>IMediator</code> instances will need to send
242
+ * <code>INotification</code>s and thus will likely want to fetch a reference
243
+ * to the <code>Facade</code> during their construction.
244
+ * </P>
245
+ */
246
+ protected function initializeView( ):void {
247
+ if ( view != null ) return;
248
+ view = View.getInstance();
249
+ }
250
+
251
+ /**
252
+ * Register an <code>ICommand</code> with the <code>Controller</code> by Notification name.
253
+ *
254
+ * @param notificationName the name of the <code>INotification</code> to associate the <code>ICommand</code> with
255
+ * @param commandClassRef a reference to the Class of the <code>ICommand</code>
256
+ */
257
+ public function registerCommand( notificationName:String, commandClassRef:Class ):void
258
+ {
259
+ controller.registerCommand( notificationName, commandClassRef );
260
+ }
261
+
262
+ /**
263
+ * Remove a previously registered <code>ICommand</code> to <code>INotification</code> mapping from the Controller.
264
+ *
265
+ * @param notificationName the name of the <code>INotification</code> to remove the <code>ICommand</code> mapping for
266
+ */
267
+ public function removeCommand( notificationName:String ):void
268
+ {
269
+ controller.removeCommand( notificationName );
270
+ }
271
+
272
+ /**
273
+ * Check if a Command is registered for a given Notification
274
+ *
275
+ * @param notificationName
276
+ * @return whether a Command is currently registered for the given <code>notificationName</code>.
277
+ */
278
+ public function hasCommand( notificationName:String ) : Boolean
279
+ {
280
+ return controller.hasCommand(notificationName);
281
+ }
282
+
283
+ /**
284
+ * Register an <code>IProxy</code> with the <code>Model</code> by name.
285
+ *
286
+ * @param proxyName the name of the <code>IProxy</code>.
287
+ * @param proxy the <code>IProxy</code> instance to be registered with the <code>Model</code>.
288
+ */
289
+ public function registerProxy ( proxy:IProxy ):void
290
+ {
291
+ model.registerProxy ( proxy );
292
+ }
293
+
294
+ /**
295
+ * Retrieve an <code>IProxy</code> from the <code>Model</code> by name.
296
+ *
297
+ * @param proxyName the name of the proxy to be retrieved.
298
+ * @return the <code>IProxy</code> instance previously registered with the given <code>proxyName</code>.
299
+ */
300
+ public function retrieveProxy ( proxyName:String ):IProxy
301
+ {
302
+ return model.retrieveProxy ( proxyName );
303
+ }
304
+
305
+ /**
306
+ * Remove an <code>IProxy</code> from the <code>Model</code> by name.
307
+ *
308
+ * @param proxyName the <code>IProxy</code> to remove from the <code>Model</code>.
309
+ * @return the <code>IProxy</code> that was removed from the <code>Model</code>
310
+ */
311
+ public function removeProxy ( proxyName:String ):IProxy
312
+ {
313
+ var proxy:IProxy;
314
+ if ( model != null ) proxy = model.removeProxy ( proxyName );
315
+ return proxy
316
+ }
317
+
318
+ /**
319
+ * Check if a Proxy is registered
320
+ *
321
+ * @param proxyName
322
+ * @return whether a Proxy is currently registered with the given <code>proxyName</code>.
323
+ */
324
+ public function hasProxy( proxyName:String ) : Boolean
325
+ {
326
+ return model.hasProxy( proxyName );
327
+ }
328
+
329
+ /**
330
+ * Register a <code>IMediator</code> with the <code>View</code>.
331
+ *
332
+ * @param mediatorName the name to associate with this <code>IMediator</code>
333
+ * @param mediator a reference to the <code>IMediator</code>
334
+ */
335
+ public function registerMediator( mediator:IMediator ):void
336
+ {
337
+ if ( view != null ) view.registerMediator( mediator );
338
+ }
339
+
340
+ /**
341
+ * Retrieve an <code>IMediator</code> from the <code>View</code>.
342
+ *
343
+ * @param mediatorName
344
+ * @return the <code>IMediator</code> previously registered with the given <code>mediatorName</code>.
345
+ */
346
+ public function retrieveMediator( mediatorName:String ):IMediator
347
+ {
348
+ return view.retrieveMediator( mediatorName ) as IMediator;
349
+ }
350
+
351
+ /**
352
+ * Remove an <code>IMediator</code> from the <code>View</code>.
353
+ *
354
+ * @param mediatorName name of the <code>IMediator</code> to be removed.
355
+ * @return the <code>IMediator</code> that was removed from the <code>View</code>
356
+ */
357
+ public function removeMediator( mediatorName:String ) : IMediator
358
+ {
359
+ var mediator:IMediator;
360
+ if ( view != null ) mediator = view.removeMediator( mediatorName );
361
+ return mediator;
362
+ }
363
+
364
+ /**
365
+ * Check if a Mediator is registered or not
366
+ *
367
+ * @param mediatorName
368
+ * @return whether a Mediator is registered with the given <code>mediatorName</code>.
369
+ */
370
+ public function hasMediator( mediatorName:String ) : Boolean
371
+ {
372
+ return view.hasMediator( mediatorName );
373
+ }
374
+
375
+ /**
376
+ * Create and send an <code>INotification</code>.
377
+ *
378
+ * <P>
379
+ * Keeps us from having to construct new notification
380
+ * instances in our implementation code.
381
+ * @param notificationName the name of the notiification to send
382
+ * @param body the body of the notification (optional)
383
+ * @param type the type of the notification (optional)
384
+ */
385
+ public function sendNotification( notificationName:String, body:Object=null, type:String=null ):void
386
+ {
387
+ notifyObservers( new Notification( notificationName, body, type ) );
388
+ }
389
+
390
+ /**
391
+ * Notify <code>Observer</code>s.
392
+ * <P>
393
+ * This method is left public mostly for backward
394
+ * compatibility, and to allow you to send custom
395
+ * notification classes using the facade.</P>
396
+ *<P>
397
+ * Usually you should just call sendNotification
398
+ * and pass the parameters, never having to
399
+ * construct the notification yourself.</P>
400
+ *
401
+ * @param notification the <code>INotification</code> to have the <code>View</code> notify <code>Observers</code> of.
402
+ */
403
+ public function notifyObservers ( notification:INotification ):void {
404
+ if ( view != null ) view.notifyObservers( notification );
405
+ }
406
+
407
+ // Private references to Model, View and Controller
408
+ protected var controller : IController;
409
+ protected var model : IModel;
410
+ protected var view : IView;
411
+
412
+ // The Singleton Facade instance.
413
+ protected static var instance : IFacade;
414
+
415
+ // Message Constants
416
+ protected const SINGLETON_MSG : String = "Facade Singleton already constructed!";
417
+
418
+ }
419
+ }
@@ -0,0 +1,115 @@
1
+ /*
2
+ PureMVC - Copyright(c) 2006-08 Futurescale, Inc., Some rights reserved.
3
+ Your reuse is governed by the Creative Commons Attribution 3.0 United States License
4
+ */
5
+ package org.puremvc.as3.patterns.mediator
6
+ {
7
+ import org.puremvc.as3.interfaces.*;
8
+ import org.puremvc.as3.patterns.observer.*;
9
+ import org.puremvc.as3.patterns.facade.Facade;
10
+
11
+ /**
12
+ * A base <code>IMediator</code> implementation.
13
+ *
14
+ * @see org.puremvc.as3.core.view.View View
15
+ */
16
+ public class Mediator extends Notifier implements IMediator, INotifier
17
+ {
18
+
19
+ /**
20
+ * The name of the <code>Mediator</code>.
21
+ *
22
+ * <P>
23
+ * Typically, a <code>Mediator</code> will be written to serve
24
+ * one specific control or group controls and so,
25
+ * will not have a need to be dynamically named.</P>
26
+ */
27
+ public static const NAME:String = 'Mediator';
28
+
29
+ /**
30
+ * Constructor.
31
+ */
32
+ public function Mediator( mediatorName:String=null, viewComponent:Object=null ) {
33
+ this.mediatorName = (mediatorName != null)?mediatorName:NAME;
34
+ this.viewComponent = viewComponent;
35
+ }
36
+
37
+ /**
38
+ * Get the name of the <code>Mediator</code>.
39
+ * @return the Mediator name
40
+ */
41
+ public function getMediatorName():String
42
+ {
43
+ return mediatorName;
44
+ }
45
+
46
+ /**
47
+ * Set the <code>IMediator</code>'s view component.
48
+ *
49
+ * @param Object the view component
50
+ */
51
+ public function setViewComponent( viewComponent:Object ):void
52
+ {
53
+ this.viewComponent = viewComponent;
54
+ }
55
+
56
+ /**
57
+ * Get the <code>Mediator</code>'s view component.
58
+ *
59
+ * <P>
60
+ * Additionally, an implicit getter will usually
61
+ * be defined in the subclass that casts the view
62
+ * object to a type, like this:</P>
63
+ *
64
+ * <listing>
65
+ * private function get comboBox : mx.controls.ComboBox
66
+ * {
67
+ * return viewComponent as mx.controls.ComboBox;
68
+ * }
69
+ * </listing>
70
+ *
71
+ * @return the view component
72
+ */
73
+ public function getViewComponent():Object
74
+ {
75
+ return viewComponent;
76
+ }
77
+
78
+ /**
79
+ * List the <code>INotification</code> names this
80
+ * <code>Mediator</code> is interested in being notified of.
81
+ *
82
+ * @return Array the list of <code>INotification</code> names
83
+ */
84
+ public function listNotificationInterests():Array
85
+ {
86
+ return [ ];
87
+ }
88
+
89
+ /**
90
+ * Handle <code>INotification</code>s.
91
+ *
92
+ * <P>
93
+ * Typically this will be handled in a switch statement,
94
+ * with one 'case' entry per <code>INotification</code>
95
+ * the <code>Mediator</code> is interested in.
96
+ */
97
+ public function handleNotification( notification:INotification ):void {}
98
+
99
+ /**
100
+ * Called by the View when the Mediator is registered
101
+ */
102
+ public function onRegister( ):void {}
103
+
104
+ /**
105
+ * Called by the View when the Mediator is removed
106
+ */
107
+ public function onRemove( ):void {}
108
+
109
+ // the mediator name
110
+ protected var mediatorName:String;
111
+
112
+ // The view component
113
+ protected var viewComponent:Object;
114
+ }
115
+ }