Esempio n. 1
0
 public void showObjectProperties(EA.Repository Repository, string GUID, EA.ObjectType ot)
 {
     eaObjectType.Text = ot.ToString();
     eaObjectName.Text = "?";
     switch(ot)
     {
         case EA.ObjectType.otAttribute:
             EA.Attribute attribute = Repository.GetAttributeByGuid(GUID);
             currentEaObject = attribute;
             currentEaObjectCollections = null;
             eaObjectName.Text = attribute.Name;
             showEmbeddedObjects.Enabled = false;
             showEmbeddedObjects.Checked = false;
             break;
         case EA.ObjectType.otElement:
             EA.Element element = Repository.GetElementByGuid(GUID);
             currentEaObject = element;
             currentEaObjectCollections = new EAElementCollections(element);
             eaObjectName.Text = element.Name;
             showEmbeddedObjects.Enabled = true;
             break;
         case EA.ObjectType.otMethod:
             EA.Method method = Repository.GetMethodByGuid(GUID);
             currentEaObject = method;
             currentEaObjectCollections = null;
             eaObjectName.Text = method.Name;
             showEmbeddedObjects.Enabled = false;
             showEmbeddedObjects.Checked = false;
             break;
         case EA.ObjectType.otPackage:
             EA.Package package = Repository.GetPackageByGuid(GUID);
             currentEaObject = package;
             currentEaObjectCollections = new EAPackageCollections(package);
             eaObjectName.Text = package.Name;
             showEmbeddedObjects.Enabled = true;
             break;
         case EA.ObjectType.otConnector:
             EA.Connector connector = Repository.GetConnectorByGuid(GUID);
             currentEaObject = connector;
             currentEaObjectCollections = null;
             showEmbeddedObjects.Enabled = false;
             showEmbeddedObjects.Checked = false;
             break;
         default:
             currentEaObject = null;
             currentEaObjectCollections = null;
             propertyGrid.SelectedObject = null;
             showEmbeddedObjects.Enabled = false;
             showEmbeddedObjects.Checked = false;
             break;
     }
     SynchPropertyGridSelection();
 }
        /// <summary>
        /// method deletes connector
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="connectorGUID">GUID of connector that should be deleted</param>
        /// <param name="diagramGUID">GUID of diagram</param>
        /// <param name="elementType">type of connector that should be deleted</param>
        public void deleteConnector(EA.Repository Repository, string connectorGUID, string diagramGUID, int elementType)
        {
            EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
            string name = connector.Name;
            EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);
            EA.Element targetElement = (EA.Element)Repository.GetElementByID(connector.SupplierID);

            for (short i = 0; i < srcElement.Connectors.Count; i++)
            {
                EA.Connector conn = (EA.Connector)srcElement.Connectors.GetAt(i);
                if (conn.ConnectorGUID == connectorGUID)
                {
                    srcElement.Connectors.DeleteAt(i, false);
                    break;
                }
            }
            srcElement.Connectors.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '"
                + name + "' between element '" + srcElement.Name +
                "' and element '" + targetElement.Name + "'");
        }
