public ForcesController(IForcesView view, IForcesModel model)
 {
     _view  = view;
     _model = model;
     _view.SetController(this);
     _model.AddObserver(_view);
 }
Esempio n. 2
0
        private static void InsertRatings(IForcesModel model, DataTable data)
        {
            foreach (Rating rating in model.GetRatings())
            {
                int decisionColumnIndex = 0;
                for (int index = ForcesTableContext.DecisionColumnIndex; index < data.Columns.Count; index++)
                {
                    if (!data.Rows[data.Rows.Count - 1][index].ToString().Equals(rating.DecisionGUID))
                    {
                        continue;
                    }
                    decisionColumnIndex = index;
                    break;
                }
                if (decisionColumnIndex == 0)
                {
                    continue;
                }

                foreach (DataRow row in data.Rows)
                {
                    if (row[ForcesTableContext.ForceGUIDColumnIndex].Equals(rating.ForceGUID) &&
                        row[ForcesTableContext.ConcernGUIDColumnIndex].Equals(rating.ConcernGUID))
                    {
                        row[decisionColumnIndex] = rating.Value;
                    }
                }
            }
        }
        public void InsertForcesTable(IForcesModel forces)
        {
            ISlide forcesSlide = new ForcesSlide(_doc, _forcesSlideTemplate, forces);

            forcesSlide.Create();
            forcesSlide.FillContent();
            forcesSlide.Save();
            forcesSlide.Add();
        }
Esempio n. 4
0
 private void InsertDecisions(IForcesModel model, DataTable data)
 {
     foreach (IEAElement decision in model.GetDecisions())
     {
         if (!decision.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, model.DiagramGUID))
         {
             continue;
         }
         data.Columns.Add(string.Format("<<{0}>>\n{1}", decision.Stereotype, decision.Name));
     }
 }
Esempio n. 5
0
        private static void InsertDecisionGuids(IForcesModel model, DataTable data)
        {
            int decisionIndex = 0;

            foreach (IEAElement decision in model.GetDecisions())
            {
                if (!decision.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, model.DiagramGUID))
                {
                    continue;
                }
                data.Rows[data.Rows.Count - 1][decisionIndex++ + ForcesTableContext.DecisionColumnIndex] = decision.GUID;
            }
        }
Esempio n. 6
0
        public void InsertForcesTable(IForcesModel forces)
        {
            WorksheetPart worksheetPart            = InsertWorksheet(forces.Name);
            const string  forcesTableTopLeftColumn = "A";
            const uint    forcesTopLeftRow         = 1;

            InsertText(worksheetPart, forcesTableTopLeftColumn, forcesTopLeftRow, "Force");
            InsertText(worksheetPart, forcesTopLeftRow, "Concern");

            foreach (IEAElement decision in forces.GetDecisions())
            {
                InsertText(worksheetPart, forcesTopLeftRow, decision.Name);
            }

            uint rowIndex = forcesTopLeftRow + 1;

            foreach (var concernsPerForce in forces.GetConcernsPerForce())
            {
                IEAElement        force    = concernsPerForce.Key;
                List <IEAElement> concerns = concernsPerForce.Value;

                foreach (IEAElement concern in concerns)
                {
                    InsertText(worksheetPart, forcesTableTopLeftColumn, rowIndex, force.Name);
                    InsertText(worksheetPart, rowIndex, concern.Name);
                    foreach (Rating rating in forces.GetRatings())
                    {
                        if (rating.ForceGUID != force.GUID || rating.ConcernGUID != concern.GUID)
                        {
                            continue;
                        }
                        if (forces.GetDecisions().Any(decision => rating.DecisionGUID == decision.GUID))
                        {
                            InsertText(worksheetPart, rowIndex, rating.Value);
                        }
                    }
                    rowIndex++;
                }
            }


            worksheetPart.Worksheet.Save();
        }
Esempio n. 7
0
        private void InsertForcesAndConcerns(IForcesModel model, DataTable table)
        {
            int rowIndex = 0;

            foreach (var dictionary in model.GetConcernsPerForce())
            {
                IEAElement        force    = dictionary.Key;
                List <IEAElement> concerns = dictionary.Value;

                foreach (IEAElement concern in concerns)
                {
                    //in first column add force and concern guid
                    var     forceConcernGuid = new object[] { force.GUID };
                    DataRow row = table.Rows.Add(forceConcernGuid);
                    _forcesTable.DataSource = table;
                    _forcesTable.Rows[rowIndex++].HeaderCell.Value = force.Name;

                    row[ForcesTableContext.ConcernColumnIndex]     = concern.Name;
                    row[ForcesTableContext.ConcernGUIDColumnIndex] = concern.GUID;
                }
            }
        }
