Subversion Repositories DevTools

Rev

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

Rev 2120 Rev 2122
Line 9... Line 9...
9
	/// <summary>
9
	/// <summary>
10
	/// Summary description for EA_RelationshipMatrix.
10
	/// Summary description for EA_RelationshipMatrix.
11
	/// </summary>
11
	/// </summary>
12
	public class EA_RelationshipMatrix
12
	public class EA_RelationshipMatrix
13
	{
13
	{
14
      private static ArrayList processedElements = null;
-
 
15
 
14
 
-
 
15
      public struct RM_ColumnType
-
 
16
      {
-
 
17
         public string columnTitle;
-
 
18
 
16
      // declare option variables
19
         public string packageGUID;
17
      private static int style = 1;
20
         public string packageName;
18
 
21
 
19
      private static string fromIntroText = null;     // This one is optional 
22
         public ArrayList elementTypes;
-
 
23
 
-
 
24
         public bool packageRecursion;
20
      private static string fromPackageGUID = null;
25
         public bool packageTrimming;
-
 
26
         public bool elementNotes;
-
 
27
      };
-
 
28
 
-
 
29
      public struct RM_TableType
-
 
30
      {
21
      private static string fromToTableTitle = null;  // This one is optional
31
         public string introText;
22
      private static string fromColumnTitle = null;
32
         public string title;
-
 
33
      };
-
 
34
 
23
      private static ArrayList fromElementTypes = null;
35
      public struct RM_MatrixType
-
 
36
      {
-
 
37
         public int style;
24
      private static bool fromPackageRecursion = true;
38
         public RM_TableType fromToTable;
25
      private static EA.Package fromPackage = null;
39
         public RM_TableType toFromTable;
-
 
40
         public RM_ColumnType from;
-
 
41
         public RM_ColumnType to;
-
 
42
      };
-
 
43
 
-
 
44
      // DATA
26
      private static bool fromPackageTrimming = false;
45
      private static RM_MatrixType RM_Matrix;
-
 
46
 
27
      private static bool fromElementNotes = false;
47
      private static EA.Element RM_Element = null;
28
 
48
 
29
      private static string toIntroText = null;       // This one is optional
-
 
30
      private static string toPackageGUID = null;
49
      private static EA.Package fromPackage = null;
31
      private static string toFromTableTitle = null;  // This one is optional
-
 
32
      private static string toColumnTitle = null;
-
 
33
      private static ArrayList toElementTypes = null;
-
 
34
      private static bool toPackageRecursion = true;
-
 
35
      private static EA.Package toPackage = null;
50
      private static EA.Package toPackage = null;
36
      private static bool toPackageTrimming = false;
-
 
37
      private static bool toElementNotes = false;
-
 
38
 
51
 
39
      
52
      private static ArrayList processedElements = null;
40
 
53
 
41
      private static string [] options_string = null;
54
      private static string [] options_string = null;
42
 
55
 
43
      private enum DictionaryValueType
56
      private enum DictionaryValueType
44
      {
57
      {
Line 48... Line 61...
48
 
61
 
49
		public static void initialise(ArrayList processedElementsRef)
62
		public static void initialise(ArrayList processedElementsRef)
50
		{
63
		{
51
         processedElements = processedElementsRef;
64
         processedElements = processedElementsRef;
52
 
65
 
53
         fromElementTypes  = new ArrayList();
66
         RM_Matrix.from.elementTypes = new ArrayList();
54
         toElementTypes    = new ArrayList();
67
         RM_Matrix.to.elementTypes = new ArrayList();
55
		}
68
		}
56
 
69
 
57
      private static void reset()
70
      private static void reset()
58
      {
71
      {
59
         style = 1;
72
         RM_Matrix.style = 1;
-
 
73
 
-
 
74
         RM_Matrix.fromToTable.introText = null;
-
 
75
         RM_Matrix.fromToTable.title = null;
-
 
76
 
-
 
77
         RM_Matrix.from.columnTitle = null;
-
 
78
         RM_Matrix.from.packageGUID = null;
-
 
79
         RM_Matrix.from.elementTypes.Clear();
-
 
80
         RM_Matrix.from.packageRecursion = true;
-
 
81
         RM_Matrix.from.packageTrimming = false;
-
 
82
         RM_Matrix.from.elementNotes = false;
-
 
83
         RM_Matrix.from.packageName = null;
60
 
84
 
61
         fromIntroText = null;
-
 
62
         fromPackageGUID = null;
-
 
63
         fromToTableTitle = null;
-
 
64
         fromColumnTitle = null;
-
 
65
         fromElementTypes.Clear();
-
 
66
         fromPackageRecursion = true;
-
 
67
         fromPackageTrimming = false;
-
 
68
         fromPackage = null;
85
         fromPackage = null;
69
         fromElementNotes = false;
-
 
70
         
86
        
71
         toIntroText = null;
87
         RM_Matrix.toFromTable.introText = null;
72
         toPackageGUID = null;
88
         RM_Matrix.toFromTable.title = null;
-
 
89
 
73
         toFromTableTitle = null;
90
         RM_Matrix.to.columnTitle = null;
74
         toColumnTitle = null;
91
         RM_Matrix.to.packageGUID = null;
75
         toElementTypes.Clear();
92
         RM_Matrix.to.elementTypes.Clear();
76
         toPackageRecursion = true;
93
         RM_Matrix.to.packageRecursion = true;
77
         toPackageTrimming = false;
94
         RM_Matrix.to.packageTrimming = false;
-
 
95
         RM_Matrix.to.elementNotes = false;
-
 
96
         RM_Matrix.to.packageName = null;
-
 
97
 
78
         toPackage = null;
98
         toPackage = null;
79
         toElementNotes = false;
-
 
80
      }
99
      }
81
 
100
 
82
 
101
 
83
      public static bool processRelationshipMatrixOptions(EA.Element theElement)
102
      public static bool processRelationshipMatrixOptions(EA.Element theElement)
84
      {
103
      {
-
 
104
         RM_Element = theElement;
-
 
105
 
85
         reset();
106
         reset();
86
 
107
 
87
         // Extract the control options from the notes of the element
108
         // Extract the control options from the notes of the element
88
         
109
         
89
         string delimStr = "\n";
110
         string delimStr = "\n";
Line 101... Line 122...
101
         {
122
         {
102
            if (s.Length > 0 && s != "\n" && s != "\r" && s[0] != '\\')
123
            if (s.Length > 0 && s != "\n" && s != "\r" && s[0] != '\\')
103
            {
124
            {
104
               if (s.StartsWith("style="))
125
               if (s.StartsWith("style="))
105
               {
126
               {
106
                  style = EA_DocGenOptions.getOptionValue(s, style);
127
                  RM_Matrix.style = EA_DocGenOptions.getOptionValue(s, RM_Matrix.style);
107
               }
128
               }
108
                  // FROM items
129
                  // FROM items
109
               else if (s.StartsWith("fromIntroText="))
130
               else if (s.StartsWith("fromIntroText="))
110
               {
131
               {
111
                  fromIntroText = EA_DocGenOptions.getOptionValue(s, null);
132
                  RM_Matrix.fromToTable.introText = EA_DocGenOptions.getOptionValue(s, null);
112
               }
133
               }
113
               else if (s.StartsWith("fromToTableTitle=")) 
134
               else if (s.StartsWith("fromToTableTitle=")) 
114
               {
135
               {
115
                  fromToTableTitle = EA_DocGenOptions.getOptionValue(s, null);
136
                  RM_Matrix.fromToTable.title = EA_DocGenOptions.getOptionValue(s, null);
116
               }
137
               }
117
               else if (s.StartsWith("fromColumnTitle=")) 
138
               else if (s.StartsWith("fromColumnTitle=")) 
118
               {
139
               {
119
                  fromColumnTitle = EA_DocGenOptions.getOptionValue(s, fromColumnTitle);
140
                  RM_Matrix.from.columnTitle = EA_DocGenOptions.getOptionValue(s, RM_Matrix.from.columnTitle);
120
               }
141
               }
121
               else if (s.StartsWith("fromPackageRecursion=")) 
142
               else if (s.StartsWith("fromPackageRecursion=")) 
122
               {
143
               {
123
                  fromPackageRecursion = EA_DocGenOptions.getOptionValue(s, fromPackageRecursion);
144
                  RM_Matrix.from.packageRecursion = EA_DocGenOptions.getOptionValue(s, RM_Matrix.from.packageRecursion);
124
               }
145
               }
125
               else if (s.StartsWith("fromPackageTrimming="))
146
               else if (s.StartsWith("fromPackageTrimming="))
126
               {
147
               {
127
                  fromPackageTrimming = EA_DocGenOptions.getOptionValue(s, fromPackageTrimming);
148
                  RM_Matrix.from.packageTrimming = EA_DocGenOptions.getOptionValue(s, RM_Matrix.from.packageTrimming);
128
               }
149
               }
129
               else if (s.StartsWith("fromPackage=")) 
150
               else if (s.StartsWith("fromPackage=")) 
130
               {
151
               {
131
                  fromPackageGUID = EA_DocGenOptions.getOptionValue(s, fromPackageGUID);
152
                  RM_Matrix.from.packageGUID = EA_DocGenOptions.getOptionValue(s, RM_Matrix.from.packageGUID);
132
               }
153
               }
133
               else if (s.StartsWith("fromElementNotes="))
154
               else if (s.StartsWith("fromElementNotes="))
134
               {
155
               {
135
                  fromElementNotes = EA_DocGenOptions.getOptionValue(s, fromElementNotes);
156
                  RM_Matrix.from.elementNotes = EA_DocGenOptions.getOptionValue(s, RM_Matrix.from.elementNotes);
-
 
157
               }
-
 
158
               else if (s.StartsWith("fromPackageName="))
-
 
159
               {
-
 
160
                  RM_Matrix.from.packageName = EA_DocGenOptions.getOptionValue(s, RM_Matrix.from.packageName);
136
               }
161
               }
137
               else if (s.StartsWith("fromElementType=")) 
162
               else if (s.StartsWith("fromElementType=")) 
138
               {
163
               {
139
                  string et = EA_DocGenOptions.getOptionValue(s,null);
164
                  string et = EA_DocGenOptions.getOptionValue(s,null);
140
                  if (et != null) 
165
                  if (et != null) 
141
                  {
166
                  {
142
                     fromElementTypes.Add( et );
167
                     RM_Matrix.from.elementTypes.Add( et );
143
                  }
168
                  }
144
               }
169
               }
145
 
170
 
146
                  // TO items
171
                  // TO items
147
               else if (s.StartsWith("toIntroText="))
172
               else if (s.StartsWith("toIntroText="))
148
               {
173
               {
149
                  toIntroText = EA_DocGenOptions.getOptionValue(s, null);
174
                  RM_Matrix.toFromTable.introText = EA_DocGenOptions.getOptionValue(s, null);
150
               }
175
               }
151
               else if (s.StartsWith("toFromTableTitle=")) 
176
               else if (s.StartsWith("toFromTableTitle=")) 
152
               {
177
               {
153
                  toFromTableTitle = EA_DocGenOptions.getOptionValue(s, null);
178
                  RM_Matrix.toFromTable.title = EA_DocGenOptions.getOptionValue(s, null);
154
               }
179
               }
155
               else if (s.StartsWith("toColumnTitle=")) 
180
               else if (s.StartsWith("toColumnTitle=")) 
156
               {
181
               {
157
                  toColumnTitle = EA_DocGenOptions.getOptionValue(s, toColumnTitle);
182
                  RM_Matrix.to.columnTitle = EA_DocGenOptions.getOptionValue(s, RM_Matrix.to.columnTitle);
158
               }
183
               }
159
               else if (s.StartsWith("toPackageRecursion=")) 
184
               else if (s.StartsWith("toPackageRecursion=")) 
160
               {
185
               {
161
                  toPackageRecursion = EA_DocGenOptions.getOptionValue(s, toPackageRecursion);
186
                  RM_Matrix.to.packageRecursion = EA_DocGenOptions.getOptionValue(s, RM_Matrix.to.packageRecursion);
162
               }
187
               }
163
               else if (s.StartsWith("toPackageTrimming=")) 
188
               else if (s.StartsWith("toPackageTrimming=")) 
164
               {
189
               {
165
                  toPackageTrimming = EA_DocGenOptions.getOptionValue(s, toPackageTrimming);
190
                  RM_Matrix.to.packageTrimming = EA_DocGenOptions.getOptionValue(s, RM_Matrix.to.packageTrimming);
166
               }               
191
               }               
167
               else if (s.StartsWith("toPackage=")) 
192
               else if (s.StartsWith("toPackage=")) 
168
               {
193
               {
169
                  toPackageGUID = EA_DocGenOptions.getOptionValue(s, toPackageGUID);
194
                  RM_Matrix.to.packageGUID = EA_DocGenOptions.getOptionValue(s, RM_Matrix.to.packageGUID);
170
               }
195
               }
171
               else if (s.StartsWith("toElementNotes="))
196
               else if (s.StartsWith("toElementNotes="))
172
               {
197
               {
173
                  toElementNotes = EA_DocGenOptions.getOptionValue(s, toElementNotes);
198
                  RM_Matrix.to.elementNotes = EA_DocGenOptions.getOptionValue(s, RM_Matrix.to.elementNotes);
174
               }
199
               }
-
 
200
               else if (s.StartsWith("toPackageName="))
-
 
201
               {
-
 
202
                  RM_Matrix.to.packageName = EA_DocGenOptions.getOptionValue(s, RM_Matrix.to.packageName);
-
 
203
               }               
175
               else if (s.StartsWith("toElementType=")) 
204
               else if (s.StartsWith("toElementType=")) 
176
               {
205
               {
177
                  string et = EA_DocGenOptions.getOptionValue(s,null);
206
                  string et = EA_DocGenOptions.getOptionValue(s,null);
178
                  if (et != null) 
207
                  if (et != null) 
179
                  {
208
                  {
180
                     toElementTypes.Add( et );
209
                     RM_Matrix.to.elementTypes.Add( et );
181
                  }
210
                  }
182
               }
211
               }
183
            }
212
            }
184
         }
213
         }
185
 
214
 
186
         // Verify that we have all the necessary compulsory options
215
         // Verify that we have all the necessary compulsory options
187
         if (fromToTableTitle == null && toFromTableTitle == null)
216
         if (RM_Matrix.fromToTable.title == null && RM_Matrix.toFromTable.title == null)
188
         {
217
         {
189
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
218
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
190
               "Missing option: Must specify at least one table title");
219
               "Missing option: Must specify at least one table title");
191
            return false;
220
            return false;
192
         }
221
         }
193
 
222
 
194
         // FROM items
223
         // FROM items
195
         if (fromColumnTitle == null)
224
         if (RM_Matrix.from.columnTitle == null)
196
         {
225
         {
197
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
226
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
198
               "Missing option: fromColumnTitle");
227
               "Missing option: fromColumnTitle");
199
            return false;
228
            return false;
200
         }
229
         }
201
         if (fromPackageGUID == null)
230
         if (RM_Matrix.from.packageGUID == null)
202
         {
231
         {
203
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
232
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
204
               "Missing option: fromPackageGUID");
233
               "Missing option: fromPackageGUID");
205
            return false;
234
            return false;
206
         }
235
         }
