Exemple #1
0
 public override void doRuleQuickFix(SQLMethod eaMethod, SQLRepository repository, int i)
 {
     if (i == 0)
     {
         eaMethod.getRealMethod().Name = Regex.Replace(eaMethod.Name, " ", "");
         eaMethod.getRealMethod().Update();
     }
 }
        /// <summary>
        /// creates an empty story diagram related to the given Method
        /// </summary>
        /// <param name="method"></param>
        /// <param name="repository"></param>
        /// <param name="currentDiagram"></param> The currently open diagram. An anchor will be added to this diagram.
        public static void createStoryDiagram(SQLMethod method, EA.Repository repository, EA.Diagram currentDiagram)
        {
            EA.Element    containingEClass = repository.GetElementByID(method.ParentID);
            SQLRepository sqlRepository    = new SQLRepository(repository, false);

            EA.Element sdmContainer = (EA.Element)(containingEClass.Elements.AddNew(method.Name, Main.EAClassType));
            sdmContainer.ParentID = containingEClass.ElementID;



            EA.Diagram sdmDiagram = (EA.Diagram)(sdmContainer.Diagrams.AddNew(method.Name + " Story Diagram", SdmDiagramMetatype[0]));
            sdmDiagram.ParentID      = sdmContainer.ElementID;
            sdmDiagram.ExtendedStyle = "HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=9;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=0;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=1;FormName=;";
            sdmDiagram.StyleEx       = sdmDiagram.StyleEx + "HideConnStereotype=0;";
            repository.SaveDiagram(sdmDiagram.DiagramID);
            sdmDiagram.Update();
            EA.Element startNode = (EA.Element)sdmContainer.Elements.AddNew(" Start", Main.EAStateNodeType);
            startNode.Subtype  = Main.EAStartNodeSubtype;
            startNode.ParentID = sdmContainer.ElementID;

            startNode.Name = SDMUtil.computeStartNodeName(sqlRepository.GetMethodByID(method.MethodID), sqlRepository.GetElementByID(containingEClass.ElementID));

            startNode.Update();
            EA.DiagramObject startNodeDiagramObject = (EA.DiagramObject)sdmDiagram.DiagramObjects.AddNew("l=50;r=70;t=50;b=70;", Main.EAStateNodeType);
            startNodeDiagramObject.ElementID = startNode.ElementID;
            startNodeDiagramObject.Update();


            method.getRealMethod().Update();
            sdmContainer.Update();

            Navigator.addAnchorEntry(sdmDiagram.DiagramID, currentDiagram.DiagramID);

            String objectStyleString = "StateNodeLBL=CX=437:CY=13:OX=-9:OY=-18:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;DUID=2B547EF9;LBL=CX=437:CY=13:OX=-6:OY=-17:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";

            repository.Execute("UPDATE t_diagramobjects SET ObjectStyle = '" + objectStyleString + "' WHERE Object_ID = " + startNodeDiagramObject.ElementID);

            repository.OpenDiagram(sdmDiagram.DiagramID);

            sdmContainer.Elements.Refresh();

            setAnchorElementTags(sqlRepository, currentDiagram, sqlRepository.GetElementByID(sdmContainer.ElementID));
            Activity activity = new Activity(sqlRepository.GetElementByID(sdmContainer.ElementID), sqlRepository);

            activity.OwningOperation = new ECOREModeling.ECOREExportWrapper.EOperation(sqlRepository.GetMethodByID(method.MethodID), sqlRepository);
            activity.saveTreeToEATaggedValue(true);

            StartNode startNodeObject = new StartNode(sqlRepository, sqlRepository.GetElementByID(startNode.ElementID));

            startNodeObject.saveTreeToEATaggedValue(true);
        }