Exemplo n.º 1
0
        public void AddChildren()
        {
            AddPSMChildrenMacroCommand c = (AddPSMChildrenMacroCommand)AddPSMChildrenMacroCommandFactory.Factory().Create(DiagramController);

            c.Set(Class);
            c.Execute();
        }
Exemplo n.º 2
0
        public override void Execute(object parameter)
        {
            PSM_Class psmClass           = (PSM_Class)ActiveDiagramView.SelectedItems.Single();
            AddPSMChildrenMacroCommand c = AddPSMChildrenMacroCommandFactory.Factory().Create(ActiveDiagramView.Controller) as AddPSMChildrenMacroCommand;

            c.Set(psmClass.ClassController.Class);
            if (c.Commands.Count > 0)
            {
                c.Execute();
            }
        }
Exemplo n.º 3
0
        //public void DrawPSMExample(int x, int y)
        //{
        //    PIM_Class clPurchase, clCustomer1, clCustomer2, clShop,
        //        clDealer, clItem, clAddress, clProduct, clRegion;
        //    XCaseAttributeContainer acCustomer1, acCustomer2,
        //        acAddress, acRegion, acProduct, acItem;
        //    XCaseAssociationChoice asc1, asc2;
        //    XCaseAssociationContainer ascoItems;
        //    List<string> prPurchase = new List<string>() { "date" },
        //        prShop = new List<string>() { "shop-number" },
        //        prDealer = new List<string>() { "dealer-number" },
        //        prProduct = new List<string>() { "product-number" },
        //        atCustomer1 = new List<string>() { "customer-number" },
        //        atCustomer2 = new List<string>() { "name", "email" },
        //        atAddress = new List<string>() { "street", "postcode", "city" },
        //        atRegion = new List<string>() { "name AS region" },
        //        atProduct = new List<string>() { "unit-price", "title" },
        //        atItem = new List<string>() { "amount" };

        //    clPurchase = AddClass("Purchase", null, "purchase", prPurchase, null, 364 + x, 65 + y);
        //    clCustomer1 = AddClass("Customer", null, null, null, null, 51 + x, 256 + y);
        //    clCustomer2 = AddClass("Customer", null, "new-customer", null, null, 172 + x, 239 + y);
        //    clShop = AddClass("Shop", null, "from-shop", prShop, null, 309 + x, 254 + y);
        //    clDealer = AddClass("Dealer", null, "from-dealer", prDealer, null, 430 + x, 229 + y);
        //    clItem = AddClass("Item", null, "item", null, null, 561 + x, 273 + y);
        //    clAddress = AddClass("Address", null, "delivery-address", null, null, 262 + x, 352 + y);
        //    clProduct = AddClass("Product", null, null, prProduct, null, 443 + x, 379 + y);
        //    clRegion = AddClass("Region", null, null, null, null, 344 + x, 460 + y);

        //    acCustomer1 = AddAttributeContainer(atCustomer1, 36 + x, 320 + y);
        //    acCustomer2 = AddAttributeContainer(atCustomer2, 153 + x, 332 + y);
        //    acAddress = AddAttributeContainer(atAddress, 193 + x, 434 + y);
        //    acRegion = AddAttributeContainer(atRegion, 353 + x, 515 + y);
        //    acProduct = AddAttributeContainer(atProduct, 468 + x, 455 + y);
        //    acItem = AddAttributeContainer(atItem, 586 + x, 364 + y);

        //    ascoItems = AddAssociationContainer("items", 532 + x, 147 + y);

        //    asc1 = AddAssociationChoice(150 + x, 150 + y);
        //    asc2 = AddAssociationChoice(395 + x, 150 + y);

        //    AddAssociation(clPurchase, asc1);
        //    AddAssociation(asc1, clCustomer1, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "buyer", "0..*", "1");
        //    AddAssociation(asc1, clCustomer2, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "buyer", "0..*", "1");
        //    AddAssociation(clCustomer1, acCustomer1);
        //    AddAssociation(clCustomer2, acCustomer2);
        //    AddAssociation(clCustomer2, clAddress, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "deliver to", "0..1", "0..1");
        //    AddAssociation(clAddress, acAddress);
        //    AddAssociation(clAddress, clRegion, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "in", "0..*", "1");
        //    AddAssociation(clRegion, acRegion);
        //    AddAssociation(clPurchase, asc2);
        //    AddAssociation(asc2, clShop, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "from shop", "0..*", "1");
        //    AddAssociation(asc2, clDealer, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "from dealer", "0..*", "1");
        //    AddAssociation(clPurchase, ascoItems);
        //    AddAssociation(ascoItems, clItem, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "<<ordered>>\ncontained in", "1", "1..*");
        //    AddAssociation(clItem, clProduct, EJunctionCapStyle.Straight, EJunctionCapStyle.FullArrow, "purchases", "0..*", "1");
        //    AddAssociation(clProduct, acProduct);
        //    AddAssociation(clItem, acItem);
        //}

        #endregion

        public void DrawPIMPSMExample()
        {
            // prepare simple PIM diagram to start with
            RepresentationCollection ModelViewMap = xCaseDrawComponent.Canvas.ElementRepresentations;
            CreationResult <Class, ClassViewHelper> classCreationResult = DiagramController.NewClass("Region", 100, 10);
            Class     clRegion     = classCreationResult.ModelElement;
            PIM_Class clRegionView = (PIM_Class)ModelViewMap[clRegion];

            classCreationResult = DiagramController.NewClass("Address", 35, 189);
            Class     clAddress     = classCreationResult.ModelElement;
            PIM_Class clAddressView = (PIM_Class)ModelViewMap[classCreationResult.ModelElement];

            Dictionary <PIM_Class, List <string> > properties = new Dictionary <PIM_Class, List <string> >();

            properties[clRegionView] = new List <string> {
                "name", "code"
            };
            properties[clAddressView] = new List <string> {
                "street", "postcode", "city"
            };

            foreach (KeyValuePair <PIM_Class, List <string> > keyValuePair in properties)
            {
                foreach (string attribute in keyValuePair.Value)
                {
                    keyValuePair.Key.ClassController.AddNewAttribute(attribute);
                }
            }

            CreationResult <Association, AssociationViewHelper> associationCreationResult = DiagramController.NewAssociation("in", (Class)clRegionView.ModelElement, (Class)clAddressView.ModelElement);
            PIM_Association aRegionAdress = (PIM_Association)ModelViewMap[associationCreationResult.ModelElement];

            aRegionAdress.Controller.ChangeMultiplicity(aRegionAdress.Ends[0], "1");
            aRegionAdress.Controller.ChangeMultiplicity(aRegionAdress.Ends[1], "0..*");

            // derive PSM diagram
            PSMClass psmRegion = clRegionView.ClassController.DerivePSMClassToNewDiagram();

            PanelWindow p = (PanelWindow)Manager.Documents.Last();
            XCaseCanvas psmDiagramView = p.xCaseDrawComponent.Canvas;
            //ManageAttributesMacroCommand c = (ManageAttributesMacroCommand)ManageAttributesMacroCommandFactory.Factory().Create(psmDiagramView.Controller);
            PSM_Class psmRegionView = (PSM_Class)psmDiagramView.ElementRepresentations[psmRegion];

            //((PSM_ClassController)psmRegionView.Controller).IncludeAttributes(new Dictionary<Property, string> { {clRegion.Attributes[0], "RegionName"}, {clRegion.Attributes[1], "RegionCode"} });

            ViewController.MoveElement(200, 20, psmRegionView.ViewHelper, DiagramController);

            // add an attribute container

            NewPSMAttributeContainerCommand attrib = (NewPSMAttributeContainerCommand)NewPSMAttributeContainerCommandFactory.Factory().Create(psmDiagramView.Controller);

            attrib.PSMAttributes.Add(psmRegion.PSMAttributes[0]);
            attrib.PSMClass   = psmRegion;
            attrib.ViewHelper = new PSMElementViewHelper(Diagram)
            {
                X = 100, Y = 100
            };
            attrib.Execute();

            NewPSMAttributeContainerCommand attrib2 = (NewPSMAttributeContainerCommand)NewPSMAttributeContainerCommandFactory.Factory().Create(psmDiagramView.Controller);

            attrib2.PSMAttributes.Add(psmRegion.PSMAttributes[0]);
            attrib2.PSMClass   = psmRegion;
            attrib2.ViewHelper = new PSMElementViewHelper(Diagram)
            {
                X = 280, Y = 100
            };
            attrib2.Execute();

            AddPSMChildrenMacroCommand command = (AddPSMChildrenMacroCommand)AddPSMChildrenMacroCommandFactory.Factory().Create(psmDiagramView.Controller);

            command.Set(psmRegion);
            command.Execute();
        }