207
         if (fromElementTypes.Count == 0)
236
         if (RM_Matrix.from.elementTypes.Count == 0)
208
         {
237
         {
209
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
238
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
210
               "Missing option(s): fromElementTypes");
239
               "Missing option(s): fromElementTypes");
211
            return false;
240
            return false;
212
         }      
241
         }      
213
 
242
 
214
         // TO items
243
         // TO items
215
         if (toColumnTitle == null)
244
         if (RM_Matrix.to.columnTitle == null)
216
         {
245
         {
217
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
246
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
218
               "Missing option: toColumnTitle");
247
               "Missing option: toColumnTitle");
219
            return false;
248
            return false;
220
         }
249
         }
221
         if (toPackageGUID == null)
250
         if (RM_Matrix.to.packageGUID == null)
222
         {
251
         {
223
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
252
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
224
               "Missing option: toPackageGUID");
253
               "Missing option: toPackageGUID");
225
            return false;
254
            return false;
226
         }
255
         }
227
         if (toElementTypes.Count == 0)
256
         if (RM_Matrix.to.elementTypes.Count == 0)
228
         {
257
         {
229
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
258
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
230
               "Missing option(s): toElementTypes");
259
               "Missing option(s): toElementTypes");
231
            return false;
260
            return false;
232
         }   
