public DataElementCreationForm() { InitializeComponent(); dataElementCreationControl.parent = this; EASubmissionCompleteControl scControl = new EASubmissionCompleteControl(); scControl.OnInsertTopXSDElement += new EventHandler(scControl_OnInsertTopXSDElement); scControl.OnInsertTopXSDAttribute += new EventHandler(scControl_OnInsertTopXSDAttribute); dataElementCreationControl.scControl = scControl; //dataElementCreationControl.OnUseResult += new EventHandler(dataElementCreationControl_OnUseResult); }
protected override void use(object sender, EventArgs e) { XmlNode srcNode = null; string selectedId = null; string selectedName = null; try { if (sender is Button) { if (((Button)sender).Name == "btnCLSUse") { srcNode = lastClassificationQueryResult; selectedId = getSelectedItem(lstClassificationQueryResult).ID; selectedName = getSelectedItem(lstClassificationQueryResult).NAME; } else if (((Button)sender).Name == "btnUse") { srcNode = lastResult; selectedId = getSelectedItem(lstResults).ID; selectedName = getSelectedItem(lstResults).NAME; } else { return; } } } catch (Exception) { MessageBox.Show("No element selected"); return; } selectedNode = srcNode.SelectSingleNode("/rs:result-set/rs:data-element[rs:names/rs:id=\"" + selectedId + "\"]", nsmanager); if (selectedNode == null) { selectedNode = srcNode.SelectSingleNode("/rs:result-set/rs:concept[rs:names/rs:id=\"" + selectedId + "\"]", nsmanager); if (selectedNode != null) { //MessageBox.Show("Not a data element"); EAUtil.insertConceptRef(m_Repository, XElement.Parse(selectedNode.OuterXml)); } else { MessageBox.Show("Result is not a data element"); } return; } EA.Package package = m_Repository.GetPackageByID(m_Repository.GetCurrentDiagram().PackageID); if (package.StereotypeEx == "XSDschema") { EASubmissionCompleteControl scControl = new EASubmissionCompleteControl(); scControl.ID = selectedId; scControl.PREFERRED = selectedName; scControl.OnInsertTopXSDElement += new EventHandler(scControl_OnInsertTopXSDElement); scControl.OnInsertTopXSDAttribute += new EventHandler(scControl_OnInsertTopXSDAttribute); scControl.Show(); } else { EAUtil.insertCDE(m_Repository, XElement.Parse(selectedNode.OuterXml), EAUtil.INSERT_XSD_TYPE.NOT_APPLICABLE); } }
protected override void use(object sender, EventArgs e) { QueryServiceControl.QueryServiceManager.resultset results = null; string selectedId = null; string selectedName = null; try { if (sender is Button) { if (((Button)sender).Name == "btnCLSUse") { results = lastClassificationQueryResult; selectedId = getSelectedItem(lstClassificationQueryResult).ID; selectedName = getSelectedItem(lstClassificationQueryResult).NAME; } else if (((Button)sender).Name == "btnUse") { results = lastResult; selectedId = getSelectedItem(lstResults).ID; selectedName = getSelectedItem(lstResults).NAME; } else { return; } } } catch (Exception) { MessageBox.Show("No element selected"); return; } QueryServiceControl.QueryServiceManager.commoninfo ci = QueryServiceControl.QueryServiceControl.getCommonInfo(selectedId, results.Items); if (ci is QueryServiceControl.QueryServiceManager.concept) { EAUtil.insertConceptRef(m_Repository, ci as QueryServiceControl.QueryServiceManager.concept); } else if (ci is QueryServiceControl.QueryServiceManager.dataelement) { selectedNode = ci as QueryServiceControl.QueryServiceManager.dataelement; EA.Diagram diagram = m_Repository.GetCurrentDiagram(); if (diagram == null) { MessageBox.Show("Please open a diagram first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } EA.Package package = m_Repository.GetPackageByID(diagram.PackageID); if (package.StereotypeEx == "XSDschema") { EASubmissionCompleteControl scControl = new EASubmissionCompleteControl(); scControl.ID = selectedId; scControl.PREFERRED = selectedName; scControl.OnInsertTopXSDElement += new EventHandler(scControl_OnInsertTopXSDElement); scControl.OnInsertTopXSDAttribute += new EventHandler(scControl_OnInsertTopXSDAttribute); scControl.Show(); } else { EAUtil.insertCDE(m_Repository, selectedNode, EAUtil.INSERT_XSD_TYPE.NOT_APPLICABLE); } } else { MessageBox.Show("Error getting selected data element"); } }