internal bool ParseCode(WhiteStarUML.IUMLPackage parentPackage) { // Get IR data from file MsgTextWriter errorWriter = new MsgTextWriter(); List <IR.Table> tables = ParseERDTables(errorWriter); LastParseLog = errorWriter.Errors; bool parseSucceded = (LastParseLog.Count() == 0); if (parseSucceded) { try { UMLFactoryHandler.Instance.AddErdDiagram(parentPackage, DiagramName, tables); } catch (System.Runtime.InteropServices.COMException e) { LastParseLog = new List <string>(); LastParseLog.Add(e.Message); LastParseLog.Add(Symbols.ERR_INVALID_OPERATION); return(false); } } return(parseSucceded); // Successful if no problems reported }
/// <summary> /// Creates tree node encapsulating IUMLPackage object /// </summary> /// <param name="package">Encapsulated data</param> /// <returns></returns> private static TreeNode CreateNode(WhiteStarUML.IUMLPackage package) { TreeNode node = new TreeNode(package.Name); node.Tag = package; return(node); }
/// <summary> /// Fills diagrams in list box /// </summary> /// <param name="parentNode"></param> private void collectChildDiagrams(TreeNode parentNode) { if (parentNode != null) { WhiteStarUML.IUMLPackage parentPackage = (WhiteStarUML.IUMLPackage)parentNode.Tag; List <WhiteStarUML.IUMLClassDiagram> diagrams = ProjectManagerHandler.Instance.GetOwnedErdDiagrams(parentPackage); diagramListBox.Items.Clear(); foreach (var package in diagrams) { diagramListBox.Items.Add(new DiagramListBoxItemWrapper(package)); } } }
/// <summary> /// Fills tree view with children of given package /// </summary> /// <param name="parentNode">Starting node</param> /// <param name="childNodes">Container for created nodes for recursive processing, null if not required</param> private static void CreateChildNodes(TreeNode parentNode, List <TreeNode> childNodes = null) { // Create list of child nodes WhiteStarUML.IUMLPackage parentPackage = (WhiteStarUML.IUMLPackage)parentNode.Tag; List <WhiteStarUML.IUMLPackage> packageNodes = ProjectManagerHandler.Instance.GetOwnedPackages(parentPackage); parentNode.Nodes.Clear(); // Process child nodes foreach (var package in packageNodes) { // Create and add child node TreeNode newNode = CreateNode(package); parentNode.Nodes.Add(newNode); if (childNodes != null) { childNodes.Add(newNode); // Collecting children } else // It is a grand child of initial node { break; // One grand child node is enough to mark parent as expandable } } }