261
         }   
233
 
262
 
234
         // Find GUID linked packages in the repository
263
         // Find GUID linked packages in the repository
235
         fromPackage = Main.EA_Repository.GetPackageByGuid( fromPackageGUID );
264
         fromPackage = Main.EA_Repository.GetPackageByGuid( RM_Matrix.from.packageGUID );
236
         if (fromPackage == null)
265
         if (fromPackage == null)
237
         {
266
         {
238
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
267
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
239
               "could not locate fromPackage in Repository");
268
               "could not locate fromPackage in Repository");
240
            return false;
269
            return false;
241
         }
270
         }
242
 
271
 
243
         toPackage = Main.EA_Repository.GetPackageByGuid( toPackageGUID );
272
         toPackage = Main.EA_Repository.GetPackageByGuid( RM_Matrix.to.packageGUID );
244
         if (toPackage == null)
273
         if (toPackage == null)
245
         {
274
         {
246
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
275
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
247
               "could not locate toPackage in Repository");
276
               "could not locate toPackage in Repository");
248
            return false;
277
            return false;
Line 296... Line 325...
296
            default:
325
            default:
297
               return "";
326
               return "";
298
         }
327
         }
299
      }
328
      }
300
 
329
 
-
 
330
 
301
      /// <summary>
331
      /// <summary>
