コード例 #1
0
ファイル: ImportForm.cs プロジェクト: luoyuxia/EA-AddIN
        private void updateConnectorEnd()
        {
            foreach (string eadId in eaIdConnectorIdMap.Keys)
            {
                int          id  = eaIdConnectorIdMap[eadId];
                EA.Connector con = this.repository.GetConnectorByID(id);
                if (eaIdPackageIdMap.ContainsKey(connectorSrcMap[id]))
                {
                    con.ClientID = repository.GetPackageByID(eaIdPackageIdMap[connectorSrcMap[id]]).Element.ElementID;
                }
                else if (eAIdElementIdMap.ContainsKey(connectorSrcMap[id]))
                {
                    con.ClientID = repository.GetElementByID(eAIdElementIdMap[connectorSrcMap[id]]).ElementID;
                }
                else
                {
                    continue;
                }

                if (eaIdPackageIdMap.ContainsKey(connectorTgtMap[id]))
                {
                    con.SupplierID = repository.GetPackageByID(eaIdPackageIdMap[connectorTgtMap[id]]).Element.ElementID;
                }
                else if (eAIdElementIdMap.ContainsKey(connectorTgtMap[id]))
                {
                    con.SupplierID = repository.GetElementByID(eAIdElementIdMap[connectorTgtMap[id]]).ElementID;
                }
                else
                {
                    continue;
                }
                con.Update();
            }
        }
