Beispiel #1
0
        private static void printCSPConstraintObject(EA.Element child, EA.Diagram diagram, EA.Repository repository, List <Point> usedPoints)
        {
            SQLRepository     sqlRep = new SQLRepository(repository, false);
            TGGObjectVariable ov     = new TGGObjectVariable(sqlRep.GetElementByID(child.ElementID), sqlRep);

            ov.loadTreeFromTaggedValue();

            int x = 4;
            int y = 1;


            while (usedPoints.Contains(new Point(x, y)))
            {
                y++;
            }

            EA.DiagramObject diagObject = diagram.DiagramObjects.AddNew("", "") as EA.DiagramObject;
            diagObject.ElementID = child.ElementID;
            diagObject.left      = x * 200;
            diagObject.right     = diagObject.left + 125;
            diagObject.top       = y * -100;
            diagObject.bottom    = diagObject.top - 50;
            diagObject.Update();
            usedPoints.Add(new Point(x, y));
        }
Beispiel #2
0
        //------- Bookmark ----------------------------//


        void btnBookmarkAdd_Click(object sender, EventArgs e)
        {
            EA.ObjectType ot = _repository.GetContextItemType();
            string        guid;

            switch (ot)
            {
            case EA.ObjectType.otDiagram:
                EA.Diagram dia = (EA.Diagram)_repository.GetContextObject();
                guid = dia.DiagramGUID;
                _historyList.Add(ot, guid);
                break;

            case EA.ObjectType.otPackage:
                EA.Package pkg = (EA.Package)_repository.GetContextObject();
                guid = pkg.PackageGUID;
                _historyList.Add(ot, guid);
                break;

            case EA.ObjectType.otElement:
                EA.Element el = (EA.Element)_repository.GetContextObject();
                guid = el.ElementGUID;
                _historyList.Add(ot, guid);
                break;
            }
        }