302
      /// This function will insert one or more relationship matrix tables into the document, 
332
      /// This function will insert one or more relationship matrix tables into the document, 
303
      /// built from content specified in options that are provided in the notes section of 
333
      /// built from content specified in options that are provided in the notes section of 
304
      /// the special element that has led to this function being called.
334
      /// the special element that has led to this function being called.
305
      /// </summary>
335
      /// </summary>
306
      /// <param name="theElement"></param>
336
      /// <param name="theElement"></param>
307
      /// <param name="recurse_level"></param>
337
      /// <param name="recurse_level"></param>
308
      public static void processRelationshipMatrixElement( EA.Element theElement, int recurse_level )
338
      public static void processRelationshipMatrixElement( EA.Element theElement, int recurse_level )
309
      {
339
      {
-
 
340
         RM_Element = theElement;
-
 
341
 
-
 
342
         if (RM_Matrix.from.packageName != null && fromPackage != null)
-
 
343
         {
-
 
344
            EA.Package newFromPackage = EA_Utilities.findNamedPackage(fromPackage, RM_Matrix.from.packageName);
-
 
345
            if (newFromPackage != null)
-
 
346
            {
-
 
347
               fromPackage = newFromPackage;
-
 
348
            }
-
 
349
            else
-
 
350
            {
-
 
351
               MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
-
 
352
                  "could not locate fromPackageName in Repository");
-
 
353
               return;
-
 
354
            }
-
 
355
         }
-
 
356
 
-
 
357
         if (RM_Matrix.to.packageName != null && toPackage != null)
-
 
358
         {
-
 
359
            EA.Package newToPackage = EA_Utilities.findNamedPackage(toPackage, RM_Matrix.to.packageName);
-
 
360
            if (newToPackage != null)
-
 
361
            {
-
 
362
               toPackage = newToPackage;
-
 
363
            }
-
 
364
            else
-
 
365
            {
-
 
366
               MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
-
 
367
                  "could not locate toPackageName in Repository");
-
 
368
               return;
-
 
369
            }
-
 
370
         }
-
 
371
 
310
         switch (style)
372
         switch (RM_Matrix.style)
311
         {
373
         {
312
            case 1:
374
            case 1:
313
               processRelationshipMatrixElementStyle1();
375
               processRelationshipMatrixElementStyle1();
314
               break;
376
               break;
315
 
377
 
Line 317... Line 379...
317
               processRelationshipMatrixElementStyle2();
379
               processRelationshipMatrixElementStyle2();
318
               break;
380
               break;
319
         }
381
         }
320
      }
382
      }
321
 
383
 
-
 
384
 
322
      /// <summary>
385
      /// <summary>
323
      /// This function will insert a relationship matrix table into the document, built from content
386
      /// This function will insert a relationship matrix table into the document, built from content
324
      /// specified in options that are provided in the notes section of the special element that
387
      /// specified in options that are provided in the notes section of the special element that
325
      /// has led to this function being called.
388
      /// has led to this function being called.
326
      /// 
389
      /// 
