/// <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); }
/// <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); }