Example #1
0
        internal override DslModeling.ModelElement SynchronizeSingleDslModelElement(
            DslModeling.ModelElement parentViewModel, EFObject modelElement)
        {
            var t = modelElement.GetType();

            if (t == typeof(ConceptualEntityType))
            {
                return(TranslateEntityType(parentViewModel as EntityDesignerViewModel, modelElement as ConceptualEntityType));
            }
            else if (t == typeof(EntityTypeBaseType))
            {
                return(TranslateBaseType(parentViewModel as EntityDesignerViewModel, (modelElement).Parent as ConceptualEntityType));
            }
            else if (t == typeof(ModelNavigationProperty))
            {
                return(TranslateNavigationProperty(parentViewModel as ViewModelEntityType, modelElement as ModelNavigationProperty));
            }
            else if (t == typeof(ComplexConceptualProperty) ||
                     t == typeof(ConceptualProperty))
            {
                return(TranslateProperty(parentViewModel as ViewModelEntityType, modelElement as ModelProperty));
            }
            else if (t == typeof(ModelAssociation))
            {
                return(TranslateAssociation(parentViewModel as EntityDesignerViewModel, modelElement as ModelAssociation));
            }
            else if (t == typeof(DesignerModel.Diagram))
            {
                return(TranslateDiagramValues(parentViewModel as EntityDesignerViewModel, modelElement as DesignerModel.Diagram));
            }

            Debug.Assert(false, "modelElement with type= " + t.Name + " is not supported");

            return(null);
        }
        /// <summary>
        /// Check whether shapes should be added for a particular element
        /// </summary>
        /// <remarks>
        /// Base class provides test when a drag-drop is performed.  This override provides the
        /// test for when reverse-engineering (load) happens.
        /// </remarks>
        /// <param name="element">The element to test</param>
        /// <returns>Whether to add a shape</returns>
        protected override bool ShouldAddShapeForElement(Microsoft.VisualStudio.Modeling.ModelElement element)
        {
            bool addShape = false;

            // Make a list of all elements mapped from the shape / connector maps
            if (element is ISpySoft.SFSchemaLanguage.DomainModel.Activity)
            {
                addShape = true;
            }
            if (element is ISpySoft.SFSchemaLanguage.DomainModel.Artifact)
            {
                addShape = true;
            }
            if (element is ISpySoft.SFSchemaLanguage.DomainModel.Mapping)
            {
                addShape = true;
            }
            if (element is ISpySoft.SFSchemaLanguage.DomainModel.ViewPoint)
            {
                addShape = true;
            }
            if (element is ISpySoft.SFSchemaLanguage.DomainModel.SchemaModelItemHasSchemaModelItem)
            {
                addShape = true;
            }
            return(addShape);
        }
        /// <summary>
        /// Check whether shapes should be added for a particular element
        /// </summary>
        /// <remarks>
        /// Base class provides test when a drag-drop is performed.  This override provides the
        /// test for when reverse-engineering (load) happens.
        /// </remarks>
        /// <param name="element">The element to test</param>
        /// <returns>Whether to add a shape</returns>
        protected override bool ShouldAddShapeForElement(Microsoft.VisualStudio.Modeling.ModelElement element)
        {
            bool addShape = false;

            // Make a list of all elements mapped from the shape / connector maps
            if (element is ISpySoft.FeatureModelLanguage.DomainModel.FeatureSet)
            {
                addShape = true;
            }
            if (element is ISpySoft.FeatureModelLanguage.DomainModel.Feature)
            {
                addShape = true;
            }
            if (element is ISpySoft.FeatureModelLanguage.DomainModel.RootFeature)
            {
                addShape = true;
            }
            if (element is ISpySoft.FeatureModelLanguage.DomainModel.RelationshipFeature)
            {
                addShape = true;
            }
            if (element is ISpySoft.FeatureModelLanguage.DomainModel.RelationshipFeatureSet)
            {
                addShape = true;
            }
            return(addShape);
        }
Example #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="link">Element link.</param>
        public ModelProtoLink(ElementLink link)
            : base(link)
        {
            if (link == null)
            {
                throw new System.ArgumentNullException("link");
            }

            IList <Microsoft.VisualStudio.Modeling.DomainRoleInfo> ilist = link.GetDomainRelationship().DomainRoles;

            rolePlayers = new System.Collections.Generic.List <ModelProtoRolePlayer>(2);
            for (int i = 0; i < 2; i++)
            {
                Microsoft.VisualStudio.Modeling.DomainRoleInfo domainRoleInfo = ilist[i];
                Microsoft.VisualStudio.Modeling.ModelElement   modelElement   = domainRoleInfo.GetRolePlayer(link);
                System.Guid guid = modelElement != null ? modelElement.Id : System.Guid.Empty;


                if (modelElement is DomainClass)
                {
                    rolePlayers.Add(new ModelProtoRolePlayer(domainRoleInfo.Id, guid, (modelElement as DomainClass).Name));
                }
                else
                {
                    rolePlayers.Add(new ModelProtoRolePlayer(domainRoleInfo.Id, guid, ""));
                }
            }
        }