コード例 #2
0
        public Boolean EA_OnPreNewConnector(EA.Repository repository, EA.EventProperties info)
        {
            if (info.Get("Stereotype").Value.Equals(SDMModelingMain.LinkVariableStereotype))
            {
                EA.Element client   = repository.GetElementByID(Int32.Parse(info.Get("ClientID").Value as String));
                EA.Element supplier = repository.GetElementByID(Int32.Parse(info.Get("SupplierID").Value as String));
                if (client != null && supplier != null)
                {
                    List <SQLConnector> clientToSupplierAssociations = new List <SQLConnector>();
                    List <SQLConnector> supplierToClientAssociations = new List <SQLConnector>();

                    SQLRepository sqlRepository      = new SQLRepository(repository, false);
                    SQLElement    clientClassifier   = sqlRepository.GetElementByID(client.ClassfierID);
                    SQLElement    supplierClassifier = sqlRepository.GetElementByID(supplier.ClassfierID);

                    LinkVariablePropertiesForm.collectPossibleAssociations(ref clientClassifier, ref supplierClassifier, ref clientToSupplierAssociations, ref supplierToClientAssociations, ref sqlRepository);
                    if (clientToSupplierAssociations.Count == 0 && supplierToClientAssociations.Count == 0)
                    {
                        System.Windows.Forms.MessageBox.Show("There is no Association between these two elements");
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
        public GoatAssociationModel Read()
        {
            GoatAssociationModel result = new GoatAssociationModel();

            SetLeftOrRight(result.Left, connector.ClientEnd, repository.GetElementByID(connector.ClientID));
            SetLeftOrRight(result.Right, connector.SupplierEnd, repository.GetElementByID(connector.SupplierID));
            result.Name = connector.Name;

            return(result);
        }
コード例 #4
0
        private void RegisterRelation(EA.Connector connector)
        {
            EA.Element client   = _repository.GetElementByID(connector.ClientID);
            EA.Element supplier = _repository.GetElementByID(connector.SupplierID);

            if (client != null && supplier != null)
            {
                string consumerName = ExtractUniqueName(client);
                string providerName = ExtractUniqueName(supplier);

                RegisterRelation(connector, consumerName, providerName);
            }
        }
コード例 #5
0
        /// <summary>
        /// Create Activity in Diagram context. Optionally you can pass your own diagram context.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="methodName"></param>
        /// <param name="diaContext">Context of the activity to add, the location of the passed diagram</param>
        /// <returns></returns>
        public static EA.Element CreateInDiagramContext(EA.Repository rep, string methodName, EA.Diagram diaContext = null)
        {
            EA.Element act = GetActivityFromMethodName(rep, methodName, verbose: false);
            if (act == null)
            {
                // Create Activity
                if (MessageBox.Show($"No Activity '{methodName}' exists in model.\r\n Create Activity?", "Create Activity?",
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var dia = diaContext ?? rep.GetCurrentDiagram();
                    if (dia != null)
                    {
                        if (dia.ParentID > 0)
                        {
                            EA.Element parentEl = rep.GetElementByID(dia.ParentID);
                            act = (EA.Element)parentEl.Elements.AddNew(methodName, "Activity");
                            parentEl.Elements.Refresh();
                        }
                        else
                        {
                            EA.Package pkg = rep.GetPackageByID(dia.PackageID);
                            act = (EA.Element)pkg.Elements.AddNew(methodName, "Activity");
                            pkg.Elements.Refresh();
                        }

                        act.Update();
                    }
                }
            }

            return(act);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        public ExtractSDM(SQLRepository sqlRepository)
        {
            InitializeComponent();
            this.sqlRepository = sqlRepository;
            repository         = sqlRepository.GetOriginalRepository();
            //save selected diagramObjects;
            allOldDiagramObjects      = new List <EA.DiagramObject>();
            selectedOldDiagramObjects = new List <EA.DiagramObject>();
            selectedActivityNodes     = new List <EA.Element>();
            selectedElementIDs        = new List <int>();
            allOldOvs = new List <EA.Element>();
            allNewOvs = new List <EA.Element>();

            oldSDMDiagram   = sqlRepository.GetCurrentDiagram();
            oldSDMContainer = repository.GetElementByID(oldSDMDiagram.ParentID);

            gatherAllDiagramObjects();
            gatherSelectedActivityNodes();
            gatherUnselectedObjectVariables();

            ovClassifiersComboBox1.initializePossibleClassifiersComboBox(SDMModelingMain.ObjectVariableStereotype, 0, sqlRepository);


            StartPosition = FormStartPosition.CenterScreen;
            textBoxNewSDM.Select();
            ShowDialog();
        }
コード例 #8
0
ファイル: Main.cs プロジェクト: HL7/ehrsfm-tool
        private void mergeDiagrams(EA.Repository repository, EA.Package package)
        {
            Dictionary <int, EA.DiagramObject> dobjects = new Dictionary <int, EA.DiagramObject>();
            Dictionary <int, EA.DiagramLink>   dlinks   = new Dictionary <int, EA.DiagramLink>();

            foreach (EA.Diagram diagram in package.Diagrams)
            {
                foreach (EA.DiagramObject dobject in diagram.DiagramObjects)
                {
                    dobjects[dobject.ElementID] = dobject;
                }
                foreach (EA.DiagramLink dlink in diagram.DiagramLinks)
                {
                    dlinks[dlink.ConnectorID] = dlink;
                }
            }

            EA.Diagram mdiagram = (EA.Diagram)package.Diagrams.AddNew(string.Format("{0} (Merged)", package.Name), "Custom");
            mdiagram.Update();

            // copy objects
            int       left    = 10;
            int       top     = 10;
            const int width   = 100;
            const int height  = 80;
            const int padding = 10;

            foreach (EA.DiagramObject dobject in dobjects.Values)
            {
                EA.Element element = repository.GetElementByID(dobject.ElementID);
                if ("Boundary".Equals(element.Type))
                {
                    continue;
                }

                string dimensions = string.Format("l={0};r={1};t={2};b={3};", left, left + width, top, top + height);
                left += padding + width;
                EA.DiagramObject mobject = (EA.DiagramObject)mdiagram.DiagramObjects.AddNew(dimensions, "");
                mobject.ElementID = element.ElementID;
                mobject.Update();

                if (left == 1000)
                {
                    left = 10;
                    top += height;
                }
            }
            mdiagram.Update();

            // copy links (o.a. NoteLinks)
            foreach (EA.DiagramLink dlink in dlinks.Values)
            {
                EA.DiagramLink mlink = (EA.DiagramLink)mdiagram.DiagramLinks.AddNew("", "");
                mlink.ConnectorID = dlink.ConnectorID;
                mlink.Update();
            }

            package.Update();
            repository.OpenDiagram(mdiagram.DiagramID);
        }
コード例 #9
0
 // On double click on output
 public void EA_OnOutputItemDoubleClicked(EA.Repository Repository, String TabName, String LineText, int ID)
 {
     if (Properties.Resources.OUTPUT_TAB_HL7_FM.Equals(TabName) && ID != -1)
     {
         Repository.ShowInProjectView(Repository.GetElementByID(ID));
     }
 }
コード例 #10
0
        private EA.Element getEventElement(EA.Repository rep, EA.EventProperties e)
        {
            var value        = e.Get(0).Value;
            int intElementId = Convert.ToInt32(value);

            return(rep.GetElementByID(intElementId));
        }
コード例 #11
0
ファイル: MetaDataManager.cs プロジェクト: Nanonid/api-add-in
 /* Finds the Objects with a classifier of API on the diagram */
 public static EA.Element diagramAPI(EA.Repository Repository, EA.Diagram diagram)
 {
     foreach (EA.DiagramObject diagramObject in diagram.DiagramObjects)
     {
         EA.Element el = Repository.GetElementByID(diagramObject.ElementID);
         if (el.Type.Equals(APIAddinClass.EA_TYPE_OBJECT))
         {
             EA.Element classifier = Repository.GetElementByID(el.ClassifierID);
             if (classifier.Name.Equals(APIAddinClass.METAMODEL_API))
             {
                 return(el);
             }
         }
     }
     return(null);
 }
コード例 #12
0
        /// informed that the deletion of the Method will delete the SDM Diagram as well.
        /// </summary>
        /// <param name="Repository"></param>
        /// <param name="Info"></param>
        /// <returns></returns>
        public Boolean EA_OnPreDeleteMethod(EA.Repository Repository, EA.Method method)
        {
            EA.Method      meth       = method;
            EA.Element     methParent = Repository.GetElementByID(meth.ParentID);
            EA.TaggedValue aTag       = null;

            SQLRepository sqlRep = new SQLRepository(Repository, false);

            foreach (EA.Element actEle in methParent.Elements)
            {
                aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(actEle, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName);
                if (aTag != null)
                {
                    if (aTag.Value.ToString() == meth.MethodGUID.ToString())
                    {
                        Boolean      delete       = false;
                        DeleteMethod deleteMethod = new DeleteMethod(delete);
                        deleteMethod.StartPosition = FormStartPosition.CenterScreen;
                        deleteMethod.ShowDialog();
                        delete = deleteMethod.setVal();
                        if (delete)
                        {
                            EAUtil.deleteElement(actEle, sqlRep);
                            return(true);
                        }
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #13
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);
                }
            }
        }
コード例 #14
0
        /// <function>
        /// Function to get all transitions of state diagram
        /// </function>
        private void GetAllTransitions(EA.Repository rep, StateDiagram diagramElementsObj, EA.Element element)
        {
            foreach (EA.Connector item in element.Connectors)
            {
                bool   isOld      = false;
                int    clientId   = item.ClientID;   // "From" state of a transition, from where the transition begins
                int    supplierId = item.SupplierID; // "To" state of a transition, where the transition ends
                char[] charsToReplaceFromEffects = new char[] { ';', '\r', '\t', '\n' };

                EA.Element clientElement   = rep.GetElementByID(clientId);
                EA.Element supplierElement = rep.GetElementByID(supplierId);

                Transition transitionObj = new Transition();
                GetStateName(clientElement.Name, rep, clientElement);
                transitionObj.from = stateName;
                GetStateName(supplierElement.Name, rep, supplierElement);
                transitionObj.to      = stateName;
                transitionObj.trigger = item.TransitionEvent;

                effectsList = item.TransitionAction;
                effectsList = effectsList.ReplaceAll(charsToReplaceFromEffects, ',');
                effectsList = Utilities.TruncateCommas(effectsList);

                if (string.IsNullOrEmpty(effectsList))
                {
                    transitionObj.effects = "";
                }
                else
                {
                    transitionObj.effects = "[" + effectsList + "]";
                }

                // To remove duplicate transitions returned by Enterprise architect API
                foreach (var transItem in diagramElementsObj.transitions)
                {
                    if (transItem.from.Equals(transitionObj.from) && transItem.to.Equals(transitionObj.to))
                    {
                        isOld = true;
                        break;
                    }
                }
                if (!isOld)
                {
                    diagramElementsObj.transitions.Add(transitionObj);
                }
            }
        }
コード例 #15
0
        public bool EA_OnPreDeleteDiagramObject(EA.Repository Repository, EA.EventProperties Info)
        {
            EA.Element element = Repository.GetElementByID(int.Parse((string)Info.Get(0).Value));
            this.deletedDiagramObjectGUIDQueue.Add(element.ElementGUID);
            this.deletedDiagramObjectsObjectTypesQueue.Add(element.ObjectType);

            return(true);
        }
コード例 #16
0
        public static void syncPopulation(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache)
        {
            logger.log("Sync Population");
            RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache);
            IList <EA.Element> diagramElements = diagramCache.elementsList;

            //IList<EA.Element> samples = MetaDataManager.diagramSamples(Repository, diagramElements);
            IList <EA.Element> samples = diagramElements;

            EA.Element container = container = MetaDataManager.findContainer(Repository, diagram, diagramCache, RoundTripAddInClass.EA_STEREOTYPE_POPULATION);

            logger.log("Classifier ID:" + container.ClassifierID);


            string containerName       = container.Name;
            string containerClassifier = "Classes";

            EA.Element containerClassifierEl = null;
            if (container.ClassifierID != 0)
            {
                containerClassifierEl = Repository.GetElementByID(container.ClassfierID);
                containerName         = container.Name;
                containerClassifier   = containerClassifierEl.Name;
            }

            EA.Package samplePkg = Repository.GetPackageByID(diagram.PackageID);

            Hashtable ht = new Hashtable();

            MetaDataManager.extractDiagramMetaData(ht, container);

            string project = (String)ht[RoundTripAddInClass.PROJECT];

            if (project == null)
            {
                MessageBox.Show("No project defined in the Population stereotyped element. Please enter project name where population should be exported.");
                return;
            }

            if (fileManager != null)
            {
                fileManager.initializeAPI(project);
                fileManager.setDataName(RoundTripAddInClass.POPULATION_PATH);
                fileManager.setup(RoundTripAddInClass.RAML_0_8);
                if (!fileManager.populationExists(container.Name, containerClassifier, RoundTripAddInClass.POPULATION_PATH, container.Name))
                {
                    MessageBox.Show("No file exists at:" + fileManager.exportPath(container.Name, containerClassifier, RoundTripAddInClass.POPULATION_PATH, container.Name));
                    return;
                }
                else
                {
                    string fullpath = fileManager.exportPath(containerName, containerClassifier, RoundTripAddInClass.POPULATION_PATH, container.Name);
                    JArray jo       = JArray.Parse(File.ReadAllText(fullpath));
                    sync_population(Repository, container, containerClassifierEl, jo, samplePkg, diagramCache);
                    samplePkg.Update();
                }
            }
        }
コード例 #17
0
 private EA.Element getContainingClass()
 {
     if (oldSDMDiagram != null)
     {
         EA.Element eClass = repository.GetElementByID(oldSDMContainer.ParentID);
         return(eClass);
     }
     return(null);
 }
コード例 #18
0
        private static void transformConstraintToCSPElement(SQLElement eaElement2, SQLWrapperClasses.SQLRepository sqlRep, EA.Repository repository)
        {
            EA.Element eaElement = EAUtil.sqlEAObjectToOriginalObject(sqlRep, eaElement2) as EA.Element;
            String     result    = repository.SQLQuery("select Diagram_ID from t_diagramobjects where Object_ID = " + eaElement.ElementID);
            string     diagramId = EAUtil.getXMLNodeContentFromSQLQueryString(result, "Diagram_ID")[0];

            if (diagramId != "")
            {
                EA.Diagram       diagram       = repository.GetDiagramByID(int.Parse(diagramId));
                EA.DiagramObject oldDiagObject = EAUtil.findDiagramObject(sqlRep, eaElement, diagram);
                EA.Element       ruleElement   = repository.GetElementByID(diagram.ParentID);
                if (ruleElement.Stereotype == TGGModelingMain.TggRuleStereotype)
                {
                    List <EA.Connector> outgoingCons = new List <EA.Connector>();

                    foreach (EA.Connector con in eaElement.Connectors)
                    {
                        if (con.Stereotype == "ConstraintLink" && con.ClientID == eaElement.ElementID)
                        {
                            outgoingCons.Add(con);
                        }
                    }

                    EA.Element newCsp = ruleElement.Elements.AddNew("", Main.EAClassType) as EA.Element;
                    newCsp.Notes      = eaElement.Notes;
                    newCsp.Stereotype = TGGModelingMain.CSPConstraintStereotype;
                    newCsp.Update();

                    EA.TaggedValue oldTag = EAUtil.findTaggedValue(eaElement, Main.MoflonExportTreeTaggedValueName);
                    if (oldTag != null)
                    {
                        EAUtil.setTaggedValueNotes(sqlRep, newCsp, oldTag.Name, oldTag.Notes);
                    }


                    EA.DiagramObject newDiagObject = diagram.DiagramObjects.AddNew("", Main.EAClassType) as EA.DiagramObject;
                    newDiagObject.ElementID = newCsp.ElementID;
                    newDiagObject.left      = oldDiagObject.left;
                    newDiagObject.right     = oldDiagObject.right;
                    newDiagObject.bottom    = oldDiagObject.bottom;
                    newDiagObject.top       = oldDiagObject.top;
                    newDiagObject.Update();

                    foreach (EA.Connector con in outgoingCons)
                    {
                        con.ClientID = newCsp.ElementID;
                        con.Update();
                    }



                    EAUtil.deleteDiagramObject(repository, diagram, eaElement);
                    EAUtil.deleteElement(eaElement, sqlRep);
                }
            }
        }
コード例 #19
0
        public void EA_MenuClick(EA.Repository Rep, string Location, string MenuName, string ItemName)
        {
            if (ItemName == "Show in Mindfusion")
            {
                EA.Diagram diag;

                switch (Rep.GetContextItemType())
                {
                case EA.ObjectType.otPackage:
                {
                    MessageBox.Show("Please select the entire diagram");
                    break;
                }

                case EA.ObjectType.otElement:
                {
                    MessageBox.Show("Please select the entire diagram");
                    break;
                }

                case EA.ObjectType.otDiagram:
                {
                    diag = Rep.GetContextObject();
                    diagramElementsList = new List <DiagramElements>();
                    foreach (EA.DiagramObject diagramObj in diag.DiagramObjects)
                    {
                        int        diagramId = diagramObj.DiagramID;
                        EA.Diagram diagram   = Rep.GetDiagramByID(diagramId);

                        int        elementId = diagramObj.ElementID;
                        EA.Element element   = Rep.GetElementByID(elementId);

                        DiagramElements diagramElement = new DiagramElements();
                        diagramElement.elementName  = element.Name;
                        diagramElement.elementType  = element.MetaType;
                        diagramElement.elementShape = element.ElementID.ToString();

                        diagramElementsList.Add(diagramElement);
                    }
                    break;
                }
                }

                StringWriter  sw = new StringWriter();
                XmlSerializer s  = new XmlSerializer(diagramElementsList.GetType());
                s.Serialize(sw, diagramElementsList);
                string xmlString = sw.ToString();

                MindFusionViewer form = new MindFusionViewer();
                form.setJsonContent(xmlString);
                form.Show();
            }
            else if (ItemName == "About")
            {
            }
        }
        private void HandleDecision(EA.Element element)
        {
            foreach (EA.Connector c in element.Connectors)
            {
                Int32      supplierID   = c.SupplierID;
                EA.Element nextActivity = m_DiagramOfInterest.GetElementByID(supplierID);

                ElementType type = EnumUtil.ParseEnum <ElementType>(nextActivity.Type, ElementType.Unknown);
                if (type == ElementType.MergeNode)
                {
                    Int32      clientID        = c.ClientID;
                    EA.Element currentActivity = m_DiagramOfInterest.GetElementByID(clientID);

                    string transitionguard = c.TransitionGuard.ToString();
                    Int32  connectorID     = c.ConnectorID;

                    Activity finalCurrentActivity = new Activity(currentActivity.Name.ToString(), EnumUtil.ParseEnum <ElementType>(currentActivity.Type, ElementType.Unknown), currentActivity.ElementID);
                    Activity finalNextActivity    = new Activity(nextActivity.Name.ToString(), EnumUtil.ParseEnum <ElementType>(nextActivity.Type, ElementType.Unknown), nextActivity.ElementID);

                    Row row = new Row(finalCurrentActivity, "", nextActivity.Name.ToString(), finalNextActivity, transitionguard, connectorID);

                    // check if row already exists
                    if (!m_Data.Containes(row))
                    {
                        m_Data.AddRow(row);
                    }
                }
                else if (type == ElementType.Decision)
                {
                    Int32      clientID        = c.ClientID;
                    EA.Element currentActivity = m_DiagramOfInterest.GetElementByID(clientID);

                    string transitionguard = c.TransitionGuard.ToString();
                    Int32  connectorID     = c.ConnectorID;

                    Activity finalCurrentActivity = new Activity(currentActivity.Name.ToString(), EnumUtil.ParseEnum <ElementType>(currentActivity.Type, ElementType.Unknown), currentActivity.ElementID);
                    Activity finalNextActivity    = new Activity(nextActivity.Name.ToString(), EnumUtil.ParseEnum <ElementType>(nextActivity.Type, ElementType.Unknown), nextActivity.ElementID);

                    Row row = new Row(finalCurrentActivity, "", nextActivity.Name.ToString(), finalNextActivity, transitionguard, connectorID);

                    // check if row already exists
                    if (!m_Data.Containes(row))
                    {
                        m_Data.AddRow(row);
                    }
                }
            }
        }
コード例 #21
0
        public void SortSelectedObjects()
        {
            // estimate sort criteria (left/right, top/bottom)
            bool isVerticalSorted = true;

            EA.DiagramObject obj1 = _dia.SelectedObjects.GetAt(0);
            EA.DiagramObject obj2 = _dia.SelectedObjects.GetAt(1);
            if (Math.Abs(obj1.left - obj2.left) > Math.Abs(obj1.top - obj2.top))
            {
                isVerticalSorted = false;
            }

            // fill the diagram objects to sort by name / by position
            var lIdsByName     = new List <DiagramObject>();
            var lObjByPosition = new List <DiagramObjectSelected>();

            foreach (EA.DiagramObject obj in _selectedObjects)
            {
                EA.Element el = _rep.GetElementByID(obj.ElementID);
                lIdsByName.Add(new DiagramObject(el.Name, el.ElementID));
                int position = obj.left;
                if (isVerticalSorted)
                {
                    position = obj.top;
                }
                lObjByPosition.Add(new DiagramObjectSelected(obj, position, obj.left));
            }

            // sort name list and position list
            lIdsByName.Sort(new DiagramObjectComparer());
            // sort diagram objects according to position and vertical / horizontal sorting
            if (isVerticalSorted)
            {
                lObjByPosition.Sort(new DiagramObjectSelectedVerticalComparer());
            }
            else
            {
                lObjByPosition.Sort(new DiagramObjectSelectedHorizontalComparer());
            }


            foreach (EA.DiagramObject obj in _dia.SelectedObjects)
            {
                // find position of element in sorted selected objects
                int pos = lIdsByName.FindIndex(x => x.Id == obj.ElementID);

                int length = obj.right - obj.left;
                int high   = obj.top - obj.bottom;
                obj.left   = lObjByPosition[pos].Left;
                obj.bottom = lObjByPosition[pos].Obj.bottom;
                obj.right  = obj.left + length;
                obj.top    = obj.bottom + high;
                obj.Update();
            }
        }
コード例 #22
0
        private void GetTransitionsByState(EA.Repository Rep, DiagramElements diagramElementsObj, EA.Element element)
        {
            foreach (EA.Connector item in element.Connectors)
            {
                bool       isOld           = false;
                int        clientId        = item.ClientID;
                int        supplierId      = item.SupplierID;
                EA.Element clientElement   = Rep.GetElementByID(clientId);
                EA.Element supplierElement = Rep.GetElementByID(supplierId);

                Transition transitionObj = new Transition();
                transitionObj.from    = Utilities.FormatElementName(clientElement.FQName);
                transitionObj.to      = Utilities.FormatElementName(supplierElement.FQName);
                transitionObj.trigger = item.TransitionEvent;

                effectsList = item.TransitionAction;
                effectsList = effectsList.ReplaceAll(charsToReplaceFromEffects, ',');
                effectsList = Utilities.TruncateCommas(effectsList);

                if (string.IsNullOrEmpty(effectsList))
                {
                    transitionObj.effects = "";
                }
                else
                {
                    transitionObj.effects = "[" + effectsList + "]";
                }
                foreach (var transItem in diagramElementsObj.transitions)
                {
                    if (transItem.from.Equals(transitionObj.from) && transItem.to.Equals(transitionObj.to))
                    {
                        isOld = true;
                        break;
                    }
                }
                if (!isOld)
                {
                    diagramElementsObj.transitions.Add(transitionObj);
                }
            }
        }
コード例 #23
0
        public static EA.Element createAnchorElementIfNecessary(EA.Repository repository, EA.Diagram openedDiagram, Boolean reloadDiagramAfter)
        {
            //checks if the current SDM Diagram already contains an Anchor element.
            //String sqlResult = repository.SQLQuery(@"SELECT Count(*) as Count FROM t_object WHERE ParentID = " + openedDiagram.ParentID +
            //                                       " AND Stereotype = '" + SDMModelingMain.SDMAnchorStereotype + "'");

            String sqlResult = repository.SQLQuery(@"select Count(*) as Count from t_diagramobjects d, t_object o where d.Object_ID = o.Object_ID 
                                                    and o.Stereotype = '" + SDMModelingMain.SDMAnchorStereotype + "' and d.Diagram_ID = " + openedDiagram.DiagramID);
            String count     = EAUtil.getXMLNodeContentFromSQLQueryString(sqlResult, "Count")[0];

            if (count == "0")
            {
                Boolean locked = false;

                EA.Element newAnchorElement = null;

                if (openedDiagram.ParentID != 0)
                {
                    EA.Element parentElement = repository.GetElementByID(openedDiagram.ParentID);
                    locked           = parentElement.Locked;
                    newAnchorElement = parentElement.Elements.AddNew("", Main.EAClassType) as EA.Element;
                }
                else
                {
                    EA.Package parentPackage = repository.GetPackageByID(openedDiagram.PackageID);
                    locked           = parentPackage.Element.Locked;
                    newAnchorElement = parentPackage.Elements.AddNew("", Main.EAClassType) as EA.Element;
                }

                if (!locked)
                {
                    newAnchorElement.Stereotype = SDMModelingMain.SDMAnchorStereotype;
                    newAnchorElement.Update();

                    EA.DiagramObject newAnchorDiagramObject = openedDiagram.DiagramObjects.AddNew("", newAnchorElement.Type) as EA.DiagramObject;
                    newAnchorDiagramObject.left      = 5;
                    newAnchorDiagramObject.top       = -5;
                    newAnchorDiagramObject.right     = 25;
                    newAnchorDiagramObject.bottom    = -25;
                    newAnchorDiagramObject.ElementID = newAnchorElement.ElementID;

                    newAnchorDiagramObject.Update();

                    if (reloadDiagramAfter)
                    {
                        repository.ReloadDiagram(openedDiagram.DiagramID);
                    }
                    return(newAnchorElement);
                }
            }
            return(null);
        }
コード例 #24
0
        /// <function>
        /// Recursive function to traverse the project tree and get the name of states as well as nested states
        /// If State1 has a nested state State2, then the name of the State2 will be listed as State1/State2
        /// </function>

        private void GetStateName(string result, EA.Repository rep, EA.Element element)
        {
            if (element.ParentID == 0)
            {
                stateName = result;
                return;
            }
            else
            {
                EA.Element parent = rep.GetElementByID(element.ParentID);
                GetStateName(parent.Name + "/" + result, rep, parent);
            }
        }
コード例 #25
0
        internal void fillSDMDiagram(EA.Diagram diagram)
        {
            EA.Element parentElement = repository.GetElementByID(diagram.ParentID);

            if (parentElement.Stereotype == SDMModelingMain.SdmContainerStereotype)
            {
                SDMUtil.fillSDMActivityNodeDiagram(repository, diagram, parentElement);
            }
            else if (parentElement.Stereotype == SDMModelingMain.StoryNodeStereotype)
            {
                SDMUtil.fillAllStoryNodeDiagrams(sqlRep, diagram, parentElement);
            }
        }
コード例 #26
0
        static public void exportWSDLs(EA.Repository repository, EA.Diagram diagram)
        {
            WSDLManager mgr = new WSDLManager();

            //mgr.path = @"D:\SOA\Modelling\Schema\";
            mgr.path = @"D:\tmp\";
            foreach (EA.DiagramObject obj in diagram.DiagramObjects)
            {
                EA.Element         component = repository.GetElementByID(obj.ElementID);
                ServiceDescription sd        = mgr.exportWSDL(repository, component);
                sd.Write(mgr.path + "/" + sd.Name + ".wsdl");
            }
        }
コード例 #27
0
        /// <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);
        }
コード例 #28
0
ファイル: MetaDataManager.cs プロジェクト: Nanonid/api-add-in
        static public IList <EA.Element> diagramSamples(EA.Repository Repository, EA.Diagram diagram)
        {
            List <EA.Element> samples = new List <EA.Element>();

            foreach (EA.DiagramObject diagramObject in diagram.DiagramObjects)
            {
                EA.Element el = Repository.GetElementByID(diagramObject.ElementID);
                if (el.Type.Equals(APIAddinClass.EA_TYPE_OBJECT))
                {
                    samples.Add(el);
                }
            }
            return(samples);
        }
コード例 #29
0
        private void HandleParameter(EA.Parameter param, Method method)
        {
            Parameter p = new Parameter();

            p.SetName(param.Name);
            Int32 id = Int32.Parse(param.ClassifierID);

            EA.Element datatype = m_InterfaceOfInterest.GetElementByID(id);
            p.SetDatatype(FetchNamespace(datatype));
            p.SetIsConst(param.IsConst);
            p.SetPositionInArgList(param.Position);

            method.AddParameter(p);
        }
コード例 #30
0
        static public EA.Element queryClassifier(EA.Repository Repository, String classifierName)
        {
            string      resultDoc = Repository.SQLQuery("select Object_ID from t_object where Name='" + classifierName + "' and Object_Type='Class'");
            XmlDocument doc       = new XmlDocument();

            doc.LoadXml(resultDoc);
            List <string> result = new List <string>();

            foreach (XmlNode node in doc.GetElementsByTagName("Object_ID"))
            {
                logger.log("Found ClassifierId for:" + classifierName + " as " + node.InnerText);
                return(Repository.GetElementByID(Int32.Parse(node.InnerText)));
            }
            return(null);
        }
コード例 #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);
                }
            }
        }