Subversion Repositories DevTools

Rev

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

Rev 2104 Rev 2106
Line 2... Line 2...
2
using System.Collections;
2
using System.Collections;
3
using System.Text;
3
using System.Text;
4
using System.ComponentModel;
4
using System.ComponentModel;
5
using System.Windows.Forms;
5
using System.Windows.Forms;
6
 
6
 
7
 
-
 
8
namespace EA_DocGen
7
namespace EA_DocGen
9
{
8
{
10
	/// <summary>
9
	/// <summary>
11
	/// Summary description for EA_RelationshipMatrix.
10
	/// Summary description for EA_RelationshipMatrix.
12
	/// </summary>
11
	/// </summary>
13
	public class EA_RelationshipMatrix
12
	public class EA_RelationshipMatrix
14
	{
13
	{
15
      private EA_Utilities EA_Utils = null;
-
 
16
      private EA.Repository EA_Repository = null;
-
 
17
      private TextualContent TextUtils = null;
-
 
18
      private TabularContent TableUtils = null;
-
 
19
      private Word.Document WordDocument = null;
-
 
20
      private ArrayList processedElements = null;
14
      private static ArrayList processedElements = null;
21
 
15
 
22
      // declare option variables
16
      // declare option variables
23
      private int style = 1;
17
      private static int style = 1;
24
 
18
 
25
      private string fromIntroText = null;     // This one is optional 
19
      private static string fromIntroText = null;     // This one is optional 
26
      private string fromPackageGUID = null;
20
      private static string fromPackageGUID = null;
27
      private string fromToTableTitle = null;  // This one is optional
21
      private static string fromToTableTitle = null;  // This one is optional
28
      private string fromColumnTitle = null;
22
      private static string fromColumnTitle = null;
29
      private ArrayList fromElementTypes = null;
23
      private static ArrayList fromElementTypes = null;
30
      private bool fromPackageRecursion = true;
24
      private static bool fromPackageRecursion = true;
31
      private EA.Package fromPackage = null;
25
      private static EA.Package fromPackage = null;
32
      private bool fromPackageTrimming = false;
26
      private static bool fromPackageTrimming = false;
33
 
27
 
34
      private string toIntroText = null;       // This one is optional
28
      private static string toIntroText = null;       // This one is optional
35
      private string toPackageGUID = null;
29
      private static string toPackageGUID = null;
36
      private string toFromTableTitle = null;  // This one is optional
30
      private static string toFromTableTitle = null;  // This one is optional
37
      private string toColumnTitle = null;
31
      private static string toColumnTitle = null;
38
      private ArrayList toElementTypes = null;
32
      private static ArrayList toElementTypes = null;
39
      private bool toPackageRecursion = true;
33
      private static bool toPackageRecursion = true;
40
      private EA.Package toPackage = null;
34
      private static EA.Package toPackage = null;
41
      private bool toPackageTrimming = false;
35
      private static bool toPackageTrimming = false;
42
 
36
 
43
      
37
      
44
 
38
 
45
      private string [] options_string = null;
39
      private static string [] options_string = null;
46
 
40
 
47
 
41
 
48
 
42
 
49
		public EA_RelationshipMatrix(
-
 
50
         EA.Repository  EA_RepRef, 
-
 
51
         TabularContent TableUtilsRef,
-
 
52
         TextualContent TextUtilsRef,
-
 
53
         EA_Utilities   EA_UtilsRef,
-
 
54
         Word.Document  WordDocumentRef,
-
 
55
         ArrayList      processedElementsRef)
43
		public static void initialise(ArrayList processedElementsRef)
56
		{
44
		{
57
         EA_Repository     = EA_RepRef;
-
 
58
         TableUtils        = TableUtilsRef;
-
 
59
         TextUtils         = TextUtilsRef;
-
 
60
         EA_Utils          = EA_UtilsRef;
-
 
61
         WordDocument      = WordDocumentRef;
-
 
62
         processedElements = processedElementsRef;
45
         processedElements = processedElementsRef;
63
 
46
 
64
         fromElementTypes  = new ArrayList();
47
         fromElementTypes  = new ArrayList();
65
         toElementTypes    = new ArrayList();
48
         toElementTypes    = new ArrayList();
66
		}
49
		}
67
 
50
 
68
      private void reset()
51
      private static void reset()
69
      {
52
      {
70
         style = 1;
53
         style = 1;
71
 
54
 
72
         fromIntroText = null;
55
         fromIntroText = null;
73
         fromPackageGUID = null;
56
         fromPackageGUID = null;
Line 86... Line 69...
86
         toPackageTrimming = false;
69
         toPackageTrimming = false;
87
         toPackage = null;
70
         toPackage = null;
88
      }
71
      }
89
 
72
 
90
 
73
 
91
      public bool processRelationshipMatrixOptions(EA.Element theElement)
74
      public static bool processRelationshipMatrixOptions(EA.Element theElement)
92
      {
75
      {
93
         reset();
76
         reset();
94
 
77
 
95
         // Extract the control options from the notes of the element
78
         // Extract the control options from the notes of the element
96
         
79
         
Line 109... Line 92...
109
         {
92
         {
110
            if (s.Length > 0 && s != "\n" && s != "\r" && s[0] != '\\')
93
            if (s.Length > 0 && s != "\n" && s != "\r" && s[0] != '\\')
111
            {
94
            {
112
               if (s.StartsWith("style="))
95
               if (s.StartsWith("style="))
113
               {
96
               {
114
                  style = EA_Utils.options.getOptionValue(s, style);
97
                  style = EA_DocGenOptions.getOptionValue(s, style);
115
               }
98
               }
116
               // FROM items
99
               // FROM items
117
               else if (s.StartsWith("fromIntroText="))
100
               else if (s.StartsWith("fromIntroText="))
118
               {
101
               {
119
                  fromIntroText = EA_Utils.options.getOptionValue(s, null);
102
                  fromIntroText = EA_DocGenOptions.getOptionValue(s, null);
120
               }
103
               }
121
               else if (s.StartsWith("fromToTableTitle=")) 
104
               else if (s.StartsWith("fromToTableTitle=")) 
122
               {
105
               {
123
                  fromToTableTitle = EA_Utils.options.getOptionValue(s, null);
106
                  fromToTableTitle = EA_DocGenOptions.getOptionValue(s, null);
124
               }
107
               }
125
               else if (s.StartsWith("fromColumnTitle=")) 
108
               else if (s.StartsWith("fromColumnTitle=")) 
126
               {
109
               {
127
                  fromColumnTitle = EA_Utils.options.getOptionValue(s, fromColumnTitle);
110
                  fromColumnTitle = EA_DocGenOptions.getOptionValue(s, fromColumnTitle);
128
               }
111
               }
129
               else if (s.StartsWith("fromPackageRecursion=")) 
112
               else if (s.StartsWith("fromPackageRecursion=")) 
130
               {
113
               {
131
                  fromPackageRecursion = EA_Utils.options.getOptionValue(s, fromPackageRecursion);
114
                  fromPackageRecursion = EA_DocGenOptions.getOptionValue(s, fromPackageRecursion);
132
               }
115
               }
133
               else if (s.StartsWith("fromPackageTrimming="))
116
               else if (s.StartsWith("fromPackageTrimming="))
134
               {
117
               {
135
                  fromPackageTrimming = EA_Utils.options.getOptionValue(s, fromPackageTrimming);
118
                  fromPackageTrimming = EA_DocGenOptions.getOptionValue(s, fromPackageTrimming);
136
               }
119
               }
137
               else if (s.StartsWith("fromPackage=")) 
120
               else if (s.StartsWith("fromPackage=")) 
138
               {
121
               {
139
                  fromPackageGUID = EA_Utils.options.getOptionValue(s, fromPackageGUID);
122
                  fromPackageGUID = EA_DocGenOptions.getOptionValue(s, fromPackageGUID);
140
               }
123
               }
141
               else if (s.StartsWith("fromElementType=")) 
124
               else if (s.StartsWith("fromElementType=")) 
142
               {
125
               {
143
                  string et = EA_Utils.options.getOptionValue(s,null);
126
                  string et = EA_DocGenOptions.getOptionValue(s,null);
144
                  if (et != null) 
127
                  if (et != null) 
145
                  {
128
                  {
146
                     fromElementTypes.Add( et );
129
                     fromElementTypes.Add( et );
147
                  }
130
                  }
148
               }
131
               }
149
 
132
 
150
                  // TO items
133
                  // TO items
151
               else if (s.StartsWith("toIntroText="))
134
               else if (s.StartsWith("toIntroText="))
152
               {
135
               {
153
                  toIntroText = EA_Utils.options.getOptionValue(s, null);
136
                  toIntroText = EA_DocGenOptions.getOptionValue(s, null);
154
               }
137
               }
155
               else if (s.StartsWith("toFromTableTitle=")) 
138
               else if (s.StartsWith("toFromTableTitle=")) 
156
               {
139
               {
157
                  toFromTableTitle = EA_Utils.options.getOptionValue(s, null);
140
                  toFromTableTitle = EA_DocGenOptions.getOptionValue(s, null);
158
               }
141
               }
159
               else if (s.StartsWith("toColumnTitle=")) 
142
               else if (s.StartsWith("toColumnTitle=")) 
160
               {
143
               {
161
                  toColumnTitle = EA_Utils.options.getOptionValue(s, toColumnTitle);
144
                  toColumnTitle = EA_DocGenOptions.getOptionValue(s, toColumnTitle);
162
               }
145
               }
163
               else if (s.StartsWith("toPackageRecursion=")) 
146
               else if (s.StartsWith("toPackageRecursion=")) 
164
               {
147
               {
165
                  toPackageRecursion = EA_Utils.options.getOptionValue(s, toPackageRecursion);
148
                  toPackageRecursion = EA_DocGenOptions.getOptionValue(s, toPackageRecursion);
166
               }
149
               }
167
               else if (s.StartsWith("toPackageTrimming=")) 
150
               else if (s.StartsWith("toPackageTrimming=")) 
168
               {
151
               {
169
                  toPackageTrimming = EA_Utils.options.getOptionValue(s, toPackageTrimming);
152
                  toPackageTrimming = EA_DocGenOptions.getOptionValue(s, toPackageTrimming);
170
               }               
153
               }               
171
               else if (s.StartsWith("toPackage=")) 
154
               else if (s.StartsWith("toPackage=")) 
172
               {
155
               {
173
                  toPackageGUID = EA_Utils.options.getOptionValue(s, toPackageGUID);
156
                  toPackageGUID = EA_DocGenOptions.getOptionValue(s, toPackageGUID);
174
               }
157
               }
175
               else if (s.StartsWith("toElementType=")) 
158
               else if (s.StartsWith("toElementType=")) 
176
               {
159
               {
177
                  string et = EA_Utils.options.getOptionValue(s,null);
160
                  string et = EA_DocGenOptions.getOptionValue(s,null);
178
                  if (et != null) 
161
                  if (et != null) 
179
                  {
162
                  {
180
                     toElementTypes.Add( et );
163
                     toElementTypes.Add( et );
181
                  }
164
                  }
182
               }
165
               }
Line 230... Line 213...
230
               "Missing option(s): toElementTypes");
213
               "Missing option(s): toElementTypes");
231
            return false;
214
            return false;
232
         }   
215
         }   
233
 
216
 
234
         // Find GUID linked packages in the repository
217
         // Find GUID linked packages in the repository
235
         fromPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID( fromPackageGUID );
218
         fromPackage = Main.EA_Repository.GetPackageByGuid( fromPackageGUID );
236
         if (fromPackage == null)
219
         if (fromPackage == null)
237
         {
220
         {
238
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
221
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
239
               "could not locate fromPackage in Repository");
222
               "could not locate fromPackage in Repository");
240
            return false;
223
            return false;
241
         }
224
         }
242
 
225
 
243
         toPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID( toPackageGUID );
226
         toPackage = Main.EA_Repository.GetPackageByGuid( toPackageGUID );
244
         if (toPackage == null)
227
         if (toPackage == null)
245
         {
228
         {
246
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
229
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
247
               "could not locate toPackage in Repository");
230
               "could not locate toPackage in Repository");
248
            return false;
231
            return false;
Line 300... Line 283...
300
      /// built from content specified in options that are provided in the notes section of 
283
      /// built from content specified in options that are provided in the notes section of 
301
      /// the special element that has led to this function being called.
284
      /// the special element that has led to this function being called.
302
      /// </summary>
285
      /// </summary>
303
      /// <param name="theElement"></param>
286
      /// <param name="theElement"></param>
304
      /// <param name="recurse_level"></param>
287
      /// <param name="recurse_level"></param>
305
      public void processRelationshipMatrixElement( EA.Element theElement, int recurse_level )
288
      public static void processRelationshipMatrixElement( EA.Element theElement, int recurse_level )
306
      {
289
      {
307
         switch (style)
290
         switch (style)
308
         {
291
         {
309
            case 1:
292
            case 1:
310
               processRelationshipMatrixElementStyle1();
293
               processRelationshipMatrixElementStyle1();
Line 322... Line 305...
322
      /// has led to this function being called.
305
      /// has led to this function being called.
323
      /// 
306
      /// 
324
      /// The style of these tables is that required for requirement to design traceability.
307
      /// The style of these tables is that required for requirement to design traceability.
325
      /// </summary>
308
      /// </summary>
326
      /// <param name="EA_RelMatrix"></param>
309
      /// <param name="EA_RelMatrix"></param>
327
      private void processRelationshipMatrixElementStyle1()
310
      private static void processRelationshipMatrixElementStyle1()
328
      {
311
      {
329
         int tableNum = 0;
312
         int tableNum = 0;
330
         Word.Table table = null;
313
         Word.Table table = null;
331
 
314
 
332
         // Scan the fromPackage to find all the "from elements".
315
         // Scan the fromPackage to find all the "from elements".
333
         ElementAccumulator fromLister = new ElementAccumulator(fromElementTypes, EA_Utils);
316
         ElementAccumulator fromLister = new ElementAccumulator(fromElementTypes);
334
         EA_Utils.findAndProcessPackageElements( fromPackage, fromLister, fromPackageRecursion );
317
         EA_Utilities.findAndProcessPackageElements( fromPackage, fromLister, fromPackageRecursion );
-
 
318
 
-
 
319
         if (createWordDoc.abortCreationThread)
-
 
320
            return;
335
 
321
 
336
         // Sort the "from elements"
322
         // Sort the "from elements"
337
         elementSortByName sorter = new elementSortByName();
323
         elementSortByName sorter = new elementSortByName();
338
         fromLister.Elements.Sort( sorter );
324
         fromLister.Elements.Sort( sorter );
339
 
325
 
-
 
326
         if (createWordDoc.abortCreationThread)
-
 
327
            return;
-
 
328
 
340
         // dictionary to support from-to table construction.
329
         // dictionary to support from-to table construction.
341
         ArrayList fromToDictionary = new ArrayList();
330
         ArrayList fromToDictionary = new ArrayList();
342
 
331
 
343
         // dictionary to support to-from table construction.
332
         // dictionary to support to-from table construction.
344
         ArrayList toFromDictionary = new ArrayList();
333
         ArrayList toFromDictionary = new ArrayList();
Line 355... Line 344...
355
         // generation of a to-from table, assuming the user has requested one.
344
         // generation of a to-from table, assuming the user has requested one.
356
         int numberOfFromToRows = 0;
345
         int numberOfFromToRows = 0;
357
         
346
         
358
         foreach(EA.Element fromElement in fromLister.Elements)
347
         foreach(EA.Element fromElement in fromLister.Elements)
359
         {
348
         {
-
 
349
            if (createWordDoc.abortCreationThread)
-
 
350
               return;
-
 
351
 
360
            // look at the elements connection collection to find references to the
352
            // look at the elements connection collection to find references to the
361
            // destination elements
353
            // destination elements
362
            bool foundToElement = false;
354
            bool foundToElement = false;
363
 
355
 
364
            EA.Collection conCollection = fromElement.Connectors;
356
            EA.Collection conCollection = fromElement.Connectors;
365
            
357
            
366
            foreach (EA.Connector thisCon in conCollection)
358
            foreach (EA.Connector thisCon in conCollection)
367
            {
359
            {
-
 
360
               if (createWordDoc.abortCreationThread)
-
 
361
                  return;
-
 
362
 
368
               EA.Element destE = EA_Repository.GetElementByID( thisCon.SupplierID );
363
               EA.Element destE = Main.EA_Repository.GetElementByID( thisCon.SupplierID );
369
               if (destE == null)
364
               if (destE == null)
370
                  continue;
365
                  continue;
371
 
366
 
372
               // ignore self-referential connections
367
               // ignore self-referential connections
373
               if (fromElement.ElementID == thisCon.SupplierID)
368
               if (fromElement.ElementID == thisCon.SupplierID)
Line 408... Line 403...
408
               fromToDictionary.Add( newFromToEntry );
403
               fromToDictionary.Add( newFromToEntry );
409
               numberOfFromToRows++;
404
               numberOfFromToRows++;
410
            }
405
            }
411
         }
406
         }
412
         
407
         
-
 
408
         if (createWordDoc.abortCreationThread)
-
 
409
            return;
-
 
410
 
413
         if (needFromToTable)
411
         if (needFromToTable)
414
         {
412
         {
415
            // Now we can actually serialise the table
413
            // Now we can actually serialise the table
416
 
414
 
417
            if (fromIntroText != null && fromIntroText.Length > 0)
415
            if (fromIntroText != null && fromIntroText.Length > 0)
418
            {
416
            {
419
               TextUtils.appendAndSelectText( fromIntroText, EA_Constants.styleName_Body1 );
417
               TextualContent.appendAndSelectText( fromIntroText, EA_Constants.styleName_Body1 );
420
            }
418
            }
421
 
419
 
422
            // create the from-to table in the word doc
420
            // create the from-to table in the word doc
423
            tableNum = TableUtils.Table_Create( fromToTableTitle, numberOfFromToRows + 1, 2 );
421
            tableNum = TabularContent.Table_Create( fromToTableTitle, true, numberOfFromToRows + 1, 2 );
424
            table = WordDocument.Tables[tableNum];
422
            table = createWordDoc.WordDocument.Tables[tableNum];
425
            
423
            
426
            TableUtils.Table_SetTableColumnTitle(table, fromColumnTitle, 1);
424
            TabularContent.Table_SetTableColumnTitle(table, fromColumnTitle, 1);
427
            TableUtils.Table_SetTableColumnTitle(table, toColumnTitle, 2);
425
            TabularContent.Table_SetTableColumnTitle(table, toColumnTitle, 2);
428
 
426
 
429
            fillInTable(fromToDictionary, table);
427
            fillInTable(fromToDictionary, table);
430
         }
428
         }
431
 
429
 
-
 
430
         if (createWordDoc.abortCreationThread)
-
 
431
            return;
-
 
432
 
432
         // Does user want a to-from table ?
433
         // Does user want a to-from table ?
433
         if (needToFromTable)
434
         if (needToFromTable)
434
         {
435
         {
435
            // re-use the fromToDictionary to prepare the to-from table content 
436
            // re-use the fromToDictionary to prepare the to-from table content 
436
            fromToDictionary.Clear();
437
            fromToDictionary.Clear();
437
 
438
 
438
            // find all elements for the left hand column of the to-from table.
439
            // find all elements for the left hand column of the to-from table.
439
            ElementAccumulator toLister = new ElementAccumulator(toElementTypes, EA_Utils);
440
            ElementAccumulator toLister = new ElementAccumulator(toElementTypes);
440
            EA_Utils.findAndProcessPackageElements( toPackage, toLister, toPackageRecursion );
441
            EA_Utilities.findAndProcessPackageElements( toPackage, toLister, toPackageRecursion );
-
 
442
 
-
 
443
            if (createWordDoc.abortCreationThread)
-
 
444
               return;
441
 
445
 
442
            // Sort the "to" elements
446
            // Sort the "to" elements
443
            toLister.Elements.Sort( sorter );
447
            toLister.Elements.Sort( sorter );
444
 
448
 
-
 
449
            if (createWordDoc.abortCreationThread)
-
 
450
               return;
-
 
451
 
445
            // To make the to-from table, we use the dictionary that was built when making the from-to
452
            // To make the to-from table, we use the dictionary that was built when making the from-to
446
            // table. The dictionary will allow rapid determination of what "from" items belong to each
453
            // table. The dictionary will allow rapid determination of what "from" items belong to each
447
            // "to" item, without us having to go back to EA and enquire on the database.
454
            // "to" item, without us having to go back to EA and enquire on the database.
448
            // We build a new fromToDictionary from the toFromDictionary, in advance of actually making 
455
            // We build a new fromToDictionary from the toFromDictionary, in advance of actually making 
449
            // the table so that we can figure out how many rows the table needs to have.
456
            // the table so that we can figure out how many rows the table needs to have.
450
            numberOfFromToRows = 0;
457
            numberOfFromToRows = 0;
451
            
458
            
452
            foreach(EA.Element toElement in toLister.Elements)
459
            foreach(EA.Element toElement in toLister.Elements)
453
            {
460
            {
-
 
461
               if (createWordDoc.abortCreationThread)
-
 
462
                  return;
-
 
463
 
454
               bool foundToElement = false;
464
               bool foundToElement = false;
455
 
465
 
456
               // right-column cell content
466
               // right-column cell content
457
               foreach (DictionaryEntry de in toFromDictionary)
467
               foreach (DictionaryEntry de in toFromDictionary)
458
               {
468
               {
Line 462... Line 472...
462
                     fromToDictionary.Add( newFromToEntry );
472
                     fromToDictionary.Add( newFromToEntry );
463
                     foundToElement = true;
473
                     foundToElement = true;
464
                  }
474
                  }
465
               }
475
               }
466
 
476
 
-
 
477
               if (createWordDoc.abortCreationThread)
-
 
478
                  return;
-
 
479
 
467
               // If we found a from-to relationship that table needs a new row.
480
               // If we found a from-to relationship that table needs a new row.
468
               if (foundToElement)
481
               if (foundToElement)
469
               {
482
               {
470
                  numberOfFromToRows++;
483
                  numberOfFromToRows++;
471
               }
484
               }
Line 477... Line 490...
477
                  fromToDictionary.Add( newFromToEntry );
490
                  fromToDictionary.Add( newFromToEntry );
478
                  numberOfFromToRows++;
491
                  numberOfFromToRows++;
479
               }
492
               }
480
            }
493
            }
481
 
494
 
-
 
495
            if (createWordDoc.abortCreationThread)
-
 
496
               return;
-
 
497
 
482
            // Now begin to add the to-from table to the word document
498
            // Now begin to add the to-from table to the word document
483
            if (toIntroText != null && toIntroText.Length > 0)
499
            if (toIntroText != null && toIntroText.Length > 0)
484
            {
500
            {
485
               TextUtils.appendAndSelectText( toIntroText, EA_Constants.styleName_Body1 );
501
               TextualContent.appendAndSelectText( toIntroText, EA_Constants.styleName_Body1 );
486
            }
502
            }
487
 
503
 
488
            // create the table in the word doc
504
            // create the table in the word doc
489
            tableNum = TableUtils.Table_Create( toFromTableTitle, numberOfFromToRows + 1, 2 );
505
            tableNum = TabularContent.Table_Create( toFromTableTitle, true, numberOfFromToRows + 1, 2 );
490
            table = WordDocument.Tables[tableNum];
506
            table = createWordDoc.WordDocument.Tables[tableNum];
491
            
507
            
492
            TableUtils.Table_SetTableColumnTitle(table, toColumnTitle, 1);
508
            TabularContent.Table_SetTableColumnTitle(table, toColumnTitle, 1);
493
            TableUtils.Table_SetTableColumnTitle(table, fromColumnTitle, 2);
509
            TabularContent.Table_SetTableColumnTitle(table, fromColumnTitle, 2);
494
 
510
 
495
            fillInTable(fromToDictionary, table);
511
            fillInTable(fromToDictionary, table);
496
         }
512
         }
497
      }
513
      }
498
 
514
 
499
      private void fillInTable(ArrayList fromToDictionary, Word.Table table )
515
      private static void fillInTable(ArrayList fromToDictionary, Word.Table table )
500
      {
516
      {
501
         int lastFromElementId = -1;
517
         int lastFromElementId = -1;
502
         bool firstToFromCon = true;
518
         bool firstToFromCon = true;
503
         int row = 1;
519
         int row = 1;
504
         foreach (DictionaryEntry de in fromToDictionary)
520
         foreach (DictionaryEntry de in fromToDictionary)
505
         {
521
         {
-
 
522
            if (createWordDoc.abortCreationThread)
-
 
523
               return;
-
 
524
 
506
            if ( ((EA.Element)de.Key).ElementID != lastFromElementId )
525
            if ( ((EA.Element)de.Key).ElementID != lastFromElementId )
507
            {
526
            {
508
               lastFromElementId = ((EA.Element)de.Key).ElementID;
527
               lastFromElementId = ((EA.Element)de.Key).ElementID;
509
               row++;
528
               row++;
510
               table.Cell(row,1).Range.Text = ((EA.Element)de.Key).Name;
529
               table.Cell(row,1).Range.Text = ((EA.Element)de.Key).Name;
Line 523... Line 542...
523
                  table.Cell(row,2).Range.Text += (string)de.Value;
542
                  table.Cell(row,2).Range.Text += (string)de.Value;
524
               }
543
               }
525
            }
544
            }
526
            else
545
            else
527
            {
546
            {
528
               if (EA_Utils.options.opt_SuppressUnAllocatedRelationshipWarnings == false)
547
               if (EA_DocGenOptions.opt_SuppressUnAllocatedRelationshipWarnings == false)
529
               {
548
               {
530
                  table.Cell(row,2).Range.Text = "Un-allocated relationship!";
549
                  table.Cell(row,2).Range.Text = "Un-allocated relationship!";
531
                  table.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
550
                  table.Cell(row,2).Range.Font.Color = Word.WdColor.wdColorRed;
532
               }
551
               }
533
            }
552
            }
Line 543... Line 562...
543
      /// Here, only a single table is generated, and the only elements in the left hand column will
562
      /// Here, only a single table is generated, and the only elements in the left hand column will
544
      /// be those serialised to the document earlier on, and the content of the right hand column
563
      /// be those serialised to the document earlier on, and the content of the right hand column
545
      /// will be the parental requirements (all the way up to root requirements).
564
      /// will be the parental requirements (all the way up to root requirements).
546
      /// </summary>
565
      /// </summary>
547
      /// <param name="EA_RelMatrix"></param>
566
      /// <param name="EA_RelMatrix"></param>
548
      private void processRelationshipMatrixElementStyle2()
567
      private static void processRelationshipMatrixElementStyle2()
549
      {
568
      {
550
         int i;
569
         int i;
551
         int tableNum = 0;
570
         int tableNum = 0;
552
         Word.Table table = null;
571
         Word.Table table = null;
553
 
572
 
554
         // Scan the fromPackage to find all the "from elements".
573
         // Scan the fromPackage to find all the "from elements".
555
         ElementAccumulator fromLister = new ElementAccumulator(fromElementTypes, EA_Utils);
574
         ElementAccumulator fromLister = new ElementAccumulator(fromElementTypes);
556
         EA_Utils.findAndProcessPackageElements( fromPackage, fromLister, fromPackageRecursion );
575
         EA_Utilities.findAndProcessPackageElements( fromPackage, fromLister, fromPackageRecursion );
-
 
576
 
-
 
577
         if (createWordDoc.abortCreationThread)
-
 
578
            return;
557
 
579
 
558
         // Remove all elements from the list that did not go to form content in the document
580
         // Remove all elements from the list that did not go to form content in the document
559
         // prior to this point in the document generation process.
581
         // prior to this point in the document generation process.
560
         for (i=0; i<fromLister.Elements.Count; )
582
         for (i=0; i<fromLister.Elements.Count; )
561
         {
583
         {
-
 
584
            if (createWordDoc.abortCreationThread)
-
 
585
               return;
-
 
586
 
562
            if ( !processedElements.Contains( ((EA.Element)fromLister.Elements[i]).ElementID ) )
587
            if ( !processedElements.Contains( ((EA.Element)fromLister.Elements[i]).ElementID ) )
563
            {
588
            {
564
               fromLister.Elements.RemoveAt(i);
589
               fromLister.Elements.RemoveAt(i);
565
               continue;
590
               continue;
566
            }
591
            }
567
            i++;
592
            i++;
568
         }
593
         }
569
 
594
 
-
 
595
         if (createWordDoc.abortCreationThread)
-
 
596
            return;
-
 
597
 
570
         // Sort the remaining "from elements"
598
         // Sort the remaining "from elements"
571
         elementSortByName sorter = new elementSortByName();
599
         elementSortByName sorter = new elementSortByName();
572
         fromLister.Elements.Sort( sorter );
600
         fromLister.Elements.Sort( sorter );
-
 
601
 
-
 
602
         if (createWordDoc.abortCreationThread)
573
         
603
            return;
-
 
604
 
574
         // Scan the toPackage to find all the "to elements".
605
         // Scan the toPackage to find all the "to elements".
575
         // Extract their element IDs into a new list.
606
         // Extract their element IDs into a new list.
576
         ElementAccumulator toLister = new ElementAccumulator(toElementTypes, EA_Utils);
607
         ElementAccumulator toLister = new ElementAccumulator(toElementTypes);
577
         EA_Utils.findAndProcessPackageElements( toPackage, toLister, toPackageRecursion );
608
         EA_Utilities.findAndProcessPackageElements( toPackage, toLister, toPackageRecursion );
578
         ArrayList acceptableParents = new ArrayList();
609
         ArrayList acceptableParents = new ArrayList();
579
         foreach(EA.Element ele in toLister.Elements)
610
         foreach(EA.Element ele in toLister.Elements)
580
         {
611
         {
-
 
612
            if (createWordDoc.abortCreationThread)
-
 
613
               return;
-
 
614
 
581
            acceptableParents.Add( ele.ElementID);
615
            acceptableParents.Add( ele.ElementID);
582
         }
616
         }
583
 
617
 
-
 
618
         if (createWordDoc.abortCreationThread)
-
 
619
            return;
-
 
620
 
584
         // The list of from elements dictates the number of rows in our table.
621
         // The list of from elements dictates the number of rows in our table.
585
         int numberOfFromToRows = fromLister.Elements.Count;
622
         int numberOfFromToRows = fromLister.Elements.Count;
586
         
623
         
587
         if (fromIntroText != null && fromIntroText.Length > 0)
624
         if (fromIntroText != null && fromIntroText.Length > 0)
588
         {
625
         {
589
            TextUtils.appendAndSelectText( fromIntroText, EA_Constants.styleName_Body1 );
626
            TextualContent.appendAndSelectText( fromIntroText, EA_Constants.styleName_Body1 );
590
         }
627
         }
591
 
628
 
592
         // create the from-to table in the word doc
629
         // create the from-to table in the word doc
593
         tableNum = TableUtils.Table_Create( fromToTableTitle, numberOfFromToRows + 1, 2 );
630
         tableNum = TabularContent.Table_Create( fromToTableTitle, true, numberOfFromToRows + 1, 2 );
594
         table = WordDocument.Tables[tableNum];
631
         table = createWordDoc.WordDocument.Tables[tableNum];
595
            
632
            
596
         TableUtils.Table_SetTableColumnTitle(table, fromColumnTitle, 1);
633
         TabularContent.Table_SetTableColumnTitle(table, fromColumnTitle, 1);
597
         TableUtils.Table_SetTableColumnTitle(table, toColumnTitle, 2);
634
         TabularContent.Table_SetTableColumnTitle(table, toColumnTitle, 2);
598
 
635
 
599
         int row = 2;
636
         int row = 2;
600
         foreach(EA.Element ele in fromLister.Elements)
637
         foreach(EA.Element ele in fromLister.Elements)
601
         {
638
         {
-
 
639
            if (createWordDoc.abortCreationThread)
-
 
640
               return;
-
 
641
 
602
            table.Cell(row,1).Range.Text = ele.Name;
642
            table.Cell(row,1).Range.Text = ele.Name;
603
 
643
 
604
            StringBuilder sb = new StringBuilder();
644
            StringBuilder sb = new StringBuilder();
605
 
645
 
606
            ArrayList parentsDiscovered = new ArrayList();
646
            ArrayList parentsDiscovered = new ArrayList();
Line 609... Line 649...
609
            elementParenthood(ele, ref acceptableParents, ref parentsDiscovered, ref sb);
649
            elementParenthood(ele, ref acceptableParents, ref parentsDiscovered, ref sb);
610
 
650
 
611
            // if no source requirements found and user has opted for trimming, delete the table row
651
            // if no source requirements found and user has opted for trimming, delete the table row
612
            if (fromPackageTrimming == true && sb.Length == 0)
652
            if (fromPackageTrimming == true && sb.Length == 0)
613
            {
653
            {
614
               TableUtils.Table_DeleteThisRow(table, row);
654
               TabularContent.Table_DeleteThisRow(table, row);
615
               continue;
655
               continue;
616
            }
656
            }
617
            
657
            
618
            // fill in the right hand cell on this row of the table with the source requirement list
658
            // fill in the right hand cell on this row of the table with the source requirement list
619
            table.Cell(row,2).Range.Text = sb.ToString();
659
            table.Cell(row,2).Range.Text = sb.ToString();
620
            row++;
660
            row++;
621
         }
661
         }
622
 
662
 
623
      }
663
      }
624
 
664
 
625
      private void elementParenthood(EA.Element ele, ref ArrayList acceptableParents, ref ArrayList parentsDiscovered, ref StringBuilder sb)
665
      private static void elementParenthood(EA.Element ele, ref ArrayList acceptableParents, ref ArrayList parentsDiscovered, ref StringBuilder sb)
626
      {
666
      {
627
         foreach(EA.Connector con in ele.Connectors)
667
         foreach(EA.Connector con in ele.Connectors)
628
         {
668
         {
-
 
669
            if (createWordDoc.abortCreationThread)
-
 
670
               return;
-
 
671
 
629
            // ignore downwards direction, indicated by the client ID being equal to the element ID
672
            // ignore downwards direction, indicated by the client ID being equal to the element ID
630
            if (con.ClientID != ele.ElementID)
673
            if (con.ClientID != ele.ElementID)
631
            {
674
            {
632
               // if we have not already come across this upward path before...
675
               // if we have not already come across this upward path before...
633
               if (!parentsDiscovered.Contains(con.ClientID))
676
               if (!parentsDiscovered.Contains(con.ClientID))
Line 637... Line 680...
637
                  // is this parent is in the list of acceptable parents...
680
                  // is this parent is in the list of acceptable parents...
638
                  if (acceptableParents.Contains(con.ClientID))
681
                  if (acceptableParents.Contains(con.ClientID))
639
                  {
682
                  {
640
                     // get the parent element, add its name to our list, and ascend through the element
683
                     // get the parent element, add its name to our list, and ascend through the element
641
                     // using recursion.
684
                     // using recursion.
642
                     EA.Element client = EA_Repository.GetElementByID(con.ClientID);
685
                     EA.Element client = Main.EA_Repository.GetElementByID(con.ClientID);
643
                     if (client != null)
686
                     if (client != null)
644
                     {
687
                     {
645
                        if (sb.Length > 0)
688
                        if (sb.Length > 0)
646
                           sb.Append("\n");
689
                           sb.Append("\n");
647
                        sb.Append(client.Name);
690
                        sb.Append(client.Name);