PageRenderTime 26ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Trident/Product/ManagementStudio/ManagementStudioControls/WorkflowManagerModule/WorkflowManagerModule.cs

#
C# | 227 lines | 129 code | 36 blank | 62 comment | 0 complexity | d2d3af46893e8b9fb468b798653e9b39 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. //*********************************************************
  2. //
  3. // Copyright (c) Microsoft. All rights reserved.
  4. // This code is licensed under the Apache License, Version 2.0.
  5. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  6. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  7. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  8. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  9. //
  10. //*********************************************************
  11. using Microsoft.Research.ScientificWorkflow.ManagementStudioControls.Interfaces;
  12. using Microsoft.Research.ScientificWorkflow.TridentUtilities;
  13. using Microsoft.Research.ScientificWorkflow.UIDesigner.WpfComposite;
  14. using Microsoft.Practices.Unity;
  15. namespace Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule
  16. {
  17. /// <summary>
  18. /// The workflow manager module. This represents the left pane controls for the workflow manager and the center pane representing the
  19. /// table view.
  20. /// </summary>
  21. public class WorkflowMgrModule : IModule
  22. {
  23. /// <summary>
  24. /// The unity container instance.
  25. /// </summary>
  26. private IUnityContainer container;
  27. /// <summary>
  28. /// The region manager. The main window.
  29. /// </summary>
  30. private IRegionManager mainContentControl;
  31. /// <summary>
  32. /// The center pane of the workflow manager.
  33. /// </summary>
  34. private WorkflowManagerContentView contentView;
  35. /// <summary>
  36. /// The left pane presentation model.
  37. /// </summary>
  38. private WorkflowManagerLeftPanePresenter workflowLeftPanePresenter;
  39. /// <summary>
  40. /// Constructor of the workflow manager module.
  41. /// </summary>
  42. /// <param name="container">The unity container instance.</param>
  43. /// <param name="window">The region manager.</param>
  44. public WorkflowMgrModule(IUnityContainer container, IRegionManager window)
  45. {
  46. this.container = container;
  47. this.mainContentControl = window;
  48. }
  49. #region IModule Members
  50. /// <summary>
  51. /// Initialize the workflow manager module.
  52. /// </summary>
  53. public void Initialize()
  54. {
  55. // Create the center pane and insert it in the region manager.
  56. this.contentView = this.container.Resolve<WorkflowManagerContentView>();
  57. this.container.RegisterInstance<WorkflowManagerContentView>(this.contentView, new ExternallyControlledLifetimeManager());
  58. this.mainContentControl.Add(this.contentView, "workflowManagerTablehost");
  59. // Create the left pane control for the module.
  60. this.workflowLeftPanePresenter = this.container.Resolve<WorkflowManagerLeftPanePresenter>();
  61. // Resolve the left pane controller.
  62. ILeftPaneNavigator leftPanePresenter = this.container.Resolve<ILeftPaneNavigator>();
  63. // Add the workflow manager control to the left pane.
  64. leftPanePresenter.Add(ManagementStudioControlsConstants.WORKFLOWMANAGERSTRING, this.workflowLeftPanePresenter);
  65. // Add the filters for the workflow manager.
  66. this.InitializeFilters();
  67. }
  68. /// <summary>
  69. /// Initialize the workflow manager left pane filters.
  70. /// </summary>
  71. private void InitializeFilters()
  72. {
  73. WorkflowManagerFilterModel availableWorkflowModel = WorkflowMgrModule.InitializeAvailableWorkflowFilter();
  74. AvailableWorkflowsListPresenter availableWorkflowListPresenter = this.container.Resolve<AvailableWorkflowsListPresenter>();
  75. this.workflowLeftPanePresenter.Add(availableWorkflowModel, availableWorkflowListPresenter);
  76. WorkflowManagerFilterModel runningWorkflowModel = WorkflowMgrModule.InitializeRunningWorkflowFilter();
  77. RunningWorkflowsListPresenter runningWorkflowListPresenter = this.container.Resolve<RunningWorkflowsListPresenter>();
  78. this.workflowLeftPanePresenter.Add(runningWorkflowModel, runningWorkflowListPresenter);
  79. WorkflowManagerFilterModel completedJobModel = WorkflowMgrModule.InitializeCompletedJobFilter();
  80. CompletedJobsListViewPresenter completedJobsListPresenter = this.container.Resolve<CompletedJobsListViewPresenter>();
  81. this.workflowLeftPanePresenter.Add(completedJobModel, completedJobsListPresenter);
  82. WorkflowManagerFilterModel scheduledWorkflowModel = WorkflowMgrModule.InitializeScheduledJobsFilter();
  83. ScheduledJobsListPresenter scheduledWorkflowListPresenter = this.container.Resolve<ScheduledJobsListPresenter>();
  84. this.workflowLeftPanePresenter.Add(scheduledWorkflowModel, scheduledWorkflowListPresenter);
  85. WorkflowManagerFilterModel deletedWorkflowModel = WorkflowMgrModule.InitializeDeletedWorkflowFilter();
  86. DeletedWorkflowsListPresenter deletedWorkflowListPresenter = this.container.Resolve<DeletedWorkflowsListPresenter>();
  87. this.workflowLeftPanePresenter.Add(deletedWorkflowModel, deletedWorkflowListPresenter);
  88. }
  89. /// <summary>
  90. /// Initialize the available workflows filter.
  91. /// </summary>
  92. /// <returns>The workflow manager filter model.</returns>
  93. private static WorkflowManagerFilterModel InitializeAvailableWorkflowFilter()
  94. {
  95. WorkflowManagerFilterModel availableWorkflowsFilter = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterAvailableWorkflows"),
  96. ManagementStudioControlsConstants.AVAILABLEWORKFLOWFILTERNAME,
  97. ManagementStudioControlsConstants.AVAILABLEWORKFLOWFILTERNAME,
  98. true);
  99. WorkflowManagerFilterModel myWorkflows = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterMyWorkflows"),
  100. ManagementStudioControlsConstants.AVAILABLEWORKFLOWFILTERNAME,
  101. ManagementStudioControlsConstants.WORKFLOWSCREATEDBYMEFILTERNAME,
  102. false);
  103. availableWorkflowsFilter.Children.Add(myWorkflows);
  104. WorkflowManagerFilterModel recentWorkflows = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterRecentWorkflows"),
  105. ManagementStudioControlsConstants.AVAILABLEWORKFLOWFILTERNAME,
  106. ManagementStudioControlsConstants.RECENTLYCREATEDWORKFLOWS,
  107. false);
  108. availableWorkflowsFilter.Children.Add(recentWorkflows);
  109. return availableWorkflowsFilter;
  110. }
  111. /// <summary>
  112. /// Initialize the Running workflow filter.
  113. /// </summary>
  114. /// <returns>The workflow manager filter model.</returns>
  115. private static WorkflowManagerFilterModel InitializeRunningWorkflowFilter()
  116. {
  117. WorkflowManagerFilterModel runningWorkflowsFilter = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterRunningJobs"),
  118. ManagementStudioControlsConstants.RUNNINGWORKFLOWSFILTERNAME,
  119. ManagementStudioControlsConstants.RUNNINGWORKFLOWSFILTERNAME,
  120. false);
  121. return runningWorkflowsFilter;
  122. }
  123. /// <summary>
  124. /// Initialize the deleted workflow filter.
  125. /// </summary>
  126. /// <returns>The deleted workflow filter.</returns>
  127. private static WorkflowManagerFilterModel InitializeDeletedWorkflowFilter()
  128. {
  129. WorkflowManagerFilterModel deletedWorkflowsFilter = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterDeletedWorkflows"),
  130. ManagementStudioControlsConstants.DELETEDWORKFLOWSFILTERNAME,
  131. ManagementStudioControlsConstants.DELETEDWORKFLOWSFILTERNAME,
  132. false);
  133. WorkflowManagerFilterModel workflowsDeletedByMe = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterWorkflowsDeletedByMe"),
  134. ManagementStudioControlsConstants.DELETEDWORKFLOWSFILTERNAME,
  135. ManagementStudioControlsConstants.WORKFLOWSDELETEDBYMEFILTERNAME,
  136. false);
  137. deletedWorkflowsFilter.Children.Add(workflowsDeletedByMe);
  138. WorkflowManagerFilterModel recentDeletedWorkflows = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterRecentlyDeletedWorkflows"),
  139. ManagementStudioControlsConstants.DELETEDWORKFLOWSFILTERNAME,
  140. ManagementStudioControlsConstants.RECENTLYDELETEDWORKFLOWS,
  141. false);
  142. deletedWorkflowsFilter.Children.Add(recentDeletedWorkflows);
  143. return deletedWorkflowsFilter;
  144. }
  145. /// <summary>
  146. /// Initialize the completed job filter.
  147. /// </summary>
  148. /// <returns>The completed job filter.</returns>
  149. private static WorkflowManagerFilterModel InitializeCompletedJobFilter()
  150. {
  151. WorkflowManagerFilterModel completedWorkflowsFilter = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterCompletedJobs"),
  152. ManagementStudioControlsConstants.COMPLETEDJOBSFILTERNAME,
  153. ManagementStudioControlsConstants.COMPLETEDJOBSFILTERNAME,
  154. false);
  155. WorkflowManagerFilterModel completedByMe = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterJobsCompletedByMe"),
  156. ManagementStudioControlsConstants.COMPLETEDJOBSFILTERNAME,
  157. ManagementStudioControlsConstants.JOBSCOMPLETEDBYMEFILTERNAME,
  158. false);
  159. completedWorkflowsFilter.Children.Add(completedByMe);
  160. WorkflowManagerFilterModel recenltyCompletedWorkflows = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterRecentlyCompletedJobs"),
  161. ManagementStudioControlsConstants.COMPLETEDJOBSFILTERNAME,
  162. ManagementStudioControlsConstants.RECENTLYCOMPLETEDJOBS,
  163. false);
  164. completedWorkflowsFilter.Children.Add(recenltyCompletedWorkflows);
  165. return completedWorkflowsFilter;
  166. }
  167. /// <summary>
  168. /// Initialize the scheduled jobs filter.
  169. /// </summary>
  170. /// <returns>The scheduled jobs filter.</returns>
  171. private static WorkflowManagerFilterModel InitializeScheduledJobsFilter()
  172. {
  173. WorkflowManagerFilterModel scheduledJobsFilter = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterScheduledJobs"),
  174. ManagementStudioControlsConstants.SCHEDULEDWORKFLOWSFILTERNAME,
  175. ManagementStudioControlsConstants.SCHEDULEDWORKFLOWSFILTERNAME,
  176. false);
  177. WorkflowManagerFilterModel scheduledByMe = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterScheduledByMe"),
  178. ManagementStudioControlsConstants.SCHEDULEDWORKFLOWSFILTERNAME,
  179. ManagementStudioControlsConstants.JOBSSCHEDULEDBYMEFILTERNAME,
  180. false);
  181. scheduledJobsFilter.Children.Add(scheduledByMe);
  182. WorkflowManagerFilterModel recentlyScheduledJobsFilter = new WorkflowManagerFilterModel(ManagementStudioResourceManager.GetString("FilterRecentlyScheduledJobs"),
  183. ManagementStudioControlsConstants.SCHEDULEDWORKFLOWSFILTERNAME,
  184. ManagementStudioControlsConstants.RECENTLYSCHEDULEDJOBS,
  185. false);
  186. scheduledJobsFilter.Children.Add(recentlyScheduledJobsFilter);
  187. return scheduledJobsFilter;
  188. }
  189. #endregion
  190. }
  191. }