Esempio n. 3
0
        public void handleContextItemChange(EA.Repository repository, string GUID, ObjectType ot)
        {
            try
            {
                switch (ot)
                {
                    case ObjectType.otElement:
                        this.currentItem = repository.GetElementByGuid(GUID);

                        if (currentItem.Type == "Class")
                        {
                            currentAttributes = new Dictionary<string, EA.Attribute>();
                            foreach (EA.Attribute attr in currentItem.Attributes)
                            {
                                currentAttributes.Add(attr.AttributeGUID, attr);
                            }
                        }

                        if (currentItem.Type == "UseCase")
                        {
                            // CONSTRAINTS
                            currentConstraintsList = new List<ConstraintWrapper>();
                            foreach (EA.Constraint constraint in currentItem.Constraints)
                            {
                                currentConstraintsList.Add(new ConstraintWrapper(constraint));
                            }

                            // SCENARIOS
                            currentScenarioList = new List<ScenarioWrapper>();
                            currentScenarioStepList = new Dictionary<string, List<EA.ScenarioStep>>();
                            foreach (EA.Scenario scenario in currentItem.Scenarios)
                            {
                                currentScenarioList.Add(new ScenarioWrapper(scenario));
                                if (!currentScenarioStepList.ContainsKey(scenario.ScenarioGUID))
                                {
                                    currentScenarioStepList.Add(scenario.ScenarioGUID, new List<ScenarioStep>());
                                }

                                foreach (ScenarioStep step in scenario.Steps)
                                {
                                    currentScenarioStepList[scenario.ScenarioGUID].Add(step);
                                }
                            }
                        }

                        this.currentConnector = null;
                        this.currentDiagram = null;
                        changed = false;
                        currentAuthor = repository.GetElementByGuid(GUID).Author;
                        break;
                    case ObjectType.otPackage:
                        this.currentItem = repository.GetElementByGuid(GUID);
                        this.currentConnector = null;
                        this.currentDiagram = null;
                        changed = false;
                        currentAuthor = repository.GetElementByGuid(GUID).Author;
                        break;
                    case ObjectType.otConnector:
                        this.currentConnector = repository.GetConnectorByGuid(GUID);
                        this.currentItem = null;
                        this.currentDiagram = null;
                        changed = false;
                        break;
                    case ObjectType.otDiagram:
                        this.currentDiagram = (EA.Diagram)repository.GetDiagramByGuid(GUID);
                        this.currentConnector = null;
                        this.currentItem = null;
                        changed = false;
                        currentAuthor = ((EA.Diagram)repository.GetDiagramByGuid(GUID)).Author;
                        currentParent = currentDiagram.ParentID.ToString();

                        currentExtensionPoints = new Dictionary<string, string>();
                        currentDiagramObjectPositions = new Dictionary<int, string>();
                        foreach (EA.DiagramObject diagramObject in currentDiagram.DiagramObjects)
                        {
                            try
                            {
                                EA.Collection col = repository.GetElementSet("" + diagramObject.ElementID, 1);
                                EA.Element element = (EA.Element)col.GetAt(0);

                                if (element.Type == "UseCase")
                                {
                                    currentExtensionPoints.Add(element.ElementGUID, element.ExtensionPoints);
                                }
                            }
                            catch (Exception ex)
                            {
                            }

                            string coordinates = "";
                            coordinates += "l=" + diagramObject.left + ";";
                            coordinates += "r=" + diagramObject.right + ";";
                            coordinates += "t=" + diagramObject.top + ";";
                            coordinates += "b=" + diagramObject.bottom + ";";
                            currentDiagramObjectPositions.Add(diagramObject.ElementID, coordinates);

                        }
                        break;
                    default:
                        return;
                }
            }
            catch (NullReferenceException nEx) { }
            catch (Exception ex) { }
        }
