Rev 2139 | Rev 2145 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
//-----------------------------------------------------------------------// This is open source licensed under GPL////using System;using System.Text;using System.Globalization;using System.Collections;using System.Windows.Forms;using ReqPro40;namespace EA_ReqPro{public class Main{public String EA_Connect(EA.Repository Repository){return "a string";}public readonly static String GUI_OUTPUT_TAB_NAME = "EA_ReqPro";/// <summary>/// Called when EA initialised. Creates an output tab for the add in./// </summary>/// <param name="repository"></param>public void EA_OnPostInitialized(EA.Repository repository){repository.CreateOutputTab(GUI_OUTPUT_TAB_NAME);repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);}public void EA_Disconnect(){GC.Collect();GC.WaitForPendingFinalizers();}/// <summary>/// Event called when user clicks on an entry in the output/// window. If an element has been associated with the message, it will/// be automatically selected in the project browser./// </summary>/// <param name="repository"></param>/// <param name="outputTabNea"></param>/// <param name="lineText"></param>/// <param name="lineIdentifier"></param>public void EA_OnOutputItemClicked( EA.Repository repository,String outputTabName,String lineText,Int32 identifier){if ((outputTabName == GUI_OUTPUT_TAB_NAME) && (identifier > 0)){try{EA.Element element = repository.GetElementByID(identifier);repository.ShowInProjectView(element);}catch{try{EA.Package package = repository.GetPackageByID(identifier);repository.ShowInProjectView(package);}catch{}}}}public object EA_GetMenuItems(EA.Repository repository, string location, string menu){switch( menu ){case "":return "-&EA_ReqPro";case "-&Traceability Use":{string[] ar = {"&Prepare Package for Traceability Use","&Import for Traceability Use","&Display Change Log",};return ar; }case "-&EA_ReqPro":{string[] ar = {"-&Traceability Use","&Import for Document Model Use","&Export to ReqPro Compatible CSV File",};return ar;}}return "";}bool IsProjectOpen(EA.Repository Repository){try{EA.Collection collection = Repository.Models;return true;}catch{return false;}}public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked){object o;EA.ObjectType type;isChecked = false;if (IsProjectOpen(repository)){switch (itemName){case "&Import for Document Model Use":case "&Prepare Package for Traceability Use":case "&Export to ReqPro Compatible CSV File":type = repository.GetTreeSelectedItem(out o);if (type == EA.ObjectType.otPackage){isEnabled = true;}else{isEnabled = false;}break;case "-&Traceability Use":isEnabled = true;break;case "&Import for Traceability Use":type = repository.GetTreeSelectedItem(out o);if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB")){isEnabled = true;}else{isEnabled = false;}break;case "&Display Change Log":type = repository.GetTreeSelectedItem(out o);if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Name == "Change Log")){isEnabled = true;}else{isEnabled = false;}break;}}else{isEnabled = false;}}public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName){switch( itemName ){case "&Prepare Package for Traceability Use":repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);ReqProDB_Artifact RQ_Artifact = new ReqProDB_Artifact();RQ_Artifact.AssociatePackageToReqProDatabase(repository);break;case "&Import for Traceability Use":{ImportReqProDatabase import_parser = new ImportReqProDatabase(repository);repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);import_parser.parse(repository);break;}case "&Import for Document Model Use":repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);CopyReqProDatabase copy_parser = new CopyReqProDatabase(repository);copy_parser.prompt_and_parse(repository);break;case "&Export to ReqPro Compatible CSV File":repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);ExportToReqProCSVForm export_dlg = new ExportToReqProCSVForm();DialogResult dlgRes = export_dlg.ShowDialog();if (dlgRes == DialogResult.OK){export_dlg.Export(repository);}break;case "&Display Change Log":{ImportReqProDatabase import_parser = new ImportReqProDatabase(repository);EA.Element changeLog = (EA.Element)repository.GetTreeSelectedObject();repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);import_parser.displayChangeLog(repository, changeLog);break;}}}}}