public void TestSectionForm() { R2Section section = new R2Section(); SectionForm form = new SectionForm(); form.Show(section); }
private void PopulateBaseModelColumn(R2Model baseModel) { modelsDataGridView.Columns[COLUMN_BASE_MODEL].HeaderText = baseModel.Name; modelsDataGridView.Columns[COLUMN_BASE_MODEL].Tag = baseModel; int rowNumber = 0; foreach (R2ModelElement element in baseModel.children) { DataGridViewCell cell = modelsDataGridView.Rows[rowNumber].Cells[COLUMN_BASE_MODEL]; cell.Style = new DataGridViewCellStyle { BackColor = R2Config.config.getSectionColor(element.GetExtId(), Color.White) }; cell.Tag = element; cell.Value = element.GetExtId(); if (element is R2Criterion) { R2Criterion criterion = (R2Criterion)element; cell.ToolTipText = criterion.Text; } else if (element is R2Function) { R2Function function = (R2Function)element; cell.ToolTipText = function.Name + "\n" + function.Description; } else if (element is R2Section) { R2Section section = (R2Section)element; cell.ToolTipText = section.Name; } rowNumber++; } }
/* * Only make Compiler Instruction if there is a baseElement * otherwise this is a new element that was not in the base. */ public static R2ModelElement CreateModelElement(R2ModelElement profileElement, R2ModelElement baseElement) { // only set in compiler instruction what is different that in base model element R2ModelElement element = null; if (profileElement is Base.R2Section) { element = new R2Section(); } else if (profileElement is Base.R2Function) { element = new R2Function(); } else if (profileElement is Base.R2Criterion) { element = new R2Criterion(); } element.BaseElement = baseElement; if (baseElement != null) { element.Stereotype = R2Const.ST_COMPILERINSTRUCTION; element.IsCompilerInstruction = true; } element.LastModified = Util.FormatLastModified(DateTime.Now); element.Priority = profileElement.Priority; element.Path = profileElement.Path; if (profileElement is Base.R2Section) { Base.R2Section profileSection = (Base.R2Section)profileElement; R2Section section = (R2Section)element; section.SectionId = profileSection.SectionId; section.Name = profileSection.Name; section.Overview = profileSection.Overview; section.Example = profileSection.Example; section.Actors = profileSection.Actors; } else if (profileElement is Base.R2Function) { Base.R2Function profileFunction = (Base.R2Function)profileElement; R2Function function = (R2Function)element; function.FunctionId = profileFunction.FunctionId; function.Name = profileFunction.Name; function.Statement = profileFunction.Statement; function.Description = profileFunction.Description; } else if (profileElement is Base.R2Criterion) { Base.R2Criterion profileCriterion = (Base.R2Criterion)profileElement; R2Criterion criterion = (R2Criterion)element; criterion.FunctionId = profileCriterion.FunctionId; criterion.CriterionSeqNo = profileCriterion.CriterionSeqNo; criterion.Text = profileCriterion.Text; criterion.Row = profileCriterion.Row; criterion.Conditional = profileCriterion.Conditional; criterion.Dependent = profileCriterion.Dependent; criterion.Optionality = profileCriterion.Optionality; } return(element); }
public void Show(R2Section section) { _section = section; BackColor = R2Config.config.getSectionColor(_section.Name, DefaultBackColor); setShowingSection(section, true); switchLinkLabel.Visible = section.HasBaseElement; ShowDialog(); }
public void setShowingSection(R2Section section, bool enableEdit) { ignoreEvents = true; lockIcon.Visible = section.IsReadOnly; if (section.IsReadOnly) { enableEdit = false; } okButton.Enabled = enableEdit; applyButton.Enabled = enableEdit; idTextBox.Enabled = enableEdit; nameTextBox.Enabled = enableEdit; overviewTextBox.Enabled = enableEdit; exampleTextBox.Enabled = enableEdit; actorsTextBox.Enabled = enableEdit; // Other properties idTextBox.Text = section.SectionId; nameTextBox.Text = section.Name; overviewTextBox.Text = section.Overview; exampleTextBox.Text = section.Example; actorsTextBox.Text = section.Actors; // TODO: Add "depends on" and "needed by" compartments if (section.HasBaseElement) { //textLinkLabel.Enabled = false; //textTextBox.Visible = true; Text = string.Format("HL7 FM Section: {0} (Profile Definition) @{1}", section.Name, section.LastModified); switchLinkLabel.Text = "Switch to base Element"; updateLabels(); } else { //textTextBox.Visible = true; //textLinkLabel.Enabled = false; Text = string.Format("HL7 FM Section: {0} @{1}", section.Name, section.LastModified); switchLinkLabel.Text = "Back to Profile Definition Element"; updateLabels(false); } ignoreEvents = false; }
private void switchLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (!switched) { switched = true; R2Section baseSection = (R2Section)_section.BaseElement; // Disable edit of base to prevent accidental changes setShowingSection(baseSection, false); } else { switched = false; setShowingSection(_section, true); } }
private void populateSelectedSection(R2Section section, int rowNumber, DataGridViewCellStyle emptyCellStyle) { if (section != null) { compareDataGridView.Rows[rowNumber].DefaultCellStyle = compareDataGridView.DefaultCellStyle; compareDataGridView.Rows[rowNumber].Cells["Priority"].Value = section.Priority; compareDataGridView.Rows[rowNumber].Cells["SectionId"].Value = section.SectionId; compareDataGridView.Rows[rowNumber].Cells["Name"].Value = section.Name; compareDataGridView.Rows[rowNumber].Cells["LastModified"].Value = section.LastModified; } else { compareDataGridView.Rows[rowNumber].DefaultCellStyle = emptyCellStyle; } }
private void selectButton_Click(object sender, EventArgs e) { if (modelsDataGridView.CurrentCell.ColumnIndex < 2) { // Ignore, cannot select FM or Merged Profile itself return; } DataGridViewCell currentCell = modelsDataGridView.CurrentCell; if (currentCell.Tag == null) { // Nothing to do, select an empty cell. return; } modelsDataGridView.CurrentRow.Cells[1].Value = currentCell.Value; R2ModelElement compilerInstruction = R2ModelV2.MAX.Factory.CreateModelElement((R2ModelElement)currentCell.Tag, (R2ModelElement)modelsDataGridView.CurrentRow.Cells[0].Tag); DataGridViewCell cell = modelsDataGridView.CurrentRow.Cells[1]; cell.Tag = compilerInstruction; if (compilerInstruction is R2Criterion) { R2Criterion criterion = (R2Criterion)compilerInstruction; criterion.ProfileDefinition = (R2ProfileDefinition)modelsDataGridView.Columns[COLUMN_MERGED_PROFILE].Tag; cell.ToolTipText = criterion.Text; } else if (compilerInstruction is R2Function) { R2Function function = (R2Function)compilerInstruction; function.ProfileDefinition = (R2ProfileDefinition)modelsDataGridView.Columns[COLUMN_MERGED_PROFILE].Tag; cell.ToolTipText = function.Name + "\n" + function.Description; } else if (compilerInstruction is R2Section) { R2Section section = (R2Section)compilerInstruction; cell.ToolTipText = section.Name; } UpdateStatistics(); }
private void LoadProfileDefinition(string maxFileName) { R2ProfileDefinition profDef = R2ModelV2.MAX.Factory.LoadProfileDefinition(baseModel, maxFileName); profDef.BaseModelName = baseModel.Name; modelsDataGridView.Columns[COLUMN_MERGED_PROFILE].HeaderText = profDef.Name; modelsDataGridView.Columns[COLUMN_MERGED_PROFILE].Tag = profDef; foreach (R2ModelElement element in profDef.children) { int rowNumber = getBaseModelRowNumber(element.GetAlignId()); if (rowNumber == -1) { // Base Model doesnot have this row, add Row at end rowNumber = modelsDataGridView.Rows.Add(); } DataGridViewCell cell = modelsDataGridView.Rows[rowNumber].Cells[COLUMN_MERGED_PROFILE]; cell.Tag = element; cell.Value = element.GetExtId(); if (element is R2Criterion) { R2Criterion criterion = (R2Criterion)element; criterion.ProfileDefinition = profDef; cell.ToolTipText = criterion.Text; } else if (element is R2Function) { R2Function function = (R2Function)element; function.ProfileDefinition = profDef; cell.ToolTipText = function.Name + "\n" + function.Description; } else if (element is R2Section) { R2Section section = (R2Section)element; cell.ToolTipText = section.Name; } } }
/** * Factory method to create correct model class based on the EA.Element */ public static R2ModelElement Create(ObjectType objectType) { R2ModelElement modelElement = null; switch (objectType.stereotype) { case R2Const.ST_FM: modelElement = new R2Model(objectType); break; case R2Const.ST_FM_PROFILEDEFINITION: case R2Const.ST_FM_PROFILE: modelElement = new R2ProfileDefinition(objectType); break; case R2Const.ST_SECTION: modelElement = new R2Section(objectType); break; case R2Const.ST_HEADER: case R2Const.ST_FUNCTION: modelElement = new R2Function(objectType); break; case R2Const.ST_CRITERION: modelElement = new R2Criterion(objectType); break; case R2Const.ST_COMPILERINSTRUCTION: // TODO: baseElement comes from BaseModel, mock to Criterion for now Console.Write("!! R2ModelV2MAX.Create ST_COMPILERINSTRUCTION mocked to Criterion"); modelElement = new R2Criterion(objectType); //modelElement.IsCompilerInstruction = true; break; } return(modelElement); }
private void LoadProfile(int columnNumber, string maxFileName, DataGridViewCellStyle cellStyle) { R2Model model = R2ModelV2.MAX.Factory.LoadModel(maxFileName, true); modelsDataGridView.Columns[columnNumber].HeaderText = model.Name; modelsDataGridView.Columns[columnNumber].Tag = model; foreach (R2ModelElement element in model.children) { int rowNumber = getBaseModelRowNumber(element.GetAlignId()); if (rowNumber == -1) { // Base Model doesnot have this row, add Row at end rowNumber = modelsDataGridView.Rows.Add(); } DataGridViewCell cell = modelsDataGridView.Rows[rowNumber].Cells[columnNumber]; cell.Style = cellStyle; cell.Tag = element; cell.Value = element.GetExtId(); if (element is R2Criterion) { R2Criterion criterion = (R2Criterion)element; cell.ToolTipText = criterion.Text; } else if (element is R2Function) { R2Function function = (R2Function)element; cell.ToolTipText = function.Name + "\n" + function.Description; } else if (element is R2Section) { R2Section section = (R2Section)element; cell.ToolTipText = section.Name; } } }
/** * Factory method to create correct model class based on the EA.Element */ public static R2ModelElement Create(EA.Repository repository, EA.Element element) { R2ModelElement modelElement = null; switch (element.Stereotype) { case R2Const.ST_FM_PROFILEDEFINITION: modelElement = new R2ProfileDefinition(element); break; case R2Const.ST_SECTION: modelElement = new R2Section(element); break; case R2Const.ST_HEADER: case R2Const.ST_FUNCTION: modelElement = new R2Function(element); break; case R2Const.ST_CRITERION: modelElement = new R2Criterion(element); break; case R2Const.ST_COMPILERINSTRUCTION: int genCount = element.Connectors.Cast <EA.Connector>().Count(c => "Generalization".Equals(c.Type)); if (genCount == 0) { // Try Dependency/Generalization in case this is a Section Compiler instruction genCount = element.Connectors.Cast <EA.Connector>().Count(c => "Dependency".Equals(c.Type) && "Generalization".Equals(c.Stereotype)); if (genCount == 0) { MessageBox.Show(string.Format("{0} is a Compiler Instruction.\nExpected one(1) Generalization to a Base Element.\nFix this manually.", element.Name), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } } else if (genCount > 1) { MessageBox.Show(string.Format("{0} is a Compiler Instruction.\nExpected one(1) Generalization, but got {1}.\nFix this manually.", element.Name, genCount), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } EA.Connector generalization = element.Connectors.Cast <EA.Connector>().SingleOrDefault(c => "Generalization".Equals(c.Type)); // Try Dependency/Generalization in case this is a Section Compiler instruction if (generalization == null) { generalization = element.Connectors.Cast <EA.Connector>().SingleOrDefault(c => "Dependency".Equals(c.Type) && "Generalization".Equals(c.Stereotype)); } EA.Element baseElement = repository.GetElementByID(generalization.SupplierID); switch (baseElement.Stereotype) { case R2Const.ST_SECTION: modelElement = new R2Section(element); modelElement.BaseElement = new R2Section(baseElement); break; case R2Const.ST_HEADER: case R2Const.ST_FUNCTION: modelElement = new R2Function(element); modelElement.BaseElement = new R2Function(baseElement); break; case R2Const.ST_CRITERION: modelElement = new R2Criterion(element); modelElement.BaseElement = new R2Criterion(baseElement); break; } modelElement.IsCompilerInstruction = true; if (repository != null) { modelElement.BaseElement.Path = GetModelElementPath(repository, baseElement); } break; } if (modelElement != null && repository != null) { modelElement.Path = GetModelElementPath(repository, element); // is element is in profile definition package this is a compiler instruction EA.Package ProfileDefinitionPackage = repository.GetPackageByID(((EA.Element)modelElement.SourceObject).PackageID); if (R2Const.ST_FM_PROFILEDEFINITION.Equals(ProfileDefinitionPackage.StereotypeEx)) { modelElement.IsCompilerInstruction = true; // The ProfileType is needed for R2FunctionCI's in the FunctionForm if (modelElement is R2Function) { R2Function function = (R2Function)modelElement; function.ProfileDefinition = (R2ProfileDefinition)Create(EAHelper.repository, ProfileDefinitionPackage.Element); } else if (modelElement is R2Criterion) { R2Criterion criterion = (R2Criterion)modelElement; criterion.ProfileDefinition = (R2ProfileDefinition)Create(EAHelper.repository, ProfileDefinitionPackage.Element); } } } return(modelElement); }
private void LoadDummyProfile(int columnNumber, DataGridViewCellStyle cellStyle) { R2Model model = new R2Model { Name = "Dummy" }; modelsDataGridView.Columns[columnNumber].HeaderText = model.Name; modelsDataGridView.Columns[columnNumber].Tag = model; R2Section section = new R2Section { SectionId = "CP", IsReadOnly = true }; model.children.Add(section); int rowNumber = getBaseModelRowNumber(section.GetAlignId()); DataGridViewCell sectionCell = modelsDataGridView.Rows[rowNumber].Cells[columnNumber]; sectionCell.Tag = section; sectionCell.Value = string.Format("{0}", section.SectionId); sectionCell.Style = cellStyle; for (int h = 1; h < 3; h++) { R2Function header = new R2Function { FunctionId = string.Format("CP.{0}", h), IsReadOnly = true }; model.children.Add(header); rowNumber = getBaseModelRowNumber(header.GetAlignId()); if (rowNumber == -1) { // Base Model doesnot have this row, add Row at end rowNumber = modelsDataGridView.Rows.Add(); } DataGridViewCell headerCell = modelsDataGridView.Rows[rowNumber].Cells[columnNumber]; headerCell.Tag = header; headerCell.Value = header.FunctionId; headerCell.Style = cellStyle; for (int f = 1; f < 3; f++) { R2Function function = new R2Function { FunctionId = string.Format("CP.{0}.{1}", h, f), IsReadOnly = true }; model.children.Add(function); rowNumber = getBaseModelRowNumber(function.GetAlignId()); if (rowNumber == -1) { // Base Model doesnot have this row, add Row at end rowNumber = modelsDataGridView.Rows.Add(); } DataGridViewCell functionCell = modelsDataGridView.Rows[rowNumber].Cells[columnNumber]; functionCell.Tag = function; functionCell.Value = function.FunctionId; functionCell.Style = cellStyle; for (int c = 1; c < 4; c++) { R2Criterion criterion = new R2Criterion { FunctionId = string.Format("CP.{0}.{1}", h, f), CriterionSeqNo = c, Text = "The system SHALL xyz", Optionality = "SHALL", IsReadOnly = true }; model.children.Add(criterion); criterion.SetRefId(null, string.Format("CP.{0}.{1}", h, f), string.Format("{0}", c + 1)); rowNumber = getBaseModelRowNumber(criterion.GetAlignId()); if (rowNumber == -1) { // Base Model doesnot have this row, add Row at end rowNumber = modelsDataGridView.Rows.Add(); } DataGridViewCell criterionCell = modelsDataGridView.Rows[rowNumber].Cells[columnNumber]; criterionCell.Tag = criterion; criterionCell.Value = string.Format("! {0}", criterion.Name); criterionCell.ToolTipText = criterion.Text; criterionCell.Style = cellStyle; } } } }