Ejemplo n.º 1
0
 /// <summary>
 /// Most connectors are mapped to element links, but there can be exceptions. This method tell if a connector should be
 /// mapped to an element link.
 /// </summary>
 public override bool IsConnectorMappedToLink(DslDiagrams::BinaryLinkShape connector)
 {
     #region Check Parameters
     global::System.Diagnostics.Debug.Assert(connector != null);
     if (connector == null)
     {
         throw new global::System.ArgumentNullException("connector");
     }
     #endregion
     if (connector.GetType() == typeof(global::imbNLP.PipelineDSLD.Forward))
     {
         return(false);
     }
     return(base.IsConnectorMappedToLink(connector));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Most connectors are mapped to element links, but there can be exceptions. This method tell if a connector should be
 /// mapped to an element link.
 /// </summary>
 public override bool IsConnectorMappedToLink(DslDiagrams::BinaryLinkShape connector)
 {
     #region Check Parameters
     global::System.Diagnostics.Debug.Assert(connector != null);
     if (connector == null)
     {
         throw new global::System.ArgumentNullException("connector");
     }
     #endregion
     if (connector.GetType() == typeof(global::ORMSolutions.ORMArchitect.Views.RelationalView.ForeignKeyConnector))
     {
         return(false);
     }
     return(base.IsConnectorMappedToLink(connector));
 }
Ejemplo n.º 3
0
		/// <summary>
		/// Called during view fixup to configure the given child element, after it has been created.
		/// </summary>
		/// <remarks>
		/// Custom code for choosing the shapes attached to either end of a connector is called from here.
		/// </remarks>
		protected override void OnChildConfiguring(DslDiagrams::ShapeElement child, bool createdDuringViewFixup)
		{
			DslDiagrams::NodeShape sourceShape;
			DslDiagrams::NodeShape targetShape;
			DslDiagrams::BinaryLinkShape connector = child as DslDiagrams::BinaryLinkShape;
			if(connector == null)
			{
				base.OnChildConfiguring(child, createdDuringViewFixup);
				return;
			}
			this.GetSourceAndTargetForConnector(connector, out sourceShape, out targetShape);
			
			global::System.Diagnostics.Debug.Assert(sourceShape != null && targetShape != null, "Unable to find source and target shapes for connector.");
			connector.Connect(sourceShape, targetShape);
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Reroute a connector when the role players of its underlying relationship change
        /// </summary>
        public override void RolePlayerChanged(DslModeling::RolePlayerChangedEventArgs e)
        {
            if (e == null)
            {
                throw new global::System.ArgumentNullException("e");
            }

            global::System.Collections.ObjectModel.ReadOnlyCollection <DslDiagrams::PresentationViewsSubject> connectorLinks = DslDiagrams::PresentationViewsSubject.GetLinksToPresentation(e.ElementLink);
            foreach (DslDiagrams::PresentationViewsSubject connectorLink in connectorLinks)
            {
                // Fix up any binary link shapes attached to the element link.
                DslDiagrams::BinaryLinkShape linkShape = connectorLink.Presentation as DslDiagrams::BinaryLinkShape;
                if (linkShape != null)
                {
                    global::Microsoft.Practices.ServiceFactory.HostDesigner.HostDesignerDiagram diagram = linkShape.Diagram as global::Microsoft.Practices.ServiceFactory.HostDesigner.HostDesignerDiagram;
                    if (diagram != null)
                    {
                        if (e.NewRolePlayer != null)
                        {
                            DslDiagrams::NodeShape fromShape;
                            DslDiagrams::NodeShape toShape;
                            diagram.GetSourceAndTargetForConnector(linkShape, out fromShape, out toShape);
                            if (fromShape != null && toShape != null)
                            {
                                if (!object.Equals(fromShape, linkShape.FromShape))
                                {
                                    linkShape.FromShape = fromShape;
                                }
                                if (!object.Equals(linkShape.ToShape, toShape))
                                {
                                    linkShape.ToShape = toShape;
                                }
                            }
                            else
                            {
                                // delete the connector if we cannot find an appropriate target shape.
                                linkShape.Delete();
                            }
                        }
                        else
                        {
                            // delete the connector if the new role player is null.
                            linkShape.Delete();
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        internal void GetSourceAndTargetForConnector(DslDiagrams::BinaryLinkShape connector, out DslDiagrams::NodeShape sourceShape, out DslDiagrams::NodeShape targetShape)
        {
            sourceShape = null;
            targetShape = null;

            if (sourceShape == null || targetShape == null)
            {
                DslDiagrams::NodeShape[] endShapes = GetEndShapesForConnector(connector);
                if (sourceShape == null)
                {
                    sourceShape = endShapes[0];
                }
                if (targetShape == null)
                {
                    targetShape = endShapes[1];
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Helper method to find shapes for either end of a connector by looking for shapes associated with either end of the relationship mapped to the connector.
        /// </summary>
        private DslDiagrams::NodeShape[] GetEndShapesForConnector(DslDiagrams::BinaryLinkShape connector)
        {
            DslModeling::ElementLink link = connector.ModelElement as DslModeling::ElementLink;
            DslDiagrams::NodeShape   sourceShape = null, targetShape = null;

            if (link != null)
            {
                global::System.Collections.ObjectModel.ReadOnlyCollection <DslModeling::ModelElement> linkedElements = link.LinkedElements;
                if (linkedElements.Count == 2)
                {
                    DslDiagrams::Diagram currentDiagram = this.Diagram;
                    DslModeling::LinkedElementCollection <DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[0]);
                    foreach (DslDiagrams::PresentationElement presentationElement in presentationElements)
                    {
                        DslDiagrams::NodeShape shape = presentationElement as DslDiagrams::NodeShape;
                        if (shape != null && shape.Diagram == currentDiagram)
                        {
                            sourceShape = shape;
                            break;
                        }
                    }

                    presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[1]);
                    foreach (DslDiagrams::PresentationElement presentationElement in presentationElements)
                    {
                        DslDiagrams::NodeShape shape = presentationElement as DslDiagrams::NodeShape;
                        if (shape != null && shape.Diagram == currentDiagram)
                        {
                            targetShape = shape;
                            break;
                        }
                    }
                }
            }

            return(new DslDiagrams::NodeShape[] { sourceShape, targetShape });
        }