private void SwitchView(ViewSchema view)
 {
     if (this.Store.GetCurrentDiagram() == this.Store.GetDiagramForView(view))
     {
         var docview = this.DocViews.First() as SingleDiagramDocView;
         docview.Diagram = view.Store.GetDiagramForDefaultView();
     }
 }
        private void DeleteDiagram(ViewSchema view)
        {
            this.Store.TransactionManager.DoWithinTransaction(() => this.Store.GetDiagramForView(view).Delete());

            var solution    = this.ServiceProvider.GetService <ISolution>();
            var modelItem   = solution.Find <IItem>(it => it.PhysicalPath == this.FileName).Single();
            var diagramFile = ConstructDiagramFileName(this.FileName, view);

            var diagramItem = modelItem.Find <IItem>(it => it.PhysicalPath == diagramFile).FirstOrDefault();

            if (diagramItem != null)
            {
                diagramItem.As <ProjectItem>().Delete();
            }
        }
        private void DeleteDiagram(ViewSchema view)
        {
            this.Store.TransactionManager.DoWithinTransaction(() => this.Store.GetDiagramForView(view).Delete());

            var solution = this.ServiceProvider.GetService<ISolution>();
            var modelItem = solution.Find<IItem>(it => it.PhysicalPath == this.FileName).Single();
            var diagramFile = ConstructDiagramFileName(this.FileName, view);

            var diagramItem = modelItem.Find<IItem>(it => it.PhysicalPath == diagramFile).FirstOrDefault();

            if (diagramItem != null)
            {
                diagramItem.As<ProjectItem>().Delete();
            }
        }
 private void SwitchView(ViewSchema view)
 {
     if (this.Store.GetCurrentDiagram() == this.Store.GetDiagramForView(view))
     {
         var docview = this.DocViews.First() as SingleDiagramDocView;
         docview.Diagram = view.Store.GetDiagramForDefaultView();
     }
 }
 private static string ConstructDiagramFileName(string modelFile, ViewSchema view)
 {
     return String.Concat(
         modelFile.Replace(Path.GetFileNameWithoutExtension(modelFile), view.DiagramId),
         DesignerConstants.DiagramFileExtension);
 }
 /// <summary>
 /// Determines whether [is view represented] [the specified diagram].
 /// </summary>
 /// <param name="diagram">The diagram.</param>
 /// <param name="view">The view to verify.</param>
 /// <returns>
 /// 	<c>true</c> if [is view represented] [the specified diagram]; otherwise, <c>false</c>.
 /// </returns>
 internal static bool IsViewRepresented(this PatternModelSchemaDiagram diagram, ViewSchema view)
 {
     return diagram.Id.ToString().Equals(view.DiagramId, StringComparison.OrdinalIgnoreCase);
 }
 private static string ConstructDiagramFileName(string modelFile, ViewSchema view)
 {
     return(String.Concat(
                modelFile.Replace(Path.GetFileNameWithoutExtension(modelFile), view.DiagramId),
                DesignerConstants.DiagramFileExtension));
 }
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, ViewSchema element, global::System.Xml.XmlWriter writer)
		{
			// ViewHasElements
			global::System.Collections.ObjectModel.ReadOnlyCollection<ViewHasElements> allViewHasElementsInstances = ViewHasElements.GetLinksToElements(element);
			if (!serializationContext.Result.Failed && allViewHasElementsInstances.Count > 0)
			{
				foreach (ViewHasElements eachViewHasElementsInstance in allViewHasElementsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachViewHasElementsInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachViewHasElementsInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachViewHasElementsInstance, writer);
				}
			}
	
			// ViewHasExtensionPoints
			global::System.Collections.ObjectModel.ReadOnlyCollection<ViewHasExtensionPoints> allViewHasExtensionPointsInstances = ViewHasExtensionPoints.GetLinksToExtensionPoints(element);
			if (!serializationContext.Result.Failed && allViewHasExtensionPointsInstances.Count > 0)
			{
				foreach (ViewHasExtensionPoints eachViewHasExtensionPointsInstance in allViewHasExtensionPointsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachViewHasExtensionPointsInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachViewHasExtensionPointsInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachViewHasExtensionPointsInstance, writer);
				}
			}
	
		}
		/// <summary>
		/// This method deserializes all child model elements.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first child XML element to deserialized.
		/// This method will read as many child elements as it can. It returns under three circumstances:
		/// 1) When an unknown child XML element is encountered. In this case, this method will position the reader at the 
		///    open tag of the unknown element. This implies that if the first child XML element is unknown, this method 
		///    should return immediately and do nothing.
		/// 2) When all child XML elemnets are read. In this case, the reader will be positioned at the end tag of the parent element.
		/// 3) EOF.
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		/// <param name="element">In-memory ViewSchema instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, ViewSchema element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				// Check if it's an instance of omit-element relationship "ViewHasElements"
				DslModeling::DomainClassXmlSerializer newViewHasElementsSerializer = serializationContext.Directory.GetSerializer(ViewHasElements.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newViewHasElementsSerializer != null, "Cannot find serializer for ViewHasElements!");
				ViewHasElements newViewHasElements = newViewHasElementsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ViewHasElements;
				if (newViewHasElements != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newViewHasElements, ViewHasElements.ViewSchemaDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newViewHasElements.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newViewHasElements.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newViewHasElements, reader);
					continue;
				}
				// Check if it's an instance of omit-element relationship "ViewHasExtensionPoints"
				DslModeling::DomainClassXmlSerializer newViewHasExtensionPointsSerializer = serializationContext.Directory.GetSerializer(ViewHasExtensionPoints.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newViewHasExtensionPointsSerializer != null, "Cannot find serializer for ViewHasExtensionPoints!");
				ViewHasExtensionPoints newViewHasExtensionPoints = newViewHasExtensionPointsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ViewHasExtensionPoints;
				if (newViewHasExtensionPoints != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newViewHasExtensionPoints, ViewHasExtensionPoints.ViewSchemaDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newViewHasExtensionPoints.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newViewHasExtensionPoints.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newViewHasExtensionPoints, reader);
					continue;
				}
				return;  // Don't know this element.
			}
		}
Example #10
0
 /// <summary>
 /// Determines whether [is view represented] [the specified diagram].
 /// </summary>
 /// <param name="diagram">The diagram.</param>
 /// <param name="view">The view to verify.</param>
 /// <returns>
 ///     <c>true</c> if [is view represented] [the specified diagram]; otherwise, <c>false</c>.
 /// </returns>
 internal static bool IsViewRepresented(this PatternModelSchemaDiagram diagram, ViewSchema view)
 {
     return(diagram.Id.ToString().Equals(view.DiagramId, StringComparison.OrdinalIgnoreCase));
 }
        /// <summary>
        /// Gets the diagram for view.
        /// </summary>
        /// <param name="store">The given store.</param>
        /// <param name="view">The given view.</param>
        /// <returns>The diagram for the view.</returns>
        internal static PatternModelSchemaDiagram GetDiagramForView(this Store store, ViewSchema view)
        {
            var diagrams = store.GetDiagrams();

            return diagrams.Single(dg => dg.IsViewRepresented(view));
        }
        /// <summary>
        /// Gets the diagram for view.
        /// </summary>
        /// <param name="store">The given store.</param>
        /// <param name="view">The given view.</param>
        /// <returns>The diagram for the view.</returns>
        internal static PatternModelSchemaDiagram GetDiagramForView(this Store store, ViewSchema view)
        {
            var diagrams = store.GetDiagrams();

            return(diagrams.Single(dg => dg.IsViewRepresented(view)));
        }