Beispiel #3
0
        private ExecResult <Boolean> Test3()
        {
            ExecResult <Boolean> result = new ExecResult <bool>();

            try
            {
                EA.Diagram diagram = Context.EARepository.GetCurrentDiagram();

                foreach (EA.DiagramLink curDL in diagram.DiagramLinks)
                {
                    EA.Connector connector = Context.EARepository.GetConnectorByID(curDL.ConnectorID);
                    foreach (EA.ConnectorTag connectorTag in connector.TaggedValues)
                    {
                        if (connectorTag.Name == "DP_Link")
                        {
                            connectorTag.Name = DAConst.DP_LinkTypeTag;
                            connectorTag.Update();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.setException(ex);
            }

            return(result);
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Enabled = false;
            Close();

            string maxFile  = textBox1.Text;
            string schFile  = textBox2.Text;
            string svrlFile = textBox3.Text;

            // Update Package SchematronFile
            EA.TaggedValue tvSchematronFile = GetSchematronTaggedValue(repository);
            tvSchematronFile.Value = schFile;
            tvSchematronFile.Update();

            // Create MAX file
            MAX_EA.MAXExporter3 exporter = new MAX_EA.MAXExporter3();
            EA.ObjectType       type     = repository.GetTreeSelectedItemType();
            if (type == EA.ObjectType.otPackage)
            {
                EA.Package package = repository.GetTreeSelectedPackage();
                exporter.exportPackage(repository, package, maxFile);
            }
            else if (type == EA.ObjectType.otDiagram)
            {
                EA.Diagram diagram = (EA.Diagram)repository.GetTreeSelectedObject();
                exporter.exportDiagram(repository, diagram, maxFile);
            }

            // Execute Transform
            issues = new MAXValidator().validate(repository, maxFile, schFile, svrlFile);
        }
        /// <summary>
        /// Publishes the selected diagram to confluence
        /// </summary>
        /// <param name="Repository"></param>
        /// <param name="diag"></param>
        private void PublishAction(EA.Repository Repository, EA.Diagram diag)
        {
            if (diag != null)
            {
                Repository.OpenDiagram(diag.DiagramID);
                string filename = Path.Combine(Path.GetTempPath(), diag.Name + ".png");
                Repository.GetProjectInterface().SaveDiagramImageToFile(filename);

                string notes       = diag.Notes;
                var    publishedTo = GetPublishUrls(notes);

                Tuple <string, string> upwd = CredentialService.GetCredentials(); // Username,Password
                var frm = new Publish();
                frm.SetPublishUrls(publishedTo);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    string selected = frm.SelectedUrl;
                    if (selected == Publish.REFRESH_ALL)
                    {
                        foreach (var puburl in publishedTo)
                        {
                            ConfluenceUploadService.Publish(upwd.Item1, upwd.Item2, puburl, filename);
                        }
                    }
                    else if (selected.StartsWith("http"))
                    {
                        ConfluenceUploadService.Publish(upwd.Item1, upwd.Item2, frm.SelectedUrl, filename);
                    }
                }
            }
        }
Beispiel #6
0
        private static void linkToParent(EA.Repository Repository, EA.Diagram diagram, EA.Element sample, EA.Element parent)
        {
            foreach (EA.Connector con in sample.Connectors)
            {
                logger.log("Connector:" + con.SupplierEnd.Role);
                EA.Element related = null;

                if (sample.ElementID == con.ClientID && parent.ElementID == con.SupplierID)
                {
                    logger.log("Found parent link");
                    return;
                }
                else if (sample.ElementID == con.SupplierID && parent.ElementID == con.ClientID)
                {
                    logger.log("Found parent link");
                    return;
                }
            }

            logger.log("No  parent link found");
            EA.Connector link = sample.Connectors.AddNew("", "Association");
            link.SupplierID = parent.ElementID;
            link.Update();

            EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
            dl.ConnectorID = link.ConnectorID;
            sample.Connectors.Refresh();
            dl.Update();
        }
        public void TestExportClassWithFirstClassAttribute()
        {
            EAMetaModel meta = new EAMetaModel();

            APIModel.createAPI_AttributesFirstClass(meta);
            meta.setupSchemaPackage();

            //Test
            JSchema jschema = SchemaManager.schemaToJsonSchema(EARepository.Repository, EARepository.currentDiagram).Value;

            {
                JSchema child = jschema.Properties["propClass"];
                Assert.AreEqual(JSchemaType.String, child.Type);
            }
            {
                JSchema child = jschema.Properties["propertyClass2"];
                Assert.AreEqual(JSchemaType.String, child.Type);
            }


            EA.Package package = SchemaManager.generateSample(EARepository.Repository);
            object     o       = package.Diagrams.GetAt(0);

            EA.Diagram diaObj = (EA.Diagram)o;

            IList <EA.Element> objects = MetaDataManager.diagramSamples(EARepository.Repository, diaObj);

            Assert.AreEqual(1 + 1, objects.Count);
        }
Beispiel #8
0
        private int AddUCComponentToDiagram(EA.Package eAMainPackage, EA.Diagram diagram, int iElementID)
        {
            int iTopOffset         = 10;
            int iHeightOneStep     = 200;
            int iSpaceBetweenSteps = 20;

            int iL = 100;
            int iR = 200;
            int iT = iTopOffset + (iHeightOneStep * m_NoUseCaseComponents) + iSpaceBetweenSteps;
            int iB = iTopOffset + (iHeightOneStep * (m_NoUseCaseComponents + 1));

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.DiagramObject diagramObj = diagram.DiagramObjects.AddNew(strPos, "");
            if (diagramObj == null)
            {
                //EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(1);
            }

            diagramObj.ElementID = iElementID;
            diagramObj.Update();
            diagram.DiagramObjects.Refresh();
            eAMainPackage.Diagrams.Refresh();
            diagram.Update();

            m_NoUseCaseComponents++;

            return(0);
        }
Beispiel #9
0
        private static void printTGGOvObject(SQLElement child, EA.Diagram diagram, EA.Repository repository, List <Point> usedPoints)
        {
            TGGObjectVariable ov = new TGGObjectVariable(child, new SQLRepository(repository, false));

            ov.loadTreeFromTaggedValue();

            int x = 1;
            int y = 1;

            if (ov.domain == DomainType.TARGET)
            {
                x = 3;
            }

            while (usedPoints.Contains(new Point(x, y)))
            {
                y++;
            }

            EA.DiagramObject diagObject = diagram.DiagramObjects.AddNew("", "") as EA.DiagramObject;
            diagObject.ElementID = child.ElementID;
            diagObject.left      = x * 200;
            diagObject.right     = diagObject.left + 125;
            diagObject.top       = y * -100;
            diagObject.bottom    = diagObject.top - 50;
            diagObject.Update();
            usedPoints.Add(new Point(x, y));
        }
Beispiel #10
0
        private static int markElementOnDiagram(SQLElement element, SQLRepository repository)
        {
            EA.Element       realElement     = element.getRealElement();
            EA.DiagramObject diagramObject   = null;
            String           diagramIdResult = repository.SQLQuery("select * from t_diagramobjects where t_diagramobjects.Object_ID = " + realElement.ElementID);
            int    count     = 0;
            String diagramID = EAEcoreAddin.Util.EAUtil.getXMLNodeContentFromSQLQueryString(diagramIdResult, "Diagram_ID")[0];

            if (diagramID != "")
            {
                count = EAEcoreAddin.Util.EAUtil.getXMLNodeContentFromSQLQueryString(diagramIdResult, "Diagram_ID").Count;

                EA.Diagram diagram = repository.GetOriginalRepository().GetDiagramByID(int.Parse(diagramID));
                foreach (EA.DiagramObject diagObject in diagram.DiagramObjects)
                {
                    if (diagObject.ElementID == realElement.ElementID)
                    {
                        diagramObject = diagObject;
                    }
                }
                if (diagramObject != null)
                {
                    repository.OpenDiagram(diagram.DiagramID);

                    diagram.SelectedObjects.AddNew(diagramObject.ElementID.ToString(), "");

                    // repository.ReloadDiagram(diagram.DiagramID);
                }
            }
            return(count);
        }
Beispiel #11
0
        public bool exportDiagram(EA.Repository Repository, EA.Diagram diagram, string fileName)
        {
            this.Repository = Repository;
            progress_max    = 1;
            progress.Show();
            progress.setup(progress_max);

            Repository.EnableCache = true;
            // Add/update export metadata to the model
            ModelType model = new ModelType();

            model.exportDate = DateTime.Now.ToString();

            // Now export selected package
            objects       = new List <ObjectType>();
            relationships = new List <RelationshipType>();
            visitDiagramObjects(diagram.DiagramID);

            model.objects       = objects.ToArray();
            model.relationships = relationships.ToArray();
            progress.Close();

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent       = true;
            settings.NewLineChars = "\n";
            XmlSerializer serializer = new XmlSerializer(typeof(ModelType));

            using (XmlWriter writer = XmlWriter.Create(fileName, settings))
            {
                serializer.Serialize(writer, model);
            }
            return(issues);
        }
        private int AddConnector(EA.Diagram diagram, EA.Element eaElSource, EA.Element eaElDest, string strText, string strControlType, string strPath = "")
        {
            string strLogInfo = "Connector for operation: " + strText;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Connector eConnector = eaElSource.Connectors.AddNew(strText, strControlType);
            if (eConnector == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            // eConnector.Notes = strNotes;
            eConnector.SupplierID = eaElDest.ElementID;
            eConnector.Width      = 2;
            eConnector.Update();

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strText, strControlType);
            if (eDiagramLink == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            if (strPath != "")
            {
                eDiagramLink.Path = strPath;
            }
            eDiagramLink.Update();

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(0);
        }
        private EA.Element AddDataObjectToSwimlane(EA.Diagram diagram, EA.Package thePackage, string strInfoExchanged, string strActorName)
        {
            string strLogInfo = "Actor: " + strActorName + " info: " + strInfoExchanged;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName];

            int iL = (iActivityHorizDistBetweenActivities * (m_NoActivities - 1)) + iActivityHorizOffset;
            int iR = iL + iActivityWidth;
            int iT = (((oSwimlane.m_iB - oSwimlane.m_iT) / 2) + oSwimlane.m_iT) - (iActivityHeight / 2);
            int iB = iT + iActivityHeight;

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.Element eElObj = AddDataObject(diagram, thePackage, strInfoExchanged, strActorName, strPos);
            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "Could not add actor \"" + strActorName + "\" info \"" + strInfoExchanged + "\" to activity diagram");
                return(null);
            }

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);

            return(eElObj);
        }
        static public void exportDiagram(EA.Repository Repository, EA.Diagram diagram)
        {
            string confluencedata = null;

            //if (diagram.Version != "1.0")
            //{
            //    confluencedata = diagram.Version;
            //}
            //else
            {
                confluencedata = diagram.Notes;
            }
            if (confluencedata == null || confluencedata.Length == 0)
            {
                //logger.log("Diagram ["+diagram.Name+"] notes field does not specify a <confluence page name>. Default to CanonicalDataModel");
                //confluencedata = "CanonicalDataModel";
                return;
            }

            {
                char[]   delimiter = { ',' };
                string[] pages     = confluencedata.Split(delimiter);
                foreach (string page in pages)
                {
                    string fullpath = fileManager.diagramPath(page, diagram.Name);
                    logger.log(fullpath);
                    SVGExport.EAPlugin.SaveDiagramAsSvg(Repository, diagram, fullpath);
                }
            }
        }
        public void TestExportPopulation()
        {
            EAMetaModel meta = new EAMetaModel().setupPopulationPackage();

            EAFactory rootClass = EAModel.createPopulation(meta);

            meta.setupPopulationPackage();
            EA.Package package = EARepository.currentPackage;


            Assert.AreEqual(1, package.Diagrams.Count);

            object o = package.Diagrams.GetAt(0);

            EA.Diagram diagram = (EA.Diagram)o;

            Assert.AreEqual(2, package.Elements.Count);

            DiagramCache diagramCache = new DiagramCache();

            //Test
            RepositoryHelper.createDiagramCache(EARepository.Repository, diagram, diagramCache);
            JArray jobject = (JArray)PopulationManager.sampleToJObject(EARepository.Repository, diagram, diagramCache)["json"];

            Assert.AreEqual(1, jobject.Count);
        }
