/// <summary> /// Gets next element associated to this element, by association type "dependency" /// </summary> /// <param name="element">Element</param> /// <param name="stereoTypeDependency">Stereotype</param> /// <returns>Next element</returns> public static T GetNext <T>(IUMLElement element, string stereoTypeDependency) where T : ActiveRecord <T>, new() { T item = new T(); TUPUX.Access.DataAccess dataAccess = new TUPUX.Access.DataAccess(); string key = element.Guid; StarUML.IUMLModelElement model = dataAccess.FindModel(key); try { if (model is StarUML.IUMLClassifier && model.GetClientDependencyCount() > 0) { for (int i = 0; i < model.GetClientDependencyCount(); i++) { StarUML.IUMLDependency depencency = model.GetClientDependencyAt(i); StarUML.IUMLClassifier prevModel = (StarUML.IUMLClassifier)depencency.Supplier; if (stereoTypeDependency.Equals(depencency.StereotypeName) && item.IsKindOf(prevModel.GetClassName(), prevModel.StereotypeName)) { item.Load(prevModel); return(item); } } } } catch (Exception ex) { log.Error("", ex); } return(null); }
/// <summary> /// Create a diagram using list of the phases and iterations /// </summary> /// <typeparam name="List">Type for the first list</typeparam> /// <typeparam name="T">Type for the first element</typeparam> /// <typeparam name="List2">Type second list</typeparam> /// <typeparam name="T2">Type for second element</typeparam> /// <param name="owner">Owner of the diagram</param> /// <param name="listPhases">Phases</param> /// <param name="listIterations">Iterations</param> /// <param name="fragmentName">File Name (ModelFragment)</param> /// <param name="diagramName">Diagram name included in the ModelFragment</param> public static void CreateDiagramPhaseIteration <List, T, List2, T2>(IUMLElement owner, List listPhases, List2 listIterations, string fragmentName, string diagramName) where T : ActiveRecord <T>, new() where T2 : ActiveRecord <T2>, new() where List : ActiveList <T, List>, new() where List2 : ActiveList <T2, List2>, new() { try { Dictionary <string, StarUML.IView> diagramElements = new Dictionary <string, StarUML.IView>(); StarUML.IUMLPackage folder = dataAccess.FindModel(owner.Guid) as StarUML.IUMLPackage; StarUML.IDiagram diagram = dataAccess.ImportModelFragment(fragmentName, folder, diagramName); if (diagram != null) { StarUML.IDiagramView diagramClassView = diagram.DiagramView; foreach (IUMLElement item in listPhases) { StarUML.IUMLPackage phase = dataAccess.FindModel(item.Guid) as StarUML.IUMLPackage; StarUML.IUMLPackageView view = dataAccess.Factory.CreatePackageView(diagramClassView, phase as StarUML.IUMLPackage); view.StereotypeDisplay = StarUML.UMLStereotypeDisplayKind.sdkIcon; diagramElements.Add(item.Guid, view); for (int i = 0; i < phase.GetAssociationCount(); i++) { StarUML.IUMLAssociationEnd end = phase.GetAssociationAt(i); StarUML.IUMLClass iteration = end.GetOtherSide().Participant as StarUML.IUMLClass; StarUML.IUMLClassView viewClass = null; if (diagramElements.ContainsKey(iteration.GetGuid())) { viewClass = (StarUML.IUMLClassView)diagramElements[iteration.GetGuid()]; } if (viewClass == null) { viewClass = dataAccess.Factory.CreateClassView(diagramClassView, iteration); viewClass.SuppressOperations = true; viewClass.SuppressAttributes = true; viewClass.StereotypeDisplay = StarUML.UMLStereotypeDisplayKind.sdkIcon; } if (!diagramElements.ContainsKey(iteration.GetGuid())) { diagramElements.Add(iteration.GetGuid(), viewClass); } dataAccess.Factory.CreateAssociationView(diagramClassView, end.Association, view, viewClass); } } foreach (IUMLElement item in listIterations) { StarUML.IUMLModelElement iteration = dataAccess.FindModel(item.Guid) as StarUML.IUMLModelElement; if (!diagramElements.ContainsKey(iteration.GetGuid())) { StarUML.IUMLClassView viewClass = dataAccess.Factory.CreateClassView(diagramClassView, iteration as StarUML.IUMLClass); viewClass.SuppressOperations = true; viewClass.SuppressAttributes = true; viewClass.StereotypeDisplay = StarUML.UMLStereotypeDisplayKind.sdkIcon; } for (int i = 0; i < iteration.GetClientDependencyCount(); i++) { StarUML.IUMLDependency dep = iteration.GetClientDependencyAt(i); StarUML.IUMLClass classAux = dep.Supplier as StarUML.IUMLClass; StarUML.IUMLClassView viewClass = null; if (diagramElements.ContainsKey(classAux.GetGuid())) { viewClass = (StarUML.IUMLClassView)diagramElements[classAux.GetGuid()]; } if (viewClass == null) { viewClass = dataAccess.Factory.CreateClassView(diagramClassView, classAux); viewClass.SuppressOperations = true; } if (!diagramElements.ContainsKey(classAux.GetGuid())) { diagramElements.Add(classAux.GetGuid(), viewClass); } dataAccess.Factory.CreateDependencyView(diagramClassView, dep, diagramElements[iteration.GetGuid()], viewClass); } } diagramClassView.LayoutDiagram(); } } catch (Exception ex) { log.Error("CreateDiagramPhaseIteration", ex); } }