Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a diagram using list of the collaborations and files
        /// </summary>
        /// <typeparam name="List">Type for the first list</typeparam>
        /// <typeparam name="T">Type for the first element</typeparam>
        /// <typeparam name="List2">Type for second list</typeparam>
        /// <typeparam name="T2">Type for second element</typeparam>
        /// <param name="owner">Owner of the diagram</param>
        /// <param name="listCollaboration">Collaboration</param>
        /// <param name="listFile">Files</param>
        /// <param name="fragmentName">File Name (ModelFragment)</param>
        /// <param name="diagramName">Diagram name included in the ModelFragment</param>
        public static void CreateDiagramCollaborationFiles <List, T, List2, T2>(IUMLElement owner, List listCollaboration, List2 listFile, 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 diagramUseView = diagram.DiagramView;

                    foreach (IUMLElement item in listCollaboration)
                    {
                        StarUML.IUMLCollaboration collaboration = dataAccess.FindModel(item.Guid) as StarUML.IUMLCollaboration;
                        if (collaboration != null)
                        {
                            StarUML.IUMLCollaborationView view = dataAccess.Factory.CreateCollaborationView(diagramUseView, collaboration);
                            diagramElements.Add(item.Guid, view);
                            for (int i = 0; i < collaboration.GetClientDependencyCount(); i++)
                            {
                                StarUML.IUMLDependency dep       = collaboration.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(diagramUseView, classAux);
                                    viewClass.SuppressOperations = true;
                                }

                                if (!diagramElements.ContainsKey(classAux.GetGuid()))
                                {
                                    diagramElements.Add(classAux.GetGuid(), viewClass);
                                }

                                dataAccess.Factory.CreateDependencyView(diagramUseView, dep, view, viewClass);
                            }
                        }
                    }

                    foreach (IUMLElement item in listFile)
                    {
                        StarUML.IUMLModelElement file = dataAccess.FindModel(item.Guid) as StarUML.IUMLModelElement;
                        if (!diagramElements.ContainsKey(file.GetGuid()))
                        {
                            StarUML.IUMLClassView viewClass = dataAccess.Factory.CreateClassView(diagramUseView, file as StarUML.IUMLClass);
                            viewClass.SuppressOperations = true;
                        }
                    }
                    diagramUseView.LayoutDiagram();
                }
            }
            catch (Exception ex)
            {
                log.Error("CreateDiagramCollaborationFiles", ex);
            }
        }