/// <summary> /// Validate the model before the file is saved. /// </summary> protected override bool CanSave(bool allowUserInterface) { // If a silent check then use a temporary ValidationController that is not connected to the error list to avoid any unwanted UI updates DslShell::VsValidationController vc = allowUserInterface ? this.ValidationController : this.CreateValidationController(); if (vc == null) { return(true); } // We check Load category first, because any violation in this category will cause the saved file to be unloadable justifying a special // error message. If the Load category passes, we then check the normal Save category, and give the normal warning message if necessary. bool unloadableError = !vc.Validate(this.GetAllElementsForValidation(), DslValidation::ValidationCategories.Load) && vc.ErrorMessages.Count != 0; // Prompt user for confirmation if there are validation errors and this is not a silent save if (allowUserInterface) { vc.Validate(this.GetAllElementsForValidation(), DslValidation::ValidationCategories.Save); if (vc.ErrorMessages.Count != 0) { string errorMsg = (unloadableError ? "UnloadableSaveValidationFailed" : "SaveValidationFailed"); global::System.Windows.Forms.DialogResult result = DslShell::PackageUtility.ShowMessageBox(this.ServiceProvider, global::TXSoftware.DataObjectsNetEntityModel.Dsl.DONetEntityModelDesignerDomainModel.SingletonResourceManager.GetString(errorMsg), VSShellInterop::OLEMSGBUTTON.OLEMSGBUTTON_YESNO, VSShellInterop::OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, VSShellInterop::OLEMSGICON.OLEMSGICON_WARNING); return(result == global::System.Windows.Forms.DialogResult.Yes); } } return(!unloadableError); }
/// <summary> /// When the doc data is closed, make sure we reset the valiation messages /// (if there's any) from the ErrorList window. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { try { if (this.validationController != null) { this.validationController.ClearMessages(); // un-register our observer with the controller. this.validationController.RemoveObserver(this.errorListObserver); this.validationController = null; if (this.errorListObserver != null) { this.errorListObserver.Dispose(); this.errorListObserver = null; } } if (this.diagramDocumentLockHolder != null) { this.diagramDocumentLockHolder.Dispose(); this.diagramDocumentLockHolder = null; } this.diagramPartitionId = global::System.Guid.Empty; } finally { base.Dispose(disposing); } }
/// <summary> /// When the doc data is closed, make sure we reset the valiation messages /// (if there's any) from the ErrorList window. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { try { if (this.validationController != null) { this.validationController.ClearMessages(); // un-register our observer with the controller. this.validationController.RemoveObserver(this.errorListObserver); this.validationController = null; if (this.errorListObserver != null) { this.errorListObserver.Dispose(); this.errorListObserver = null; } } if (this.diagramDocumentLockHolder != null) { this.diagramDocumentLockHolder.Dispose(); this.diagramDocumentLockHolder = null; } if (this.eventsCookie != 0) { DslShell::SubordinateFileHelper.UnadviseRunningDocumentTableEvents(this.ServiceProvider, this.eventsCookie); this.eventsCookie = 0; } } finally { base.Dispose(disposing); } }
/// <summary> /// When the doc data is closed, make sure we reset the valiation messages /// (if there's any) from the ErrorList window. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { try { if (this.validationController != null) { this.validationController.ClearMessages(); // un-register our observer with the controller. this.validationController.RemoveObserver(this.errorListObserver); this.validationController = null; if ( this.errorListObserver != null ) { this.errorListObserver.Dispose(); this.errorListObserver = null; } } if (this.diagramDocumentLockHolder != null) { this.diagramDocumentLockHolder.Dispose(); this.diagramDocumentLockHolder = null; } this.diagramPartitionId = global::System.Guid.Empty; } finally { base.Dispose(disposing); } }
/// <summary> /// When the doc data is closed, make sure we reset the valiation messages /// (if there's any) from the ErrorList window. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { try { if (this.validationController != null) { this.validationController.ClearMessages(); // un-register our observer with the controller. this.validationController.RemoveObserver(this.errorListObserver); this.validationController = null; if ( this.errorListObserver != null ) { this.errorListObserver.Dispose(); this.errorListObserver = null; } } if (this.diagramDocumentLockHolder != null) { this.diagramDocumentLockHolder.Dispose(); this.diagramDocumentLockHolder = null; } if (this.eventsCookie != 0) { DslShell::SubordinateFileHelper.UnadviseRunningDocumentTableEvents(this.ServiceProvider, this.eventsCookie); this.eventsCookie = 0; } } finally { base.Dispose(disposing); } }