Beispiel #16
0
        /// <summary>
        /// adds a package with the given Stereotype as a Subpackage to the given package
        /// </summary>
        /// <param name="package">The package, which is the parent of the newly created package</param>
        /// <param name="cStereotype">The stereotype of which the newly created package should be type of</param>
        /// <param name="name">The name of the package to add</param>
        ///
        internal EA.Package addViewPackage(EA.Package package, UMM cStereotype, String name, EA_Element diagramType)
        {
            // at first add the new package to the parent package
            EA.Package childPackage = (EA.Package)package.Packages.AddNew(name, "");
            childPackage.Update();
            childPackage = this.populateUMMView(childPackage, cStereotype);

            /* also add the child package to the package diagram contained in the parent
             * package, if wanted. if the package diagram doenst exist than create it */


            EA.Diagram packageDiagram = (EA.Diagram)childPackage.Diagrams.AddNew(childPackage.Name, diagramType.ToString());
            packageDiagram.ShowDetails = 0;
            packageDiagram.Update();


            /* now add the child package to the package diagram of the parent */
            EA.Collection    diagramObjects = packageDiagram.DiagramObjects;
            EA.DiagramObject diagramObject  = (EA.DiagramObject)diagramObjects.AddNew("l=200;r=400;t=200;b=600;", "");
            diagramObject.ElementID = childPackage.Element.ElementID;
            diagramObject.Update();

            repository.RefreshModelView(package.PackageID);
            return(childPackage);
        }
        public override void doEaGuiStuff()
        {
            base.doEaGuiStuff();
            EA.Element realElement = ActivityNodeEAElement.getRealElement();
            if (StatementExpression == null)
            {
                realElement.Notes = "";
                realElement.Update();
            }
            else
            {
                realElement.Notes = StatementExpression.ToString();
                //diagramObject.right = diagramObject.left + 20 + longestConstraint * 5;

                foreach (String id in EAUtil.getDiagramIDsOfObject(ActivityNodeEAElement, Repository))
                {
                    if (id != "")
                    {
                        EA.Diagram currentDiagram = Repository.GetOriginalRepository().GetDiagramByID(int.Parse(id));
                        if (currentDiagram != null)
                        {
                            EA.DiagramObject diagramObject = EAEcoreAddin.Util.EAUtil.findDiagramObject(Repository, realElement, currentDiagram);
                            if (diagramObject != null)
                            {
                                diagramObject.right  = diagramObject.left + 20 + StatementExpression.ToString().Length * 5;
                                diagramObject.bottom = diagramObject.top - 80;
                                diagramObject.Update();
                            }
                        }
                    }
                }
            }
            realElement.Stereotype = SDMModelingMain.StatementNodeStereotype;
            realElement.Update();
        }
 public void EA_OnPostOpenDiagram(EA.Repository repository, EA.Diagram openedDiagram)
 {
     if (openedDiagram.MetaType == SDMModelingMain.SdmDiagramMetatype[0])
     {
         createAnchorElementIfNecessary(repository, openedDiagram, true);
     }
 }
