示例#1
0
        public ClassData(ModuleData moduleData, XmlNode xmlNode)
        {
            Parent           = moduleData;
            AssociationClass = false;

            Inherit = null;

            ListOfGroups = new Dictionary <string, GroupData>();

            InDashBoard   = false;
            StateWorkflow = false;
            Process       = false;

            DashboardAction = new Dictionary <string, string>();

            if (xmlNode.Attributes["xmi:type"] != null)
            {
                if (xmlNode.Attributes["xmi:type"].Value.Equals("uml:Class"))
                {
                    Name = xmlNode.Attributes["name"].Value.ToLower();

                    ID = xmlNode.Attributes["xmi:idref"].Value;

                    Alias = (xmlNode["properties"].Attributes["alias"] != null) ? xmlNode["properties"].Attributes["alias"].Value : Utils.firstCharUpper(Name.Replace("_", " "));

                    Documentation = (xmlNode["properties"].Attributes["documentation"] != null) ? xmlNode["properties"].Attributes["documentation"].Value : null;
                    if (Documentation == null)
                    {
                        Documentation = Alias;
                    }

                    ListOfProperties = new List <PropertyData>();

                    PropertyData Identifiant = new PropertyData();
                    Identifiant.Name   = Name + "_id";
                    Identifiant.Typage = "integer";
                    Identifiant.Parent = this;

                    ListOfProperties.Add(Identifiant);

                    if (xmlNode["attributes"] != null)
                    {
                        foreach (XmlNode propXmlNode in xmlNode["attributes"].ChildNodes)
                        {
                            PropertyData propertyData = new PropertyData(this, propXmlNode);

                            ListOfProperties.Add(propertyData);
                        }
                    }

                    ListOfOperations = new Dictionary <string, OperationData>();
                    if (xmlNode["operations"] != null)
                    {
                        foreach (XmlNode opXmlNode in xmlNode["operations"].ChildNodes)
                        {
                            OperationData operationData = new OperationData(this, opXmlNode);

                            ListOfOperations.Add(operationData.Name, operationData);
                        }
                    }

                    ListOfLinks = new List <LinkData>();
                    if (xmlNode["links"] != null)
                    {
                        foreach (XmlNode lnkXmlNode in xmlNode["links"].ChildNodes)
                        {
                            LinkData linkData = new LinkData(this, lnkXmlNode);

                            ListOfLinks.Add(linkData);
                        }
                    }

                    ListOfConstraints = new Dictionary <string, string>();
                    if (xmlNode["constraints"] != null)
                    {
                        foreach (XmlNode constXmlNode in xmlNode["constraints"].ChildNodes)
                        {
                            ListOfConstraints.Add(constXmlNode.Attributes["name"].Value, constXmlNode.Attributes["description"].Value);
                        }
                    }


                    Columns = Utils.getExtra(xmlNode, "col", "6")[0];
                    if (ListOfProperties.Count < 3)
                    {
                        Columns = "4";
                        if (ListOfProperties.Count < 2)
                        {
                            Columns = "2";
                        }
                    }

                    DateStart = Utils.getExtra(xmlNode, "date_start", "")[0];
                    DateStop  = Utils.getExtra(xmlNode, "date_stop", "")[0];

                    GraphX = Utils.getExtra(xmlNode, "graphx", "")[0];
                    GraphY = Utils.getExtra(xmlNode, "graphy", "");

                    Code   = Utils.getExtra(xmlNode, "code", "")[0];
                    Target = Utils.getExtra(xmlNode, "target", "")[0];

                    FormId = Utils.getExtra(xmlNode, "formid", "")[0];
                    TreeId = Utils.getExtra(xmlNode, "treeid", "")[0];

                    ModuleName = Utils.getExtra(xmlNode, "module", moduleData.ModuleName)[0];

                    XpathForm    = Utils.getExtra(xmlNode, "xpathform", "/form")[0];
                    FormPosition = Utils.getExtra(xmlNode, "formpos", "inside")[0];
                    XpathTree    = Utils.getExtra(xmlNode, "xpathtree", "/tree")[0];
                    TreePosition = Utils.getExtra(xmlNode, "treepos", "inside")[0];

                    Accounting         = Utils.getExtra(xmlNode, "accounting", "")[0];
                    AccountingFunction = "";
                    AccountingArgs     = new List <string>();

                    if (!Accounting.Equals(""))
                    {
                        string[] func = Accounting.Split(new char[] { '(' });

                        AccountingFunction = func[0];

                        if (AccountingFunction.Equals("move"))
                        {
                            string[] args = func[1].Substring(0, func[1].Length - 1).Split(new char[] { ',' });
                            for (int i = 0; i < args.Length; i++)
                            {
                                AccountingArgs.Add(args[i].Trim());
                            }
                        }
                    }

                    Picture = "";

                    string mode = "";

                    if (!DateStart.Equals(""))
                    {
                        mode += ",calendar";
                    }

                    if (!GraphX.Equals(""))
                    {
                        mode += ",graph";
                    }



                    ListOfAction = new List <ActionData>();

                    ListOfAction.Add(new ActionData("action_" + Name, Alias, this, "view_" + Name + "_tree", "form,tree" + mode));

                    if (Target.ToLower().Trim().Equals("new"))
                    {
                        ListOfAction[0].Data["target"] = "new";
                    }

                    ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_tree", ViewKind.Tree, "1"));
                    ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_form", ViewKind.Form, "2"));

                    int seq = 3;

                    if (!DateStart.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_calendar", ViewKind.Calendar, seq.ToString()));
                        seq++;
                    }

                    if (!GraphX.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_graph", ViewKind.Graph, seq.ToString()));
                        seq++;
                    }

                    if (!Picture.Equals(""))
                    {
                        ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_kanban", ViewKind.Kanban, seq.ToString()));
                        seq++;
                    }


                    //ActionRapportData = new ActionData("action_rapport_" + Name, Alias, this, "", "form");
                    //ActionRapportData.Data["res_model"] = "rapport." + Parent.ClassicName + "." + Name;;
                    //ActionRapportData.Data["view_type"] = "form";
                    //ActionRapportData.Data["search_view_id"] = "view_rapport_" + Name + "_search";
                    //ActionRapportData.Data["context"] = "";

                    //ListOfAction.Add(ActionRapportData);

                    /*ListOfAction.Add(new ActionData(ListOfAction[0], this, "view_" + Name + "_gantt", ViewKind.Gantt, "4"));*/



                    ListOfView = new List <ViewData>();

                    ListOfView.Add(new ActData("view_" + Name, Alias, this, "form,tree"));

                    ListOfView.Add(new TreeData("view_" + Name + "_tree", ListOfAction[0], Alias, this, "1"));
                    ListOfView.Add(new FormData("view_" + Name + "_form", ListOfAction[0], Alias, this, "2"));

                    seq = 3;

                    if (!DateStart.Equals(""))
                    {
                        ListOfView.Add(new CalendarData("view_" + Name + "_calendar", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    if (!GraphX.Equals(""))
                    {
                        ListOfView.Add(new GraphData("view_" + Name + "_graph", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    if (!Picture.Equals(""))
                    {
                        ListOfView.Add(new KanbanData("view_" + Name + "_kanban", ListOfAction[0], Alias, this, seq.ToString()));
                        seq++;
                    }

                    /*ListOfView.Add(new GanttData((ActData)ListOfView[0], ListOfAction[0], Alias, this, "4"));*/

                    if (Inherit == null)
                    {
                        ListOfView.Add(new SearchData("view_" + Name + "_search", ListOfAction[0], Alias, this, seq.ToString()));
                    }

                    //SearchData searchRapportData = new SearchData("view_rapport_" + Name + "_search", actionRapportData, Alias, this, seq.ToString());

                    //ListOfView.Add(searchRapportData);
                    //seq++;

                    string dashboard = Utils.getExtra(xmlNode, "dashboard", "")[0];

                    if (!dashboard.Equals(""))
                    {
                        string[] dashboards = dashboard.Split(new char[] { ':' });
                        dashboard = dashboards[0].Trim();

                        string dashboard_position = "1";
                        if (dashboard.Length > 1)
                        {
                            dashboard_position = dashboards[1].Trim();
                        }

                        InDashBoard = true;

                        DashboardAction["id"]        = "action_dashboard_" + Name + "_" + dashboard;
                        DashboardAction["name"]      = Alias;
                        DashboardAction["res_model"] = Parent.ClassicName + "." + Name;
                        DashboardAction["view_type"] = "form";
                        DashboardAction["view_mode"] = "tree,form" + mode;// dashboard;
                        //DashboardAction["context"] = "{}";
                        DashboardAction["view_id"]  = "view_" + Name + "_" + dashboard;
                        DashboardAction["position"] = dashboard_position;
                        //DashboardAction["domain"] = "[]";
                    }


                    ListOfMenu = new List <MenuData>();
                    Menu       = Utils.getExtra(xmlNode, "menu", "")[0];

                    if (!Menu.Equals("false"))
                    {
                        string menuParent        = "default";
                        string menuRapportParent = "leftsubmenu_rapport_" + Parent.ClassicName;

                        if (!Menu.Equals(""))
                        {
                            string classicName = Utils.ClassicName(Menu);

                            if (!Parent.ListOfMenu.ContainsKey("leftmenu_" + classicName))
                            {
                                Parent.Menus += "\r\n\t\t" + "<menuitem name=\"" + Menu + "\" parent=\"menu_" + Parent.ClassicName + "\" id=\"leftmenu_" + classicName + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                                Parent.ListOfMenu["leftmenu_" + classicName] = "leftmenu_" + classicName;

                                Parent.menu_count++;

                                // ------------------------------

                                Parent.Menus += "\r\n\t\t" + "<menuitem name=\"" + Menu + "\" parent=\"leftmenu_rapport_" + Parent.ClassicName + "\" id=\"leftsubmenu_rapport_" + classicName + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                                Parent.ListOfMenu["leftsubmenu_rapport_" + classicName] = "leftsubmenu_rapport_" + classicName;

                                Parent.menu_count++;
                            }

                            menuParent        = "leftmenu_" + classicName;
                            menuRapportParent = "leftsubmenu_rapport_" + classicName;
                        }


                        string menu_name         = "leftmenu_" + Name;
                        string menu_rapport_name = "leftsubmenu_rapport_" + Name;

                        if (Parent.ListOfMenu.ContainsKey(menu_name))
                        {
                            Random rnd = new Random(DateTime.Now.Second);
                            menu_name += "_" + rnd.Next(1000, 9999).ToString();
                        }

                        if (Parent.ListOfMenu.ContainsKey(menu_rapport_name))
                        {
                            Random rnd = new Random(DateTime.Now.Second);
                            menu_rapport_name += "_" + rnd.Next(1000, 9999).ToString();
                        }

                        ListOfMenu.Add(new MenuData(menu_name, Alias, Parent.ListOfMenu[menuParent], "action_" + Name, this));
                        MenuRapport = "\t\t" + "<menuitem name=\"" + Alias + "\" parent=\"" + menuRapportParent + "\" id=\"" + menu_name + "_rapport\" action=\"action_rapport_" + Name + "\" sequence=\"" + Parent.menu_count.ToString() + "\"/>";

                        Parent.menu_count++;
                    }
                }
            }
        }
示例#2
0
        void dg_Area_VertexSelectedForED(object sender, GraphX.Models.VertexSelectedEventArgs args)
        {
            if (_isInEDMode)
            {
                if (_edVertex == null) //select starting vertex
                {
                    _edVertex = args.VertexControl;
                    _edFakeDV = new DataVertex() { ID = -666 };
                    _edGeo = new PathGeometry(new PathFigureCollection() { new PathFigure() { IsClosed = false, StartPoint = _edVertex.GetPosition(), Segments = new PathSegmentCollection() { new PolyLineSegment(new List<Point>() { new Point() }, true) } } });
                    var dedge = new DataEdge(_edVertex.Vertex as DataVertex, _edFakeDV);
                    _edEdge = new EdgeControl(_edVertex, null, dedge) { ManualDrawing = true };
                    dg_Area.AddEdge(dedge, _edEdge);
                    dg_Area.LogicCore.Graph.AddVertex(_edFakeDV);
                    dg_Area.LogicCore.Graph.AddEdge(dedge);
                    _edEdge.SetEdgePathManually(_edGeo);
                }
                else if (_edVertex != args.VertexControl) //finish draw
                {
                    _edEdge.Target = args.VertexControl;
                    var dedge = _edEdge.Edge as DataEdge;
                    dedge.Target = args.VertexControl.Vertex as DataVertex;
                    var fig = _edGeo.Figures[0];
                    var seg = fig.Segments[_edGeo.Figures[0].Segments.Count - 1] as PolyLineSegment;

                    if (seg.Points.Count > 0)
                    {
                        var targetPos = _edEdge.Target.GetPosition();
                        var sourcePos = _edEdge.Source.GetPosition();
                        //get the size of the source
                        var sourceSize = new Size()
                        {
                            Width = _edEdge.Source.ActualWidth,
                            Height = _edEdge.Source.ActualHeight
                        };
                        var targetSize = new Size()
                        {
                            Width = _edEdge.Target.ActualWidth,
                            Height = _edEdge.Target.ActualHeight
                        };

                        var src_start = seg.Points.Count == 0 ? fig.StartPoint : seg.Points[0];
                        var src_end = seg.Points.Count > 1 ? (seg.Points[seg.Points.Count - 1] == targetPos ? seg.Points[seg.Points.Count - 2] : seg.Points[seg.Points.Count - 1]) : fig.StartPoint;
                        Point p1 = GeometryHelper.GetEdgeEndpoint(sourcePos, new Rect(sourceSize), src_start, _edEdge.Source.MathShape);
                        Point p2 = GeometryHelper.GetEdgeEndpoint(targetPos, new Rect(targetSize), src_end, _edEdge.Target.MathShape);

                        fig.StartPoint = p1;
                        if (seg.Points.Count > 1)
                            seg.Points[seg.Points.Count - 1] = p2;
                    }
                    GeometryHelper.TryFreeze(_edGeo);
                    _edEdge.SetEdgePathManually(new PathGeometry(_edGeo.Figures));
                    _isInEDMode = false;
                    clearEdgeDrawing();
                }
            }
        }