Line 331... Line 394...
331
      {
394
      {
332
         int tableNum = 0;
395
         int tableNum = 0;
333
         Word.Table table = null;
396
         Word.Table table = null;
334
 
397
 
335
         // Scan the fromPackage to find all the "from elements".
398
         // Scan the fromPackage to find all the "from elements".
336
         ElementAccumulator fromLister = new ElementAccumulator(fromElementTypes);
399
         ElementAccumulator fromLister = new ElementAccumulator(RM_Matrix.from.elementTypes);
337
         EA_Utilities.findAndProcessPackageElements( fromPackage, fromLister, fromPackageRecursion );
400
         EA_Utilities.findAndProcessPackageElements( fromPackage, fromLister, RM_Matrix.from.packageRecursion );
338
 
401
 
339
         if (createWordDoc.abortCreationThread)
402
         if (createWordDoc.abortCreationThread)
340
            return;
403
            return;
341
 
404
 
342
         // Scan the toPackage to find all the "to elements".
405
         // Scan the toPackage to find all the "to elements".
343
         ElementAccumulator toLister = new ElementAccumulator(toElementTypes);
406
         ElementAccumulator toLister = new ElementAccumulator(RM_Matrix.to.elementTypes);
344
         EA_Utilities.findAndProcessPackageElements( toPackage, toLister, toPackageRecursion );
407
         EA_Utilities.findAndProcessPackageElements( toPackage, toLister, RM_Matrix.to.packageRecursion );
345
 
408
 
346
         if (createWordDoc.abortCreationThread)
409
         if (createWordDoc.abortCreationThread)
347
            return;
410
            return;
348
 
411
 
349
         // Sort the "from elements"
412
         // Sort the "from elements"
Line 361... Line 424...
361
 
424
 
362
         // dictionary to support to-from table construction.
425
         // dictionary to support to-from table construction.
363
         ArrayList toFromDictionary = new ArrayList();
426
         ArrayList toFromDictionary = new ArrayList();
364
         
427
         
365
         bool needFromToTable = false;
428
         bool needFromToTable = false;
366
         if (fromToTableTitle != null && fromToTableTitle.Length > 0)
429
         if (RM_Matrix.fromToTable.title != null && RM_Matrix.fromToTable.title.Length > 0)
367
            needFromToTable = true;
430
            needFromToTable = true;
368
 
431
 
369
         bool needToFromTable = false;
432
         bool needToFromTable = false;
370
         if (toFromTableTitle != null && toFromTableTitle.Length > 0)
433
         if (RM_Matrix.toFromTable.title != null && RM_Matrix.toFromTable.title.Length > 0)
371
            needToFromTable = true;
434
            needToFromTable = true;
372
 
435
 
373
         // NOTE: this code has to execute even if no from-to table is needed, in order to support the
436
         // NOTE: this code has to execute even if no from-to table is needed, in order to support the
374
         // generation of a to-from table, assuming the user has requested one.
437
         // generation of a to-from table, assuming the user has requested one.
375
         int numberOfFromToRows = 0;
438
         int numberOfFromToRows = 0;
Line 397... Line 460...
397
               // ignore self-referential connections
460
               // ignore self-referential connections
398
               if (fromElement.ElementID == thisCon.SupplierID)
461
               if (fromElement.ElementID == thisCon.SupplierID)
399
                  continue;
462
                  continue;
400
 
463
 
401
               // if the destination element is of a type that the user has requested to include...
464
               // if the destination element is of a type that the user has requested to include...
402
               if (!toElementTypes.Contains( destE.Type ))
465
               if (!RM_Matrix.to.elementTypes.Contains( destE.Type ))
403
                  continue;
466
                  continue;
404
 
467
 
405
               // if the destination element is in the "to list"...
468
               // if the destination element is in the "to list"...
406
               if ( !toLister.ElementIds.Contains(destE.ElementID) )
469
               if ( !toLister.ElementIds.Contains(destE.ElementID) )
407
                  continue;
470
                  continue;
Line 429... Line 492...
429
            {
492
            {
430
               numberOfFromToRows++;
493
               numberOfFromToRows++;
431
            }
494
            }
432
               // If we did not find a from-to relationship that table still needs a new row 
495
               // If we did not find a from-to relationship that table still needs a new row 
433
               // if the user wants all "from elements", even if some have no "to elements".
496
               // if the user wants all "from elements", even if some have no "to elements".
434
            else if (fromPackageTrimming == false)
497
            else if (RM_Matrix.from.packageTrimming == false)
435
            {
498
            {
436
               DictionaryEntry newFromToEntry = new DictionaryEntry(fromElement, null);
499
               DictionaryEntry newFromToEntry = new DictionaryEntry(fromElement, null);
437
               fromToDictionary.Add( newFromToEntry );
500
               fromToDictionary.Add( newFromToEntry );
438
               numberOfFromToRows++;
501
               numberOfFromToRows++;
439
            }
502
            }
Line 444... Line 507...
444
 
507
 
445
         if (needFromToTable)
508
         if (needFromToTable)
446
         {
509
         {
447
            // Now we can actually serialise the table
510
            // Now we can actually serialise the table
448
 
511
 
449
            if (fromIntroText != null && fromIntroText.Length > 0)
512
            if (RM_Matrix.fromToTable.introText != null && RM_Matrix.fromToTable.introText.Length > 0)
450
            {
513
            {
451
               TextualContent.appendAndSelectText( fromIntroText, EA_Constants.styleName_Body1 );
514
               Word.Range wr = TextualContent.appendAndSelectText( RM_Matrix.fromToTable.introText, EA_Constants.styleName_Body1 );
-
 
515
               object obj = string.Format("EA_DocGen Informational Comment - This table has been produced using the following options:\n\n{0}", RM_Element.Notes);
-
 
516
               createWordDoc.WordDocument.Comments.Add(wr, ref obj);
452
            }
517
            }
453
 
518
 
454
            // create the from-to table in the word doc
519
            // create the from-to table in the word doc
455
            tableNum = TabularContent.Table_Create( fromToTableTitle, true, numberOfFromToRows + 1, 2 );
520
            tableNum = TabularContent.Table_Create( RM_Matrix.fromToTable.title, true, numberOfFromToRows + 1, 2 );
456
            table = createWordDoc.WordDocument.Tables[tableNum];
521
            table = createWordDoc.WordDocument.Tables[tableNum];
457
            
522
            
458
            TabularContent.Table_SetTableColumnTitle(table, fromColumnTitle, 1);
523
            TabularContent.Table_SetTableColumnTitle(table, RM_Matrix.from.columnTitle, 1);
459
            TabularContent.Table_SetTableColumnTitle(table, toColumnTitle, 2);
524
            TabularContent.Table_SetTableColumnTitle(table, RM_Matrix.to.columnTitle, 2);
460
 
525
 
461
            fillInTable(fromToDictionary, table, DictionaryValueType.DVT_EA_ELEMENT);
526
            fillInTable(fromToDictionary, table, DictionaryValueType.DVT_EA_ELEMENT);
462
         }
527
         }
463
 
528
 
464
         if (createWordDoc.abortCreationThread)
529
         if (createWordDoc.abortCreationThread)
Line 466... Line 531...
466
 
531
 
467
         // Does user want a to-from table ?
532
         // Does user want a to-from table ?
468
         if (needToFromTable)
533
         if (needToFromTable)
469
         {
534
         {
470
            // update fromElementNotes with toElementNotes setting
535
            // update fromElementNotes with toElementNotes setting
471
            fromElementNotes = toElementNotes;
536
            RM_Matrix.from.elementNotes = RM_Matrix.to.elementNotes;
472
 
537
 
473
            // re-use the fromToDictionary to prepare the to-from table content 
538
            // re-use the fromToDictionary to prepare the to-from table content 
474
            fromToDictionary.Clear();
539
            fromToDictionary.Clear();
475
 
540
 
476
            // We've already found all elements for the left hand column of the to-from table.
541
            // We've already found all elements for the left hand column of the to-from table.
Line 512... Line 577...
512
               {
577
               {
513
                  numberOfFromToRows++;
578
                  numberOfFromToRows++;
514
               }
579
               }
515
                  // if user wants all "from elements", even if some have no "to elements", then add a dictionary
580
                  // if user wants all "from elements", even if some have no "to elements", then add a dictionary
516
                  // entry and bump row count.
581
                  // entry and bump row count.
517
               else if (toPackageTrimming == false)
582
               else if (RM_Matrix.to.packageTrimming == false)
518
               {
583
               {
519
                  DictionaryEntry newFromToEntry = new DictionaryEntry(toElement, "");
584
                  DictionaryEntry newFromToEntry = new DictionaryEntry(toElement, "");
520
                  fromToDictionary.Add( newFromToEntry );
585
                  fromToDictionary.Add( newFromToEntry );
521
                  numberOfFromToRows++;
586
                  numberOfFromToRows++;
522
               }
587
               }
Line 524... Line 589...
524
 
589
 
525
            if (createWordDoc.abortCreationThread)
590
            if (createWordDoc.abortCreationThread)
526
               return;
591
               return;
527
 
592
 
528
            // Now begin to add the to-from table to the word document
593
            // Now begin to add the to-from table to the word document
529
            if (toIntroText != null && toIntroText.Length > 0)
594
            if (RM_Matrix.toFromTable.introText != null && RM_Matrix.toFromTable.introText.Length > 0)
530
            {
595
            {
531
               TextualContent.appendAndSelectText( toIntroText, EA_Constants.styleName_Body1 );
596
               Word.Range wr = TextualContent.appendAndSelectText( RM_Matrix.toFromTable.introText, EA_Constants.styleName_Body1 );
-
 
597
 
-
 
598
               // add options comment only if user did not generate a from-to table, since there is no point in repeating
-
 
599
               // the options comment which applies to both from-to and to-from table pair.
-
 
600
               if (!needFromToTable)
-
 
601
               {
-
 
602
                  object obj = string.Format("EA_DocGen Informational Comment - This table has been produced using the following options:\n\n{0}", RM_Element.Notes);
-
 
603
                  createWordDoc.WordDocument.Comments.Add(wr, ref obj);
-
 
604
               }
532
            }
605
            }
533
 
606
 
534
            // create the table in the word doc
607
            // create the table in the word doc
535
            tableNum = TabularContent.Table_Create( toFromTableTitle, true, numberOfFromToRows + 1, 2 );
608
            tableNum = TabularContent.Table_Create( RM_Matrix.toFromTable.title, true, numberOfFromToRows + 1, 2 );
536
            table = createWordDoc.WordDocument.Tables[tableNum];
609
            table = createWordDoc.WordDocument.Tables[tableNum];
537
            
610
            
538
            TabularContent.Table_SetTableColumnTitle(table, toColumnTitle, 1);
611
            TabularContent.Table_SetTableColumnTitle(table, RM_Matrix.to.columnTitle, 1);
539
            TabularContent.Table_SetTableColumnTitle(table, fromColumnTitle, 2);
612
            TabularContent.Table_SetTableColumnTitle(table, RM_Matrix.from.columnTitle, 2);
540
 
613
 
541
            fillInTable(fromToDictionary, table, DictionaryValueType.DVT_STRING);
614
            fillInTable(fromToDictionary, table, DictionaryValueType.DVT_STRING);
542
         }
615
         }
543
      }
616
      }
