void getElementFromEA( ) { EA.Repository repo = ProjectSetting.getEARepo(); EA.ObjectType otype = repo.GetContextItemType(); if (otype == EA.ObjectType.otElement) { // Code for when an element is selected EA.Element eaElemObj = (EA.Element)repo.GetContextObject(); if (eaElemObj != null && (eaElemObj.Type == "Class" || eaElemObj.Type == "Enumeration")) { ElementVO eaElement = ObjectEAConverter.getElementFromEAObject(eaElemObj); textBoxElementName.Text = eaElement.name; targetElement = eaElement; } else { textBoxElementName.Text = "(EA上でクラスを選択してください)"; targetElement = null; } } else { textBoxElementName.Text = "(EA上でクラスを選択してください)"; targetElement = null; } }
private void exportDiagram(EA.Repository Repository) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } DiagramManager.exportDiagram(Repository, diagram); }
private void exportAll(EA.Repository Repository, DiagramCache diagramCache) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); exportRoundTripPackage(Repository, apiPackage, diagramCache); }
private void exportAll(EA.Repository Repository) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } APIManager.exportAPI(Repository, diagram); EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); exportAPIPackage(Repository, apiPackage); }
/// <summary> /// Bulk Change Diagram Style according to: /// liParameter[0] Styles/StyleEx /// liParameter[1] PDATA/ExtendedStyle /// liParameter[2] Properties /// liParameter[3] Diagram types as comma, semicolon separated list /// </summary> /// <param name="rep"></param> /// <param name="liParameter"></param> /// <param name="changeScope"></param> public static void ChangeDiagramStyle(EA.Repository rep, string[] liParameter, ChangeScope changeScope = ChangeScope.PackageRecursive) { switch (rep.GetContextItemType()) { case EA.ObjectType.otDiagram: EA.Diagram dia = (EA.Diagram)rep.GetContextObject(); SetDiagramStyle(rep, dia, liParameter); break; case EA.ObjectType.otPackage: EA.Package pkg = (EA.Package)rep.GetContextObject(); RecursivePackages.DoRecursivePkg(rep, pkg, null, null, SetDiagramStyle, liParameter, changeScope); break; case EA.ObjectType.otElement: EA.Element el = (EA.Element)rep.GetContextObject(); RecursivePackages.DoRecursiveEl(rep, el, null, SetDiagramStyle, liParameter, changeScope); break; } }
/// /// Called when user makes a selection in the menu. /// This is your main exit point to the rest of your Add-in /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// <param name="ItemName" />the name of the selected menu item public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName) { logger.enable(Repository); EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } switch (ItemName) { case menuExportAll: exportAll(Repository); break; case menuExportPackage: exportPackage(Repository); break; case menuExportDiagram: exportDiagram(Repository); break; case menuExportSchema: try { SchemaManager.exportSchema(Repository, diagram); MetaDataManager.setAsSchemaDiagram(Repository, diagram); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; //case menuExportCanonical: // try // { // SchemaManager.exportCanonical(Repository, diagram); // //MetaDataManager.setAsCanonicalDiagram(Repository, diagram); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } // break; case menuExportSample: SampleManager.exportSample(Repository, diagram); MetaDataManager.setAsSampleDiagram(Repository, diagram); break; case menuSyncSample: SampleManager.syncSample(Repository, diagram); break; case menuCreateSample: SchemaManager.generateSample(Repository); break; case menuUpdateClassFromInstance: SchemaManager.updateClassFromInstance(Repository); break; case menuUpdateInstanceFromClass: SchemaManager.operateOnSample(Repository, SchemaManager.updateSampleFromClass); break; case menuValidateDiagram: if (diagram != null) { if (diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { SampleManager.validateDiagram(Repository, diagram); } else if (diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { SchemaManager.validateDiagram(Repository, diagram); } else if (diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_APIDIAGRAM)) { APIManager.validateDiagram(Repository, diagram); } } break; case menuExportAPI: APIManager.exportAPI(Repository, diagram); MetaDataManager.setAsAPIDiagram(Repository, diagram); break; case menuExportAPIRAML1: APIManager.exportAPI_RAML1(Repository, diagram); MetaDataManager.setAsAPIDiagram(Repository, diagram); break; case menuToggleLogging: logger.toggleLogging(Repository); break; case menuWeb: this.callWeb(Repository); break; case menuImportSOA: WSDLManager.importWSDLs(Repository, diagram); break; case menuExportSOA: WSDLManager.exportWSDLs(Repository, diagram); break; } }
/// /// Called once Menu has been opened to see what menu items should active. /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// <param name="ItemName" />the name of the menu item /// <param name="IsEnabled" />boolean indicating whethe the menu item is enabled /// <param name="IsChecked" />boolean indicating whether the menu is checked public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked) { logger.log("Get Menu State:" + MenuName + ":" + ItemName); if (IsProjectOpen(Repository)) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } switch (ItemName) { case menuWeb: IsEnabled = true; break; case menuValidateDiagram: IsEnabled = true; break; // there shouldn't be any other, but just in case disable it. case menuExportAPI: case menuExportAPIRAML1: IsEnabled = false; if (diagram != null && ( diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_APIDIAGRAM) || diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SOADIAGRAM) ) ) { IsEnabled = true; } break; case menuExportSchema: case menuCreateSample: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { IsEnabled = true; } break; case menuExportSample: case menuSyncSample: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { IsEnabled = true; } break; case menuExportAll: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_APIDIAGRAM)) { IsEnabled = true; } break; //case menuExportCanonical: // IsEnabled = false; // if (diagram != null && diagram.Stereotype.Equals(APIAddInClass.EA_STEREOTYPE_CANONICALDIAGRAM)) // IsEnabled = true; // break; default: IsEnabled = true; break; } } else { // If no open project, disable all menu options IsEnabled = false; } }
/// /// Called when user Clicks Add-Ins Menu item from within EA. /// Populates the Menu with our desired selections. /// Location can be "TreeView" "MainMenu" or "Diagram". /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// public object EA_GetMenuItems(EA.Repository Repository, string Location, string MenuName) { logger.log("location:" + Location); logger.log("MenuName:" + MenuName); logger.log("ContextItemType:" + Repository.GetContextItemType()); EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } else if (Repository.GetContextItemType() == ObjectType.otElement) { diagram = Repository.GetCurrentDiagram(); } switch (MenuName) { // defines the top level menu option case "": return(menuHeader); case menuHeader: string[] subMenusOther = { menuExportPackage, menuExportAll, menuExportDiagram, menuToggleLogging }; string[] subMenusAPI = { menuExportPackage, menuExportAll, menuExportDiagram, menuExportAPI, menuExportAPIRAML1, menuValidateDiagram, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; string[] subMenusSOA = { menuExportPackage, menuExportSOA, menuExportDiagram, menuImportSOA }; string[] subMenusSchema = { menuExportPackage, menuExportAll, menuExportDiagram, menuValidateDiagram, menuExportSchema, menuCreateSample, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; string[] subMenusSample = { menuExportPackage, menuExportAll, menuExportDiagram, menuExportSample, menuValidateDiagram, menuSyncSample, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; //string[] subMenusCanonical = { menuExportAll, menuExportDiagram, menuExportCanonical, menuCreateSample, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_APIDIAGRAM)) { logger.log("API Menus"); return(subMenusAPI); } else if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SOADIAGRAM)) { logger.log("SOA Menus"); return(subMenusSOA); } else if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { logger.log("Schema Menus"); return(subMenusSchema); } else if (diagram != null && diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { logger.log("Sample Menus"); return(subMenusSample); } //else if (diagram != null && diagram.Stereotype.Equals(APIAddInClass.EA_STEREOTYPE_CANONICALDIAGRAM)) //{ // logger.log("Canonical Menus"); // return subMenusCanonical; //} return(subMenusOther); case menuHeaderExperimental: string[] subMenus2 = { menuSqlQuery, menuWeb, }; //EA.Element apiEl = diagramAPI(Repository); //if (apiEl == null) //{ // return new string[] { menuGenerate, menuGenerateSamples, menuGenerateAPI, menuValidateDiagram, }; //} return(subMenus2); } return(""); }
/// /// Called when user makes a selection in the menu. /// This is your main exit point to the rest of your Add-in /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// <param name="ItemName" />the name of the selected menu item public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName) { logger.enable(Repository); DiagramCache diagramCache = new DiagramCache(); EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } switch (ItemName) { case menuExportMapping: MappingManager.exportMapping(Repository, diagram, diagramCache); break; case menuSyncMapping: MappingManager.syncMapping(Repository, diagram, diagramCache); break; case menuExportHierarchy: logger.log("Menu Export Hierarchy"); HierarchyManager.exportHierarchy(Repository, diagram, diagramCache); break; case menuExportPopulation: PopulationManager.exportPopulation(Repository, diagram, diagramCache); break; case menuSyncPopulation: PopulationManager.syncPopulation(Repository, diagram, diagramCache); break; case menuSyncHierarchy: HierarchyManager.syncHierarchy(Repository, diagram, diagramCache); break; case menuExportConstraint: ConstraintManager.exportConstraint(Repository, diagram, diagramCache); break; case menuSyncConstraint: ConstraintManager.syncConstraint(Repository, diagram, diagramCache); break; case menuExportAll: exportAll(Repository, diagramCache); break; case menuExportPackage: exportPackage(Repository, diagramCache); break; case menuExportDiagram: exportDiagram(Repository); break; case menuExportSchema: try { SchemaManager.exportSchema(Repository, diagram, diagramCache); MetaDataManager.setAsSchemaDiagram(Repository, diagram); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; //case menuExportCanonical: // try // { // SchemaManager.exportCanonical(Repository, diagram); // //MetaDataManager.setAsCanonicalDiagram(Repository, diagram); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } // break; case menuExportSample: SampleManager.exportSample(Repository, diagram, diagramCache); MetaDataManager.setAsSampleDiagram(Repository, diagram); break; case menuSyncSample: SampleManager.syncSample(Repository, diagram, diagramCache); break; case menuCreateSample: SchemaManager.generateSample(Repository, diagramCache); break; case menuUpdateClassFromInstance: SchemaManager.updateClassFromInstance(Repository); break; case menuUpdateInstanceFromClass: SchemaManager.operateOnSample(Repository, SchemaManager.updateSampleFromClass); break; case menuValidateDiagram: if (diagram != null) { if (diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { SampleManager.validateDiagram(Repository, diagram, diagramCache); } else if (diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { SchemaManager.validateDiagram(Repository, diagram, diagramCache); } } break; case menuToggleLogging: logger.toggleLogging(Repository); break; case menuWeb: this.callWeb(Repository); break; } }
/// /// Called once Menu has been opened to see what menu items should active. /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// <param name="ItemName" />the name of the menu item /// <param name="IsEnabled" />boolean indicating whethe the menu item is enabled /// <param name="IsChecked" />boolean indicating whether the menu is checked public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked) { logger.log("Get Menu State:" + MenuName + ":" + ItemName); if (IsProjectOpen(Repository)) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } switch (ItemName) { case menuWeb: IsEnabled = true; break; case menuValidateDiagram: IsEnabled = true; break; // there shouldn't be any other, but just in case disable it. case menuExportSchema: case menuCreateSample: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { IsEnabled = true; } break; case menuExportSample: case menuSyncSample: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { IsEnabled = true; } break; case menuSyncPopulation: case menuExportPopulation: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_POPULATIONDIAGRAM)) { IsEnabled = true; } break; case menuExportMapping: case menuSyncMapping: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_MAPPINGDIAGRAM)) { IsEnabled = true; } break; case menuExportHierarchy: case menuSyncHierarchy: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_HIERARCHYDIAGRAM)) { IsEnabled = true; } break; case menuSyncConstraint: case menuExportConstraint: IsEnabled = false; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_CONSTRAINTDIAGRAM)) { IsEnabled = true; } break; case menuExportAll: IsEnabled = false; if (diagram != null) { IsEnabled = true; } break; //case menuExportCanonical: // IsEnabled = false; // if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_CANONICALDIAGRAM)) // IsEnabled = true; // break; default: IsEnabled = true; break; } } else { // If no open project, disable all menu options IsEnabled = false; } }
/// /// Called when user Clicks Add-Ins Menu item from within EA. /// Populates the Menu with our desired selections. /// Location can be "TreeView" "MainMenu" or "Diagram". /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// public object EA_GetMenuItems(EA.Repository Repository, string Location, string MenuName) { logger.log("location:" + Location); logger.log("MenuName:" + MenuName); logger.log("ContextItemType:" + Repository.GetContextItemType()); EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } else if (Repository.GetContextItemType() == ObjectType.otElement) { diagram = Repository.GetCurrentDiagram(); } switch (MenuName) { // defines the top level menu option case "": return(menuHeader); case menuHeader: string[] subMenusOther = { menuExportPackage, menuExportAll, menuExportDiagram, menuToggleLogging }; //string[] subMenusAPI = { menuExportPackage, menuExportAll, menuExportDiagram, menuExportAPI, menuExportAPIRAML1, menuValidateDiagram, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; string[] subMenusSchema = { menuExportPackage, menuExportAll, menuExportDiagram, menuValidateDiagram, menuExportSchema, menuCreateSample, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; string[] subMenusSample = { menuExportPackage, menuExportAll, menuExportDiagram, menuExportSample, menuValidateDiagram, menuSyncSample, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; string[] subMenusPopulation = { menuExportPopulation, menuSyncPopulation, menuExportDiagram, menuToggleLogging }; string[] subMenusHierarchy = { menuExportHierarchy, menuSyncHierarchy, menuExportDiagram, menuToggleLogging }; string[] subMenusMapping = { menuExportMapping, menuSyncMapping, menuExportDiagram, menuToggleLogging }; string[] subMenusConstraint = { menuExportConstraint, menuSyncConstraint, menuExportDiagram, menuToggleLogging }; //string[] subMenusCanonical = { menuExportAll, menuExportDiagram, menuExportCanonical, menuCreateSample, menuUpdateClassFromInstance, menuUpdateInstanceFromClass, menuToggleLogging }; if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { logger.log("Schema Menus"); return(subMenusSchema); } else if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { logger.log("Sample Menus"); return(subMenusSample); } else if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_POPULATIONDIAGRAM)) { logger.log("Population Menus"); return(subMenusPopulation); } else if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_HIERARCHYDIAGRAM)) { logger.log("Population Menus"); return(subMenusHierarchy); } else if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_MAPPINGDIAGRAM)) { logger.log("Mapping Menus"); return(subMenusMapping); } else if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_CONSTRAINTDIAGRAM)) { logger.log("Constraint Menus"); return(subMenusConstraint); } //else if (diagram != null && diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_CANONICALDIAGRAM)) //{ // logger.log("Canonical Menus"); // return subMenusCanonical; //} return(subMenusOther); case menuHeaderExperimental: string[] subMenus2 = { menuSqlQuery, menuWeb, }; //EA.Element apiEl = diagramAPI(Repository); //if (apiEl == null) //{ // return new string[] { menuGenerate, menuGenerateSamples, menuGenerateAPI, menuValidateDiagram, }; //} return(subMenus2); } return(""); }