Example #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="link">Element link.</param>
        public ModelProtoLink(ElementLink link)
            : base(link)
        {
            if (link == null)
            {
                throw new System.ArgumentNullException("link");
            }

            IList <Microsoft.VisualStudio.Modeling.DomainRoleInfo> ilist = link.GetDomainRelationship().DomainRoles;

            rolePlayers = new System.Collections.Generic.List <ModelProtoRolePlayer>(2);
            for (int i = 0; i < 2; i++)
            {
                Microsoft.VisualStudio.Modeling.DomainRoleInfo domainRoleInfo = ilist[i];
                Microsoft.VisualStudio.Modeling.ModelElement   modelElement   = domainRoleInfo.GetRolePlayer(link);
                System.Guid guid = modelElement != null ? modelElement.Id : System.Guid.Empty;

                string name = "";
                if (modelElement is IDomainModelOwnable)
                {
                    if ((modelElement as IDomainModelOwnable).DomainElementHasName)
                    {
                        name = (modelElement as IDomainModelOwnable).DomainElementName;
                    }
                }

                rolePlayers.Add(new ModelProtoRolePlayer(domainRoleInfo.Id, guid, name));
            }

            this.isTargetIncludedSubmodel = false;
            this.domainFilePath           = "";
        }
Example #6
0
 /// <summary>
 /// Connects the specified source element.
 /// </summary>
 /// <param name="sourceElement">The source element.</param>
 /// <param name="targetElement">The target element.</param>
 internal static void Connect(Microsoft.VisualStudio.Modeling.ModelElement sourceElement, Microsoft.VisualStudio.Modeling.ModelElement targetElement)
 {
     if (CanAcceptSourceAndTarget(sourceElement, targetElement))
     {
         Entity source = (Entity)sourceElement;
         Entity target = (Entity)targetElement;
         new EntityHasSubClasses(source, target);
         source.SuperClass = target;
     }
 }
Example #7
0
        /// <summary>
        /// Merges the disconnect layer package.
        /// </summary>
        /// <param name="sourceElement">The source element.</param>
        private void MergeDisconnectLayerPackage(Microsoft.VisualStudio.Modeling.ModelElement sourceElement)
        {
            // Delete link for path ComponentHasLayerPackages.LayerPackages
            LayerPackage lp = sourceElement as LayerPackage;

            foreach (ElementLink link in global::DSLFactory.Candle.SystemModel.ComponentHasLayerPackages.GetLinks((global::DSLFactory.Candle.SystemModel.SoftwareComponent) this, (LayerPackage)sourceElement))
            {
                // Delete the link, but without possible delete propagation to the element since it's moving to a new location.
                link.Delete(global::DSLFactory.Candle.SystemModel.ComponentHasLayerPackages.ComponentDomainRoleId, global::DSLFactory.Candle.SystemModel.ComponentHasLayerPackages.LayerPackageDomainRoleId);
            }
        }
Example #8
0
 /// <summary>
 /// Determines whether this instance [can accept source and target] the specified source element.
 /// </summary>
 /// <param name="sourceElement">The source element.</param>
 /// <param name="targetElement">The target element.</param>
 /// <returns>
 ///     <c>true</c> if this instance [can accept source and target] the specified source element; otherwise, <c>false</c>.
 /// </returns>
 internal static bool CanAcceptSourceAndTarget(Microsoft.VisualStudio.Modeling.ModelElement sourceElement, Microsoft.VisualStudio.Modeling.ModelElement targetElement)
 {
     // On ne permet une connection que si il n'y en a pas.
     if (sourceElement is Entity)
     {
         if (targetElement is Entity)
         {
             return(EntityHasSubClasses.GetLinks((Entity)sourceElement, (Entity)targetElement).Count == 0);
         }
     }
     return(false);
 }
