emergent-core 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bnsignore +16 -0
- data/History.txt +4 -0
- data/Manifest.txt +348 -0
- data/README.rdoc +47 -0
- data/Rakefile +39 -0
- data/app_generators/emergent_core/USAGE +5 -0
- data/app_generators/emergent_core/emergent_core_generator.rb +73 -0
- data/app_generators/emergent_core/templates/core/actionscript.properties +16 -0
- data/app_generators/emergent_core/templates/core/actionscriptair.properties +16 -0
- data/app_generators/emergent_core/templates/core/app.yaml.erb +12 -0
- data/app_generators/emergent_core/templates/core/default_tasks.rake +51 -0
- data/app_generators/emergent_core/templates/core/empty.txt +0 -0
- data/app_generators/emergent_core/templates/core/expressInstall.swf +0 -0
- data/app_generators/emergent_core/templates/core/flex.properties +2 -0
- data/app_generators/emergent_core/templates/core/generate.rb +17 -0
- data/app_generators/emergent_core/templates/core/html-template/AC_OETags.js +276 -0
- data/app_generators/emergent_core/templates/core/html-template/history/history.css +6 -0
- data/app_generators/emergent_core/templates/core/html-template/history/history.js +645 -0
- data/app_generators/emergent_core/templates/core/html-template/history/historyFrame.html +29 -0
- data/app_generators/emergent_core/templates/core/html-template/index.template.html +121 -0
- data/app_generators/emergent_core/templates/core/html-template/playerProductInstall.swf +0 -0
- data/app_generators/emergent_core/templates/core/index.html.erb +18 -0
- data/app_generators/emergent_core/templates/core/index.yaml +11 -0
- data/app_generators/emergent_core/templates/core/mainair-app.xml +134 -0
- data/app_generators/emergent_core/templates/core/mainapp-config.xml +21 -0
- data/app_generators/emergent_core/templates/core/mainapp.mxml +106 -0
- data/app_generators/emergent_core/templates/core/project-textmate.erb +52 -0
- data/app_generators/emergent_core/templates/core/project.properties +18 -0
- data/app_generators/emergent_core/templates/core/projectair.properties +24 -0
- data/app_generators/emergent_core/templates/core/swfobject.js +5 -0
- data/bin/emergent +17 -0
- data/lib/emergent_core.rb +49 -0
- data/lib/restfulx/active_foo.rb +194 -0
- data/lib/restfulx/active_record_tasks.rb +81 -0
- data/lib/restfulx/configuration.rb +76 -0
- data/lib/restfulx/datamapper_foo.rb +31 -0
- data/lib/restfulx/rails/recipes.rb +60 -0
- data/lib/restfulx/rails/swf_helper.rb +60 -0
- data/lib/restfulx/tasks.rb +85 -0
- data/lib/restfulx.rb +117 -0
- data/rails_generators/emergent_cms/USAGE +5 -0
- data/rails_generators/emergent_cms/emergent_cms_generator.rb +21 -0
- data/rails_generators/emergent_cms/templates/PagesEditModel.as +114 -0
- data/rails_generators/emergent_cms/templates/PagesEditView.mxml +102 -0
- data/rails_generators/emergent_config/USAGE +5 -0
- data/rails_generators/emergent_config/emergent_config_generator.rb +330 -0
- data/rails_generators/emergent_config/templates/app/controllers/accounts_controller.rb +104 -0
- data/rails_generators/emergent_config/templates/app/controllers/addresses_controller.rb +97 -0
- data/rails_generators/emergent_config/templates/app/controllers/application.rb +26 -0
- data/rails_generators/emergent_config/templates/app/controllers/assets_controller.rb +1 -0
- data/rails_generators/emergent_config/templates/app/controllers/content_assignments_controller.rb +97 -0
- data/rails_generators/emergent_config/templates/app/controllers/contents_controller.rb +114 -0
- data/rails_generators/emergent_config/templates/app/controllers/sessions_controller.rb +72 -0
- data/rails_generators/emergent_config/templates/app/controllers/sites_controller.rb +1 -0
- data/rails_generators/emergent_config/templates/app/controllers/users_controller.rb +97 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/command/ICommand.as +16 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/command/Undoable.as +46 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/command/UpdateDocumentCommand.as +73 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/DocumentEvent.as +46 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/NavigationEvent.as +31 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/ResourceEvent.as +27 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/UndoEvent.as +36 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/AboutUsManager.as +15 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/AccountManager.as +31 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/AuthenticationManager.as +76 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/ContentManager.as +92 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/DocumentManager.as +131 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/DocumentsManager.as +156 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/HomeManager.as +18 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/MainManager.as +23 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/PagesManager.as +71 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/ResourceManager.as +195 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/SiteManager.as +25 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/UndoManager.as +143 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/DocumentMap.mxml +123 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/DocumentsMap.mxml +134 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/ManagerPresentationModelMap.mxml +59 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/ObjectMap.mxml +75 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/PresentationModelViewMap.mxml +81 -0
- data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/PresenterViewMap.mxml +67 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/constant/DocumentType.as +52 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/constant/Resource.as +25 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/constant/ResourceAction.as +28 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/constant/ResourceResult.as +8 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Account.as +32 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Address.as +26 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Asset.as +25 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/AssetAssignment.as +25 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Content.as +46 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/ContentAssignment.as +33 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Document.as +131 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/PlainDocument.as +19 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/RichDocument.as +19 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Session.as +13 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Snapshot.as +21 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/domain/User.as +28 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/factory/DocumentFactory.as +61 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/factory/DocumentViewFactory.as +59 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/factory/ResourceFactory.as +28 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/AboutUsModel.as +22 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/AccountModel.as +68 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/AuthenticationModel.as +44 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ContactUsModel.as +45 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ContentModel.as +70 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/DocumentModel.as +235 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/DocumentsModel.as +169 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/HomeModel.as +23 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/MainModel.as +35 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/PagesModel.as +44 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ProfileModel.as +99 -0
- data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ResourceModel.as +100 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/about_us/about_us.mxml +105 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/account/account.mxml +97 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/contact_us/contact_us.mxml +65 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/document/document.mxml +71 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/document/documents.mxml +201 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/document/plain_document.mxml +9 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/document/rich_document.mxml +12 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/gallery/gallery.mxml +37 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/home/home.mxml +58 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/home/home_presenter.as +81 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/home/home_troparchy.mxml +71 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/login/login.mxml +50 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/main/main.mxml +131 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/main/main_presenter.as +166 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/main/main_troparchy.mxml +74 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_bottom_model.as +13 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_bottom_presenter.as +10 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_bottom_view.mxml +48 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_left_model.as +13 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_left_presenter.as +10 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_left_view.mxml +43 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_right_model.as +13 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_right_presenter.as +10 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_right_view.mxml +47 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_top_model.as +13 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_top_presenter.as +10 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_top_view.mxml +49 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bars_presenter.as +63 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bars_troparchy.mxml +63 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bars_view.mxml +59 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/pages/pages.mxml +44 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/pages/pages_presenter.as +83 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/pages/pages_troparchy.mxml +62 -0
- data/rails_generators/emergent_config/templates/app/flex/application/views/profile/profile.mxml +73 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/fonts/MyriadPro-Bold.otf +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/fonts/MyriadPro-Regular.otf +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/html/lorem.html +3 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture10.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture11.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture12.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture13.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture14.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture3.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture4.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture5.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture6.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture7.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture8.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture9.png +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_0.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_180.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_270.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_90.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_bottom.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_top.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/styles/itunes7Bg.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/styles/jukebox.css +764 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/styles/jukeboxGfx.swf +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/styles/obsidian.css +734 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/styles/obsidianBg.jpg +0 -0
- data/rails_generators/emergent_config/templates/app/flex/assets/styles/obsidianGfx.swf +0 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/actions/LayoutAction.as +377 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/actions/SimpleLayoutAction.as +210 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/animators/FourDTweenCollection.mxml +50 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/animators/IAnimator.as +39 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/animators/TweenMaxAnimator.as +269 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/cameras/AstroCamera.as +177 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/components/FourDDataGrid.mxml +105 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/components/FourDItemRenderer.mxml +54 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/CenterPerspectiveProjection.as +72 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/ComplexCondition.as +44 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/ConditionsUtil.as +82 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/FourDComponent.as +309 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/InstanceMethodInvoker.as +50 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/InstancePropertyInjector.as +43 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/MethodCaller.as +51 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Pathway.as +10 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/PathwayEvent.as +28 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Pheron.as +34 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Pheron2.as +41 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/PheronReceptor.as +125 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Properties.as +57 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Router.as +50 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/RouterUtil.as +70 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/SimpleCondition.as +42 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/SimpleZSortVO.as +1 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/SimpleZSorter.as +1 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Tecton.as +70 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Tecton2.as +234 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonCache.as +111 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonEvent.as +39 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonMap.as +515 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonMap2.as +289 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonMapSample.mxml +73 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonReceptor.as +43 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonScope.as +38 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonScopeProperties.as +18 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonUtils.as +51 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/events/LayoutActionEvent.as +75 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/CarouselLayout.as +85 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/CircleLayout.as +102 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/CoverFlowLayout.as +136 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/FourDLayout.as +272 -0
- data/rails_generators/emergent_config/templates/app/flex/com/fourD/utils/TweenUtil.as +110 -0
- data/rails_generators/emergent_config/templates/app/helpers/accounts_helper.rb +93 -0
- data/rails_generators/emergent_config/templates/app/helpers/application_helper.rb +3 -0
- data/rails_generators/emergent_config/templates/app/models/account.rb +84 -0
- data/rails_generators/emergent_config/templates/app/models/account_mailer.rb +24 -0
- data/rails_generators/emergent_config/templates/app/models/account_observer.rb +17 -0
- data/rails_generators/emergent_config/templates/app/models/address.rb +2 -0
- data/rails_generators/emergent_config/templates/app/models/asset.rb +6 -0
- data/rails_generators/emergent_config/templates/app/models/asset_assignment.rb +4 -0
- data/rails_generators/emergent_config/templates/app/models/category.rb +35 -0
- data/rails_generators/emergent_config/templates/app/models/comment.rb +98 -0
- data/rails_generators/emergent_config/templates/app/models/content.rb +89 -0
- data/rails_generators/emergent_config/templates/app/models/content_assignment.rb +21 -0
- data/rails_generators/emergent_config/templates/app/models/image.rb +3 -0
- data/rails_generators/emergent_config/templates/app/models/post.rb +76 -0
- data/rails_generators/emergent_config/templates/app/models/section.rb +97 -0
- data/rails_generators/emergent_config/templates/app/models/site.rb +1 -0
- data/rails_generators/emergent_config/templates/app/models/tag.rb +1 -0
- data/rails_generators/emergent_config/templates/app/models/user.rb +4 -0
- data/rails_generators/emergent_config/templates/app/views/account_mailer/activation.erb +3 -0
- data/rails_generators/emergent_config/templates/app/views/account_mailer/signup_notification.erb +8 -0
- data/rails_generators/emergent_config/templates/config/Capfile +4 -0
- data/rails_generators/emergent_config/templates/config/README.txt +18 -0
- data/rails_generators/emergent_config/templates/config/deploy.rb +36 -0
- data/rails_generators/emergent_config/templates/config/routes.rb +72 -0
- data/rails_generators/emergent_config/templates/core/actionscript.properties +16 -0
- data/rails_generators/emergent_config/templates/core/actionscriptair.properties +16 -0
- data/rails_generators/emergent_config/templates/core/app.yaml.erb +12 -0
- data/rails_generators/emergent_config/templates/core/default_tasks.rake +51 -0
- data/rails_generators/emergent_config/templates/core/emergent_tasks.rake +42 -0
- data/rails_generators/emergent_config/templates/core/empty.txt +0 -0
- data/rails_generators/emergent_config/templates/core/expressInstall.swf +0 -0
- data/rails_generators/emergent_config/templates/core/flex.properties +2 -0
- data/rails_generators/emergent_config/templates/core/generate.rb +17 -0
- data/rails_generators/emergent_config/templates/core/html-template/AC_OETags.js +276 -0
- data/rails_generators/emergent_config/templates/core/html-template/history/history.css +6 -0
- data/rails_generators/emergent_config/templates/core/html-template/history/history.js +645 -0
- data/rails_generators/emergent_config/templates/core/html-template/history/historyFrame.html +29 -0
- data/rails_generators/emergent_config/templates/core/html-template/index.template.html +121 -0
- data/rails_generators/emergent_config/templates/core/html-template/playerProductInstall.swf +0 -0
- data/rails_generators/emergent_config/templates/core/index.html.erb +18 -0
- data/rails_generators/emergent_config/templates/core/index.yaml +11 -0
- data/rails_generators/emergent_config/templates/core/mainair-app.xml +134 -0
- data/rails_generators/emergent_config/templates/core/mainapp-config.xml +21 -0
- data/rails_generators/emergent_config/templates/core/mainapp.mxml +101 -0
- data/rails_generators/emergent_config/templates/core/project-textmate.erb +52 -0
- data/rails_generators/emergent_config/templates/core/project.properties +18 -0
- data/rails_generators/emergent_config/templates/core/projectair.properties +24 -0
- data/rails_generators/emergent_config/templates/core/restfulx.yml +14 -0
- data/rails_generators/emergent_config/templates/core/restfulx_tasks.rake +6 -0
- data/rails_generators/emergent_config/templates/core/swfobject.js +5 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_accounts.rb +40 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_addresses.rb +18 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_asset_assignments.rb +19 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_assets.rb +20 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_content_assignments.rb +26 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_contents.rb +21 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_sessions.rb +16 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_sites.rb +27 -0
- data/rails_generators/emergent_config/templates/db/migrate/create_users.rb +15 -0
- data/rails_generators/emergent_config/templates/lib/analytics.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/app_controller.rb.erb +26 -0
- data/rails_generators/emergent_config/templates/lib/as3corelib-0.92.1.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/as3crypto-1.3patched.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/as3crypto.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/as3ds-1.04.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/as3httpclientlib-1.0.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/authenticated_system.rb +189 -0
- data/rails_generators/emergent_config/templates/lib/authenticated_test_helper.rb +11 -0
- data/rails_generators/emergent_config/templates/lib/containerEx.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/flare.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/flash_session_hack.rb +27 -0
- data/rails_generators/emergent_config/templates/lib/flex2BrowserManager.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/flexlib.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/fluint.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/mate_0_8_6_enhanced.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/openflux.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/pv3d.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/restfulx.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/site_keys.rb +38 -0
- data/rails_generators/emergent_config/templates/lib/tweenMax.swc +0 -0
- data/rails_generators/emergent_config/templates/lib/urlkitFlex3.swc +0 -0
- data/rails_generators/emergent_config/templates/shell_script +31 -0
- data/rails_generators/emergent_controller/USAGE +5 -0
- data/rails_generators/emergent_controller/emergent_controller_generator.rb +25 -0
- data/rails_generators/emergent_controller/templates/controller.as.erb +37 -0
- data/rails_generators/emergent_core/USAGE +5 -0
- data/rails_generators/emergent_core/emergent_core_generator.rb +157 -0
- data/rails_generators/emergent_iphone/USAGE +5 -0
- data/rails_generators/emergent_iphone/emergent_iphone_generator.rb +27 -0
- data/rails_generators/emergent_scaffold/USAGE +5 -0
- data/rails_generators/emergent_scaffold/emergent_scaffold_generator.rb +157 -0
- data/rails_generators/emergent_scaffold/templates/component.mxml.erb +101 -0
- data/rails_generators/emergent_scaffold/templates/controller.rb.erb +101 -0
- data/rails_generators/emergent_scaffold/templates/edit_index_view.mxml.erb +114 -0
- data/rails_generators/emergent_scaffold/templates/edit_show_view.mxml.erb +84 -0
- data/rails_generators/emergent_scaffold/templates/filter_view.mxml.erb +1 -0
- data/rails_generators/emergent_scaffold/templates/fixtures.yml.erb +128 -0
- data/rails_generators/emergent_scaffold/templates/index_view.mxml.erb +58 -0
- data/rails_generators/emergent_scaffold/templates/item_renderer.mxml.erb +53 -0
- data/rails_generators/emergent_scaffold/templates/manager.as.erb +31 -0
- data/rails_generators/emergent_scaffold/templates/migration.rb.erb +22 -0
- data/rails_generators/emergent_scaffold/templates/model.as.erb +42 -0
- data/rails_generators/emergent_scaffold/templates/model.rb.erb +11 -0
- data/rails_generators/emergent_scaffold/templates/presentation_model.as.erb +33 -0
- data/rails_generators/emergent_scaffold/templates/presenter.as.erb +98 -0
- data/rails_generators/emergent_scaffold/templates/show_view.mxml.erb +50 -0
- data/rails_generators/emergent_scaffold/templates/view_map.mxml.erb +40 -0
- data/rails_generators/emergent_scaffold/templates/views_panel.mxml.erb +64 -0
- data/rails_generators/emergent_styler/USAGE +5 -0
- data/rails_generators/emergent_styler/emergent_styler_generator.rb +21 -0
- data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +49 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/emergent_core_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/manifest.rake +48 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +279 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/test/test_emergent_core.rb +0 -0
- data/test/test_emergent_iphone_generator.rb +46 -0
- data/test/test_generator_helper.rb +29 -0
- metadata +437 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
/* Copyright 2008 Theo Hultberg/Iconara */
|
2
|
+
|
3
|
+
package <%= base_package %>.models.factory
|
4
|
+
{
|
5
|
+
import flash.utils.Dictionary;
|
6
|
+
|
7
|
+
import mx.core.Container;
|
8
|
+
|
9
|
+
import <%= base_package %>.models.domain.Document;
|
10
|
+
import <%= base_package %>.models.constant.DocumentType;
|
11
|
+
|
12
|
+
import <%= base_package %>.views.document.*;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* A factory for document views that can create the appropriate view instance for a particular
|
16
|
+
* document type.
|
17
|
+
*/
|
18
|
+
public class DocumentViewFactory {
|
19
|
+
|
20
|
+
private static var _factoryMap:Dictionary;
|
21
|
+
|
22
|
+
|
23
|
+
private function get factoryMap( ):Dictionary {
|
24
|
+
if ( _factoryMap == null ) {
|
25
|
+
_factoryMap = new Dictionary();
|
26
|
+
_factoryMap[DocumentType.PLAIN] = PlainDocumentView;
|
27
|
+
_factoryMap[DocumentType.RICH] = RichDocumentView;
|
28
|
+
}
|
29
|
+
|
30
|
+
return _factoryMap;
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Creates a view that can display the specified document.
|
36
|
+
*
|
37
|
+
* Throws an exception if the document is null or if the document type is not supported.
|
38
|
+
*/
|
39
|
+
public function createDocumentView(document:Document):Container {
|
40
|
+
if ( document == null ) {
|
41
|
+
throw new ArgumentError("Cannot create document view, document was null");
|
42
|
+
}
|
43
|
+
|
44
|
+
if ( factoryMap[document.documentType] == null ) {
|
45
|
+
throw new ArgumentError("Cannot create new document view, unknown type: \"" + document.documentType + "\"");
|
46
|
+
}
|
47
|
+
|
48
|
+
var viewClass:Class = factoryMap[document.documentType];
|
49
|
+
|
50
|
+
var view:Container = new viewClass();
|
51
|
+
|
52
|
+
view.data = document;
|
53
|
+
|
54
|
+
return view;
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
package <%= base_package %>.models.factory {
|
2
|
+
|
3
|
+
import flash.utils.*;
|
4
|
+
|
5
|
+
import org.restfulx.models.RxModel;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* A factory for creating Resource instances. The specific implementation created
|
9
|
+
* depends on the ResourceType that is passed to the createResource method.
|
10
|
+
* This class was created to abstract away the ResourceManager, so you don't have to
|
11
|
+
* have a ResourceManager for each friggin Resource, which would be too repetitive.
|
12
|
+
*/
|
13
|
+
public class ResourceFactory {
|
14
|
+
|
15
|
+
public function createResource(r:RxModel):RxModel {
|
16
|
+
var className:String = getQualifiedClassName(r).replace( "::", "." );
|
17
|
+
var resource:RxModel;
|
18
|
+
|
19
|
+
var ModelClass:Object = getDefinitionByName(className) as Class;
|
20
|
+
|
21
|
+
if(ModelClass != null) {
|
22
|
+
resource = RxModel(new ModelClass());
|
23
|
+
}
|
24
|
+
|
25
|
+
return resource;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
package <%= base_package %>.models.presentation {
|
2
|
+
|
3
|
+
import flash.events.Event;
|
4
|
+
import flash.events.IOErrorEvent;
|
5
|
+
|
6
|
+
import <%= base_package %>.models.constant.Resource;
|
7
|
+
import <%= base_package %>.models.domain.Content;
|
8
|
+
import <%= base_package %>.models.domain.ContentAssignment;
|
9
|
+
import <%= base_package %>.models.domain.AssetAssignment;
|
10
|
+
|
11
|
+
import org.restfulx.utils.RxFileReference;
|
12
|
+
|
13
|
+
// Pages and components should extend this
|
14
|
+
public class AboutUsModel extends ContentModel {
|
15
|
+
|
16
|
+
public function AboutUsModel() {
|
17
|
+
target = new Content();
|
18
|
+
contentAssignment = new ContentAssignment();
|
19
|
+
assetAssignment = new AssetAssignment();
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
package <%= base_package %>.models.presentation {
|
2
|
+
|
3
|
+
import flash.events.Event;
|
4
|
+
import flash.events.KeyboardEvent;
|
5
|
+
import flash.events.IOErrorEvent;
|
6
|
+
|
7
|
+
import org.restfulx.utils.RxFileReference;
|
8
|
+
|
9
|
+
import <%= base_package %>.models.presentation.ResourceModel;
|
10
|
+
import <%= base_package %>.models.constant.Resource;
|
11
|
+
import <%= base_package %>.models.domain.Account;
|
12
|
+
import <%= base_package %>.controllers.event.ResourceEvent;
|
13
|
+
|
14
|
+
public class AccountModel extends ResourceModel {
|
15
|
+
|
16
|
+
[Bindable] public var photoFileName:String = "None selected";
|
17
|
+
[Bindable] public var signUpFormDirty:Boolean = true;
|
18
|
+
[Bindable] public var photoErrorString:String;
|
19
|
+
|
20
|
+
[Bindable] public var accountEvent:ResourceEvent;
|
21
|
+
|
22
|
+
private var photo:RxFileReference;
|
23
|
+
|
24
|
+
private var _account:Account; [Bindable]
|
25
|
+
public function get account():Account { return _account; }
|
26
|
+
public function set account(value:Account):void {
|
27
|
+
_account = value;
|
28
|
+
}
|
29
|
+
|
30
|
+
public function AccountModel() {
|
31
|
+
account = new Account();
|
32
|
+
}
|
33
|
+
|
34
|
+
public function signUp():void {
|
35
|
+
create(account, accountEvent);
|
36
|
+
}
|
37
|
+
|
38
|
+
public function signUpOnEnter(event:KeyboardEvent):void {
|
39
|
+
if (event.keyCode == 13) {
|
40
|
+
signUp();
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
public function chooseFile():void {
|
45
|
+
photo = new RxFileReference("avatar");
|
46
|
+
photo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
|
47
|
+
photo.addEventListener(Event.SELECT, selectFile, false, 0, true);
|
48
|
+
photo.addEventListener(Event.CANCEL, cancelBrowse, false, 0, true);
|
49
|
+
photo.browse();
|
50
|
+
}
|
51
|
+
|
52
|
+
private function fileSelected(event:Event):void {
|
53
|
+
photoFileName = RxFileReference(event.target).name;
|
54
|
+
}
|
55
|
+
|
56
|
+
private function ioErrorHandler(event:Event):void {
|
57
|
+
photoErrorString = "Failed to selected a file. Please try again.";
|
58
|
+
}
|
59
|
+
|
60
|
+
private function selectFile(event:Event):void {
|
61
|
+
fileSelected(event)
|
62
|
+
}
|
63
|
+
|
64
|
+
private function cancelBrowse(event:Event):void {
|
65
|
+
photo = null;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
package <%= base_package %>.models.presentation {
|
2
|
+
|
3
|
+
import flash.events.KeyboardEvent;
|
4
|
+
|
5
|
+
import <%= base_package %>.models.presentation.ResourceModel;
|
6
|
+
import <%= base_package %>.models.domain.Session;
|
7
|
+
import <%= base_package %>.models.constant.Resource;
|
8
|
+
import <%= base_package %>.models.constant.ResourceAction;
|
9
|
+
import <%= base_package %>.controllers.event.ResourceEvent;
|
10
|
+
|
11
|
+
public class AuthenticationModel extends ResourceModel {
|
12
|
+
|
13
|
+
/** Injector targets */
|
14
|
+
[Bindable] public var sessionEvent:ResourceEvent;
|
15
|
+
|
16
|
+
[Bindable] public var loginErrorString:String;
|
17
|
+
|
18
|
+
private var _session:Session; [Bindable]
|
19
|
+
public function get session():Session { return _session; }
|
20
|
+
public function set session(value:Session):void {
|
21
|
+
_session = value;
|
22
|
+
}
|
23
|
+
|
24
|
+
private var _loginDirty:Boolean; [Bindable]
|
25
|
+
public function get loginDirty():Boolean { return _loginDirty; }
|
26
|
+
public function set loginDirty(value:Boolean):void {
|
27
|
+
_loginDirty = value;
|
28
|
+
}
|
29
|
+
|
30
|
+
public function AuthenticationModel() {
|
31
|
+
session = new Session();
|
32
|
+
}
|
33
|
+
|
34
|
+
public function login():void {
|
35
|
+
create(session, sessionEvent);
|
36
|
+
}
|
37
|
+
|
38
|
+
public function loginOnEnter(event:KeyboardEvent):void {
|
39
|
+
if (event.keyCode == 13) {
|
40
|
+
login();
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
package <%= base_package %>.models.presentation {
|
2
|
+
|
3
|
+
import flash.events.Event;
|
4
|
+
import flash.events.EventDispatcher;
|
5
|
+
import flash.events.IEventDispatcher;
|
6
|
+
|
7
|
+
import mx.binding.utils.BindingUtils;
|
8
|
+
import mx.collections.ICollectionView;
|
9
|
+
import mx.events.CollectionEvent;
|
10
|
+
|
11
|
+
import org.restfulx.models.RxModel;
|
12
|
+
import org.restfulx.collections.ModelsCollection;
|
13
|
+
import org.restfulx.utils.RxUtils;
|
14
|
+
|
15
|
+
import <%= base_package %>.models.presentation.ResourceModel;
|
16
|
+
|
17
|
+
public class ContactUsModel extends ResourceModel {
|
18
|
+
|
19
|
+
public var emailSent:Boolean;
|
20
|
+
|
21
|
+
[Bindable]
|
22
|
+
public function get submitButtonEnabled():Boolean {
|
23
|
+
return emailSent;
|
24
|
+
}
|
25
|
+
|
26
|
+
public function ContactUsModel() {
|
27
|
+
}
|
28
|
+
|
29
|
+
public function sendEmail():void
|
30
|
+
{
|
31
|
+
/* var senderName:String = senderName.text;
|
32
|
+
var senderEmail:String = senderEmail.text;
|
33
|
+
var sendToName:String = sendToName.text;
|
34
|
+
var sendToEmail:String = sendToEmail.text;
|
35
|
+
var emailMessage:String = emailMessage.text;
|
36
|
+
|
37
|
+
this.emailService.send({senderName: senderName, senderEmail:senderEmail, sendToName: sendToName, sendToEmail: sendToEmail, emailMessage: emailMessage});
|
38
|
+
|
39
|
+
if (cb.selected == true)
|
40
|
+
{
|
41
|
+
this.emailService.send({senderName: senderName, senderEmail:senderEmail, sendToName: sendToName, sendToEmail: senderEmail, emailMessage: emailMessage});
|
42
|
+
} */
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
package <%= base_package %>.models.presentation {
|
2
|
+
|
3
|
+
import flash.events.Event;
|
4
|
+
import flash.events.IOErrorEvent;
|
5
|
+
|
6
|
+
import <%= base_package %>.controllers.event.ResourceEvent;
|
7
|
+
import <%= base_package %>.models.presentation.ResourceModel;
|
8
|
+
import <%= base_package %>.models.constant.Resource;
|
9
|
+
import <%= base_package %>.models.domain.Content;
|
10
|
+
import <%= base_package %>.models.domain.ContentAssignment;
|
11
|
+
import <%= base_package %>.models.domain.AssetAssignment;
|
12
|
+
|
13
|
+
import org.restfulx.utils.RxFileReference;
|
14
|
+
|
15
|
+
// Pages and components should extend this
|
16
|
+
public class ContentModel extends ResourceModel {
|
17
|
+
|
18
|
+
/** Injector targets */
|
19
|
+
[Bindable] public var contentEvent:ResourceEvent;
|
20
|
+
[Bindable] public var contentAssignmentEvent:ResourceEvent;
|
21
|
+
|
22
|
+
protected var contentAssignment:ContentAssignment;
|
23
|
+
protected var assetAssignment:AssetAssignment;
|
24
|
+
|
25
|
+
[Bindable] public var assignContentDesired:Boolean;
|
26
|
+
[Bindable] public var assetsDesired:Boolean;
|
27
|
+
|
28
|
+
private var _target:Content; [Bindable]
|
29
|
+
public function get target():Content { return _target; }
|
30
|
+
public function set target(value:Content):void {
|
31
|
+
_target = value;
|
32
|
+
}
|
33
|
+
|
34
|
+
private var _parent:Content; [Bindable]
|
35
|
+
public function get parent():Content { return _parent; }
|
36
|
+
public function set parent(value:Content):void {
|
37
|
+
_parent = value;
|
38
|
+
}
|
39
|
+
|
40
|
+
public function ContentModel() {
|
41
|
+
target = new Content();
|
42
|
+
contentAssignment = new ContentAssignment();
|
43
|
+
assetAssignment = new AssetAssignment();
|
44
|
+
}
|
45
|
+
|
46
|
+
public function assignContent():void {
|
47
|
+
contentAssignment.target = target;
|
48
|
+
contentAssignment.ancestor = parent;//target.getParentAssignment(parentContentNode);
|
49
|
+
create(contentAssignment, contentAssignmentEvent);
|
50
|
+
}
|
51
|
+
|
52
|
+
public function assignAssets():void {
|
53
|
+
// assetAssigment.assignableAsset = photo;
|
54
|
+
// assetAssignment.content = target;
|
55
|
+
// resourceName = Resource.ASSET_ASSIGNMENT;
|
56
|
+
// create(assetAssignment);
|
57
|
+
}
|
58
|
+
|
59
|
+
public function saveContent():void {
|
60
|
+
if (assetsDesired) {
|
61
|
+
assignAssets();
|
62
|
+
}
|
63
|
+
if (assignContentDesired) {
|
64
|
+
assignContent();
|
65
|
+
} else {
|
66
|
+
create(target, contentEvent);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,235 @@
|
|
1
|
+
/* Copyright 2008 Theo Hultberg/Iconara */
|
2
|
+
|
3
|
+
package <%= base_package %>.models.presentation {
|
4
|
+
|
5
|
+
import flash.events.Event;
|
6
|
+
import flash.events.EventDispatcher;
|
7
|
+
import flash.events.IEventDispatcher;
|
8
|
+
|
9
|
+
import mx.binding.utils.BindingUtils;
|
10
|
+
|
11
|
+
import <%= base_package %>.controllers.command.Undoable;
|
12
|
+
|
13
|
+
import <%= base_package %>.controllers.event.DocumentEvent;
|
14
|
+
import <%= base_package %>.controllers.event.UndoEvent;
|
15
|
+
|
16
|
+
import <%= base_package %>.models.domain.Document;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* The presentation model of DocumentView.
|
20
|
+
*
|
21
|
+
* The dispatcher, document, documentDirty, undoHistory, undoPossible and redoPossible
|
22
|
+
* properties are injected by the local controller.
|
23
|
+
*
|
24
|
+
* The methods save, undo, redo, restore and update (which is private but called by
|
25
|
+
* the setters for title and text) insulates the view from the details of communicating
|
26
|
+
* with the application. In the current implementation they dispatch events on the
|
27
|
+
* dispatcher provided by the local controller, but this could very well change and the
|
28
|
+
* important thing here is that the view doesn't need to know if it does.
|
29
|
+
*
|
30
|
+
* The presentation model acts as a mediator between the view and the application. It
|
31
|
+
* presents a view-centric interface of the application model for the view, and takes
|
32
|
+
* care of all state logic like which buttons should be enabled, etc. This makes the
|
33
|
+
* view very simple, and it makes the state logic testable.
|
34
|
+
*
|
35
|
+
* This particular presentation model is also unware of how the rest of the application
|
36
|
+
* works, it communicates with the local and application controllers with implicit
|
37
|
+
* invokation, i.e. it dispatches events.
|
38
|
+
*
|
39
|
+
* Many of the properties of this class only have a getter, but are still bindable.
|
40
|
+
* The way this works is that the getters are defined to use custom binding events, and
|
41
|
+
* these events are dispatched at the appropriate time. Consider for example the getter
|
42
|
+
* for the enabled state of the undo button, undoButtonEnabled. It's binding tag says
|
43
|
+
* [Bindable(event="undoStateChanged")], which means that whenever that event is
|
44
|
+
* dispatched the binding system should trigger that binding and update everyone that
|
45
|
+
* are bound to it. The event is dispatched in the setter for undoPossible, which is
|
46
|
+
* where the _undoPossible variable that the getter for undoButtonEnabled uses changes
|
47
|
+
* (the event is dispatched in the setter for redoPossible too, just because I wanted
|
48
|
+
* to keep things simple and not have too many events). It may seem like a complicated
|
49
|
+
* way of doing something that could easily be done with plain bindable variables; the
|
50
|
+
* setter for undoPossible could just set the value for a undoButtonEnabled variable,
|
51
|
+
* and be done with it. That, however, has two downsides: firstly the undoButtonEnabled
|
52
|
+
* variable would become changeable from the outside of this class, which is something
|
53
|
+
* that you generally want to avoid. Secondly the algorithm for determining the enabled
|
54
|
+
* state could be more complex than being just a reflection of another value, it could
|
55
|
+
* depend on the value of several variables that all changed independently. Take a look
|
56
|
+
* at the getter for displayTitle, for example. It depends on two things: the document
|
57
|
+
* title and whether or not the document is unsaved ("dirty"). The getter declares this
|
58
|
+
* by having two bindable statements with different events. Whenever either of these
|
59
|
+
* events is dispatched the binding system knows that it should update everyone that
|
60
|
+
* are bound to the property. The code that dispatches these events doesn't need to know
|
61
|
+
* how to create the right value for the displayTitle, actually it doesn't even need
|
62
|
+
* to know about the displayTitle property at all! This is the power of loose coupling.
|
63
|
+
*/
|
64
|
+
public class DocumentModel extends EventDispatcher {
|
65
|
+
|
66
|
+
public var dispatcher:IEventDispatcher;
|
67
|
+
|
68
|
+
private var _document:Document;
|
69
|
+
|
70
|
+
private var _undoHistory:Array;
|
71
|
+
|
72
|
+
private var _undoPossible :Boolean;
|
73
|
+
private var _redoPossible :Boolean;
|
74
|
+
private var _documentDirty:Boolean;
|
75
|
+
|
76
|
+
/** This property is injected by the application. */
|
77
|
+
public function set undoPossible(value:Boolean):void {
|
78
|
+
_undoPossible = value;
|
79
|
+
|
80
|
+
dispatchEvent(new Event("undoStateChanged"));
|
81
|
+
}
|
82
|
+
|
83
|
+
/** This property is injected by the application. */
|
84
|
+
public function set redoPossible(value:Boolean):void {
|
85
|
+
_redoPossible = value;
|
86
|
+
|
87
|
+
dispatchEvent(new Event("undoStateChanged"));
|
88
|
+
}
|
89
|
+
|
90
|
+
/** This property is injected by the application. */
|
91
|
+
public function set documentDirty(value:Boolean):void {
|
92
|
+
_documentDirty = value;
|
93
|
+
|
94
|
+
dispatchEvent(new Event("documentDirtyChanged"));
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Returns the undo history sorted from the most recent command to the oldest.
|
99
|
+
*/
|
100
|
+
[Bindable]
|
101
|
+
public function get undoHistory():Array {
|
102
|
+
// this may look weird, but does a few necessary things that
|
103
|
+
// aren't easy to express in ActionScript:
|
104
|
+
// - it avoids the possibility that the undoHistory is null
|
105
|
+
// - it creates a copy of the array to avoid the possibility that
|
106
|
+
// the caller changes the list outside of this object's control
|
107
|
+
return (_undoHistory || []).slice().reverse();
|
108
|
+
}
|
109
|
+
|
110
|
+
/** The undo history is injected by the application. */
|
111
|
+
public function set undoHistory(value:Array):void {
|
112
|
+
_undoHistory = value;
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* This property is injected by the application. The getter is only here because
|
117
|
+
* BindingUtils.bindSetter throws an error for read-only properties (see the constructor).
|
118
|
+
*/
|
119
|
+
[Bindable]
|
120
|
+
public function get document():Document {
|
121
|
+
return _document;
|
122
|
+
}
|
123
|
+
|
124
|
+
public function set document(value:Document):void {
|
125
|
+
_document = value;
|
126
|
+
|
127
|
+
// as a side effect of this property being set the titleChanged
|
128
|
+
// and textChanged methods will be called, because of the bindings
|
129
|
+
// set up in the constructor
|
130
|
+
}
|
131
|
+
|
132
|
+
[Bindable(event="documentDirtyChanged")]
|
133
|
+
public function get displayTitle( ):String {
|
134
|
+
return document.content.title + (_documentDirty ? " *":"");
|
135
|
+
}
|
136
|
+
|
137
|
+
/*
|
138
|
+
* The following three getters encapsulate the logic that determines
|
139
|
+
* if the undo, redo and save buttons should be enabled. The view
|
140
|
+
* only needs to bind to these three, which keeps it simple.
|
141
|
+
*/
|
142
|
+
|
143
|
+
[Bindable(event="undoStateChanged")]
|
144
|
+
public function get undoButtonEnabled( ):Boolean {
|
145
|
+
return _undoPossible;
|
146
|
+
}
|
147
|
+
|
148
|
+
[Bindable(event="undoStateChanged")]
|
149
|
+
public function get redoButtonEnabled( ):Boolean {
|
150
|
+
return _redoPossible;
|
151
|
+
}
|
152
|
+
|
153
|
+
[Bindable(event="documentDirtyChanged")]
|
154
|
+
public function get saveButtonEnabled( ):Boolean {
|
155
|
+
return _documentDirty;
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
public function DocumentModel() {
|
161
|
+
// whenever the document property or the title and text properties of the
|
162
|
+
// document changes, call the titleChanged and/or textChanged methods
|
163
|
+
BindingUtils.bindSetter(update, this, ["document", "content", "title"]);
|
164
|
+
BindingUtils.bindSetter(update, this, ["document", "content", "body"]);
|
165
|
+
}
|
166
|
+
|
167
|
+
/**
|
168
|
+
* Returns a prettified label for an undoable command, the label contains the
|
169
|
+
* index of the command in the history (1 is most recent), the description and
|
170
|
+
* the timestamp in HH:MM:SS format.
|
171
|
+
*/
|
172
|
+
public function labelForUndoable( undoable:Undoable ):String {
|
173
|
+
var hours :String = (undoable.timestamp.hours < 10 ? "0":"") + undoable.timestamp.hours;
|
174
|
+
var minutes:String = (undoable.timestamp.minutes < 10 ? "0":"") + undoable.timestamp.minutes;
|
175
|
+
var seconds:String = (undoable.timestamp.seconds < 10 ? "0":"") + undoable.timestamp.seconds;
|
176
|
+
var index :int = undoHistory.indexOf(undoable) + 1;
|
177
|
+
|
178
|
+
return index + ". " + undoable.description + " (" + hours + ":" + minutes + ":" + seconds + ")";
|
179
|
+
}
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Notifies the application that the document needs updating.
|
183
|
+
*/
|
184
|
+
private function update(property:*=null):void {
|
185
|
+
dispatchEvent(new Event("documentDirtyChanged"));
|
186
|
+
|
187
|
+
var event:DocumentEvent = new DocumentEvent(DocumentEvent.UPDATE);
|
188
|
+
|
189
|
+
event.reference = document;
|
190
|
+
|
191
|
+
// somethings wrong with the dispatcher injection, shouldn't have to do this
|
192
|
+
if (dispatcher == null) { return; }
|
193
|
+
|
194
|
+
dispatcher.dispatchEvent(event);
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Notifies the application that the document needs saving (after first calling update).
|
199
|
+
*/
|
200
|
+
public function save():void {
|
201
|
+
update();
|
202
|
+
|
203
|
+
var event:DocumentEvent = new DocumentEvent(DocumentEvent.SAVE);
|
204
|
+
|
205
|
+
event.reference = document;
|
206
|
+
|
207
|
+
dispatcher.dispatchEvent(event);
|
208
|
+
}
|
209
|
+
|
210
|
+
/**
|
211
|
+
* Notifies the application that the user has requested an undo. When the
|
212
|
+
* application handles the undo request the document may change, and this
|
213
|
+
* will be handled as any other change in the document's state.
|
214
|
+
*/
|
215
|
+
public function undo( ):void {
|
216
|
+
dispatcher.dispatchEvent(new UndoEvent(UndoEvent.UNDO));
|
217
|
+
}
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Notifies the application that the user has requested a redo.
|
221
|
+
*/
|
222
|
+
public function redo( ):void {
|
223
|
+
dispatcher.dispatchEvent(new UndoEvent(UndoEvent.REDO));
|
224
|
+
}
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Notifies the application that the user has requested a restore.
|
228
|
+
*/
|
229
|
+
public function restore( undoable:Undoable ):void {
|
230
|
+
dispatcher.dispatchEvent(new UndoEvent(UndoEvent.RESTORE, undoable));
|
231
|
+
}
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
}
|