544
 
617
 
-
 
618
 
545
      private static void fillInTable(ArrayList fromToDictionary, Word.Table table, DictionaryValueType valueType )
619
      private static void fillInTable(ArrayList fromToDictionary, Word.Table table, DictionaryValueType valueType )
546
      {
620
      {
547
         int lastFromElementId = -1;
621
         int lastFromElementId = -1;
548
         bool firstCellContent = true;
622
         bool firstCellContent = true;
549
         int row = 1;
623
         int row = 1;
Line 557... Line 631...
557
               lastFromElementId = ((EA.Element)de.Key).ElementID;
631
               lastFromElementId = ((EA.Element)de.Key).ElementID;
558
               row++;
632
               row++;
559
               table.Cell(row,1).Range.Text = ((EA.Element)de.Key).Name;
633
               table.Cell(row,1).Range.Text = ((EA.Element)de.Key).Name;
560
               firstCellContent = true;
634
               firstCellContent = true;
561
 
635
 
562
               if (fromElementNotes && ((EA.Element)de.Key).Notes != null && ((EA.Element)de.Key).Notes.Length > 0)
636
               if (RM_Matrix.from.elementNotes)
563
               {
637
               {
-
 
638
                  if (((EA.Element)de.Key).Notes != null && ((EA.Element)de.Key).Notes.Length > 0)
-
 
639
                  {
564
                  table.Cell(row,1).Range.Text += ((EA.Element)de.Key).Notes;
640
                     table.Cell(row,1).Range.Text += ((EA.Element)de.Key).Notes;
-
 
641
                  }
-
 
642
                  // Because we are including both the short description and the notes of the requirement
-
 
643
                  // in the cell, we need to discriminate them. We do this by bolding the short description,
-
 
644
                  // and reducing the font size of the notes to 8.
-
 
645
                  Word.Range wr = table.Cell(row,1).Range;
-
 
646
                  wr.Sentences[1].Font.Bold = 1;
-
 
647
                  for(int i=2; i<=wr.Sentences.Count; i++)
-
 
648
                     wr.Sentences[i].Font.Size = 8;
565
               }
649
               }
566
            }
650
            }
