Commit a40750b

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-09 04:04:50
started splitting the presentation modules from the presenter logic.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@64 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent d6a77d7
trunk/product/MyMoney/Presentation/Presenters/Commands/run_the.cs
@@ -4,11 +4,12 @@ using MoMoney.Utility.Core;
 namespace MoMoney.Presentation.Presenters.Commands
 {
     public interface IRunThe<Presenter> : ICommand where Presenter : IPresenter
-    {}
+    {
+    }
 
     public class run_the<Presenter> : IRunThe<Presenter> where Presenter : IPresenter
     {
-        private readonly IApplicationController applicationController;
+        readonly IApplicationController applicationController;
 
         public run_the(IApplicationController applicationController)
         {
trunk/product/MyMoney/Presentation/Presenters/Commands/run_presenter_command.cs → trunk/product/MyMoney/Presentation/Presenters/Commands/RunPresenterCommand.cs
@@ -7,11 +7,11 @@ namespace MoMoney.Presentation.Presenters.Commands
         void run<Presenter>() where Presenter : IPresenter;
     }
 
-    public class run_presenter_command : IRunPresenterCommand
+    public class RunPresenterCommand : IRunPresenterCommand
     {
         private readonly IApplicationController application_controller;
 
-        public run_presenter_command(IApplicationController applicationController)
+        public RunPresenterCommand(IApplicationController applicationController)
         {
             application_controller = applicationController;
         }
trunk/product/MyMoney/Presentation/Presenters/Navigation/MainMenuModule.cs
@@ -0,0 +1,33 @@
+using MoMoney.Infrastructure.eventing;
+using MoMoney.Presentation.Core;
+using MoMoney.Presentation.Model.messages;
+using MoMoney.Presentation.Presenters.Commands;
+
+namespace MoMoney.Presentation.Presenters.Navigation
+{
+    public interface IMainMenuModule : IPresentationModule, IEventSubscriber<new_project_opened>
+    {
+    }
+
+    public class MainMenuModule : IMainMenuModule
+    {
+        readonly IRunPresenterCommand command;
+        readonly IEventAggregator broker;
+
+        public MainMenuModule(IEventAggregator broker, IRunPresenterCommand command)
+        {
+            this.broker = broker;
+            this.command = command;
+        }
+
+        public void run()
+        {
+            broker.subscribe_to(this);
+        }
+
+        public void notify(new_project_opened message)
+        {
+            command.run<IMainMenuPresenter>();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Navigation/MainMenuPresenter.cs
@@ -1,13 +1,12 @@
-using MoMoney.Infrastructure.eventing;
 using MoMoney.Presentation.Core;
-using MoMoney.Presentation.Model.messages;
+using MoMoney.Presentation.Views.core;
 using MoMoney.Presentation.Views.Navigation;
 using MoMoney.Utility.Core;
 using MoMoney.Utility.Extensions;
 
 namespace MoMoney.Presentation.Presenters.Navigation
 {
-    public interface IMainMenuPresenter : IPresentationModule, IEventSubscriber<new_project_opened>
+    public interface IMainMenuPresenter : IContentPresenter
     {
     }
 
@@ -15,24 +14,21 @@ namespace MoMoney.Presentation.Presenters.Navigation
     {
         readonly IMainMenuView view;
         readonly IRegistry<IActionTaskPaneFactory> registry;
-        readonly IEventAggregator broker;
 
-        public MainMenuPresenter(IMainMenuView view, IRegistry<IActionTaskPaneFactory> registry, IEventAggregator broker)
+        public MainMenuPresenter(IMainMenuView view, IRegistry<IActionTaskPaneFactory> registry)
         {
             this.view = view;
-            this.broker = broker;
             this.registry = registry;
         }
 
         public void run()
         {
-            broker.subscribe_to(this);
             registry.all().each(x => view.add(x.create()));
         }
 
-        public void notify(new_project_opened message)
+        IDockedContentView IContentPresenter.View
         {
-            view.display();
+            get { return view; }
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Navigation/NavigationModule.cs
@@ -0,0 +1,33 @@
+using MoMoney.Infrastructure.eventing;
+using MoMoney.Presentation.Core;
+using MoMoney.Presentation.Model.messages;
+using MoMoney.Presentation.Presenters.Commands;
+
+namespace MoMoney.Presentation.Presenters.Navigation
+{
+    public interface INavigationModule : IPresentationModule, IEventSubscriber<new_project_opened>
+    {
+    }
+
+    public class NavigationModule : INavigationModule
+    {
+        readonly IEventAggregator broker;
+        readonly IRunPresenterCommand command;
+
+        public NavigationModule(IEventAggregator broker, IRunPresenterCommand command)
+        {
+            this.broker = broker;
+            this.command = command;
+        }
+
+        public void run()
+        {
+            broker.subscribe_to(this);
+        }
+
+        public void notify(new_project_opened message)
+        {
+            command.run<INavigationPresenter>();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Navigation/NavigationPresenter.cs
@@ -1,12 +1,11 @@
-using MoMoney.Infrastructure.eventing;
 using MoMoney.Presentation.Core;
-using MoMoney.Presentation.Model.messages;
 using MoMoney.Presentation.Model.Navigation;
+using MoMoney.Presentation.Views.core;
 using MoMoney.Presentation.Views.Navigation;
 
 namespace MoMoney.Presentation.Presenters.Navigation
 {
-    public interface INavigationPresenter : IPresentationModule, IEventSubscriber<new_project_opened>
+    public interface INavigationPresenter : IContentPresenter
     {
     }
 
@@ -14,24 +13,21 @@ namespace MoMoney.Presentation.Presenters.Navigation
     {
         readonly INavigationView view;
         readonly INavigationTreeVisitor tree_view_visitor;
-        readonly IEventAggregator broker;
 
-        public NavigationPresenter(INavigationView view, INavigationTreeVisitor tree_view_visitor,
-                                   IEventAggregator broker)
+        public NavigationPresenter(INavigationView view, INavigationTreeVisitor tree_view_visitor)
         {
             this.view = view;
-            this.broker = broker;
             this.tree_view_visitor = tree_view_visitor;
         }
 
         public void run()
         {
-            broker.subscribe_to(this);
+            view.accept(tree_view_visitor);
         }
 
-        public void notify(new_project_opened message)
+        IDockedContentView IContentPresenter.View
         {
-            view.accept(tree_view_visitor);
+            get { return view; }
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Navigation/NavigationPresenterSpecs.cs
@@ -1,5 +1,4 @@
 using jpboodhoo.bdd.contexts;
-using MoMoney.Presentation.Model.messages;
 using MoMoney.Presentation.Model.Navigation;
 using MoMoney.Presentation.Views.Navigation;
 using MoMoney.Testing.MetaData;
@@ -19,7 +18,7 @@ namespace MoMoney.Presentation.Presenters.Navigation
                             tree_view_visitor = the_dependency<INavigationTreeVisitor>();
                         };
 
-        because b = () => sut.notify(new new_project_opened(""));
+        because b = () => sut.run();
 
         static INavigationView view;
         static INavigationTreeVisitor tree_view_visitor;
trunk/product/MyMoney/Presentation/Presenters/Shell/GettingStartedModule.cs
@@ -0,0 +1,34 @@
+using MoMoney.Infrastructure.eventing;
+using MoMoney.Presentation.Core;
+using MoMoney.Presentation.Model.messages;
+using MoMoney.Presentation.Presenters.Commands;
+
+namespace MoMoney.Presentation.Presenters.Shell
+{
+    public interface IGettingStartedModule : IPresentationModule, IEventSubscriber<new_project_opened>
+    {
+    }
+
+    public class GettingStartedModule : IGettingStartedModule
+    {
+        readonly IEventAggregator broker;
+        IRunPresenterCommand command;
+
+        public GettingStartedModule(IEventAggregator broker, IRunPresenterCommand command)
+        {
+            this.broker = broker;
+            this.command = command;
+        }
+
+        public void run()
+        {
+            broker.subscribe_to(this);
+            command.run<IGettingStartedPresenter>();
+        }
+
+        public void notify(new_project_opened message)
+        {
+            command.run<IGettingStartedPresenter>();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Shell/GettingStartedModuleSpecs.cs
@@ -0,0 +1,32 @@
+using jpboodhoo.bdd.contexts;
+using MoMoney.Infrastructure.eventing;
+using MoMoney.Presentation.Presenters.Commands;
+using MoMoney.Testing.spechelpers.contexts;
+using MoMoney.Testing.spechelpers.core;
+
+namespace MoMoney.Presentation.Presenters.Shell
+{
+    public class GettingStartedModuleSpecs
+    {
+        public class behaves_like_the_getting_started_module :
+            concerns_for<IGettingStartedModule, GettingStartedModule>
+        {
+            context c = () =>
+                            {
+                                broker = the_dependency<IEventAggregator>();
+                                command = the_dependency<IRunPresenterCommand>();
+                            };
+
+            protected static IEventAggregator broker;
+            protected static IRunPresenterCommand command;
+        }
+
+        public class when_initializing_the_getting_started_module : behaves_like_the_getting_started_module
+        {
+            it should_start_listening_for_when_a_new_project_is_started =
+                () => broker.was_told_to(x => x.subscribe_to(sut));
+
+            because b = () => sut.run();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Shell/GettingStartedPresenter.cs
@@ -1,36 +1,30 @@
-using JetBrains.Annotations;
-using MoMoney.Infrastructure.eventing;
 using MoMoney.Presentation.Core;
-using MoMoney.Presentation.Model.messages;
+using MoMoney.Presentation.Views.core;
 using MoMoney.Presentation.Views.Shell;
 
 namespace MoMoney.Presentation.Presenters.Shell
 {
-    public interface IGettingStartedPresenter : IPresentationModule, IEventSubscriber<new_project_opened>
+    public interface IGettingStartedPresenter : IContentPresenter
     {
     }
 
-    [UsedImplicitly]
     public class GettingStartedPresenter : IGettingStartedPresenter
     {
         readonly IGettingStartedView view;
-        readonly IEventAggregator broker;
 
-        public GettingStartedPresenter(IGettingStartedView view, IEventAggregator broker)
+        public GettingStartedPresenter(IGettingStartedView view)
         {
             this.view = view;
-            this.broker = broker;
         }
 
         public void run()
         {
-            broker.subscribe_to(this);
             view.display();
         }
 
-        public void notify(new_project_opened message)
+        public IDockedContentView View
         {
-            //view.display();
+            get { return view; }
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Presenters/Shell/GettingStartedPresenterSpecs.cs
@@ -1,6 +1,5 @@
 using jpboodhoo.bdd.contexts;
 using MoMoney.Infrastructure.eventing;
-using MoMoney.Presentation.Model.messages;
 using MoMoney.Presentation.Views.Shell;
 using MoMoney.Testing.spechelpers.contexts;
 using MoMoney.Testing.spechelpers.core;
@@ -12,11 +11,6 @@ namespace MoMoney.Presentation.Presenters.Shell
         public class behaves_like_the_getting_started_presenter :
             concerns_for<IGettingStartedPresenter, GettingStartedPresenter>
         {
-            //public override IGettingStartedPresenter create_sut()
-            //{
-            //    return new GettingStartedPresenter(view, broker);
-            //}
-
             context c = () =>
                             {
                                 view = the_dependency<IGettingStartedView>();
@@ -27,19 +21,11 @@ namespace MoMoney.Presentation.Presenters.Shell
             protected static IGettingStartedView view;
         }
 
-        public class when_initializing_the_getting_started_module : behaves_like_the_getting_started_presenter
-        {
-            it should_start_listening_for_when_a_new_project_is_started =
-                () => broker.was_told_to(x => x.subscribe_to(sut));
-
-            because b = () => sut.run();
-        }
-
         public class when_a_new_project_is_opened : behaves_like_the_getting_started_presenter
         {
             it should_display_the_getting_started_screen = () => view.was_told_to(x => x.display());
 
-            because b = () => sut.notify(new new_project_opened(""));
+            because b = () => sut.run();
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Presentation/Views/core/ApplicationDockedWindow.cs
@@ -23,6 +23,7 @@ namespace MoMoney.Presentation.Views.core
             InitializeComponent();
             Icon = ApplicationIcons.Application;
             dock_state = DockState.Document;
+            HideOnClose = true;
         }
 
         public IApplicationDockedWindow create_tool_tip_for(string title, string caption, Control control)
trunk/product/MyMoney/Presentation/Views/Shell/WelcomeScreen.cs
@@ -6,11 +6,8 @@ namespace MoMoney.Presentation.Views.Shell
 {
     public partial class WelcomeScreen : ApplicationDockedWindow, IGettingStartedView
     {
-        readonly IShell shell;
-
-        public WelcomeScreen(IShell shell)
+        public WelcomeScreen()
         {
-            this.shell = shell;
             InitializeComponent();
             titled("Getting Started");
             //base.BackgroundImage = ApplicationImages.Welcome;
@@ -28,19 +25,6 @@ namespace MoMoney.Presentation.Views.Shell
                 .when_hovered_over_will_show(ApplicationImages.CreateNewFileSelected)
                 .will_execute<INewCommand>(() => true)
                 .with_tool_tip("Create New File", "Create a new project.");
-
-            //ux_company_details_button
-            //    .will_be_shown_as(ApplicationImages.CompanyDetails)
-            //    .when_hovered_over_will_show(ApplicationImages.CompanyDetailsSelected)
-            //    .will_execute<ICompanyTreeNode>(is_there_a_protocol_selected)
-            //    .with_tool_tip("Company Details", "Capture the company details.");
-
-            //ux_generate_report_button
-            //    .will_be_shown_as(ApplicationImages.GenerateReport)
-            //    .when_hovered_over_will_show(ApplicationImages.GenerateReportSelected)
-            //    .will_execute<IGenerateReportCommand>(is_there_a_protocol_selected)
-            //    .with_tool_tip("Generate Report", "Generate a printable report.");
-            shell.add(this);
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -329,7 +329,7 @@
     <Compile Include="Presentation\Presenters\billing\dto\register_new_company.cs" />
     <Compile Include="Presentation\Presenters\billing\ViewAllBillsPresenter.cs" />
     <Compile Include="Presentation\Presenters\Commands\RestartCommand.cs" />
-    <Compile Include="Presentation\Presenters\Commands\run_presenter_command.cs" />
+    <Compile Include="Presentation\Presenters\Commands\RunPresenterCommand.cs" />
     <Compile Include="Presentation\Presenters\Commands\run_the.cs" />
     <Compile Include="Presentation\Presenters\Commands\run_the_specs.cs" />
     <Compile Include="Presentation\Presenters\excel\Cell.cs" />
@@ -360,7 +360,11 @@
     <Compile Include="Presentation\Presenters\Navigation\ExpandoBuilder.cs" />
     <Compile Include="Presentation\Presenters\Navigation\ExpandoItemBuilder.cs" />
     <Compile Include="Presentation\Presenters\Navigation\IActionTaskPaneFactory.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\MainMenuModule.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\NavigationModule.cs" />
     <Compile Include="Presentation\Presenters\Shell\ApplicationShellPresenter.cs" />
+    <Compile Include="Presentation\Presenters\Shell\GettingStartedModule.cs" />
+    <Compile Include="Presentation\Presenters\Shell\GettingStartedModuleSpecs.cs" />
     <Compile Include="Presentation\Presenters\Shell\GettingStartedPresenter.cs" />
     <Compile Include="Presentation\Presenters\Shell\GettingStartedPresenterSpecs.cs" />
     <Compile Include="Presentation\Presenters\Shell\ToolBarPresenter.cs" />