Beispiel #19
0
        /// <summary>
        /// Sets a normal EA.Package as an UMM view package. This means, that a stereotype is
        /// applied and also the taggedvalues, which every "UMM view package" inherits
        /// from "BusinessLibrary" from UMM base. Additionally a package diagram is created if
        /// the package is stereotyped as BDV, BRV or BTV
        /// </summary>
        /// <param name="package">the EA.Package which should be modified to an UMM "view package"</param>
        /// <param name="stereotype">the stereotype, which should be applied</param>
        /// <returns>a reference to the modified package</returns>
        private EA.Package populateUMMView(EA.Package package, UMM stereotype)
        {
            // set the stereotype
            package.Element.Stereotype = stereotype.ToString();
            // add the tagged values
            foreach (string tv_string in Enum.GetNames(typeof(BusinessLibraryTV)))
            {
                EA.TaggedValue tv = (EA.TaggedValue)package.Element.TaggedValues.AddNew(tv_string, "");
                tv.Update();
            }

            /* if the stereotype is BRV or BCV the package is own of the core views.
             * then for a more convinient modeling, a package diagram is added */
            if (stereotype.Equals(UMM.bRequirementsV) || stereotype.Equals(UMM.bChoreographyV))
            {
                EA.Diagram diagram = (EA.Diagram)package.Diagrams.AddNew(package.Name, EA_Element.Package.ToString());
                diagram.ShowDetails = 0;
                diagram.Update();
            }
            //For the BIV we add a class diagram
            else if (stereotype.Equals(UMM.bInformationV))
            {
                EA.Diagram diagram = (EA.Diagram)package.Diagrams.AddNew(package.Name, EA_Element.Class.ToString());
                diagram.ShowDetails = 0;
                diagram.Update();
            }

            package.Update();
            return(package);
        }