Esempio n. 8
0
        public void UpdateTable(IForcesModel model)
        {
            //deactivate cell value listener
            _forcesTable.CellValueChanged -= _forcesTable_CellValueChanged;

            var data = new DataTable();

            // the first three rows are:
            // ForceGUID, Concern, ConcernGUID
            data.Columns.Add(ForcesTableContext.ForceGUIDHeader);
            data.Columns.Add(ForcesTableContext.ConcernHeader);
            data.Columns.Add(ForcesTableContext.ConcernGUIDHeader);

            // insert the decisions names as new columns in the table
            InsertDecisions(model, data);

            // insert the force guids, force, concerns and concerns guids
            _forcesTable.DataSource = data;
            InsertForcesAndConcerns(model, data);

            // insert the decision guids in the table
            data.Rows.Add(new object[] { ForcesTableContext.EmptyCellValue, ForcesTableContext.EmptyCellValue, ForcesTableContext.EmptyCellValue });
            InsertDecisionGuids(model, data);
            _forcesTable.DataSource = data;
            _forcesTable.Rows[_forcesTable.Rows.Count - 1].HeaderCell.Value = ForcesTableContext.DecisionGUIDHeader;
            HideRow(_forcesTable.Rows.Count - 1);

            if (data.Columns.Count <= 0)
            {
                return;
            }


            // hide the columns and row which contain the guids of the elements
            HideColumn(ForcesTableContext.ForceGUIDHeader);
            HideColumn(ForcesTableContext.ConcernGUIDHeader);
            ReadOnlyColumn(ForcesTableContext.ConcernHeader);

            foreach (DataGridViewColumn column in _forcesTable.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
                // Colour decision header
                ColourDecisionHeader(_forcesTable.Columns.IndexOf(column));
            }

            //Colour each row header
            foreach (DataGridViewRow row in _forcesTable.Rows)
            {
                ColourForceHeader(_forcesTable.Rows.IndexOf(row));
            }

            // insert the ratings in the table
            InsertRatings(model, data);
            //activate cell value listener
            _forcesTable.Columns[0].Frozen = true;
            _forcesTable.Columns[1].Frozen = true;
            _forcesTable.CellValueChanged += _forcesTable_CellValueChanged;

            //Update view
            Invalidate();
        }
Esempio n. 9
0
 public void Update(IForcesModel model)
 {
     UpdateTable(model);
 }
Esempio n. 10
0
 public ForcesSlide(PresentationDocument document, SlidePart templateSlide, IForcesModel forces)
     : base(document, templateSlide)
 {
     _forces = forces;
 }
        public void InsertForcesTable(IForcesModel forces)
        {
            Paragraph     para          = _body.AppendChild(new Paragraph());
            Run           run           = para.AppendChild(new Run());
            RunProperties runProperties = getHeading2(run);

            run.AppendChild(new Text(++_diagmarCounter + ". Decision Forces Viewpoint: " + forces.Name));
            //_body.AppendChild(new Paragraph(new Run(new Text(++_diagmarCounter + ". Decision Forces Viewpoint"))));
            _body.AppendChild(new Paragraph(new Run(new Text())));

            var table = new Table();

            var props = new TableProperties(
                new TableBorders(
                    new TopBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new BottomBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new LeftBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new RightBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new InsideHorizontalBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            },
                    new InsideVerticalBorder
            {
                Val  = new EnumValue <BorderValues>(BorderValues.Single),
                Size = 11
            }));

            table.AppendChild(props);

            var emptyCell = new TableCell();

            // insert an empty cell in tol left of forces table
            var decRow = new TableRow();

            decRow.AppendChild(emptyCell);
            emptyCell.AppendChild(new Paragraph(new Run(new Text(""))));

            // insert the concern header and the decisions names
            var concCellHeader = new TableCell(new Paragraph(new Run(new Text("Concerns"))));

            decRow.AppendChild(concCellHeader);
            foreach (
                TableCell decCell in
                forces.GetDecisions()
                .Select(decision => new TableCell(new Paragraph(new Run(new Text(decision.Name))))))
            {
                decRow.AppendChild(decCell);
            }
            table.AppendChild(decRow);


            foreach (var concernsPerForces in forces.GetConcernsPerForce())
            {
                IEAElement        force    = concernsPerForces.Key;
                List <IEAElement> concerns = concernsPerForces.Value;

                foreach (IEAElement concern in concerns)
                {
                    var forceRow  = new TableRow();
                    var forceCell = new TableCell(new Paragraph(new Run(new Text(force.Name))));
                    forceRow.AppendChild(forceCell);
                    var concCell = new TableCell();
                    concCell.AppendChild(new Paragraph(new Run(new Text(concern.Name))));
                    forceRow.AppendChild(concCell);

                    // insert ratings
                    foreach (Rating rating in forces.GetRatings())
                    {
                        if (rating.ForceGUID != force.GUID || rating.ConcernGUID != concern.GUID)
                        {
                            continue;
                        }
                        if (forces.GetDecisions().Any(decision => rating.DecisionGUID == decision.GUID))
                        {
                            var ratCell = new TableCell();
                            ratCell.AppendChild(new Paragraph(new Run(new Text(rating.Value))));
                            forceRow.AppendChild(ratCell);
                        }
                    }
                    table.AppendChild(forceRow);
                }
            }


            _body.AppendChild(table);
            _body.AppendChild(new Paragraph());
        }