Example #9
0
        /// <summary>
        /// Merges the disconnect layer.
        /// </summary>
        /// <param name="sourceElement">The source element.</param>
        private void MergeDisconnectLayer(Microsoft.VisualStudio.Modeling.ModelElement sourceElement)
        {
            SoftwareLayer layer = sourceElement as SoftwareLayer;

            if (layer != null)
            {
                foreach (ElementLink link in SoftwareComponentHasLayers.GetLinks(this, layer))
                {
                    // Delete the link, but without possible delete propagation to the element since it's moving to a new location.
                    link.Delete(SoftwareComponentHasLayers.SoftwareComponentDomainRoleId, SoftwareComponentHasLayers.SoftwareLayerDomainRoleId);
                }
            }
        }
Example #10
0
        /// <summary>
        /// Lors de l'ajout d'un layer, on crée automatiquement le packageLayer qui le contient
        /// </summary>
        /// <param name="sourceElement">The source element.</param>
        /// <param name="elementGroup">The element group.</param>
        private void MergeRelateLayer(Microsoft.VisualStudio.Modeling.ModelElement sourceElement, Microsoft.VisualStudio.Modeling.ElementGroup elementGroup)
        {
            Layer sourceLayer = sourceElement as Layer;

            if (sourceLayer != null)
            {
                // Un Layer est toujours dans un LayerPackage
                if (this.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.IsSerializing || this.Store.InUndoRedoOrRollback)
                {
                    return;
                }

                // Recherche du package layer associé et si il n'existe pas on le crée
                LayerPackage parentPackage = null;
                foreach (LayerPackage package in this.LayerPackages)
                {
                    if (package.Level == sourceLayer.Level)
                    {
                        parentPackage = package;
                        break;
                    }
                }

                // Transaction pour forcer la création du package avant l'ajout du layer
                // cf LayerPackageInsertRule
                using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Add layer package"))
                {
                    if (parentPackage == null)
                    {
                        parentPackage       = new LayerPackage(this.Store);
                        parentPackage.Level = (short)sourceLayer.Level;
                        MergeRelateLayerPackage(parentPackage, null);
                    }

                    // Ajout
                    parentPackage.Layers.Add(sourceLayer);
                    transaction.Commit();
                }
            }

            this.Layers.Add(sourceElement as SoftwareLayer);
        }
Example #11
0
        /// <summary>
        /// A la création d'un package, on ajoute sa couche d'interface
        /// </summary>
        /// <param name="sourceElement">The source element.</param>
        /// <param name="elementGroup">The element group.</param>
        private void MergeRelateLayerPackage(Microsoft.VisualStudio.Modeling.ModelElement sourceElement, Microsoft.VisualStudio.Modeling.ElementGroup elementGroup)
        {
            // Ajout du package
            LayerPackage layerPackage = sourceElement as LayerPackage;

            this.LayerPackages.Add(layerPackage);

            if (this.Store.TransactionManager.CurrentTransaction.IsSerializing || this.Store.InUndoRedoOrRollback)
            {
                return;
            }

            // Recherche si il existe une couche d'interface de ce niveau
            short newLevel = (short)(layerPackage.Level + 1);

            // Pas d'interface pour la couche UI
            if (layerPackage.InterfaceLayer == null)  //&& layerPackage.Level != 100) // UIWorkflowLayer.Level
            {
                InterfaceLayer il = new InterfaceLayer(layerPackage.Store);
                il.Level = layerPackage.LayerLevel;
                layerPackage.InterfaceLayer = il;
                this.Layers.Add(il);
            }
        }
        /// <summary>
        /// Write all properties that need to be serialized as XML attributes.
        /// </summary>
        /// <param name="serializationContext">Serialization context.</param>
        /// <param name="element">LinkShape instance to be serialized.</param>
        /// <param name="writer">XmlWriter to write serialized data to.</param>
        protected override void WritePropertiesAsAttributes(Microsoft.VisualStudio.Modeling.SerializationContext serializationContext, Microsoft.VisualStudio.Modeling.ModelElement element, System.Xml.XmlWriter writer)
        {
            base.WritePropertiesAsAttributes(serializationContext, element, writer);

            LinkShape instanceOfLinkShape = element as LinkShape;

            global::System.Diagnostics.Debug.Assert(instanceOfLinkShape != null, "Expecting an instance of LinkShape");

            if (!serializationContext.Result.Failed)
            {
                string serializedPropValue = SerializationUtilities.GetString <Guid>(serializationContext, instanceOfLinkShape.SourceAnchor.FromShape.Id);
                DiagramsDSLSerializationHelper.Instance.WriteAttributeString(serializationContext, element, writer, "sourceShapeId", serializedPropValue);

                serializedPropValue = SerializationUtilities.GetString <Guid>(serializationContext, instanceOfLinkShape.TargetAnchor.ToShape.Id);
                DiagramsDSLSerializationHelper.Instance.WriteAttributeString(serializationContext, element, writer, "targetShapeId", serializedPropValue);
            }
        }