-
 
651
 
567
            if ((valueType == DictionaryValueType.DVT_EA_ELEMENT) && (((EA.Element)de.Value) != null))
652
            if ((valueType == DictionaryValueType.DVT_EA_ELEMENT) && (((EA.Element)de.Value) != null))
568
            {
653
            {
569
               if (firstCellContent)
654
               if (firstCellContent)
570
               {
655
               {
571
                  firstCellContent = false;
656
                  firstCellContent = false;
Line 597... Line 682...
597
               }
682
               }
598
            }
683
            }
599
         }
684
         }
600
      }
685
      }
601
 
686
 
-
 
687
 
602
      /// <summary>
688
      /// <summary>
603
      /// This function will insert a relationship matrix table into the document, built from content
689
      /// This function will insert a relationship matrix table into the document, built from content
604
      /// specified in options that are provided in the notes section of the special element that
690
      /// specified in options that are provided in the notes section of the special element that
605
      /// has led to this function being called.
691
      /// has led to this function being called.
606
      /// 
692
      /// 
Line 615... Line 701...
615
         int i;
701
         int i;
616
         int tableNum = 0;
702
         int tableNum = 0;
617
         Word.Table table = null;
703
         Word.Table table = null;
618
 
704
 
619
         // Scan the fromPackage to find all the "from elements".
705
         // Scan the fromPackage to find all the "from elements".
620
         ElementAccumulator fromLister = new ElementAccumulator(fromElementTypes);
706
         ElementAccumulator fromLister = new ElementAccumulator(RM_Matrix.from.elementTypes);
621
         EA_Utilities.findAndProcessPackageElements( fromPackage, fromLister, fromPackageRecursion );
707
         EA_Utilities.findAndProcessPackageElements( fromPackage, fromLister, RM_Matrix.from.packageRecursion );
622
 
708
 
623
         if (createWordDoc.abortCreationThread)
709
         if (createWordDoc.abortCreationThread)
624
            return;
710
            return;
625
 
711
 
626
         // Remove all elements from the list that did not go to form content in the document
712
         // Remove all elements from the list that did not go to form content in the document
Line 648... Line 734...
648
         if (createWordDoc.abortCreationThread)
734
         if (createWordDoc.abortCreationThread)
649
            return;
735
            return;
650
 
736
 
651
         // Scan the toPackage to find all the "to elements".
737
         // Scan the toPackage to find all the "to elements".
652
         // Extract their element IDs into a new list.
738
         // Extract their element IDs into a new list.
653
         ElementAccumulator toLister = new ElementAccumulator(toElementTypes);
739
         ElementAccumulator toLister = new ElementAccumulator(RM_Matrix.to.elementTypes);
