Esempio n. 1
0
 /// <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);
     }
 }
Esempio n. 2
0
 /// <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);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Loads the given file.
        /// </summary>
        protected override void Load(string fileName, bool isReload)
        {
            DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();

            global::pelsoft.FWK_Dsl.ModelRoot modelRoot      = null;
            DslModeling::ISchemaResolver      schemaResolver = new DslShell::ModelingSchemaResolver(this.ServiceProvider);

            // Enable diagram fixup rules in our store, because we will load diagram data.
            global::pelsoft.FWK_Dsl.FWK_DslDomainModel.EnableDiagramRules(this.Store);
            string diagramFileName = fileName + this.DiagramExtension;

            modelRoot = global::pelsoft.FWK_Dsl.FWK_DslSerializationHelper.Instance.LoadModelAndDiagram(serializationResult, this.Store, fileName, diagramFileName, schemaResolver, null /* no load-time validation */);

            // Report serialization messages.
            this.SuspendErrorListRefresh();
            try
            {
                foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
                {
                    this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
                }
            }
            finally
            {
                this.ResumeErrorListRefresh();
            }

            if (serializationResult.Failed)
            {
                // Load failed, can't open the file.
                throw new global::System.InvalidOperationException(global::pelsoft.FWK_Dsl.FWK_DslDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
            }
            else
            {
                this.SetRootElement(modelRoot);
                if (this.Hierarchy != null && global::System.IO.File.Exists(diagramFileName))
                {
                    // Add a lock to the subordinate diagram file.
                    if (this.diagramDocumentLockHolder == null)
                    {
                        uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
                        if (itemId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
                        {
                            this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
                            if (this.diagramDocumentLockHolder == null)
                            {
                                throw new global::System.InvalidOperationException(string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
                                                                                                 global::pelsoft.FWK_Dsl.FWK_DslDomainModel.SingletonResourceManager.GetString("CannotCloseExistingDiagramDocument"),
                                                                                                 diagramFileName));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 /// <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.diagramDocumentLockHolder != null)
         {
             this.diagramDocumentLockHolder.Dispose();
             this.diagramDocumentLockHolder = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
Esempio n. 5
0
		/// <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.diagramDocumentLockHolder != null)
				{
					this.diagramDocumentLockHolder.Dispose();
					this.diagramDocumentLockHolder = null;
				}
			}
			finally
			{
				base.Dispose(disposing);
			}
		}
Esempio n. 6
0
 /// <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.diagramDocumentLockHolder != null)
         {
             this.diagramDocumentLockHolder.Dispose();
             this.diagramDocumentLockHolder = null;
         }
         this.diagramPartitionId = global::System.Guid.Empty;
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Replace the subordinate file in the project and create a new lock.
        /// </summary>
        private void RestoreSubordinateFile()
        {
            // The subordinate file may have been temporarily removed from the project.
            // Put it back if we were asked to.
            if (this.restoreSubordinateFile)
            {
                // Put the file back in the project
                DslShell::SubordinateFileHelper.EnsureChildProjectItem(this.Hierarchy, this.ItemId, this.FileName + this.DiagramExtension);

                // Get the new ChildId
                uint childId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);

                // Make a new lock
                this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, childId);

                this.restoreSubordinateFile = false;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Propagates file name changes to the diagram file.
        /// </summary>
        protected override void OnFileNameChanged(global::System.EventArgs e)
        {
            base.OnFileNameChanged(e);

            if (this.IsLoaded && this.Hierarchy != null)
            {
                uint childId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
                if (childId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
                {
                    // If the file is loaded, then we should remove the subordinate file's lock and restore it after the rename.
                    this.diagramDocumentLockHolder.UnregisterSubordinateDocument();
                    this.diagramDocumentLockHolder = null;

                    // Perform the rename
                    DslShell::SubordinateFileHelper.EnsureChildFileName(this.ServiceProvider, this.Hierarchy, childId, this.FileName + this.DiagramExtension);

                    // Because we've removed the file from the project and dropped our lock, make a note to put them back later via an event.
                    // We don't do this here, as the SaveAs code in Visual Studio will query overwriting these files if they are in the project here.
                    // We dont retake the lock here as Visual Studio will close the parent docdata if we delete from the project a locked item.
                    this.restoreSubordinateFile = true;
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Loads the given file.
        /// </summary>
        protected override void Load(string fileName, bool isReload)
        {
            DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();

            global::UPM_IPS.RAARMAPMCWeberMDD.WebERMDD modelRoot = null;
            DslModeling::ISchemaResolver schemaResolver          = new DslShell::ModelingSchemaResolver(this.ServiceProvider);

            //clear the current root element
            this.SetRootElement(null);
            // Enable diagram fixup rules in our store, because we will load diagram data.
            global::UPM_IPS.RAARMAPMCWeberMDD.RAARMAPMCWeberMDDDomainModel.EnableDiagramRules(this.Store);
            string diagramFileName = fileName + this.DiagramExtension;

            modelRoot = global::UPM_IPS.RAARMAPMCWeberMDD.RAARMAPMCWeberMDDSerializationHelper.Instance.LoadModelAndDiagram(serializationResult, this.GetModelPartition(), fileName, this.GetDiagramPartition(), diagramFileName, schemaResolver, null /* no load-time validation */, this.SerializerLocator);

            // Report serialization messages.
            this.SuspendErrorListRefresh();
            try
            {
                foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
                {
                    this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
                }
            }
            finally
            {
                this.ResumeErrorListRefresh();
            }

            if (serializationResult.Failed)
            {
                // Load failed, can't open the file.
                throw new global::System.InvalidOperationException(global::UPM_IPS.RAARMAPMCWeberMDD.RAARMAPMCWeberMDDDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
            }
            else
            {
                this.SetRootElement(modelRoot);

                // Attempt to set the encoding
                if (serializationResult.Encoding != null)
                {
                    this.ModelingDocStore.SetEncoding(serializationResult.Encoding);
                    global::Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.SetDocDataDirty(0));                     // Setting the encoding will mark the document as dirty, so clear the dirty flag.
                }

                if (this.Hierarchy != null && global::System.IO.File.Exists(diagramFileName))
                {
                    // Add a lock to the subordinate diagram file.
                    if (this.diagramDocumentLockHolder == null)
                    {
                        uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
                        if (itemId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
                        {
                            this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
                            if (this.diagramDocumentLockHolder == null)
                            {
                                throw new global::System.InvalidOperationException(string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
                                                                                                 global::UPM_IPS.RAARMAPMCWeberMDD.RAARMAPMCWeberMDDDomainModel.SingletonResourceManager.GetString("CannotCloseExistingDiagramDocument"),
                                                                                                 diagramFileName));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
0
		/// <summary>
		/// Loads the given file.
		/// </summary>
		protected override void Load(string fileName, bool isReload)
		{
			DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();
			global::Microsoft.Practices.ServiceFactory.DataContracts.DataContractModel modelRoot = null;
			DslModeling::ISchemaResolver schemaResolver = new DslShell::ModelingSchemaResolver(this.ServiceProvider);
			//clear the current root element
			this.SetRootElement(null);
			// Enable diagram fixup rules in our store, because we will load diagram data.
			global::Microsoft.Practices.ServiceFactory.DataContracts.DataContractDslDomainModel.EnableDiagramRules(this.Store);
			string diagramFileName = fileName + this.DiagramExtension;
			
			modelRoot = global::Microsoft.Practices.ServiceFactory.DataContracts.DataContractDslSerializationHelper.Instance.LoadModelAndDiagram(serializationResult, this.GetModelPartition(), fileName, this.GetDiagramPartition(), diagramFileName, schemaResolver, null /* no load-time validation */, this.SerializerLocator);

			// Report serialization messages.
			this.SuspendErrorListRefresh();
			try
			{
				foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
				{
					this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
				}
			}
			finally
			{
				this.ResumeErrorListRefresh();
			}

			if (serializationResult.Failed)
			{	
				// Load failed, can't open the file.
				throw new global::System.InvalidOperationException(global::Microsoft.Practices.ServiceFactory.DataContracts.DataContractDslDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
			}
			else
			{
				this.SetRootElement(modelRoot);
				
				// Attempt to set the encoding
				if (serializationResult.Encoding != null)
				{
					this.ModelingDocStore.SetEncoding(serializationResult.Encoding);
					global::Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.SetDocDataDirty(0)); // Setting the encoding will mark the document as dirty, so clear the dirty flag.
				}
				
				if (this.Hierarchy != null && global::System.IO.File.Exists(diagramFileName))
				{
					// Add a lock to the subordinate diagram file.
					if (this.diagramDocumentLockHolder == null)
					{
						uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
						if (itemId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
						{
							this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
							if (this.diagramDocumentLockHolder == null)
							{
								throw new global::System.InvalidOperationException(string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
													global::Microsoft.Practices.ServiceFactory.DataContracts.DataContractDslDomainModel.SingletonResourceManager.GetString("CannotCloseExistingDiagramDocument"),
													diagramFileName));
							}
						}
					}
				}
			}
		}
Esempio n. 11
0
		/// <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);
			}
		}
Esempio n. 12
0
		/// <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.diagramDocumentLockHolder != null)
				{
					this.diagramDocumentLockHolder.Dispose();
					this.diagramDocumentLockHolder = null;
				}
				this.diagramPartitionId = global::System.Guid.Empty;
			}
			finally
			{
				base.Dispose(disposing);
			}
		}
Esempio n. 13
0
		/// <summary>
		/// Loads the given file.
		/// </summary>
		protected override void Load(string fileName, bool isReload)
		{
			DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();
			global::Altinoren.ActiveWriter.Model modelRoot = null;
			DslModeling::ISchemaResolver schemaResolver = new DslShell::ModelingSchemaResolver(this.ServiceProvider);
			
			// Enable diagram fixup rules in our store, because we will load diagram data.
			global::Altinoren.ActiveWriter.ActiveWriterDomainModel.EnableDiagramRules(this.Store);
			string diagramFileName = fileName + this.DiagramExtension;
			
			// Ensure that subordinate diagram file is named properly; handles the case where a rename occurs while the designer was closed.
			if(this.Hierarchy != null)
			{
				uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
				if(itemId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
				{
					global::System.Diagnostics.Debug.Assert(!this.IsLoaded);
					// Make sure the name is right before we lock the item in the RDT.
					DslShell::SubordinateFileHelper.EnsureChildFileName(this.ServiceProvider, this.Hierarchy, itemId, diagramFileName);

					// Found the diagram file, lock it in the running documents table.
					this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
					if (this.diagramDocumentLockHolder == null)
					{
						throw new global::System.InvalidOperationException(global::Altinoren.ActiveWriter.ActiveWriterDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
					}
				}
			}
			
			try
			{
				modelRoot = global::Altinoren.ActiveWriter.ActiveWriterSerializationHelper.Instance.LoadModelAndDiagram(serializationResult, this.Store, fileName, diagramFileName, schemaResolver, null /* no load-time validation */);
			}
			finally
			{
				if (this.diagramDocumentLockHolder != null && (modelRoot == null || serializationResult.Failed))
				{
					// Load failed, release the document lock if we added one above.
					this.diagramDocumentLockHolder.UnregisterSubordinateDocument();
					this.diagramDocumentLockHolder = null;
				}
			}

			// Report serialization messages.
			this.SuspendErrorListRefresh();
			try
			{
				foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
				{
					this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
				}
			}
			finally
			{
				this.ResumeErrorListRefresh();
			}

			if (serializationResult.Failed)
			{	
				// Load failed, can't open the file.
				throw new global::System.InvalidOperationException(global::Altinoren.ActiveWriter.ActiveWriterDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
			}
			else
			{
				this.SetRootElement(modelRoot);
				if (this.Hierarchy != null && global::System.IO.File.Exists(diagramFileName))
				{
					DslShell::SubordinateFileHelper.EnsureChildProjectItem(this.Hierarchy, this.ItemId, diagramFileName);

					// Should have a subordinate diagram file now. If we didn't add a lock above, add one now.
					if (this.diagramDocumentLockHolder == null)
					{
						uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
						this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
						if (this.diagramDocumentLockHolder == null)
						{
							throw new global::System.InvalidOperationException(global::Altinoren.ActiveWriter.ActiveWriterDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
						}
					}

					// Connect to events on the RDT in order to allow delayed rename handling.
					this.eventsCookie = DslShell::SubordinateFileHelper.AdviseRunningDocumentTableEvents(this.ServiceProvider, this);
				}
			}
		}
Esempio n. 14
0
        /// <summary>
        /// Loads the given file.
        /// </summary>
        protected override void Load(string fileName, bool isReload)
        {
            DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();

            global::DSLFactory.Candle.SystemModel.CandleModel modelRoot = null;
            DslModeling::ISchemaResolver schemaResolver = new DslShell::ModelingSchemaResolver(this.ServiceProvider);

            // Enable diagram fixup rules in our store, because we will load diagram data.
            global::DSLFactory.Candle.SystemModel.CandleDomainModel.EnableDiagramRules(this.Store);
            string diagramFileName = fileName + this.DiagramExtension;

            // Ensure that subordinate diagram file is named properly; handles the case where a rename occurs while the designer was closed.
            if (this.Hierarchy != null)
            {
                uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
                if (itemId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
                {
                    global::System.Diagnostics.Debug.Assert(!this.IsLoaded);
                    // Make sure the name is right before we lock the item in the RDT.
                    DslShell::SubordinateFileHelper.EnsureChildFileName(this.ServiceProvider, this.Hierarchy, itemId, diagramFileName);

                    // Found the diagram file, lock it in the running documents table.
                    this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
                    if (this.diagramDocumentLockHolder == null)
                    {
                        throw new global::System.InvalidOperationException(global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
                    }
                }
            }

            try
            {
                modelRoot = global::DSLFactory.Candle.SystemModel.CandleSerializationHelper.Instance.LoadModelAndDiagram(serializationResult, this.Store, fileName, diagramFileName, schemaResolver, null /* no load-time validation */);
            }
            finally
            {
                if (this.diagramDocumentLockHolder != null && (modelRoot == null || serializationResult.Failed))
                {
                    // Load failed, release the document lock if we added one above.
                    this.diagramDocumentLockHolder.UnregisterSubordinateDocument();
                    this.diagramDocumentLockHolder = null;
                }
            }

            // Report serialization messages.
            this.SuspendErrorListRefresh();
            try
            {
                foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
                {
                    this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
                }
            }
            finally
            {
                this.ResumeErrorListRefresh();
            }

            if (serializationResult.Failed)
            {
                // Load failed, can't open the file.
                throw new global::System.InvalidOperationException(global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
            }
            else
            {
                this.SetRootElement(modelRoot);
                if (this.Hierarchy != null && global::System.IO.File.Exists(diagramFileName))
                {
                    DslShell::SubordinateFileHelper.EnsureChildProjectItem(this.Hierarchy, this.ItemId, diagramFileName);

                    // Should have a subordinate diagram file now. If we didn't add a lock above, add one now.
                    if (this.diagramDocumentLockHolder == null)
                    {
                        uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
                        this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
                        if (this.diagramDocumentLockHolder == null)
                        {
                            throw new global::System.InvalidOperationException(global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
                        }
                    }

                    // Connect to events on the RDT in order to allow delayed rename handling.
                    this.eventsCookie = DslShell::SubordinateFileHelper.AdviseRunningDocumentTableEvents(this.ServiceProvider, this);
                }
            }
        }
Esempio n. 15
0
		/// <summary>
		/// Replace the subordinate file in the project and create a new lock.
		/// </summary>
		private void RestoreSubordinateFile()
		{
			// The subordinate file may have been temporarily removed from the project.
			// Put it back if we were asked to.
			if (this.restoreSubordinateFile)
			{
				// Put the file back in the project
				DslShell::SubordinateFileHelper.EnsureChildProjectItem(this.Hierarchy, this.ItemId, this.FileName + this.DiagramExtension);

				// Get the new ChildId
				uint childId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);

				// Make a new lock
				this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, childId);

				this.restoreSubordinateFile = false;
			}
		}
Esempio n. 16
0
		/// <summary>
		/// Propagates file name changes to the diagram file.
		/// </summary>
		protected override void OnFileNameChanged(global::System.EventArgs e)
		{
			base.OnFileNameChanged(e);

			if (this.IsLoaded && this.Hierarchy != null)
			{
				uint childId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
				if (childId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
				{
					// If the file is loaded, then we should remove the subordinate file's lock and restore it after the rename.
					this.diagramDocumentLockHolder.UnregisterSubordinateDocument();
					this.diagramDocumentLockHolder = null;

					// Perform the rename
					DslShell::SubordinateFileHelper.EnsureChildFileName(this.ServiceProvider, this.Hierarchy, childId, this.FileName + this.DiagramExtension);

					// Because we've removed the file from the project and dropped our lock, make a note to put them back later via an event.
					// We don't do this here, as the SaveAs code in Visual Studio will query overwriting these files if they are in the project here.
					// We dont retake the lock here as Visual Studio will close the parent docdata if we delete from the project a locked item.
					this.restoreSubordinateFile = true;
				}
			}
		}
Esempio n. 17
0
		/// <summary>
		/// Loads the given file.
		/// </summary>
		protected override void Load(string fileName, bool isReload)
		{
			DslModeling::SerializationResult serializationResult = new DslModeling::SerializationResult();
			global::LinqToRdf.Design.ModelRoot modelRoot = null;
			DslModeling::ISchemaResolver schemaResolver = new DslShell::ModelingSchemaResolver(this.ServiceProvider);
			
			// Enable diagram fixup rules in our store, because we will load diagram data.
			global::LinqToRdf.Design.LinqToRdfDomainModel.EnableDiagramRules(this.Store);
			string diagramFileName = fileName + this.DiagramExtension;
			
			modelRoot = global::LinqToRdf.Design.LinqToRdfSerializationHelper.Instance.LoadModelAndDiagram(serializationResult, this.Store, fileName, diagramFileName, schemaResolver, null /* no load-time validation */);

			// Report serialization messages.
			this.SuspendErrorListRefresh();
			try
			{
				foreach (DslModeling::SerializationMessage serializationMessage in serializationResult)
				{
					this.AddErrorListItem(new DslShell::SerializationErrorListItem(this.ServiceProvider, serializationMessage));
				}
			}
			finally
			{
				this.ResumeErrorListRefresh();
			}

			if (serializationResult.Failed)
			{	
				// Load failed, can't open the file.
				throw new global::System.InvalidOperationException(global::LinqToRdf.Design.LinqToRdfDomainModel.SingletonResourceManager.GetString("CannotOpenDocument"));
			}
			else
			{
				this.SetRootElement(modelRoot);
				if (this.Hierarchy != null && global::System.IO.File.Exists(diagramFileName))
				{
					// Add a lock to the subordinate diagram file.
					if (this.diagramDocumentLockHolder == null)
					{
						uint itemId = DslShell::SubordinateFileHelper.GetChildProjectItemId(this.Hierarchy, this.ItemId, this.DiagramExtension);
						if (itemId != global::Microsoft.VisualStudio.VSConstants.VSITEMID_NIL)
						{
							this.diagramDocumentLockHolder = DslShell::SubordinateFileHelper.LockSubordinateDocument(this.ServiceProvider, this, diagramFileName, itemId);
							if (this.diagramDocumentLockHolder == null)
							{
								throw new global::System.InvalidOperationException(string.Format(global::System.Globalization.CultureInfo.CurrentCulture,
													global::LinqToRdf.Design.LinqToRdfDomainModel.SingletonResourceManager.GetString("CannotCloseExistingDiagramDocument"),
													diagramFileName));
							}
						}
					}
				}
			}
		}
Esempio n. 18
0
		/// <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);
			}
		}