/// <summary> /// Merges the relate interface layer. /// </summary> /// <param name="sourceElement">The source element.</param> /// <param name="elementGroup">The element group.</param> private void MergeRelateInterfaceLayer(ModelElement sourceElement, ElementGroup elementGroup) { InterfaceLayer iLayer = sourceElement as InterfaceLayer; InterfaceLayer = iLayer; iLayer.Level = LayerLevel; Component.Layers.Add(iLayer); }
/// <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); }
/// <summary> /// Creates the link. /// </summary> /// <param name="contract">The contract.</param> /// <param name="clazz">The clazz.</param> /// <returns></returns> private static ElementLink CreateLink(ServiceContract contract, ClassImplementation clazz) { // Le contrat est en dessous if (contract.Layer.Level < clazz.Layer.Level) { InterfaceLayer iLayer = GetDownestLayer(clazz.Layer, contract.Layer) as InterfaceLayer; if (iLayer == contract.Layer) { return(new ClassUsesOperations(clazz, contract)); } ServiceContract contract2 = CreateContract(contract, iLayer); new ClassUsesOperations(clazz, contract2); return(CreateLink(contract2, contract)); //// Sélection de l'opération //OperationSelectorDlg dlg = new OperationSelectorDlg(contract); //if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ // Operation op = dlg.SelectedOperation; // if (op != null) // { // ClassUsesOperations link = new ClassUsesOperations(clazz, contract); // link.Operation = op; // return link; // } //} //throw new CanceledByUser(); } // Le contrat est au dessus else { Layer nextLayer = GetDownestLayer(contract.Layer, clazz.Layer) as Layer; if (nextLayer == null) { return(null); } if (nextLayer == clazz.Layer) { // Si c'est la couche du dessous, on donne le bon nom à l'interface //contract.Name = StrategyManager.GetInstance(clazz.Store).NamingStrategy.CreateElementName(contract.Layer, clazz.Name); return(new Implementation(clazz, contract)); } ClassImplementation clazz2 = CreateClass(contract, nextLayer); return(CreateLink(clazz2, clazz)); } }
/// <summary> /// Creates the link. /// </summary> /// <param name="contract">The contract.</param> /// <param name="targetLayer">The target layer.</param> /// <returns></returns> private static ElementLink CreateLink(ServiceContract contract, SoftwareLayer targetLayer) { InterfaceLayer iLayer = targetLayer as InterfaceLayer; Layer layer = targetLayer as Layer; Debug.Assert(iLayer != null || layer != null); int layerLevel = 0; if (layer != null) { layerLevel = layer.Level; } else if (iLayer != null) { layerLevel = iLayer.Level; } // On descend if (contract.Layer.Level > layerLevel) { // Implémentation Layer downLayer = GetDownestLayer(contract.Layer, targetLayer) as Layer; Debug.Assert(downLayer != null); ClassImplementation impl = CreateClass(contract, downLayer); Implementation link = new Implementation(impl, contract); if (downLayer == targetLayer) { return(link); } return(CreateLink(impl, targetLayer)); } else { // On monte if (layer != null) { ClassImplementation impl = CreateClass(contract, layer); return(CreateLink(contract, impl)); } // Sinon la couche destinatrice est une couche d'interface ServiceContract contract2 = CreateContract(contract, iLayer); return(CreateLink(contract, contract2)); } }
/// <summary> /// Merges the disconnect interface layer. /// </summary> /// <param name="sourceElement">The source element.</param> private void MergeDisconnectInterfaceLayer(ModelElement sourceElement) { InterfaceLayer layer = sourceElement as InterfaceLayer; if (layer != null) { foreach (ElementLink link in LayerPackageReferencesInterfaceLayer.GetLinks(this, layer)) { // Delete the link, but without possible delete propagation to the element since it's moving to a new location. link.Delete(LayerPackageReferencesInterfaceLayer.InterfaceLayerDomainRoleId, LayerPackageReferencesInterfaceLayer.LayerPackageDomainRoleId); } foreach (ElementLink link in SoftwareComponentHasLayers.GetLinks(Component, 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); } } }
/// <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> /// Creates the link. /// </summary> /// <param name="clazz">The clazz.</param> /// <param name="layer">The layer.</param> /// <returns></returns> private static ElementLink CreateLink(ClassImplementation clazz, SoftwareLayer layer) { if (clazz.Layer.Level > ((ISortedLayer)layer).Level) { InterfaceLayer iLayer = (InterfaceLayer)GetDownestLayer(clazz.Layer, layer); ServiceContract contract = CreateContract(clazz, iLayer); ClassUsesOperations link = new ClassUsesOperations(clazz, contract); if (iLayer == layer) { return(link); } return(CreateLink(contract, layer)); } else // On monte { if (layer is InterfaceLayer) { ServiceContract contract = CreateContract(clazz, (InterfaceLayer)layer); return(CreateLink(contract, clazz)); } ClassImplementation clazz2 = CreateClass(clazz, (Layer)layer); return(CreateLink(clazz2, clazz)); } }
/// <summary> /// Gets the parent for interface layer. /// </summary> /// <param name="childElement">The child element.</param> /// <returns></returns> private Microsoft.VisualStudio.Modeling.ModelElement GetParentForInterfaceLayer(InterfaceLayer childElement) { return(childElement.Component); }