654
         EA_Utilities.findAndProcessPackageElements( toPackage, toLister, toPackageRecursion );
740
         EA_Utilities.findAndProcessPackageElements( toPackage, toLister, RM_Matrix.to.packageRecursion );
655
         ArrayList acceptableParents = new ArrayList();
741
         ArrayList acceptableParents = new ArrayList();
656
         foreach(EA.Element ele in toLister.Elements)
742
         foreach(EA.Element ele in toLister.Elements)
657
         {
743
         {
658
            if (createWordDoc.abortCreationThread)
744
            if (createWordDoc.abortCreationThread)
659
               return;
745
               return;
Line 665... Line 751...
665
            return;
751
            return;
666
 
752
 
667
         // The list of from elements dictates the number of rows in our table.
753
         // The list of from elements dictates the number of rows in our table.
668
         int numberOfFromToRows = fromLister.Elements.Count;
754
         int numberOfFromToRows = fromLister.Elements.Count;
669
         
755
         
670
         if (fromIntroText != null && fromIntroText.Length > 0)
756
         if (RM_Matrix.fromToTable.introText != null && RM_Matrix.fromToTable.introText.Length > 0)
671
         {
757
         {
672
            TextualContent.appendAndSelectText( fromIntroText, EA_Constants.styleName_Body1 );
758
            Word.Range wr = TextualContent.appendAndSelectText( RM_Matrix.fromToTable.introText, EA_Constants.styleName_Body1 );
-
 
759
            object obj = string.Format("EA_DocGen Informational Comment - This table has been produced using the following options:\n\n{0}", RM_Element.Notes);
-
 
760
            createWordDoc.WordDocument.Comments.Add(wr, ref obj);
673
         }
761
         }
674
 
762
 
675
         // create the from-to table in the word doc
763
         // create the from-to table in the word doc
676
         tableNum = TabularContent.Table_Create( fromToTableTitle, true, numberOfFromToRows + 1, 2 );
764
         tableNum = TabularContent.Table_Create( RM_Matrix.fromToTable.title, true, numberOfFromToRows + 1, 2 );
677
         table = createWordDoc.WordDocument.Tables[tableNum];
765
         table = createWordDoc.WordDocument.Tables[tableNum];
678
            
766
            
679
         TabularContent.Table_SetTableColumnTitle(table, fromColumnTitle, 1);
767
         TabularContent.Table_SetTableColumnTitle(table, RM_Matrix.from.columnTitle, 1);
680
         TabularContent.Table_SetTableColumnTitle(table, toColumnTitle, 2);
768
         TabularContent.Table_SetTableColumnTitle(table, RM_Matrix.to.columnTitle, 2);
681
 
769
 
682
         int row = 2;
770
         int row = 2;
683
         foreach(EA.Element ele in fromLister.Elements)
771
         foreach(EA.Element ele in fromLister.Elements)
684
         {
772
         {
685
            if (createWordDoc.abortCreationThread)
773
            if (createWordDoc.abortCreationThread)
686
               return;
774
               return;
687
 
775
 
688
            table.Cell(row,1).Range.Text = ele.Name;
776
            table.Cell(row,1).Range.Text = ele.Name;
689
 
777
 
690
            if (fromElementNotes && ele.Notes != null && ele.Notes.Length > 0)
778
            if (RM_Matrix.from.elementNotes && ele.Notes != null && ele.Notes.Length > 0)
691
            {
779
            {
692
               table.Cell(row,1).Range.Text += ele.Notes;
780
               table.Cell(row,1).Range.Text += ele.Notes;
693
            }
781
            }
694
 
782
 
695
            StringBuilder sb = new StringBuilder();
783
            StringBuilder sb = new StringBuilder();
Line 698... Line 786...
698
 
786
 
699
            // Find this requirement's parent (source) requirements
787
            // Find this requirement's parent (source) requirements
700
            elementParenthood(ele, ref acceptableParents, ref parentsDiscovered, ref sb);
788
            elementParenthood(ele, ref acceptableParents, ref parentsDiscovered, ref sb);
701
 
789
 
702
            // if no source requirements found and user has opted for trimming, delete the table row
790
            // if no source requirements found and user has opted for trimming, delete the table row
703
            if (fromPackageTrimming == true && sb.Length == 0)
791
            if (RM_Matrix.from.packageTrimming == true && sb.Length == 0)
704
            {
792
            {
705
               TabularContent.Table_DeleteThisRow(table, row);
793
               TabularContent.Table_DeleteThisRow(table, row);
706
               continue;
794
               continue;
707
            }
795
            }
708
            
796
            
Line 711... Line 799...
711
            row++;
799
            row++;
712
         }
800
         }
713
 
801
 
714
      }
802
      }
715
 
803
 
-
 
804
 
716
      private static void elementParenthood(EA.Element ele, ref ArrayList acceptableParents, ref ArrayList parentsDiscovered, ref StringBuilder sb)
805
      private static void elementParenthood(EA.Element ele, ref ArrayList acceptableParents, ref ArrayList parentsDiscovered, ref StringBuilder sb)
717
      {
806
      {
718
         foreach(EA.Connector con in ele.Connectors)
807
         foreach(EA.Connector con in ele.Connectors)
719
         {
808
         {
720
            if (createWordDoc.abortCreationThread)
809
            if (createWordDoc.abortCreationThread)