private static void addFactory(UMLModel model, UMLFactory factory) { if (!instances.ContainsKey(model)) { instances.Add(model, factory); } }
/// returns the factory that corresponds to the given model protected static UMLFactory getFactory(UMLModel model) { UMLFactory instance = null; instances.TryGetValue(model, out instance); return(instance); }
/// <summary> /// To initialize an UMLTabItem instance from a .uml file (in xml format) /// </summary> /// <param name="text">the text string of the source .sn file</param> public override void SetText(string text) { //generate an SNModel instance from the .uml source code UMLModel uml = UMLModel.LoadUMLModelFromXML(text); if (uml.Assertion != null) { AssertionNode.Tag = uml.Assertion; } else { AssertionNode.Tag = " "; } DiagramsNode.Nodes.Clear(); foreach (var diagram in uml.Diagrams) { TreeNode node = DiagramsNode.Nodes.Add(diagram.Key); node.Tag = diagram.Value; node.Name = diagram.Key; } textEditorControl.Visible = true; InitTextEditor(); }
/// returns the singleton instance of the factory public static UMLFactory getInstance(UMLModel model) { UMLFactory instance = getFactory(model); if (instance == null) { instance = model.factory; } return(instance); }
private bool FindPackageRoot(UMLModel model) { if (model.Name == this._packageRoot) { return(true); } else { return(false); } }
//Generate XML from the current UMLTabItem private XmlDocument GetDoc() { string assertion = ""; if (AssertionNode.Tag != null) { assertion = AssertionNode.Tag.ToString(); } Dictionary <string, StateDiagram> diagrams = new Dictionary <string, StateDiagram>(); foreach (TreeNode node in DiagramsNode.Nodes) { diagrams.Add(node.Name, new StateDiagram(node.Name, (node.Tag as StateDiagram).XmiContent)); } UMLModel umlModel = new UMLModel("UMLModel", diagrams, assertion); return(umlModel.GenerateXML()); }
public UMLFactory(UMLModel model) { this.model = model; UMLFactory.addFactory(model, this); }
//METHODS #region Methods /* * This method has the responsbility of ensuring that all the file generation is completed * successfully. */ public void CreateFiles(object observer) { List<UMLFile> files; List<IUMLElement> rootItems; UMLPackage package; bool obsValid = false; if (observer != null) { if (observer is IGenerationStageObserver) { obsValid = true; } } //1. Setup the environment UMLModelCollection models = UMLProject.GetInstance().GetUMLModels(); //find if package-root already exists UMLModel pkgRoot = models.Find(FindPackageRoot); if (pkgRoot == null) { pkgRoot = new UMLModel(); pkgRoot.Name = this._packageRoot; pkgRoot.Owner = UMLProject.GetInstance(); pkgRoot.Save(); } //find if package already exists rootItems = pkgRoot.GetOwnedElements(); package = (UMLPackage)(rootItems.Find(FindPackage)); if (package != null) { package.Delete(); } package = new UMLPackage(); package.Owner = pkgRoot; package.Name = this._packageName; package.Save(); if (obsValid == true) { ((IGenerationStageObserver)observer).setStage(1); } //2. Analyze the model UMLClassCollection classes = UMLProject.GetInstance().GetUMLClasses(); IDictionary relationships = HelperRelationships.GetRelationships((UMLClassCollection)classes); files = analyzer.CreateFiles(relationships); if (obsValid == true) { ((IGenerationStageObserver)observer).setStage(2); } //3. Save the files to StarUML foreach (UMLFile file in files) { file.Owner = package; file.Stereotype = TUPUX.Entity.Constants.UMLFile.STEREOTYPE; file.Save(); foreach (UMLAttribute a in file.Attributes) { a.Owner = file; a.Save(); } } if (obsValid == true) { ((IGenerationStageObserver)observer).setStage(3); } }
private bool FindPackageRoot(UMLModel model) { if (model.Name == this._packageRoot) { return true; } else { return false; } }
//METHODS #region Methods /* * This method has the responsbility of ensuring that all the file generation is completed * successfully. */ public void CreateFiles(object observer) { List <UMLFile> files; List <IUMLElement> rootItems; UMLPackage package; bool obsValid = false; if (observer != null) { if (observer is IGenerationStageObserver) { obsValid = true; } } //1. Setup the environment UMLModelCollection models = UMLProject.GetInstance().GetUMLModels(); //find if package-root already exists UMLModel pkgRoot = models.Find(FindPackageRoot); if (pkgRoot == null) { pkgRoot = new UMLModel(); pkgRoot.Name = this._packageRoot; pkgRoot.Owner = UMLProject.GetInstance(); pkgRoot.Save(); } //find if package already exists rootItems = pkgRoot.GetOwnedElements(); package = (UMLPackage)(rootItems.Find(FindPackage)); if (package != null) { package.Delete(); } package = new UMLPackage(); package.Owner = pkgRoot; package.Name = this._packageName; package.Save(); if (obsValid == true) { ((IGenerationStageObserver)observer).setStage(1); } //2. Analyze the model UMLClassCollection classes = UMLProject.GetInstance().GetUMLClasses(); IDictionary relationships = HelperRelationships.GetRelationships((UMLClassCollection)classes); files = analyzer.CreateFiles(relationships); if (obsValid == true) { ((IGenerationStageObserver)observer).setStage(2); } //3. Save the files to StarUML foreach (UMLFile file in files) { file.Owner = package; file.Stereotype = TUPUX.Entity.Constants.UMLFile.STEREOTYPE; file.Save(); foreach (UMLAttribute a in file.Attributes) { a.Owner = file; a.Save(); } } if (obsValid == true) { ((IGenerationStageObserver)observer).setStage(3); } }
/// <summary> /// Finds model with name "Design Model" /// </summary> /// <param name="model"></param> /// <returns></returns> private bool FindDesignView(UMLModel model) { //if (model.Name == "Logical View") if (model.Name == "Design Model") { return true; } return false; }
/// <summary> /// Finds model with name "Phase Iteration Model" /// </summary> /// <param name="model"></param> /// <returns></returns> private bool FindLogicalView(UMLModel model) { //if (model.Name == "Logical View") if (model.Name == "Phase Iteration Model") { return true; } return false; }
/// <summary> /// Finds model with name "Use Case Model" /// </summary> /// <param name="model"></param> /// <returns></returns> private bool FindScenarios(UMLModel model) { //if (model.Name == "Scenarios") if (model.Name == "Use Case Model") { return true; } return false; }