Subversion Repositories DevTools

Rev

Rev 2088 | Rev 2092 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2088 Rev 2090
Line 1433... Line 1433...
1433
         fromLister.Elements.Sort( sorter );
1433
         fromLister.Elements.Sort( sorter );
1434
         
1434
         
1435
         // dictionary to support to-from table construction.
1435
         // dictionary to support to-from table construction.
1436
         ArrayList fromToDictionary = new ArrayList();
1436
         ArrayList fromToDictionary = new ArrayList();
1437
 
1437
 
-
 
1438
         
-
 
1439
         bool needFromToTable = false;
-
 
1440
         if (EA_RelMatrix.fromToTableTitle != null && EA_RelMatrix.fromToTableTitle.Length > 0)
1438
         // create the table in the word doc
1441
            needFromToTable = true;
-
 
1442
 
-
 
1443
         bool needToFromTable = false;
-
 
1444
         if (EA_RelMatrix.toFromTableTitle != null && EA_RelMatrix.toFromTableTitle.Length > 0)
-
 
1445
            needToFromTable = true;
-
 
1446
 
1439
         if (EA_RelMatrix.fromToTableTitle != null)
1447
         if (needFromToTable)
1440
         {
1448
         {
1441
            if (EA_RelMatrix.fromIntroText != null)
1449
            if (EA_RelMatrix.fromIntroText != null && EA_RelMatrix.fromIntroText.Length > 0)
1442
            {
1450
            {
1443
               appendAndSelectText( EA_RelMatrix.fromIntroText, "Body 1" );
1451
               appendAndSelectText( EA_RelMatrix.fromIntroText, "Body 1" );
1444
            }
1452
            }
1445
 
1453
 
-
 
1454
            // create the from-to table in the word doc
1446
            tableNum = createTable( EA_RelMatrix.fromToTableTitle, fromLister.Elements.Count + 1, 2 );
1455
            tableNum = createTable( EA_RelMatrix.fromToTableTitle, fromLister.Elements.Count + 1, 2 );
1447
            table = WordDocument.Tables[tableNum];
1456
            table = WordDocument.Tables[tableNum];
1448
            
1457
            
1449
            table.Cell(1,1).Range.Text = EA_RelMatrix.fromColumnTitle;
1458
            table.Cell(1,1).Range.Text = EA_RelMatrix.fromColumnTitle;
1450
            table.Cell(1,1).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
1459
            table.Cell(1,1).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
Line 1452... Line 1461...
1452
            table.Cell(1,2).Range.Text = EA_RelMatrix.toColumnTitle;
1461
            table.Cell(1,2).Range.Text = EA_RelMatrix.toColumnTitle;
1453
            table.Cell(1,2).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
1462
            table.Cell(1,2).Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
1454
            table.Cell(1,2).Range.Font.Bold = 1;
1463
            table.Cell(1,2).Range.Font.Bold = 1;
1455
         }
1464
         }
1456
 
1465
 
-
 
1466
         // Add from-to content to the from-to table. 
-
 
1467
         // NOTE: this code has to execute even if no from-to table is needed, in order to support the
-
 
1468
         // generation of a to-from table, assuming the user has requested one.
1457
         int row = 2;
1469
         int row = 2;
1458
         foreach(EA.Element fromElement in fromLister.Elements)
1470
         foreach(EA.Element fromElement in fromLister.Elements)
1459
         {
1471
         {
-
 
1472
            // Output the left hand column text to the from-to table, if one has been requested
1460
            if (EA_RelMatrix.fromToTableTitle != null)
1473
            if (needFromToTable)
1461
               table.Cell(row,1).Range.Text = fromElement.Name;
1474
               table.Cell(row,1).Range.Text = fromElement.Name;
1462
 
1475
 
1463
            // look at the elements connection collection to find references to the
1476
            // look at the elements connection collection to find references to the
1464
            // destination elements
1477
            // destination elements
1465
            EA.Collection conCollection = fromElement.Connectors;
1478
            EA.Collection conCollection = fromElement.Connectors;
Line 1468... Line 1481...
1468
            {
1481
            {
1469
               EA.Element destE = EA_Repository.GetElementByID( thisCon.SupplierID );
1482
               EA.Element destE = EA_Repository.GetElementByID( thisCon.SupplierID );
1470
               if (destE == null)
1483
               if (destE == null)
1471
                  continue;
1484
                  continue;
1472
 
1485
 
1473
               // if the destination element is of a type that the user has requested to include...
1486
               // ignore self-referential connections
1474
               if (!EA_RelMatrix.toElementTypes.Contains( destE.Type ))
1487
               if (fromElement.ElementID == thisCon.SupplierID)
1475
                  continue;
1488
                  continue;
1476
 
1489
 
-
 
1490
               // if the destination element is of a type that the user has requested to include...
1477
               if ( (destE.Type == "Requirement") && (destE.Status == "Rejected") )
1491
               if (!EA_RelMatrix.toElementTypes.Contains( destE.Type ))
1478
                  continue;
1492
                  continue;
1479
 
1493
 
1480
               // Output the text
1494
               // Output the right hand column text to the from-to table, if one has been requested
1481
               if (firstCon)
1495
               if (needFromToTable)
1482
               {
1496
               {
1483
                  firstCon = false;
1497
                  if (firstCon)
-
 
1498
                  {
1484
                  if (EA_RelMatrix.fromToTableTitle != null)
1499
                     firstCon = false;
1485
                     table.Cell(row,2).Range.Text = destE.Name;
1500
                     table.Cell(row,2).Range.Text = destE.Name;
1486
               }
1501
                  }
1487
               else
1502
                  else
1488
               {
1503
                  {
1489
                  if (EA_RelMatrix.fromToTableTitle != null)
-
 
1490
                     table.Cell(row,2).Range.Text += destE.Name;
1504
                     table.Cell(row,2).Range.Text += destE.Name;
-
 
1505
                  }
1491
               }
1506
               }
1492
 
1507
 
1493
               // Capture the from-to relationship in a dictionary where the key is the
1508
               // Capture the from-to relationship in a dictionary where the key is the
1494
               // ID of the destination element, and the value is the from element name.
1509
               // ID of the destination element, and the value is the from element name.
1495
               // This dictionary will enable rapid construction of the to-from table if
1510
               // This dictionary will enable rapid construction of the to-from table if
1496
               // the user has requested it, from the exact same relationship info used
1511
               // the user has requested it, from the exact same relationship info used
1497
               // for the from-to table.
1512
               // to construct the from-to table.
1498
               if (EA_RelMatrix.toFromTableTitle != null)
1513
               if (needToFromTable)
1499
               {
1514
               {
1500
                  DictionaryEntry newEntry = new DictionaryEntry(destE.ElementID, fromElement.Name);
1515
                  DictionaryEntry newEntry = new DictionaryEntry(destE.ElementID, fromElement.Name);
1501
                  fromToDictionary.Add( newEntry );
1516
                  fromToDictionary.Add( newEntry );
1502
               }
1517
               }
1503
            }
1518
            }
1504
            row++;
1519
            row++;
1505
         }
1520
         }
