private void updateCompilerInstruction(ListViewItem item) { R2ModelElementHolder dl = (R2ModelElementHolder)item.Tag; // Include if (includeRadioButton.Checked) { setCompilerInstruction(dl, R2Const.Qualifier.None); } // Deprecate else if (deprecateRadioButton.Checked) { setCompilerInstruction(dl, R2Const.Qualifier.Deprecate); } // Delete else if (deleteRadioButton.Checked) { setCompilerInstruction(dl, R2Const.Qualifier.Delete); } // Exclude else if (excludeRadioButton.Checked) { deleteCompilerInstruction(dl); } }
private void criteriaListView_ItemChecked(object sender, ItemCheckedEventArgs e) { if (!ignoreEvent) { ListViewItem selected = e.Item; R2ModelElementHolder dl = (R2ModelElementHolder)selected.Tag; if (!selected.Checked) { setCompilerInstruction(dl, R2Const.Qualifier.Exclude); } else { // Tri-state; back to normal if (dl.compilerInstructionEAElement != null) { ignoreEvent = true; selected.Checked = false; deleteCompilerInstruction(dl); ignoreEvent = false; } else { setCompilerInstruction(dl, R2Const.Qualifier.None); } } updateListViewItem(selected); } }
private void setCompilerInstruction(R2ModelElementHolder dl, R2Const.Qualifier qualifier, string change_note = null) { // If there is no Compiler Instruction, create one if (dl.compilerInstructionEAElement == null) { dl.compilerInstructionEAElement = (EA.Element)profileDefinitionPackage.Elements.AddNew(dl.baseModelEAElement.Name, "Class"); dl.compilerInstructionEAElement.Stereotype = R2Const.ST_COMPILERINSTRUCTION; dl.compilerInstructionEAElement.Update(); if (dl.baseModelEAElement.Type == "Package") { EA.Connector con = (EA.Connector)dl.compilerInstructionEAElement.Connectors.AddNew("", "Dependency"); con.Stereotype = "Generalization"; con.SupplierID = dl.baseModelEAElement.ElementID; con.Update(); } else { EA.Connector con = (EA.Connector)dl.compilerInstructionEAElement.Connectors.AddNew("", "Generalization"); con.SupplierID = dl.baseModelEAElement.ElementID; con.Update(); } dl.compilerInstructionEAElement.Connectors.Refresh(); dl.modelElement = R2ModelV2.EA_API.Factory.Create(repository, dl.compilerInstructionEAElement); profileDefinitionPackage.Elements.Refresh(); } switch (qualifier) { case R2Const.Qualifier.Deprecate: EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "DEP"); break; case R2Const.Qualifier.Delete: EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "D"); break; case R2Const.Qualifier.Exclude: EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "EXCLUDE"); break; case R2Const.Qualifier.None: default: EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, ""); break; } if (!string.IsNullOrEmpty(change_note)) { EAHelper.SetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_CHANGENOTE, "<memo>", change_note); } else { EAHelper.DeleteTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_CHANGENOTE); } dl.compilerInstructionEAElement.TaggedValues.Refresh(); dl.compilerInstructionEAElement.Refresh(); }
private void textBox1_TextChanged(object sender, EventArgs e) { if (!ignoreEvent) { ListViewItem selected = criteriaListView.SelectedItems[0]; R2ModelElementHolder dl = (R2ModelElementHolder)selected.Tag; setCompilerInstruction(dl, R2Const.Qualifier.None, textBox1.Text); } }
private void deleteCompilerInstruction(R2ModelElementHolder dl) { // Only delete if there is a Compiler Instruction if (dl.compilerInstructionEAElement != null) { Cursor = Cursors.WaitCursor; deleteElementRecurse(profileDefinitionPackage.Elements, dl.compilerInstructionEAElement.ElementID); dl.compilerInstructionEAElement = null; dl.modelElement = R2ModelV2.EA_API.Factory.Create(repository, dl.baseModelEAElement); Cursor = Cursors.Default; } }
private void mainListView_MouseDoubleClick(object sender, MouseEventArgs e) { ListViewItem selected = mainListView.SelectedItems[0]; R2ModelElementHolder dl = (R2ModelElementHolder)selected.Tag; if (dl.modelElement is R2Section) { new SectionForm().Show((R2Section)dl.modelElement); } else { new FunctionForm().Show((R2Function)dl.modelElement); } }
private void button2_Click(object sender, EventArgs e) { if (mainListView.SelectedItems.Count > 0) { R2ModelElementHolder dl = (R2ModelElementHolder)mainListView.SelectedItems[0].Tag; if (dl.compilerInstructionEAElement != null) { repository.ShowInProjectView(dl.compilerInstructionEAElement); } else if (dl.baseModelEAElement != null) { repository.ShowInProjectView(dl.baseModelEAElement); } } }
private void findButton_Click(object sender, EventArgs e) { string id = findTextBox.Text.ToUpper(); foreach (ListViewItem item in mainListView.Items) { R2ModelElementHolder dl = (R2ModelElementHolder)item.Tag; if (dl.baseModelEAElement.Name.ToUpper().StartsWith(id)) { mainListView.SelectedItems.Clear(); item.Selected = true; mainListView.EnsureVisible(item.Index); mainListView.Select(); return; } } MessageBox.Show(string.Format("There is no element with ID '{0}'", id), "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private ListViewItem createCriteriaListViewItem(EA.Element element) { ListViewItem item = new ListViewItem(); R2ModelElementHolder dl = new R2ModelElementHolder(repository, element); item.Tag = dl; if (dl.modelElement != null) { R2Criterion criterion = (R2Criterion)dl.modelElement; item.Text = string.Format("{0} {1}", criterion.Name, criterion.Text); } else { item.Text = "Invalid Compiler Instruction"; } updateListViewItem(item); return(item); }
private void updateListViewItem(ListViewItem item) { bool _ignoreEvent = ignoreEvent; ignoreEvent = true; R2ModelElementHolder dl = (R2ModelElementHolder)item.Tag; if (dl.compilerInstructionEAElement != null) { switch (EAHelper.GetTaggedValue(dl.compilerInstructionEAElement, R2Const.TV_QUALIFIER, "")) { case "DEP": item.ForeColor = Color.White; item.BackColor = BACKCOLOR_DEPRECATED; item.Checked = true; break; case "D": item.ForeColor = Color.White; item.BackColor = BACKCOLOR_DELETED; item.Checked = false; break; case "EXCLUDE": // special for excluded criteria; excluded is kind of deleted item.ForeColor = Color.LightGray; item.BackColor = BACKCOLOR_EXCLUDED; item.Checked = false; break; default: // "" item.ForeColor = Color.White; item.BackColor = BACKCOLOR_INCLUDED; item.Checked = true; break; } } else { item.ForeColor = Color.Black; item.BackColor = BACKCOLOR_EXCLUDED; item.Checked = false; } ignoreEvent = _ignoreEvent; }