Beispiel #1
0
        /// <summary>
        /// Recherche de la couche immédiatement en dessous
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <param name="potentialLayer">The potential layer.</param>
        /// <returns></returns>
        private static SoftwareLayer GetDownestLayer(SoftwareLayer layer, SoftwareLayer potentialLayer)
        {
            // Recherche du layerPackage en dessous
            if (layer is InterfaceLayer)
            {
                LayerPackage layerPackage = null;
                foreach (LayerPackage lp in layer.SoftwareComponent.LayerPackages)
                {
                    if (lp.Level < ((InterfaceLayer)layer).Level)
                    {
                        if (layerPackage == null || layerPackage.Level < lp.Level)
                        {
                            layerPackage = lp;
                        }
                    }
                }

                if (layerPackage != null)
                {
                    List <SoftwareLayer> layers = new List <SoftwareLayer>();
                    foreach (SoftwareLayer sl in layerPackage.Layers)
                    {
                        layers.Add(sl);
                    }
                    // TODO a voir - On retourne tjs le 1er layer
                    if (layers.Count == 0)
                    {
                        return(null);
                    }
                    foreach (SoftwareLayer sl in layers)
                    {
                        if (sl == potentialLayer)
                        {
                            return(potentialLayer);
                        }
                    }
                    return(layers[0]);
                }
            }
            else
            {
                // Recherche de la couche d'interface
                ISortedLayer theLayer = null;
                foreach (AbstractLayer al in layer.SoftwareComponent.Layers)
                {
                    ISortedLayer sl = al as ISortedLayer;
                    if (sl != null && sl.Level < ((Layer)layer).Level)
                    {
                        if (theLayer == null || theLayer.Level < sl.Level)
                        {
                            theLayer = sl;
                        }
                    }
                }

                return(theLayer as SoftwareLayer);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// TIPS Affectation d'un parent graphique diffèrent que le parent du modèle à un enfant
        /// </summary>
        /// <param name="childShape">The child shape.</param>
        /// <returns>The parent shape for the child shape.</returns>
        public override ShapeElement ChooseParentShape(ShapeElement childShape)
        {
            // Les layers apparaissent graphiquement dans un PackageLayer mais leur père reste
            // le composant
            if (childShape.ModelElement is Layer)
            {
                // Recherche du shape du layerPackage
                LayerPackage package = ((Layer)childShape.ModelElement).LayerPackage;
                if (package != null)
                {
                    IList <PresentationElement> shapes = PresentationViewsSubject.GetPresentation(package);
                    if (shapes.Count > 0)
                    {
                        NodeShape parentShape = (NodeShape)shapes[0];
                        return(parentShape);
                    }
                }
            }

            if (childShape.ModelElement is DataLayer)
            {
                CandleModel model = ((DataLayer)childShape.ModelElement).Component.Model;
                if (model != null)
                {
                    IList <PresentationElement> shapes = PresentationViewsSubject.GetPresentation(model);
                    if (shapes.Count > 0)
                    {
                        NodeShape parentShape = (NodeShape)shapes[0];
                        return(parentShape);
                    }
                }
            }

            return(base.ChooseParentShape(childShape));
        }
        /// <summary>
        /// Determines whether this instance [can accept layer package and layer as source and target] the specified source layer package.
        /// </summary>
        /// <param name="sourceLayerPackage">The source layer package.</param>
        /// <param name="targetLayer">The target layer.</param>
        /// <returns>
        ///     <c>true</c> if this instance [can accept layer package and layer as source and target] the specified source layer package; otherwise, <c>false</c>.
        /// </returns>
        private static bool CanAcceptLayerPackageAndLayerAsSourceAndTarget(LayerPackage sourceLayerPackage, Layer targetLayer)
        {
            ISortedLayer sl = targetLayer as ISortedLayer;

            if (sl == null)
            {
                return(false);
            }
            return(sourceLayerPackage.Level == sl.Level);
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Alerts listeners when the shape is dragged and dropped.
 /// </summary>
 /// <param name="e">The diagram drag event arguments.</param>
 public override void OnDragDrop(DiagramDragEventArgs e)
 {
     base.OnDragDrop(e);
     if (e.Data.GetDataPresent("CF_VSREFPROJECTS"))
     {
         LayerPackage package = ModelElement as LayerPackage;
         if (package != null)
         {
             ImportProjectHelper.Import(e.Data.GetData("CF_VSREFPROJECTS"), package.Component, package);
         }
     }
 }
Beispiel #6
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);
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
 /// <summary>
 /// Gets the parent for layer package.
 /// </summary>
 /// <param name="layerPackage">The layer package.</param>
 /// <returns></returns>
 private Microsoft.VisualStudio.Modeling.ModelElement GetParentForLayerPackage(LayerPackage layerPackage)
 {
     return(layerPackage.Component);
 }