Example #1
0
        public static DslModeling::ElementLink Connect(DslModeling::ModelElement source, DslModeling::ModelElement target)
        {
            if (source == null)
            {
                throw new global::System.ArgumentNullException("source");
            }
            if (target == null)
            {
                throw new global::System.ArgumentNullException("target");
            }

            if (CanAcceptSourceAndTarget(source, target))
            {
                if (target is ExternalComponent)
                {
                    if (source is DataLayer)
                    {
                        return(new DataLayerReferencesExternalComponent((DataLayer)source, (ExternalComponent)target));
                    }
                }

                // Enregistrement de la position initiale de l'élément initial pour aligner
                // les élements verticalement dans le cas d'une référence multicouches.
                IList <PresentationElement> shapes = null;
                // On privilégie la source
                if (source is ClassImplementation || source is ServiceContract)
                {
                    shapes = PresentationViewsSubject.GetPresentation(source);
                }
                else if (target is ClassImplementation || target is ServiceContract)
                {
                    shapes = PresentationViewsSubject.GetPresentation(target);
                }

                if (shapes != null && shapes.Count > 0)
                {
                    UnplacedModelHelper.RegisterInitialPosition(source.Store, ((NodeShape)shapes[0]).AbsoluteBoundingBox.X);
                }

                ElementLink link = CreateLink(source, target);
                if (link != null)
                {
                    return(link);
                }
            }

            global::System.Diagnostics.Debug.Fail("Having agreed that the connection can be accepted we should never fail to make one.");
            throw new global::System.InvalidOperationException();
        }
Example #2
0
        /// <summary>
        /// Création d'un nouveau contrat
        /// </summary>
        /// <param name="port">The port.</param>
        /// <param name="layer">The layer.</param>
        /// <returns></returns>
        private static ServiceContract CreateContract(CandleElement port, InterfaceLayer layer)
        {
            string name = StrategyManager.GetInstance(port.Store).NamingStrategy.CreateElementName(layer, port.RootName);

            // Vérification de l'existence
            foreach (ServiceContract sc in layer.ServiceContracts)
            {
                if (sc.Name == name)
                {
                    return(sc);
                }
            }

            // Sinon création avec copie des opérations
            ServiceContract contract = new ServiceContract(layer.Store);

            layer.ServiceContracts.Add(contract);
            contract.RootName = port.RootName;
            UnplacedModelHelper.RegisterNewModel(layer.Store, contract);

            TypeWithOperations copiedContract = null;

            if (port != null)
            {
                if (port is ServiceContract || port is ExternalServiceContract)
                {
                    copiedContract = port as TypeWithOperations;
                    contract.Name  = name;
                }
                else
                {
                    ClassImplementation clazz = port as ClassImplementation;
                    contract.Name = StrategyManager.GetInstance(clazz.Store).NamingStrategy.CreateElementName(layer, clazz.Name);
                    if (clazz.Contract != null)
                    {
                        copiedContract = clazz.Contract;
                    }
                    contract.Comment = clazz.Comment;
                }
            }

            if (copiedContract != null)
            {
                TypeWithOperations.CopyOperations(copiedContract, contract);
            }

            return(contract);
        }
Example #3
0
        /// <summary>
        /// Création d'une nouvelle classe
        /// </summary>
        /// <param name="elem">The elem.</param>
        /// <param name="layer">The layer.</param>
        /// <returns></returns>
        private static ClassImplementation CreateClass(CandleElement elem, Layer layer)
        {
            string name = StrategyManager.GetInstance(elem.Store).NamingStrategy.CreateElementName(layer, elem.RootName);

            // On regarde d'abord si il n'existe pas une classe du même nom
            foreach (ClassImplementation cl in layer.Classes)
            {
                if (cl.Name == name)
                {
                    return(cl);
                }
            }

            // Sinon création d'une nouvelle
            ClassImplementation clazz = new ClassImplementation(layer.Store);

            clazz.RootName = elem.RootName;
            clazz.Name     = name;
            clazz.Comment  = elem.Comment;
            layer.Classes.Add(clazz);

            UnplacedModelHelper.RegisterNewModel(layer.Store, clazz);
            return(clazz);
        }
Example #4
0
        /// <summary>
        /// Création d'un scenario
        /// </summary>
        /// <param name="elem">The elem.</param>
        /// <param name="layer">The layer.</param>
        /// <returns></returns>
        private static Scenario CreateScenario(CandleElement elem, UIWorkflowLayer layer)
        {
            string name = StrategyManager.GetInstance(elem.Store).NamingStrategy.CreateElementName(layer, elem.RootName);

            // On regarde d'abord si il n'existe pas une classe du même nom
            foreach (Scenario cl in layer.Scenarios)
            {
                if (cl.Name == name)
                {
                    return(cl);
                }
            }

            // Sinon création d'une nouvelle
            Scenario scenario = new Scenario(layer.Store);

            scenario.RootName = elem.RootName;
            scenario.Name     = name;
            scenario.Comment  = elem.Comment;
            layer.Scenarios.Add(scenario);

            UnplacedModelHelper.RegisterNewModel(layer.Store, scenario);
            return(scenario);
        }