コード例 #1
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) { }
        }