Пример #1
0
        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++;
            }
        }
Пример #2
0
            /*
             * 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);
            }
Пример #3
0
 public void Show(R2Function function)
 {
     _function = function;
     BackColor = R2Config.config.getSectionColor(_function.FunctionId, DefaultBackColor);
     setShowingFunction(function, true);
     switchLinkLabel.Visible = function.HasBaseElement;
     ShowDialog();
 }
Пример #4
0
 private void switchLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (!switched)
     {
         switched = true;
         R2Function baseFunction = (R2Function)_function.BaseElement;
         // Disable edit of base to prevent accidental changes
         setShowingFunction(baseFunction, false);
     }
     else
     {
         switched = false;
         setShowingFunction(_function, true);
     }
 }
Пример #5
0
        public void TestFunctionForm()
        {
            MessageBox.Show("Enter 'CP.1.4 Test' in the Name field");
            R2Function   function = new R2Function();
            FunctionForm form     = new FunctionForm();

            form.Show(function);
            Assert.AreEqual(R2Const.ST_FUNCTION, function.Stereotype);
            Assert.AreEqual("CP.1.4", function.FunctionId);
            Assert.AreEqual("CP.1.4", function.GetAlignId());
            Assert.AreEqual("CP.1.4", function.GetExtId());
            Assert.IsNull(function.RefId);
            Assert.IsNull(function.Id);
            Assert.AreEqual("CP.1.4 Test", function.Name);
            Assert.AreEqual("", function.Description);
            Assert.AreEqual("", function.ChangeNote);
            Assert.IsFalse(function.IsCompilerInstruction);
            Assert.IsNull(function.BaseElement);
        }
Пример #6
0
 private void populateSelectedFunction(R2Function function, int rowNumber, DataGridViewCellStyle emptyCellStyle, R2Function compareFunction, DataGridViewCellStyle diffCellStyle)
 {
     if (compareFunction == null)
     {
         compareFunction = function;
     }
     if (function != null)
     {
         compareDataGridView.Rows[rowNumber].DefaultCellStyle = compareDataGridView.DefaultCellStyle;
         populateSelectedCell(compareDataGridView.Rows[rowNumber].Cells["Priority"], function.Priority, compareFunction.Priority, diffCellStyle);
         populateSelectedCell(compareDataGridView.Rows[rowNumber].Cells["FunctionId"], function.FunctionId, compareFunction.FunctionId, diffCellStyle);
         populateSelectedCell(compareDataGridView.Rows[rowNumber].Cells["Name"], function.Name, compareFunction.Name, diffCellStyle);
         populateSelectedCell(compareDataGridView.Rows[rowNumber].Cells["LastModified"], function.LastModified, compareFunction.LastModified, diffCellStyle);
     }
     else
     {
         compareDataGridView.Rows[rowNumber].DefaultCellStyle = emptyCellStyle;
     }
 }
Пример #7
0
        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();
        }
Пример #8
0
        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;
                }
            }
        }
Пример #9
0
            /**
             * 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);
            }
Пример #10
0
        public void TestCIFunctionForm()
        {
            R2Function function = new R2Function()
            {
                FunctionId = "CP.1.4", Name = "CP.1.4 Test", ChangeNote = "CI ChangeNote"
            };

            function.IsCompilerInstruction = true;
            function.BaseElement           = new R2Function();
            FunctionForm form = new FunctionForm();

            form.Show(function);
            Assert.AreEqual(R2Const.ST_FUNCTION, function.Stereotype);
            Assert.AreEqual("CP.1.4", function.FunctionId);
            Assert.AreEqual("CP.1.4", function.GetAlignId());
            Assert.AreEqual("CP.1.4", function.GetExtId());
            Assert.IsNull(function.RefId);
            Assert.IsNull(function.Id);
            Assert.AreEqual("CP.1.4 Test", function.Name);
            Assert.AreEqual("", function.Description);
            Assert.AreEqual("", function.ChangeNote);
            Assert.IsFalse(function.IsCompilerInstruction);
            Assert.IsNull(function.BaseElement);
        }
Пример #11
0
        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;
                }
            }
        }
Пример #12
0
            /**
             * 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);
            }
Пример #13
0
        private void setShowingFunction(R2Function function, bool enableEdit)
        {
            ignoreEvents = true;

            lockIcon.Visible = function.IsReadOnly;
            if (function.IsReadOnly)
            {
                enableEdit = false;
            }
            okButton.Enabled    = enableEdit;
            applyButton.Enabled = enableEdit;

            // always show ChangeNote
            changeNoteLinkLabel.Visible = true;
            changeNoteLinkLabel.Enabled = true;
            changeNoteTextBox.Visible   = false;
            changeNoteTextBox.Text      = function.ChangeNote;
            changeNoteTextBox.Enabled   = enableEdit;

            if (function.IsCompilerInstruction)
            {
                priorityLabel.Visible    = true;
                priorityComboBox.Text    = function.Priority;
                priorityComboBox.Visible = true;
                if (function.ProfileDefinition.ExtraPriorities.Any())
                {
                    priorityComboBox.Items.Add("");
                    priorityComboBox.Items.AddRange(function.ProfileDefinition.ExtraPriorities.ToArray());
                }
                toolTip1.SetToolTip(priorityComboBox, function.ProfileDefinition.PrioDef);
            }
            else
            {
                priorityLabel.Visible    = false;
                priorityComboBox.Text    = R2Const.EmptyPriority;
                priorityComboBox.Visible = false;
            }

            if (function.HasBaseElement)
            {
                descriptionLinkLabel.Enabled = false;
                descriptionTextBox.Visible   = true;

                Text = string.Format("HL7 FM {0}: {1} (Profile Definition) @{2}", function.Stereotype, function.Name, function.LastModified);
                switchLinkLabel.Text = "Switch to base Element";

                updateLabels();
            }
            else
            {
                descriptionTextBox.Visible   = true;
                descriptionLinkLabel.Enabled = false;

                Text = string.Format("HL7 FM {0}: {1} @{2}", function.Stereotype, function.Name, function.LastModified);
                switchLinkLabel.Text = "Back to Profile Definition Element";

                updateLabels(false);
            }
            pathLabel.Text = function.Path;

            // Other properties
            idTextBox.Text          = function.FunctionId;
            nameTextBox.Text        = function.Name;
            statementTextBox.Text   = function.Statement;
            descriptionTextBox.Text = function.Description;

            if (enableEdit)
            {
                if (function.IsCompilerInstruction)
                {
                    idTextBox.Enabled = false;
                    // If this is a Realm Profile or this is a new Function you can edit all fields
                    bool overrideEnableEdit = "Realm".Equals(function.ProfileDefinition.Type) || !function.HasBaseElement;
                    nameTextBox.Enabled        = overrideEnableEdit;
                    statementTextBox.Enabled   = overrideEnableEdit;
                    descriptionTextBox.Enabled = true;
                }
                else
                {
                    idTextBox.Enabled          = false;
                    nameTextBox.Enabled        = true;
                    statementTextBox.Enabled   = true;
                    descriptionTextBox.Enabled = true;
                }
            }
            else
            {
                idTextBox.Enabled          = false;
                nameTextBox.Enabled        = false;
                statementTextBox.Enabled   = false;
                descriptionTextBox.Enabled = false;
            }
            ignoreEvents = false;
        }
Пример #14
0
        private void updateCompareDataGridView(bool reset, int selectedRow, int compareRow)
        {
            DataGridViewCell cell0 = modelsDataGridView.Rows[selectedRow].Cells[0];
            DataGridViewCell cell1 = modelsDataGridView.Rows[selectedRow].Cells[1];
            DataGridViewCell cell2 = modelsDataGridView.Rows[selectedRow].Cells[2];
            DataGridViewCell cell3 = modelsDataGridView.Rows[selectedRow].Cells[3];
            DataGridViewCell cell4 = modelsDataGridView.Rows[selectedRow].Cells[4];

            // Get type of rows by the cell type. Some rows have no base, so then we use the profile.
            DataGridViewCell typeCell = cell0;

            if (typeCell.Tag == null)
            {
                typeCell = cell1;
            }
            if (typeCell.Tag == null)
            {
                typeCell = cell2;
            }
            if (typeCell.Tag == null)
            {
                typeCell = cell3;
            }
            if (typeCell.Tag == null)
            {
                typeCell = cell4;
            }
            if (typeCell.Tag == null)
            {
                // Happens when a row is empty, e.g. by clearing
                return;
            }

            if (reset)
            {
                // setup datagrid to selected Element type
                compareDataGridView.Columns.Clear();
                compareDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                // Create columns based on element type of the cell
                if (typeCell.Tag is R2Section)
                {
                    compareDataGridView.Columns.Add("Priority", "Priority");
                    compareDataGridView.Columns.Add("SectionId", "SectionId");
                    compareDataGridView.Columns.Add("Name", "Name");
                    compareDataGridView.Columns.Add("LastModified", "LastModified");
                }
                else if (typeCell.Tag is R2Function)
                {
                    compareDataGridView.Columns.Add("Priority", "Priority");
                    compareDataGridView.Columns.Add("FunctionId", "FunctionId");
                    compareDataGridView.Columns.Add("Name", "Name");
                    compareDataGridView.Columns.Add("LastModified", "LastModified");
                }
                else if (typeCell.Tag is R2Criterion)
                {
                    compareDataGridView.Columns.Add("Priority", "Priority");
                    compareDataGridView.Columns.Add("Name", "Name");
                    compareDataGridView.Columns.Add("Optionality", "Optionality");
                    compareDataGridView.Columns.Add("Text", "Text");
                    compareDataGridView.Columns.Add("Dependent", "Dependent");
                    compareDataGridView.Columns.Add("Conditional", "Conditional");
                    compareDataGridView.Columns.Add("Row#", "Row#");
                    compareDataGridView.Columns.Add("LastModified", "LastModified");
                }

                compareDataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
                compareDataGridView.Rows.Add(5);
                for (int rowNumber = 0; rowNumber < modelsDataGridView.Columns.Count; rowNumber++)
                {
                    DataGridViewColumn col       = modelsDataGridView.Columns[rowNumber];
                    string             modelName = "";
                    if (col.Tag is R2Model)
                    {
                        modelName = ((R2Model)col.Tag).Name;
                    }
                    else if (col.Tag is R2ProfileDefinition)
                    {
                        modelName = ((R2ProfileDefinition)col.Tag).Name;
                    }
                    compareDataGridView.Rows[rowNumber].HeaderCell.Value = modelName;
                }
            }

            // populate cells
            DataGridViewCellStyle emptyCellStyle = new DataGridViewCellStyle {
                BackColor = Color.LightGray
            };
            DataGridViewCellStyle c2CellStyle = new DataGridViewCellStyle {
                BackColor = Color.LightYellow
            };
            DataGridViewCellStyle diffCellStyle = new DataGridViewCellStyle {
                BackColor = Color.LightGreen
            };

            R2ModelElement compareElement;

            switch (compareRow)
            {
            case 1:
                compareElement = (R2ModelElement)cell1.Tag;
                break;

            case 2:
                compareElement = (R2ModelElement)cell2.Tag;
                break;

            case 3:
                compareElement = (R2ModelElement)cell3.Tag;
                break;

            case 4:
                compareElement = (R2ModelElement)cell4.Tag;
                break;

            default:
                compareElement = (R2ModelElement)cell0.Tag;
                break;
            }

            if (typeCell.Tag is R2Section)
            {
                populateSelectedSection((R2Section)cell0.Tag, 0, emptyCellStyle);
                populateSelectedSection((R2Section)cell1.Tag, 1, c2CellStyle);
                populateSelectedSection((R2Section)cell2.Tag, 2, emptyCellStyle);
                populateSelectedSection((R2Section)cell3.Tag, 3, emptyCellStyle);
                populateSelectedSection((R2Section)cell4.Tag, 4, emptyCellStyle);
            }
            else if (typeCell.Tag is R2Function)
            {
                R2Function compareFunction = (R2Function)compareElement;
                populateSelectedFunction((R2Function)cell0.Tag, 0, emptyCellStyle, compareFunction, diffCellStyle);
                populateSelectedFunction((R2Function)cell1.Tag, 1, c2CellStyle, compareFunction, diffCellStyle);
                populateSelectedFunction((R2Function)cell2.Tag, 2, emptyCellStyle, compareFunction, diffCellStyle);
                populateSelectedFunction((R2Function)cell3.Tag, 3, emptyCellStyle, compareFunction, diffCellStyle);
                populateSelectedFunction((R2Function)cell4.Tag, 4, emptyCellStyle, compareFunction, diffCellStyle);
            }
            else if (typeCell.Tag is R2Criterion)
            {
                R2Criterion compareCriterion = (R2Criterion)compareElement;
                populateSelectedCriterion((R2Criterion)cell0.Tag, 0, emptyCellStyle, compareCriterion, diffCellStyle);
                populateSelectedCriterion((R2Criterion)cell1.Tag, 1, c2CellStyle, compareCriterion, diffCellStyle);
                populateSelectedCriterion((R2Criterion)cell2.Tag, 2, emptyCellStyle, compareCriterion, diffCellStyle);
                populateSelectedCriterion((R2Criterion)cell3.Tag, 3, emptyCellStyle, compareCriterion, diffCellStyle);
                populateSelectedCriterion((R2Criterion)cell4.Tag, 4, emptyCellStyle, compareCriterion, diffCellStyle);
            }
        }
Пример #15
0
        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;
                    }
                }
            }
        }