/// <summary> /// Initializes a new instance of the <see cref="TeamProjectPickerPresenter"/> class. /// </summary> /// <param name="pickerView">The team project picker the presenter controls</param> /// <param name="projectDocument">The team project document the presenter uses for the data.</param> /// <param name="factory">The factory used to create other objects.</param> /// <param name="waitNotifier">The wait notifier to be used to tell the user if there is a wait.</param> public TeamProjectPickerPresenter(ITeamProjectPickerView pickerView, ITeamProjectDocument projectDocument, IFactory factory, IWaitNotifier waitNotifier) { if (pickerView == null) { throw new ArgumentNullException("pickerView"); } if (projectDocument == null) { throw new ArgumentNullException("projectDocument"); } if (factory == null) { throw new ArgumentNullException("factory"); } if (waitNotifier == null) { throw new ArgumentNullException("waitNotifier"); } this.pickerView = pickerView; this.projectDocument = projectDocument; this.factory = factory; this.waitNotifier = waitNotifier; }
/// <summary> /// Handles the <see cref="Application.DocumentBeforeClose"/> event. /// </summary> /// <param name="sender">The event arguments.</param> /// <param name="e">The sender of the event.</param> private void HandleDocumentBeforeClose(object sender, CancellableDocumentOperationEventArgs e) { this.logger.Log(TraceEventType.Information, "Closing: {0}", e.Document.Name); DocumentHandle handle = this.MakeDocumentHandle(e.Document); if (this.openDocuments.ContainsKey(handle)) { IUnityContainer childContainer = this.openDocuments[handle].Container; ITeamProjectDocument closingDocument = childContainer.Resolve <ITeamProjectDocument>(); CancelEventArgs cancelArgs = new CancelEventArgs(); if (this.ActiveDocument == closingDocument && this.DocumentBeforeClose != null) { this.DocumentBeforeClose(this, cancelArgs); } if (!cancelArgs.Cancel) { this.openDocuments.Remove(handle); childContainer.Dispose(); } e.Cancel = cancelArgs.Cancel; } }
private void HandleTeamRibbonRefresh(object sender, System.EventArgs e) { this.Logger.Log(TraceEventType.Information, "Flow controller HandleTeamRibbonRefresh called"); Debug.Assert(this.Manager.ActiveDocument != null, "There should be an active document in the team project document manager"); ITeamProjectDocument doc = this.Manager.ActiveDocument; if (!this.Manager.ActiveDocument.IsInsertable) { this.TeamRibbonPresenter.DisplayError(FlowControllerResources.DocumentNotRefreshable, string.Empty); } else { CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); TaskScheduler scheduler = this.UnityContainer.Resolve <TaskScheduler>(); Task runRefreshTask = new Task( () => { this.Logger.Log(TraceEventType.Information, "Starting refresh"); try { IEnumerable <string> errors = doc.RefreshWorkItems(cancellationTokenSource.Token); if (errors.Count() > 0) { this.TeamRibbonPresenter.DisplayError(FlowControllerResources.CannotRefreshInvalidDocument, string.Join(Environment.NewLine, errors.ToArray())); } } finally { this.Logger.Log(TraceEventType.Information, "End of asynch operation"); } }, cancellationTokenSource.Token); this.AddFinalErrorHandlingTask(scheduler, runRefreshTask); runRefreshTask.Start(scheduler); this.TeamRibbonPresenter.StartCancellableOperation(FlowControllerResources.StartRefreshExecution, cancellationTokenSource); } }
public void Show() { try { if (this.designerDocument == null) { ITeamProject existingConnection = null; if (this.manager.ActiveDocument != null && this.manager.ActiveDocument.IsConnected) { existingConnection = this.manager.ActiveDocument.TeamProject; } this.designerDocument = this.manager.Add(true); this.designerDocument.Close += new EventHandler(this.HandleDesignerDocumentClose); if (existingConnection != null) { this.designerDocument.TeamProject = existingConnection; this.designerDocument.SaveTeamProject(); this.ConnectDesignerDocument(true); } } this.SetEditorControls(); this.SetViewLayoutList(); LayoutInformation layout = this.GetViewOrderedLayoutList().FirstOrDefault(); if (layout != null) { this.ChangeDisplayedLayout(layout); } this.view.ShowLayoutDesigner(); } catch (Exception ex) { this.DisplayError(this.view, ex); } }
/// <summary> /// Initializes a new instance of the <see cref="WorkItemQueryAndLayoutPickerWizardPresenter"/> class. /// </summary> /// <param name="projectDocument">The team project document used to store the query and layout.</param> /// <param name="wizardView">The wizard view.</param> /// <param name="queryPagePresenter">The presenter to use for the query picker page.</param> /// <param name="layoutPagePresenter">The presenter to use for the layout picker page.</param> public WorkItemQueryAndLayoutPickerWizardPresenter(ITeamProjectDocument projectDocument, IWorkItemQueryAndLayoutPickerWizardView wizardView, IWorkItemQueryPickerWizardPagePresenter queryPagePresenter, ILayoutPickerWizardPagePresenter layoutPagePresenter) : base(wizardView) { this.projectDocument = projectDocument; this.queryPagePresenter = queryPagePresenter; this.layoutPagePresenter = layoutPagePresenter; }
/// <summary> /// Sets the mock manager not to have any active document. /// </summary> private void SetNoActiveDocument() { ITeamProjectDocument document = null; this.mockDocumentManager.Setup(manager => manager.ActiveDocument).Returns(document); }