Beispiel #20
0
        public override Dictionary <SQLElement, string> doGlobalRule(SQLWrapperClasses.SQLRepository repository)
        {
            Dictionary <SQLElement, string> results = new Dictionary <SQLElement, string>();

            String ruleElements = repository.SQLQuery("select * from t_object where Stereotype = '" + TGGModelingMain.TggRuleStereotype + "'");

            foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(ruleElements, "Row"))
            {
                if (row != "")
                {
                    SQLElement ruleElement  = new SQLElement(repository, row);
                    SQLDiagram ruleDiagram  = ruleElement.Diagrams.GetAt(0) as SQLDiagram;
                    EA.Diagram rruleDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, ruleDiagram) as EA.Diagram;

                    foreach (EA.DiagramObject diagObject in rruleDiagram.DiagramObjects)
                    {
                        SQLElement diagElement = repository.GetElementByID(diagObject.ElementID);
                        if (diagElement.ParentID != ruleElement.ElementID &&
                            (diagElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
                             diagElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype))
                        {
                            results.Add(diagElement, "Element is no child of Rule: " + ruleElement.Name + " but is contained on its Rule Diagram");
                        }
                    }
                }
            }
            return(results);
        }
        public static bool openSelectedMethodSDM(EA.Diagram actDiag, SQLMethod meth, SQLRepository sqlRepository, out SQLElement methParent, out SQLElement container)
        {
            SQLTaggedValue aTag = null;

            methParent = sqlRepository.GetElementByID(meth.ParentID);
            container  = null;
            foreach (SQLElement sdmContainer in methParent.Elements)
            {
                aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sdmContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName);
                if (aTag != null)
                {
                    if (aTag.Value == meth.MethodGUID.ToString())
                    {
                        container = sdmContainer;
                        break;
                    }
                }
            }
            SQLDiagram sdmDiagg = null;

            if (container != null)
            {
                foreach (SQLDiagram sdmDiag in container.Diagrams)
                {
                    sdmDiagg = sdmDiag;
                    Navigator.addAnchorEntry(sdmDiag.DiagramID, actDiag.DiagramID);
                    sqlRepository.OpenDiagram(sdmDiag.DiagramID);

                    setAnchorElementTags(sqlRepository, actDiag, container);

                    return(true);
                }
            }
            return(false);
        }
Beispiel #22
0
        /// <summary>
        /// AddDiagram
        /// </summary>
        /// <param name="ePackage"></param>
        /// <returns>EA.Diagram</returns>
        internal static EA.Diagram AddDiagram(EA.Package eAPackage, string strDiagramName, string strEADiagramType)
        {
            string strLogInfo = "Diagram: " + strEADiagramType + " " + strDiagramName;

            LogMsg(LogMsgType.Adding, strLogInfo);
            EA.Diagram diagram = null;

            try
            {
                diagram = eAPackage.Diagrams.GetByName(strDiagramName);
            }
            catch (Exception ex)
            {
                LogMsg(LogMsgType.MiscExceptions, m_Repository.Stereotypes.GetLastError() + " : " + ex.Message);
            }

            if (diagram == null)
            {
                diagram = eAPackage.Diagrams.AddNew(strDiagramName, strEADiagramType);
                diagram.Update();
                eAPackage.Diagrams.Refresh();
                LogMsg(LogMsgType.Added, strLogInfo);
            }
            else
            {
                LogMsg(LogMsgType.Exists, strLogInfo);
            }

            return(diagram);
        }