Example #13
0
 /// <summary>
 /// Determines whether this instance [can accept source] the specified source element.
 /// </summary>
 /// <param name="sourceElement">The source element.</param>
 /// <returns>
 ///     <c>true</c> if this instance [can accept source] the specified source element; otherwise, <c>false</c>.
 /// </returns>
 internal static bool CanAcceptSource(Microsoft.VisualStudio.Modeling.ModelElement sourceElement)
 {
     return(sourceElement is Entity);
 }
Example #14
0
 /// <summary>
 ///     Synchronize DSL Model with the value from modelElement.
 /// </summary>
 /// <param name="parentViewModel"></param>
 /// <param name="modelElement"></param>
 /// <returns></returns>
 internal abstract DslModeling.ModelElement SynchronizeSingleDslModelElement(
     DslModeling.ModelElement parentViewModel, EFObject modelElement);
        /// <summary>
        ///     This uses the XRef in our context to find the Model item that is the basis for
        ///     each DSL object in the selection collection.  For each Model item, we get the correct
        ///     item descriptor and create a new selection array of these.
        /// </summary>
        /// <param name="objects"></param>
        /// <returns></returns>
        private ArrayList ConvertDslModelElementArrayToItemDescriptors(object[] objects, bool gettingAllObjects)
        {
            // save off this reference
            var selectedDesignerObjects = objects;

            // create a new array to hold the item descriptors
            var selectedModelObjects           = new List <EFObject>();
            var selectedModelObjectDescriptors = new ArrayList();

            foreach (var o in selectedDesignerObjects)
            {
                DslModeling.ModelElement dslElem = null;
                var elemList = o as DslDiagrams.ElementListCompartment;
                var presElem = o as DslDiagrams.PresentationElement;
                if (elemList != null)
                {
                    // if the user selects a compartment element, we want to display the entity-type and the shape property.
                    if (elemList.IsNestedChild &&
                        elemList.ParentShape != null)
                    {
                        presElem = elemList.ParentShape;
                        dslElem  = presElem.ModelElement;
                    }
                    else
                    {
                        // they have selected one of the compartments, probably wanting to show
                        // the right-click context menu
                        continue;
                    }
                }
                else if (presElem != null)
                {
                    // if this is a shape, gets it corresponding DSL object
                    dslElem = presElem.ModelElement;
                }
                else
                {
                    // o is a non-shape
                    dslElem = o as DslModeling.ModelElement;
                }

                // there might be no ModelElement corresponding to the selected object
                if (dslElem != null)
                {
                    EFObject modelElem;
                    // If an EntityType is selected in DSL canvas, we want to show the property of the EntityTypeShape.
                    if (dslElem is EntityType &&
                        presElem != null)
                    {
                        modelElem = XRef.GetExisting(presElem);
                    }
                    else
                    {
                        modelElem = XRef.GetExisting(dslElem);
                    }
                    // model element might not be yet created
                    if (modelElem != null)
                    {
                        selectedModelObjects.Add(modelElem);
                        selectedModelObjectDescriptors.Add(PropertyWindowViewModel.GetObjectDescriptor(modelElem, Context, true));
                    }
                }
            }

            if (gettingAllObjects == false)
            {
                // update the selection for the Entity Designer in case anyone else is interested
                if (Context != null &&
                    Context.Items != null)
                {
                    Context.Items.SetValue(new EntityDesignerSelection(selectedModelObjects));
                }
            }

            return(selectedModelObjectDescriptors);
        }
Example #16
0
 internal DslModeling.ModelElement SynchronizeSingleDslModelElement(DslModeling.ModelElement parentViewModel, EFObject modelElement)
 {
     return(_translatorStrategy.SynchronizeSingleDslModelElement(parentViewModel, modelElement));
 }
        public override string CalculateQualifiedName(Microsoft.VisualStudio.Modeling.DomainXmlSerializerDirectory directory, Microsoft.VisualStudio.Modeling.ModelElement element)
        {
            if (directory == null)
            {
                throw new System.ArgumentNullException("directory");
            }
            if (element == null)
            {
                throw new System.ArgumentNullException("element");
            }
            PropertyGridEditor propertyGridEditor = element as PropertyGridEditor;
            string             s1 = this.GetMonikerQualifier(directory, propertyGridEditor);
            string             s2 = propertyGridEditor.Name;

            object[] objArr = new object[] {
                s1,
                s2
            };
            return(System.String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0}/{1}", objArr));
        }