1506
 
1521
 
1507
         // Does user want a to-from table ?
1522
         // Does user want a to-from table ?
1508
         if (EA_RelMatrix.toFromTableTitle != null)
1523
         if (needToFromTable)
1509
         {
1524
         {
1510
            ElementAccumulator toLister = new ElementAccumulator(EA_RelMatrix.toElementTypes);
1525
            ElementAccumulator toLister = new ElementAccumulator(EA_RelMatrix.toElementTypes);
1511
            EA_Utils.findAndProcessPackageElements( EA_RelMatrix.toPackage, toLister, EA_RelMatrix.toPackageRecursion );
1526
            EA_Utils.findAndProcessPackageElements( EA_RelMatrix.toPackage, toLister, EA_RelMatrix.toPackageRecursion );
1512
 
1527
 
1513
            // Sort the "to" elements
1528
            // Sort the "to" elements
1514
            toLister.Elements.Sort( sorter );
1529
            toLister.Elements.Sort( sorter );
1515
 
1530
 
1516
            if (EA_RelMatrix.toIntroText != null)
1531
            if (EA_RelMatrix.toIntroText != null && EA_RelMatrix.toIntroText.Length > 0)
1517
            {
1532
            {
1518
               appendAndSelectText( EA_RelMatrix.toIntroText, "Body 1" );
1533
               appendAndSelectText( EA_RelMatrix.toIntroText, "Body 1" );
1519
            }
1534
            }
1520
 
1535
 
1521
            // create the table in the word doc
1536
            // create the table in the word doc
Line 1531... Line 1546...
1531
 
1546
 
1532
            // To make the to-from table, we use the dictionary that was built when making the from-to
1547
            // To make the to-from table, we use the dictionary that was built when making the from-to
1533
            // table. The dictionary will allow rapid determination of what "from" items belong to each
1548
            // table. The dictionary will allow rapid determination of what "from" items belong to each
1534
            // "to" item, without us having to go back to EA and enquire on the database.
1549
            // "to" item, without us having to go back to EA and enquire on the database.
1535
            row = 2;
1550
            row = 2;
1536
            foreach(EA.Element fromElement in toLister.Elements)
1551
            foreach(EA.Element toElement in toLister.Elements)
1537
            {
1552
            {
1538
               // from 
1553
               // left-column cell content
1539
               table.Cell(row,1).Range.Text = fromElement.Name;
1554
               table.Cell(row,1).Range.Text = toElement.Name;
1540
 
-
 
1541
               // skip rejected requirements - not needed because it is done in the ElementAccumulator class
-
 
1542
               //if ( (fromElement.Type == "Requirement") && (fromElement.Status == "Rejected") )
-
 
1543
               //   continue;
-
 
1544
 
1555
 
1545
               // to's
1556
               // right-column cell content
1546
               bool firstCon = true;
1557
               bool firstCon = true;
1547
               foreach (DictionaryEntry de in fromToDictionary)
1558
               foreach (DictionaryEntry de in fromToDictionary)
1548
               {
1559
               {
1549
                  if ((int)de.Key == fromElement.ElementID)
1560
                  if ((int)de.Key == toElement.ElementID)
1550
                  {
1561
                  {
1551
                     if (firstCon)
1562
                     if (firstCon)
1552
                     {
1563
                     {
1553
                        firstCon = false;
1564
                        firstCon = false;
1554
                        table.Cell(row,2).Range.Text = (string)de.Value;
1565
                        table.Cell(row,2).Range.Text = (string)de.Value;