Beispiel #23
0
        public bool Show(EA.Repository repository)
        {
            this.repository = repository;
            string defaultFolder = Filters.CurrentOutputPath;
            string maxFile       = "";
            string xsltFile      = GetXsltTaggedValue(repository).Value;
            string outputFile    = "";

            EA.ObjectType type = repository.GetTreeSelectedItemType();
            if (type == EA.ObjectType.otPackage)
            {
                EA.Package package = repository.GetTreeSelectedPackage();
                maxFile    = Path.Combine(defaultFolder, string.Format("{0}.max", package.Name));
                outputFile = Path.Combine(defaultFolder, string.Format("{0}.{1}", package.Name, outputFormat));
            }
            else if (type == EA.ObjectType.otDiagram)
            {
                EA.Diagram diagram = (EA.Diagram)repository.GetTreeSelectedObject();
                maxFile    = Path.Combine(defaultFolder, string.Format("{0}.max", diagram.Name));
                outputFile = Path.Combine(defaultFolder, string.Format("{0}.{1}", diagram.Name, outputFormat));
            }

            textBox1.Text = maxFile;
            textBox2.Text = xsltFile;
            textBox3.Text = outputFile;

            ShowDialog();
            return(issues);
        }
 private void buttonToggleMceVis_Click(object sender, EventArgs e)
 {
     checkFunctions();
     if (activateSDMVerboseButton)
     {
         EA.Diagram currentDiagram = repository.GetCurrentDiagram();
         if (currentDiagram.Notes.Contains("Moflon::MceVisualization=true"))
         {
             SDMUtil.setAllMceVisTags(false, repository, currentDiagram);
             currentDiagram.Notes = currentDiagram.Notes.Replace("Moflon::MceVisualization=true", "Moflon::MceVisualization=false");
         }
         else if (currentDiagram.Notes.Contains("Moflon::MceVisualization=false"))
         {
             SDMUtil.setAllMceVisTags(true, repository, currentDiagram);
             currentDiagram.Notes = currentDiagram.Notes.Replace("Moflon::MceVisualization=false", "Moflon::MceVisualization=true");
         }
         else
         {
             SDMUtil.setAllMceVisTags(false, repository, currentDiagram);
             currentDiagram.Notes = currentDiagram.Notes += "Moflon::MceVisualization=false";
         }
         currentDiagram.Update();
         repository.ReloadDiagram(currentDiagram.DiagramID);
     }
     else
     {
         MessageBox.Show("To use this function open a SDM Diagram");
     }
 }
        private EA.Element AddActivityToSwimlane(EA.Diagram diagram, EA.Package thePackage, string strActivityName, string strActorName, ImportFieldsValidator oFields)
        {
            string strLogInfo = "Add activity to swimlane. Actor: " + strActorName + " activity: " + strActivityName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName];

            int iL = (iActivityHorizDistBetweenActivities * m_NoActivities) + iActivityHorizOffset;
            int iR = iL + iActivityWidth;
            int iT = (((oSwimlane.m_iB - oSwimlane.m_iT) / 2) + oSwimlane.m_iT) - (iActivityHeight / 2);
            int iB = iT + iActivityHeight;

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.Element eElObj = AddActivity(diagram, thePackage, strActivityName, strActorName, strPos, oFields);

            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            m_NoActivities++;

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(eElObj);
        }
