Blame | Last modification | View Log | RSS feed
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;namespace EA_ReqPro{/// <summary>/// Summary description for ExportForm./// </summary>public class ExportForm : System.Windows.Forms.Form{private ReqPro_object m_rq_root_package;private ArrayList m_req_types;private string m_default_pkg_selection_guid;private bool m_got_pkg_selection;private System.Windows.Forms.Button button_ok;private System.Windows.Forms.Button button_cancel;private System.Windows.Forms.TreeView PackageFilterTreeView;private System.Windows.Forms.TextBox textBox_newFolder;private System.Windows.Forms.CheckBox checkBox_createFolder;private System.Windows.Forms.ComboBox comboBox_ReqType;private System.Windows.Forms.Label label1;private System.Windows.Forms.Label label2;private System.Windows.Forms.ComboBox comboBox_ExportExtent;private System.Windows.Forms.Label label4;/// <summary>/// Required designer variable./// </summary>private System.ComponentModel.Container components = null;public enum ExportExtent{SINGLE_REQ,PACKAGE_REQS,REQPRODB_REQS};public ExportForm(){//// Required for Windows Form Designer support//InitializeComponent();//// TODO: Add any constructor code after InitializeComponent call//}/// <summary>/// Clean up any resources being used./// </summary>protected override void Dispose( bool disposing ){if( disposing ){if(components != null){components.Dispose();}}base.Dispose( disposing );}#region Windows Form Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){this.button_ok = new System.Windows.Forms.Button();this.button_cancel = new System.Windows.Forms.Button();this.PackageFilterTreeView = new System.Windows.Forms.TreeView();this.textBox_newFolder = new System.Windows.Forms.TextBox();this.checkBox_createFolder = new System.Windows.Forms.CheckBox();this.comboBox_ReqType = new System.Windows.Forms.ComboBox();this.label1 = new System.Windows.Forms.Label();this.label2 = new System.Windows.Forms.Label();this.comboBox_ExportExtent = new System.Windows.Forms.ComboBox();this.label4 = new System.Windows.Forms.Label();this.SuspendLayout();//// button_ok//this.button_ok.DialogResult = System.Windows.Forms.DialogResult.OK;this.button_ok.Location = new System.Drawing.Point(328, 552);this.button_ok.Name = "button_ok";this.button_ok.TabIndex = 4;this.button_ok.Text = "OK";//// button_cancel//this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;this.button_cancel.Location = new System.Drawing.Point(424, 552);this.button_cancel.Name = "button_cancel";this.button_cancel.TabIndex = 5;this.button_cancel.Text = "Cancel";//// PackageFilterTreeView//this.PackageFilterTreeView.HideSelection = false;this.PackageFilterTreeView.ImageIndex = -1;this.PackageFilterTreeView.Location = new System.Drawing.Point(8, 40);this.PackageFilterTreeView.Name = "PackageFilterTreeView";this.PackageFilterTreeView.SelectedImageIndex = -1;this.PackageFilterTreeView.Size = new System.Drawing.Size(488, 368);this.PackageFilterTreeView.TabIndex = 0;//// textBox_newFolder//this.textBox_newFolder.Location = new System.Drawing.Point(8, 424);this.textBox_newFolder.Name = "textBox_newFolder";this.textBox_newFolder.Size = new System.Drawing.Size(456, 22);this.textBox_newFolder.TabIndex = 1;this.textBox_newFolder.Text = "new sub-folder name here (if applicable)";this.textBox_newFolder.TextChanged += new System.EventHandler(this.textBox_newFolder_TextChanged);//// checkBox_createFolder//this.checkBox_createFolder.Location = new System.Drawing.Point(472, 424);this.checkBox_createFolder.Name = "checkBox_createFolder";this.checkBox_createFolder.Size = new System.Drawing.Size(24, 24);this.checkBox_createFolder.TabIndex = 4;//// comboBox_ReqType//this.comboBox_ReqType.Location = new System.Drawing.Point(192, 464);this.comboBox_ReqType.Name = "comboBox_ReqType";this.comboBox_ReqType.Size = new System.Drawing.Size(304, 24);this.comboBox_ReqType.TabIndex = 2;this.comboBox_ReqType.Text = "comboBox1";//// label1//this.label1.Location = new System.Drawing.Point(8, 465);this.label1.Name = "label1";this.label1.Size = new System.Drawing.Size(176, 23);this.label1.TabIndex = 7;this.label1.Text = "Export As Requirement Type";//// label2//this.label2.Location = new System.Drawing.Point(8, 8);this.label2.Name = "label2";this.label2.Size = new System.Drawing.Size(400, 16);this.label2.TabIndex = 6;this.label2.Text = "Select ReqPro package where new requirements will be written";//// comboBox_ExportExtent//this.comboBox_ExportExtent.Location = new System.Drawing.Point(120, 504);this.comboBox_ExportExtent.Name = "comboBox_ExportExtent";this.comboBox_ExportExtent.Size = new System.Drawing.Size(376, 24);this.comboBox_ExportExtent.TabIndex = 10;this.comboBox_ExportExtent.Text = "comboBox1";//// label4//this.label4.Location = new System.Drawing.Point(8, 504);this.label4.Name = "label4";this.label4.Size = new System.Drawing.Size(104, 16);this.label4.TabIndex = 11;this.label4.Text = "Extent of Export";//// ExportForm//this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);this.ClientSize = new System.Drawing.Size(512, 592);this.Controls.Add(this.label4);this.Controls.Add(this.comboBox_ExportExtent);this.Controls.Add(this.label2);this.Controls.Add(this.label1);this.Controls.Add(this.comboBox_ReqType);this.Controls.Add(this.checkBox_createFolder);this.Controls.Add(this.textBox_newFolder);this.Controls.Add(this.PackageFilterTreeView);this.Controls.Add(this.button_cancel);this.Controls.Add(this.button_ok);this.Name = "ExportForm";this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;this.Text = "Export To ReqPro Database";this.ResumeLayout(false);}#endregion#region Form methods/// <summary>/// Populate the treeView control with package names and hierarchy captured and passed in/// in the form of a ReqPro_object (the root object)/// </summary>/// <param name="rq_root_package"></param>public void populate(ReqPro_object rq_root_package,string defaultPackageselectionGUID,ArrayList req_types,ArrayList rq_req_status_types){m_rq_root_package = rq_root_package;m_default_pkg_selection_guid = defaultPackageselectionGUID;// Package Filter populationm_got_pkg_selection = false;PackageFilterTreeView.BeginUpdate();PackageFilterTreeView.Nodes.Clear();int i_new = PackageFilterTreeView.Nodes.Add(new TreeNode(rq_root_package.name));populate_PackageFilterTreeView_node(rq_root_package, PackageFilterTreeView.Nodes[i_new].Nodes);PackageFilterTreeView.ExpandAll();if (false == m_got_pkg_selection)PackageFilterTreeView.SelectedNode = PackageFilterTreeView.Nodes[i_new];PackageFilterTreeView.EndUpdate();// Requirement Type combo populationcomboBox_ReqType.BeginUpdate();comboBox_ReqType.Items.Clear();populate_RequirementTypeList(req_types);comboBox_ReqType.EndUpdate();// set default export extentcomboBox_ExportExtent.BeginUpdate();comboBox_ExportExtent.Items.Clear();populate_ExtentOfExport();comboBox_ExportExtent.EndUpdate();}private void populate_PackageFilterTreeView_node(ReqPro_object rq_obj, TreeNodeCollection tnc){// scan this ReqPro objects sub-objects. For each package found, add a// tree node, and recurse to find and populate tree nodes for its sub-packagesforeach( ReqPro_object sub_obj in rq_obj.ReqPro_objects ){if (sub_obj.isPackage){int i_new = 0;// Add a tree node to the controlif (sub_obj.numberOfRequirements > 0){string nodeName = String.Format("{0} ({1})", sub_obj.name, sub_obj.numberOfRequirements);i_new = tnc.Add(new TreeNode(nodeName));}else{i_new = tnc.Add(new TreeNode(sub_obj.name));}// Use the Node's Tag to hold a reference to our ReqPro_object.// This allows rapid access to the object whenever we do something with or to// a node during the use of the dialog.tnc[i_new].Tag = sub_obj;if (m_got_pkg_selection == false && sub_obj.guid.Equals(this.m_default_pkg_selection_guid)){m_got_pkg_selection = true;PackageFilterTreeView.SelectedNode = tnc[i_new];}// recursepopulate_PackageFilterTreeView_node(sub_obj, tnc[i_new].Nodes);}}}private void populate_RequirementTypeList(ArrayList req_types){m_req_types = req_types;bool gotDefaultSelection = false;foreach(ReqPro_ReqType req_type in req_types){string node_name = String.Format("{0} ({1})", req_type.name, req_type.prefix);int i = comboBox_ReqType.Items.Add(node_name);if (node_name.IndexOf("SPR",0) >= 0){comboBox_ReqType.SelectedIndex = i;gotDefaultSelection = true;}}if (!gotDefaultSelection)comboBox_ReqType.SelectedIndex = 0;}private void populate_ExtentOfExport(){comboBox_ExportExtent.Items.Add("Selected (single) requirement only");comboBox_ExportExtent.Items.Add("Req's from selected package and below");comboBox_ExportExtent.Items.Add("Req's from ReqProDB container package and below"); // DefaultcomboBox_ExportExtent.SelectedIndex = 2;}public ReqPro_object user_selected_object(){return (ReqPro_object)PackageFilterTreeView.SelectedNode.Tag;}public bool user_create_folder_selection(out string folderName){if (checkBox_createFolder.Checked){folderName = textBox_newFolder.Text;return true;}else{folderName = null;return false;}}public string user_selected_requirement_type(){return (string)comboBox_ReqType.SelectedItem;}public ExportExtent user_selected_export_extent(){return (ExportExtent)comboBox_ExportExtent.SelectedIndex;}#endregionprivate void textBox_newFolder_TextChanged(object sender, System.EventArgs e){checkBox_createFolder.Checked = true;}}}