Esempio n. 4
0
        public void broadcastEvent(Wrapper.Model model, EA.Repository Repository, string GUID, EA.ObjectType ot)
        {
            ping(GUID, Repository);

            if (ot == EA.ObjectType.otElement)
            {
                object element = Repository.GetElementByGuid(GUID);
                foreach (Rule registeredRule in eventWatchers[((EA.Element)element).Type])
                {
                    string rslt = registeredRule.activate(element, model);
                    if (rslt != "")
                    {
                        if (!active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = createRuleEntry(model, rslt, element, registeredRule);

                            if (active.ContainsKey(GUID))
                            {
                                active[GUID].Add(ruleEntry);
                            }
                            else
                            {
                                List<RuleEntry> ruleEntryList = new List<RuleEntry>();
                                ruleEntryList.Add(ruleEntry);
                                active.Add(GUID, ruleEntryList);
                            }

                            showErrorWindow(Repository);
                            addToDefectsList(rslt, ruleEntry);
                        }
                        else
                        {
                            foreach (RuleEntry ruleEntry in active[GUID])
                            {
                                if (ruleEntry.rule == registeredRule)
                                {
                                    addToDefectsList(rslt, ruleEntry);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = active[GUID].Find(x => x.rule == registeredRule);

                            if (ruleEntry != null)
                            {
                                BPAddIn.BPAddIn.defectsWindow.removeFromList(ruleEntry.listBoxObject);
                                BPAddIn.BPAddIn.defectsWindow.removeFromHiddenList(ruleEntry.listBoxObject);
                                active.Remove(GUID);
                            }
                        }
                    }
                }
            }
            else if (ot == EA.ObjectType.otConnector)
            {
                object connector = Repository.GetConnectorByGuid(GUID);
                foreach (Rule registeredRule in eventWatchers[((EA.Connector)connector).Type])
                {
                    string rslt = registeredRule.activate(connector, model);
                    if (rslt != "")
                    {
                        if (!active.ContainsKey(GUID) || active[GUID].Find(x => x.rule == registeredRule) == null)
                        {
                            RuleEntry ruleEntry = createRuleEntry(model, rslt, connector, registeredRule);

                            if (active.ContainsKey(GUID))
                            {
                                active[GUID].Add(ruleEntry);
                            }
                            else
                            {
                                List<RuleEntry> ruleEntryList = new List<RuleEntry>();
                                ruleEntryList.Add(ruleEntry);
                                active.Add(GUID, ruleEntryList);
                            }

                            showErrorWindow(Repository);
                            addToDefectsList(rslt, ruleEntry);
                        }
                        else
                        {
                            foreach (RuleEntry ruleEntry in active[GUID])
                            {
                                if (ruleEntry.rule == registeredRule)
                                {
                                    addToDefectsList(rslt, ruleEntry);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = active[GUID].Find(x => x.rule == registeredRule);

                            if (ruleEntry != null)
                            {
                                BPAddIn.BPAddIn.defectsWindow.removeFromList(ruleEntry.listBoxObject);
                                BPAddIn.BPAddIn.defectsWindow.removeFromHiddenList(ruleEntry.listBoxObject);
                                active.Remove(GUID);
                            }
                        }
                    }
                }
            }
            else if (ot == EA.ObjectType.otDiagram)
            {
                object diagram = Repository.GetDiagramByGuid(GUID);
                foreach (Rule registeredRule in eventWatchers[((EA.Diagram)diagram).Type])
                {
                    string rslt = registeredRule.activate(diagram, model);
                    if (rslt != "")
                    {
                        if (!active.ContainsKey(GUID) || active[GUID].Find(x => x.rule == registeredRule) == null)
                        {
                            RuleEntry ruleEntry = createRuleEntry(model, rslt, diagram, registeredRule);

                            if (active.ContainsKey(GUID))
                            {
                                active[GUID].Add(ruleEntry);
                            }
                            else
                            {
                                List<RuleEntry> ruleEntryList = new List<RuleEntry>();
                                ruleEntryList.Add(ruleEntry);
                                active.Add(GUID, ruleEntryList);
                            }

                            showErrorWindow(Repository);
                            addToDefectsList(rslt, ruleEntry);
                        }
                        else
                        {
                            foreach (RuleEntry ruleEntry in active[GUID])
                            {
                                if (ruleEntry.rule == registeredRule)
                                {
                                    addToDefectsList(rslt, ruleEntry);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (active.ContainsKey(GUID))
                        {
                            RuleEntry ruleEntry = active[GUID].Find(x => x.rule == registeredRule);

                            if (ruleEntry != null)
                            {
                                BPAddIn.BPAddIn.defectsWindow.removeFromList(ruleEntry.listBoxObject);
                                BPAddIn.BPAddIn.defectsWindow.removeFromHiddenList(ruleEntry.listBoxObject);
                                active.Remove(GUID);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// method changes cardinality of connector at target element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="connectorGUID">GUID of changed connector at target element</param>
        /// <param name="cardinality">new cardinality of changed connector at target element</param>
        /// <param name="oldCardinality">old cardinality of changed connector at target element</param>
        /// <param name="elementType">type of changed connector</param>
        public void changeConnectorTargetCardinality(EA.Repository Repository, string connectorGUID, string cardinality, string oldCardinality, int elementType)
        {
            EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
            connector.SupplierEnd.Cardinality = cardinality;
            connector.Update();

            EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);
            EA.Element targetElement = (EA.Element)Repository.GetElementByID(connector.SupplierID);

            BPAddIn.synchronizationWindow.addToList("Change of cardinality of " + itemTypes.getElementTypeInEnglish(elementType) + " '" +
               connector.Name + "' at target element - previous cardinality: '" + oldCardinality + "', current cardinality: '" + cardinality +
               "' (Connector between element '" + srcElement.Name + "' and element '" + targetElement.Name + "')");
        }
        /// <summary>
        /// method changes target element of connector
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="connectorGUID">GUID of changed connector</param>
        /// <param name="targetGUID">GUID of new target element of changed connector</param>
        /// <param name="oldTargetGUID">GUID of previous target element of changed connector</param>
        /// <param name="elementType">type of changed connector</param>
        public void changeConnectorTarget(EA.Repository Repository, string connectorGUID, string targetGUID, string oldTargetGUID, int elementType)
        {
            EA.Element targetElement = (EA.Element)Repository.GetElementByGuid(targetGUID);
            EA.Element oldTargetElement = (EA.Element)Repository.GetElementByGuid(oldTargetGUID);

            EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
            connector.SupplierID = targetElement.ElementID;
            connector.Update();

            EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);

            BPAddIn.synchronizationWindow.addToList("Change of target element of " + itemTypes.getElementTypeInEnglish(elementType) + " '" +
               connector.Name + "' - previous target element: '" + oldTargetElement.Name + "', current target element: '" + targetElement.Name +
               "' (Connector between element '" + srcElement.Name + "' and element '" + targetElement.Name + "')");
        }
        /// <summary>
        /// method changes notes of connector
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="connectorGUID">GUID of changed connector</param>
        /// <param name="notes">new notes of changed connector</param>
        /// <param name="elementType">type of changed connector</param>
        public void changeConnectorNotes(EA.Repository Repository, string connectorGUID, string notes, int elementType)
        {
            EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
            connector.Notes = notes;
            connector.Update();

            EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);
            EA.Element targetElement = (EA.Element)Repository.GetElementByID(connector.SupplierID);

            BPAddIn.synchronizationWindow.addToList("Change of notes of " + itemTypes.getElementTypeInEnglish(elementType) + " '" +
               connector.Name + "' (Connector between element '" + srcElement.Name + "' and element '" + targetElement.Name + "')");
        }
        /// <summary>
        /// method changes guard of connector
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="connectorGUID">GUID of changed connector</param>
        /// <param name="guard">new guard of changed connector</param>
        /// <param name="oldGuard">previous guard of changed connector</param>
        /// <param name="elementType">type of changed connector</param>
        public void changeConnectorGuard(EA.Repository Repository, string connectorGUID, string guard, string oldGuard, int elementType)
        {
            EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
            connector.TransitionGuard = guard;
            connector.Update();

            EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);
            EA.Element targetElement = (EA.Element)Repository.GetElementByID(connector.SupplierID);

            BPAddIn.synchronizationWindow.addToList("Change of guard of " + itemTypes.getElementTypeInEnglish(elementType) + " '" +
               connector.Name + "' - previous guard: '" + oldGuard + "', current guard: '" + guard +
               "' (Connector between element '" + srcElement.Name + "' and element '" + targetElement.Name + "')");
        }