Beispiel #26
0
        public void TestExportSample()
        {
            EAMetaModel meta = new EAMetaModel().setupSchemaPackage();

            EAFactory rootClass = APIModels.APIModel.createAPI1(meta);

            meta.setupSchemaPackage();

            EA.Package package = SchemaManager.generateSample(EARepository.Repository);

            Assert.AreEqual(1, package.Diagrams.Count);
            object o = package.Diagrams.GetAt(0);

            EA.Diagram diagram = (EA.Diagram)o;

            Assert.AreEqual(3, package.Elements.Count);

            o = package.Elements.GetAt(0);
            EA.Element sample = (EA.Element)o;
            sample.RunState = ObjectManager.addRunState(sample.RunState, "intAttribute", "123", rootClass.clientElement.ElementID);

            meta.setupSamplePackage();
            //Test
            JObject jobject = (JObject)SampleManager.sampleToJObject(EARepository.Repository, diagram)["json"];

            Assert.AreEqual(8, jobject.Count);
        }
        /// <summary>
        /// List all diagram elements.
        /// </summary>
        /// <param name="args[2]">guid of the diagram</param>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool ListDiagramElements(string[] args)
        {
            // guid passed, use the selected diagram
            if (args.Length > 2 && args[2].StartsWith("{"))
            {
                EA.Diagram dia = (EA.Diagram)_repository.GetDiagramByGuid(args[2].Trim());
                if (dia != null)
                {
                    foreach (EA.DiagramObject diaObj in dia.DiagramObjects)
                    {
                        EA.Element el = _repository.GetElementByID(diaObj.ElementID);
                        if (el != null)
                        {
                            Print(el.Name);
                            _repository.ShowInProjectView(el);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("No Diagram guid passed");
                MessageBox.Show("Diagram guid should be passed", "No Diagram guid passed");
                return(false);
            }


            return(true);
        }
Beispiel #28
0
 private void checkForFunctions()
 {
     EA.Diagram currentDiag = repository.GetCurrentDiagram();
     activateTGGDeriveButton       = false;
     activateMultipleButton        = false;
     activateTGGVerboseButton      = false;
     activateExportImportCSPButton = false;
     if (currentDiag != null && TGGModelingMain.TggSchemaDiagramMetatype.Contains(currentDiag.MetaType))
     {
         if (currentDiag.SelectedObjects.Count > 0)
         {
             activateTGGDeriveButton = true;
         }
     }
     if (currentDiag != null && TGGModelingMain.TggRuleDiagramMetatype.Contains(currentDiag.MetaType))
     {
         if (currentDiag.SelectedObjects.Count > 0)
         {
             activateTGGDeriveButton   = true;
             activateMultipleButton    = true;
             activatePostProcessButton = true;
         }
         activateTGGVerboseButton = true;
     }
     EA.Package selectedPackage = repository.GetTreeSelectedPackage() as EA.Package;
     if (selectedPackage != null && selectedPackage.Element != null && selectedPackage.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype)
     {
         activateExportImportCSPButton = true;
     }
 }
Beispiel #29
0
        public static void syncSample(EA.Repository Repository, EA.Diagram diagram)
        {
            logger.log("Sync Sample");
            IList <EA.Element> samples = MetaDataManager.diagramSamples(Repository, diagram);

            EA.Element container             = container = findContainer(Repository, diagram);
            EA.Element containerClassifierEl = Repository.GetElementByID(container.ClassfierID);
            string     containerName         = container.Name;
            string     containerClassifier   = containerClassifierEl.Name;


            //logger.log("Sample Root:" + container.Name);

            EA.Package samplePkg      = Repository.GetPackageByID(diagram.PackageID);
            EA.Package samplesPackage = Repository.GetPackageByID(samplePkg.ParentID);
            EA.Package apiPackage     = Repository.GetPackageByID(samplesPackage.ParentID);
            if (fileManager != null)
            {
                fileManager.initializeAPI(apiPackage.Name);
                fileManager.setup(APIAddinClass.RAML_0_8);
                if (!fileManager.sampleExists(container.Name, containerClassifier, fileManager.getNamespace(Repository, apiPackage)))
                {
                    MessageBox.Show("No file exists at:" + fileManager.samplePath(container.Name, containerClassifier, fileManager.getNamespace(Repository, apiPackage)));
                    return;
                }
                else
                {
                    string  fullpath = fileManager.samplePath(containerName, containerClassifier, fileManager.getNamespace(Repository, apiPackage));
                    JObject jo       = JObject.Parse(File.ReadAllText(fullpath));
                    sync_sample(Repository, container, jo);
                }
            }
        }
Beispiel #30
0
        private EA.Diagram CreateDiagramFromElement(EA.Element element)
        {
            EA.Diagram diagram = (EA.Diagram)element.Diagrams.AddNew(element.Name, "Requirements");
            diagram.Update();

            EA.DiagramObject fobj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(string.Format("l={0};r={1};t={2};b={3}", 10, 630, 10, 110), "");
            fobj.ElementID = element.ElementID;
            fobj.Update();

            int       left    = 10;
            int       top     = 210;
            const int width   = 200;
            const int height  = 100;
            const int padding = 10;

            foreach (EA.Element subElement in element.Elements)
            {
                string           dimensions = string.Format("l={0};r={1};t={2};b={3};", left, left + width, top, top + height);
                EA.DiagramObject obj        = (EA.DiagramObject)diagram.DiagramObjects.AddNew(dimensions, "");
                obj.ElementID = subElement.ElementID;
                obj.Update();

                left += width + padding;
                if (left > 600)
                {
                    left = 10;
                    top += height + padding;
                }
            }
            diagram.Update();
            return(diagram);
        }
Beispiel #31
0
        public static void ProcessUseCase(EA.Repository rep, EA.Package navigationPackage, EA.Package interactionPackage,
            List<EA.Element> useCases, string patternType = null)
        {
            repository = rep;
            string[] res = repository.ConnectionString.Split('\\');
            string projectName = res[res.Length - 1].Split('.')[0];
            nsDiagram = XISMobileHelper.CreateDiagram(navigationPackage, projectName + "NavigationSpace Diagram",
                "XIS-Mobile_Diagrams::NavigationSpaceViewModel");
            bool isStartingUC = true;

            if (patternType != null)
            {
                homeDiagram = XISMobileHelper.CreateDiagram(interactionPackage, "HomeIS Diagram",
                    "XIS-Mobile_Diagrams::InteractionSpaceViewModel");
                homeIS = new XisInteractionSpace(repository, interactionPackage, homeDiagram, "HomeIS", "Home", true);
            }

            foreach (EA.Element useCase in useCases)
            {
                foreach (EA.Connector connector in useCase.Connectors)
                {
                    if (connector.Stereotype == "XisEntityUC-BEAssociation")
                    {
                        EA.Element be = repository.GetElementByID(connector.SupplierID);
                        XisEntity master = null;
                        List<XisEntity> details = new List<XisEntity>();
                        List<XisEntity> references = new List<XisEntity>();

                        #region [Get Entities (Master, Details and References)]
                        foreach (EA.Connector beConn in be.Connectors)
                        {
                            switch (beConn.Stereotype)
                            {
                                case "XisBE-EntityMasterAssociation":
                                    master = new XisEntity(repository.GetElementByID(beConn.SupplierID),
                                        GetConnectorTag(beConn.TaggedValues, "filter").Value);
                                    break;
                                case "XisBE-EntityDetailAssociation":
                                    details.Add(new XisEntity(repository.GetElementByID(beConn.SupplierID),
                                        GetConnectorTag(beConn.TaggedValues, "filter").Value));
                                    break;
                                case "XisBE-EntityReferenceAssociation":
                                    references.Add(new XisEntity(repository.GetElementByID(beConn.SupplierID),
                                        GetConnectorTag(beConn.TaggedValues, "filter").Value));
                                    break;
                                default:
                                    break;
                            }
                        }
                        #endregion

                        if (master != null)
                        {
                            //MessageBox.Show(master.Element.Name);

                            #region [Add cardinality to Entities]
                            if (details.Count > 0 || references.Count > 0)
                            {
                                foreach (EA.Connector conn in master.Element.Connectors)
                                {
                                    foreach (XisEntity detail in details)
                                    {
                                        if (conn.ClientID == detail.Element.ElementID)
                                        {
                                            detail.Cardinality = string.IsNullOrEmpty(conn.ClientEnd.Cardinality) ? "1" : conn.ClientEnd.Cardinality;
                                            detail.BeCardinality = string.IsNullOrEmpty(conn.SupplierEnd.Cardinality) ? "1" : conn.SupplierEnd.Cardinality;
                                            //MessageBox.Show("client: " + detail.Element.Name);
                                        }
                                        else if (conn.SupplierID == detail.Element.ElementID)
                                        {
                                            detail.Cardinality = string.IsNullOrEmpty(conn.SupplierEnd.Cardinality) ? "1" : conn.SupplierEnd.Cardinality;
                                            detail.BeCardinality = string.IsNullOrEmpty(conn.ClientEnd.Cardinality) ? "1" : conn.ClientEnd.Cardinality;
                                            //MessageBox.Show("supplier: " + detail.Element.Name);
                                        }
                                    }

                                    foreach (XisEntity reference in references)
                                    {
                                        if (conn.ClientID == reference.Element.ElementID)
                                        {
                                            reference.Cardinality = string.IsNullOrEmpty(conn.ClientEnd.Cardinality) ? "1" : conn.ClientEnd.Cardinality;
                                            reference.BeCardinality = string.IsNullOrEmpty(conn.SupplierEnd.Cardinality) ? "1" : conn.SupplierEnd.Cardinality;
                                            //MessageBox.Show("client: " + reference.Element.Name);
                                        }
                                        else if (conn.SupplierID == reference.Element.ElementID)
                                        {
                                            reference.Cardinality = string.IsNullOrEmpty(conn.SupplierEnd.Cardinality) ? "1" : conn.SupplierEnd.Cardinality;
                                            reference.BeCardinality = string.IsNullOrEmpty(conn.ClientEnd.Cardinality) ? "1" : conn.ClientEnd.Cardinality;
                                            //MessageBox.Show("supplier: " + reference.Element.Name);
                                        }
                                    }
                                }
                            }
                            #endregion

                            master.Details = details;
                            master.References = references;

                            EA.TaggedValue ucType = GetTaggedValue(useCase.TaggedValues, "type");

                            if (ucType != null)
                            {
                                if (ucType.Value == "EntityManagement")
                                {
                                    if (isStartingUC && useCases.Count > 1)
                                    {
                                        ProcessManagerUseCase(interactionPackage, master, useCase, be, isStartingUC,
                                            useCases.GetRange(1, useCases.Count - 1), patternType);
                                    }
                                    else
                                    {
                                        ProcessManagerUseCase(interactionPackage, master, useCase, be, isStartingUC, null, patternType);
                                    }
                                }
                                else if (ucType.Value == "EntityConfiguration")
                                {
                                    if (isStartingUC && useCases.Count > 1)
                                    {
                                        ProcessDetailUseCase(interactionPackage, master, useCase, be, isStartingUC,
                                            useCases.GetRange(1, useCases.Count - 1), patternType);
                                    }
                                    else
                                    {
                                        ProcessDetailUseCase(interactionPackage, master, useCase, be, isStartingUC, null, patternType);
                                    }
                                }
                            }
                        }
                    }
                    else if (connector.Stereotype == "XisServiceUC-BEAssociation")
                    {
                        EA.Element be = repository.GetElementByID(connector.SupplierID);
                        XisEntity master = null;
                        List<XisEntity> details = new List<XisEntity>();
                        List<XisEntity> references = new List<XisEntity>();

                        foreach (EA.Connector beConn in be.Connectors)
                        {
                            switch (beConn.Stereotype)
                            {
                                case "XisBE-EntityMasterAssociation":
                                    master = new XisEntity(repository.GetElementByID(beConn.SupplierID),
                                        GetConnectorTag(beConn.TaggedValues, "filter").Value);
                                    break;
                                default:
                                    break;
                            }
                        }

                        if (master != null)
                        {
                            ProcessServiceUseCase(interactionPackage, master, useCase, be, isStartingUC, null, patternType);
                        }
                    }
                }
                isStartingUC = false;
            }

            if (patternType != null)
            {
                if (patternType == "Springboard")
                {
                    ComputeSprinboardPositions();
                }
                else
                {
                    ComputePositions(homeIS, homeDiagram);
                }
            }
        }
 public  FindAndReplaceItemDiagram(EA.Repository rep, string GUID)  :base( rep, GUID)
 {
     this._dia = rep.GetDiagramByGuid(GUID);
     this.load(rep);
 }