Subversion Repositories DevTools

Rev

Rev 2124 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2088 ghuddy 1
using System;
2
using System.Windows.Forms;
3
using System.IO;
4
using System.Collections;
2094 ghuddy 5
using System.Collections.Specialized;
6
using System.Text;
2088 ghuddy 7
 
8
namespace EA_DocGen
9
{
10
   /// <summary>
11
   /// Summary description for EA_DocGenOptions.
12
   /// </summary>
13
   public class EA_DocGenOptions
14
   {
2106 ghuddy 15
      // Strings used in the notes section of an EA_DocGen element that persists the options.
16
      public static string optstr_GeneralOptions = "[GeneralOptions]";
17
      public static string optstr_ElementTypes   = "[ElementTypes]";
2094 ghuddy 18
 
2106 ghuddy 19
      private static string [] options_string = null;
20
      private static bool options_found = false;
2088 ghuddy 21
 
2116 ghuddy 22
      // Boolean options
23
      public enum boolean_options_e
24
      {
25
         SUPPRESS_PRIVATE_CLASSES = 0,
26
         SUPPRESS_PRIVATE_ATTRIBUTES,
27
         SUPPRESS_PRIVATE_METHODS,
28
         SUPPRESS_METHOD_CHARACTERISTICS,
29
         SUPPRESS_CLASS_CHARACTERISTICS,
30
         SUPPRESS_CLASS_REQUIREMENTS,
31
         SUPPRESS_CLASS_CONSTRAINTS,
32
         SUPPRESS_CLASS_BASE_CLASSES,
33
         SUPPRESS_CLASS_REALISES,
34
         SUPPRESS_ATTRIBUTE_CHARACTERISTICS,
35
         SUPPRESS_ELEMENT_DESC_MISSING_WARNINGS,
36
         SUPPRESS_UN_ALLOCATED_RELATIONSHIP_WARNINGS,
37
         CONSIDER_API_ELEMENTS_ONLY,
38
         CONSIDER_API_DIAGRAMS_ONLY,
39
         CONSIDER_API_PACKAGES_ONLY,
40
         RESTRICT_FOR_LINKED_PACKAGES_ONLY,
41
         USE_NUM_PARA_FOR_GENERATED_TEST_CASES,
2124 ghuddy 42
         SUPPRESS_REQUIREMENT_NOTES,
2132 ghuddy 43
         FORCE_HEADING_TABS_TO_2_5_CM,
2088 ghuddy 44
 
2116 ghuddy 45
         UNKNOWN = -1
46
      };
2094 ghuddy 47
 
2116 ghuddy 48
      // local class to collect together stuff for a discrete boolean option
49
      private class boolopt
50
      {
51
         public boolean_options_e enumVal;
52
         public int level;
53
         public string optstr;
54
         public string displayName;
55
         public bool value;
56
         public boolopt(int l, boolean_options_e e, string o, string dn, bool v)
57
         {
58
            enumVal = e;
59
            level = l;
60
            optstr = o;
61
            displayName = dn;
62
            value = v;
63
         }
64
      };
2088 ghuddy 65
 
2116 ghuddy 66
      // A collection of boolean options
67
      public static ArrayList boolopts;
68
      private static int i_boolopts;
69
 
2094 ghuddy 70
 
2088 ghuddy 71
      // Element Types list
2106 ghuddy 72
      public static ArrayList opt_ElementTypes = null;
2088 ghuddy 73
 
2116 ghuddy 74
 
2106 ghuddy 75
      public static void initialise()
2088 ghuddy 76
      {
2116 ghuddy 77
         // Create discrete boolean options collection. The ordering of these statements dictates the display order in
78
         // the options form.
79
         //
80
         // WARNING: level number can be 1 or 2, but no higher.
81
         //
82
         // BIG WARNING
83
         // Make sure that if any option string is a substring of another option string, then the longest of the
84
         // two must appear first in this initialisation sequence
85
 
86
         boolopts = new ArrayList();
2124 ghuddy 87
         boolopts.Add(new boolopt(1, boolean_options_e.CONSIDER_API_ELEMENTS_ONLY,         
88
                                  "ConsiderAPIClassesOnly", 
89
                                  "Consider API Stereotyped Elements Only", 
90
                                  false) );
2116 ghuddy 91
 
2124 ghuddy 92
         boolopts.Add(new boolopt(1, boolean_options_e.CONSIDER_API_DIAGRAMS_ONLY,         
93
                                  "ConsiderAPIDiagramsOnly",                    
94
                                  "Consider API Stereotyped Diagrams Only", 
95
                                  false) );
2116 ghuddy 96
 
2124 ghuddy 97
         boolopts.Add(new boolopt(1, boolean_options_e.CONSIDER_API_PACKAGES_ONLY,         
98
                                  "ConsiderAPIPackagesOnly",                    
99
                                  "Consider API Stereotyped Packages Only", 
100
                                  false) );
2116 ghuddy 101
 
2124 ghuddy 102
         boolopts.Add(new boolopt(2, boolean_options_e.RESTRICT_FOR_LINKED_PACKAGES_ONLY,  
103
                                  "APIPackageRestrictionForLinkedPackagesOnly", 
104
                                  "Restriction Applies Only To Linked Packages", 
105
                                  true) );
2116 ghuddy 106
 
2124 ghuddy 107
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_ATTRIBUTE_CHARACTERISTICS, 
108
                                  "SuppressAttributeCharacteristics", 
109
                                  "Suppress Attribute Characteristics", 
110
                                  false) );
2116 ghuddy 111
 
2124 ghuddy 112
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_CLASS_BASE_CLASSES,        
113
                                  "SuppressClassBaseClasses",     
114
                                  "Suppress Class Base Class List", 
115
                                  false) );
2116 ghuddy 116
 
2124 ghuddy 117
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_CLASS_CHARACTERISTICS,     
118
                                  "SuppressClassCharacteristics", 
119
                                  "Suppress Class Characteristics", 
120
                                  false) );
121
 
122
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_CLASS_CONSTRAINTS,         
123
                                  "SuppressClassConstraints",     
124
                                  "Suppress Class Constraints", 
125
                                  false) );
126
 
127
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_CLASS_REALISES,            
128
                                  "SuppressClassRealises",        
129
                                  "Suppress Class Realisation List", 
130
                                  false) );
131
 
132
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_CLASS_REQUIREMENTS,        
133
                                  "SuppressClassRequirements",    
134
                                  "Suppress Class Requirements", 
135
                                  false) );
136
 
137
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_ELEMENT_DESC_MISSING_WARNINGS,      
138
                                  "SuppressElementDescriptionMissingWarnings", 
139
                                  "Suppress Element Description Missing Warnings", 
140
                                  false) );
141
 
142
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_METHOD_CHARACTERISTICS,    
143
                                  "SuppressMethodCharacteristics",    
144
                                  "Suppress Method Characteristics", 
145
                                  false) );
146
 
147
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_PRIVATE_ATTRIBUTES,        
148
                                  "SuppressPrivateAttributes",        
149
                                  "Suppress Private Attributes", 
150
                                  false) );
151
 
152
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_PRIVATE_CLASSES,           
153
                                  "SuppressPrivateClasses",           
154
                                  "Suppress Private Classes", 
155
                                  false) );
156
 
157
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_PRIVATE_METHODS,           
158
                                  "SuppressPrivateMethods",           
159
                                  "Suppress Private Methods", 
160
                                  false) );
161
 
162
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_UN_ALLOCATED_RELATIONSHIP_WARNINGS, 
163
                                  "SuppressUnAllocatedRelationshipWarnings",   
164
                                  "Suppress Un-Allocated Relationship Warnings", 
165
                                  false) );
166
 
167
         boolopts.Add(new boolopt(1, boolean_options_e.SUPPRESS_REQUIREMENT_NOTES,                  
168
                                  "SuppressRequirementNotes", 
169
                                  "Suppress Use Of Requirement Element Notes", 
170
                                  true) );
171
 
172
         boolopts.Add(new boolopt(1, boolean_options_e.USE_NUM_PARA_FOR_GENERATED_TEST_CASES,       
173
                                  "UseNumParaForGeneratedTestCases", 
174
                                  "Use NumPara Styles For Generated Test Case Sections", 
175
                                  true) );
176
 
2132 ghuddy 177
         boolopts.Add(new boolopt(1, boolean_options_e.FORCE_HEADING_TABS_TO_2_5_CM,
178
                                  "ForceHeadingTabsTo2_5cm",
179
                                  "Force Heading Style Tabs To 2.5cm",
180
                                  false) );
2124 ghuddy 181
 
2116 ghuddy 182
         // Create element types list
2108 ghuddy 183
         if (opt_ElementTypes == null)
184
            opt_ElementTypes = new ArrayList();
185
         opt_ElementTypes.Clear();
2088 ghuddy 186
         setDefaults();
187
      }
188
 
2116 ghuddy 189
 
190
      /// <summary>
191
      /// Function to return to another class the value of a specified discrete boolean option
192
      /// </summary>
193
      /// <param name="e"></param>
194
      /// <returns></returns>
195
      public static bool optionValue(boolean_options_e e)
196
      {
197
         foreach (boolopt bo in boolopts)
198
         {
199
            if (bo.enumVal == e)
200
            {
201
               return bo.value;
202
            }
203
         }
204
         return false;
205
      }
206
 
207
      /// <summary>
208
      /// Function to allow another class to set the value of a discrete boolean option.
209
      /// Normally, this will only be done from the editing form class.
210
      /// </summary>
211
      /// <param name="e"></param>
212
      /// <param name="value"></param>
213
      public static void optionValue(boolean_options_e e, bool value)
214
      {
215
         foreach (boolopt bo in boolopts)
216
         {
217
            if (bo.enumVal == e)
218
            {
219
               bo.value = value;
220
               break;
221
            }
222
         }
223
      }
224
 
225
      /// <summary>
226
      /// Function to return the option string to use for a specified
227
      /// discrete boolean option. Option strings are used in the actual EA element to record
228
      /// the state of the option. They are (or may be) similar to the display names for the options
229
      /// but without any spaces, and they may be shortened somewhat too.
230
      /// </summary>
231
      /// <param name="e"></param>
232
      /// <returns></returns>
233
      private static string optionString(boolean_options_e e)
234
      {
235
         foreach (boolopt bo in boolopts)
236
         {
237
            if (bo.enumVal == e)
238
            {
239
               return bo.optstr;
240
            }
241
         }
242
         return null;
243
      }
244
 
245
      /// <summary>
246
      /// Helper for getFirstBooleanOption() and getNextBooleanOption()
247
      /// </summary>
248
      /// <param name="index"></param>
249
      /// <param name="e"></param>
250
      /// <param name="level"></param>
251
      /// <param name="displayName"></param>
252
      /// <param name="value"></param>
253
      private static void getBooleanOption(int index, out boolean_options_e e, out int level, out string displayName, out bool value)
254
      {
255
         boolopt o = (boolopt)boolopts[index];
256
         e = o.enumVal;
257
         level = o.level;
258
         displayName = o.displayName;
259
         value = o.value;
260
      }
261
 
262
      /// <summary>
263
      /// Function to return the details of the first discrete boolean option.
264
      /// This will be used by the option editing form class to populate a list for user editing.
265
      /// </summary>
266
      /// <param name="e"></param>
267
      /// <param name="level"></param>
268
      /// <param name="displayName"></param>
269
      /// <param name="value"></param>
270
      /// <returns></returns>
271
      public static bool getFirstBooleanOption(out boolean_options_e e, out int level, out string displayName, out bool value)
272
      {
273
         i_boolopts = 0;
274
 
275
         e = boolean_options_e.UNKNOWN;
276
         level = 1;
277
         displayName = "";
278
         value = false;
279
 
280
         if (i_boolopts < boolopts.Count)
281
         {
282
            getBooleanOption(i_boolopts, out e, out level, out displayName, out value);
283
            return true;
284
         }
285
         else
286
         {
287
            return false;
288
         }
289
      }
290
 
291
      /// <summary>
292
      /// Function to return the details of the next discrete boolean option.
293
      /// This will be used by the option editing form class to populate a list for user editing.
294
      /// </summary>
295
      /// <param name="e"></param>
296
      /// <param name="level"></param>
297
      /// <param name="displayName"></param>
298
      /// <param name="value"></param>
299
      /// <returns></returns>
300
      public static bool getNextBooleanOption(out boolean_options_e e, out int level, out string displayName, out bool value)
301
      {
302
         i_boolopts++;
303
 
304
         e = boolean_options_e.UNKNOWN;
305
         level = 1;
306
         displayName = "";
307
         value = false;
308
 
309
         if (i_boolopts < boolopts.Count)
310
         {
311
            getBooleanOption(i_boolopts, out e, out level, out displayName, out value);
312
            return true;
313
         }
314
         else
315
         {
316
            return false;
317
         }
318
      }
319
 
320
      /// <summary>
321
      /// Set default values for the discrete boolean options.
322
      /// </summary>
2106 ghuddy 323
      private static void setDefaults()
2088 ghuddy 324
      {
2116 ghuddy 325
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_ELEMENT_DESC_MISSING_WARNINGS, false);
326
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_UN_ALLOCATED_RELATIONSHIP_WARNINGS, false);
327
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_ATTRIBUTES, false);
328
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_METHODS, false);
329
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_PRIVATE_CLASSES, false);
330
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_METHOD_CHARACTERISTICS, false);
331
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_CHARACTERISTICS, false);
2124 ghuddy 332
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_REALISES, false);
2116 ghuddy 333
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_REQUIREMENTS, false);
334
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_CONSTRAINTS, false);
2124 ghuddy 335
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_CLASS_BASE_CLASSES, false);
2116 ghuddy 336
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_ATTRIBUTE_CHARACTERISTICS, false);
337
         optionValue(EA_DocGenOptions.boolean_options_e.CONSIDER_API_ELEMENTS_ONLY, false);
338
         optionValue(EA_DocGenOptions.boolean_options_e.CONSIDER_API_DIAGRAMS_ONLY, false);
339
         optionValue(EA_DocGenOptions.boolean_options_e.CONSIDER_API_PACKAGES_ONLY, false);
340
         optionValue(EA_DocGenOptions.boolean_options_e.RESTRICT_FOR_LINKED_PACKAGES_ONLY, true);
2124 ghuddy 341
         optionValue(EA_DocGenOptions.boolean_options_e.SUPPRESS_REQUIREMENT_NOTES, false);
342
         optionValue(EA_DocGenOptions.boolean_options_e.USE_NUM_PARA_FOR_GENERATED_TEST_CASES, true);
2132 ghuddy 343
         optionValue(EA_DocGenOptions.boolean_options_e.FORCE_HEADING_TABS_TO_2_5_CM, false);
2088 ghuddy 344
      }
345
 
346
 
347
      /// <summary>
348
      /// Looks for the EA_DocGen element in the selected package. To generate a document
349
      /// on a package, the package must contain the EA_DocGen element, even if that elements
350
      /// notes are empty. It serves to denote a package as a document model that is allowed
351
      /// to be processed by this add-in.
352
      /// </summary>
353
      /// <param name="parentPackage"></param>
354
      /// <returns></returns>
2122 ghuddy 355
      public static EA.Package lookForAndProcess_EA_DocGen_Element( EA.Package pkg )
2088 ghuddy 356
      {
2122 ghuddy 357
         options_found = false;
2088 ghuddy 358
 
2122 ghuddy 359
         // iterate up through the package hiearchy
360
         while (pkg != null)
2088 ghuddy 361
         {
2122 ghuddy 362
            // Look for an EA_DocGen element in this package
363
            foreach(EA.Element theElement in pkg.Elements)
364
            {
365
               options_found = lookForAndProcess_EA_DocGen_Element(theElement);
366
               if (options_found)
367
               {
368
                  return pkg;
369
               }
370
            }            
371
 
372
            // Didnt find EA_DocGen element, go up one package level ready for the next loop iteration
373
            if (pkg.ParentID > 0)
374
            {
375
               pkg = Main.EA_Repository.GetPackageByID(pkg.ParentID);
376
            }
377
            else
378
            {
379
               // force loop termination if cannot go up one more package level
380
               pkg = null;
381
            }
382
         }
383
 
384
         return pkg;
2094 ghuddy 385
      }
2088 ghuddy 386
 
2106 ghuddy 387
      public static bool lookForAndProcess_EA_DocGen_Element( EA.Element theElement )
2094 ghuddy 388
      {
2108 ghuddy 389
         initialise();
390
 
2094 ghuddy 391
         options_string = null;
392
         options_found  = false;
2088 ghuddy 393
 
2094 ghuddy 394
         // Special handling for the EA_DocGen element designed to control this document
395
         // generator
396
         if (0 == theElement.Name.CompareTo(EA_Constants.EA_DocGenBaseName))
397
         {
398
            options_found = true;
2088 ghuddy 399
 
2094 ghuddy 400
            // Extract the content of the EA_DocGen element notes section, into a list of
401
            // strings.
402
            string delimStr = "\n";
403
            char [] delim = delimStr.ToCharArray();
2132 ghuddy 404
            options_string = theElement.Notes.Split(delim,400);
2094 ghuddy 405
 
406
            int i = 0;
407
            foreach(string s in options_string)
408
            {
409
               options_string[i] = s.Trim();
410
               i++;
2088 ghuddy 411
            }
412
 
2094 ghuddy 413
            // Extract general options from the list of strings
414
            extractGeneralOptions();
415
 
416
            // Extract element types list from the list of strings
417
            extractElementTypes();
418
         }
419
 
2088 ghuddy 420
         return options_found;
421
      }
422
 
423
 
2106 ghuddy 424
      private static string getOptionValueString(string optionLine)
2088 ghuddy 425
      {
426
         string delimStr = "=";
427
         char [] delim = delimStr.ToCharArray();
428
         string [] optionLineParts = optionLine.Split(delim,2);
429
         if (optionLineParts.GetLength(0) == 2)
430
         {
431
            return optionLineParts[1];
432
         }
433
         else
434
         {
435
            MessageBox.Show( "Error in EA_DocGen option\n\n" + optionLine + "\n\n" + "Missing value" );
436
         }
437
         return null;
438
      }
439
 
440
 
441
      // Overloaded "get option value" methods
2106 ghuddy 442
      public static int getOptionValue(string s, int defaultReturnValue)
2088 ghuddy 443
      {
444
         int returnVal = defaultReturnValue;
445
 
446
         string optionValue = getOptionValueString(s);
447
         if (optionValue != null)
448
         {
449
            try
450
            {
451
               returnVal = Convert.ToInt32(optionValue);
452
            }
453
            catch(Exception)
454
            {
455
               MessageBox.Show( "Error in EA_DocGen option\n\n" + s + "\n\n" + "Expected valid integer" );
456
            }
457
         }   
458
         return returnVal;
459
      }
460
 
2106 ghuddy 461
      public static double getOptionValue(string s, double defaultReturnValue)
2100 ghuddy 462
      {
463
         double returnVal = defaultReturnValue;
464
 
465
         string optionValue = getOptionValueString(s);
466
         if (optionValue != null)
467
         {
468
            try
469
            {
470
               returnVal = Convert.ToDouble(optionValue);
471
            }
472
            catch(Exception)
473
            {
474
               MessageBox.Show( "Error in EA_DocGen option\n\n" + s + "\n\n" + "Expected valid double" );
475
            }
476
         }   
477
         return returnVal;
478
      }
479
 
2106 ghuddy 480
      public static bool getOptionValue(string s, bool defaultReturnValue)
2088 ghuddy 481
      {
482
         bool returnVal = defaultReturnValue;
483
 
484
         string optionValue = getOptionValueString(s);
485
         if (optionValue != null)
486
         {
487
            try
488
            {
489
               returnVal = Convert.ToBoolean(optionValue);
490
            }
491
            catch(Exception)
492
            {
493
               MessageBox.Show( "Error in EA_DocGen option\n\n" + s + "\n\n" + "Expected valid boolean" );
494
            }
495
         }   
496
         return returnVal;
497
      }
498
 
499
 
2106 ghuddy 500
      public static string getOptionValue(string s, string defaultReturnValue)
2088 ghuddy 501
      {
502
         string returnVal = defaultReturnValue;
503
 
504
         string optionValue = getOptionValueString(s);
505
         if (optionValue != null)
506
         {
507
            returnVal = optionValue;
508
         }   
509
         return returnVal;
510
      }
511
 
512
 
2106 ghuddy 513
      public static char getOptionValue(string s, char defaultReturnValue)
2088 ghuddy 514
      {
515
         char returnVal = defaultReturnValue;
516
 
517
         string optionValue = getOptionValueString(s);
518
         if (optionValue != null && optionValue.Length > 0)
519
         {
520
            returnVal = optionValue[0];
521
         }   
522
         return returnVal;
523
      }
524
 
525
 
526
 
527
      /// <summary>
528
      /// Method to extract all the general options from the string array obtained from
529
      /// the EA_DocGen element
530
      /// </summary>
2106 ghuddy 531
      private static void extractGeneralOptions()
2088 ghuddy 532
      {
533
         bool parsingGenOpts = false;
534
 
535
         if (options_string != null)
536
         {
537
            // iterate through the string array obtained from the EA_DocGen element
538
            foreach(string s in options_string)
539
            {
2094 ghuddy 540
               if (s.StartsWith(optstr_GeneralOptions))
2088 ghuddy 541
               {
542
                  parsingGenOpts = true;
543
                  continue;
544
               }
545
               else if (   (parsingGenOpts == true) 
546
                        && (s.Length >= 1)
547
                        && (s.Substring(0,1) == "[") )
548
               {
549
                  // we have gone past the general options and reached another section in EA_DocGen
550
                  // so there is no point in continuing. Exit the loop
551
                  break;
552
               }
553
 
554
               if (parsingGenOpts == true)
555
               {
2116 ghuddy 556
                  foreach(boolopt bo in boolopts)
2088 ghuddy 557
                  {
2116 ghuddy 558
                     if (s.StartsWith(bo.optstr))
559
                     {
560
                        optionValue(bo.enumVal, getOptionValue(s, bo.value));
561
                     }
2088 ghuddy 562
                  }
563
               }
564
            }         
565
         }
566
      }
567
 
568
 
2106 ghuddy 569
      private static void extractElementTypes()
2088 ghuddy 570
      {
571
         bool parsingElementTypes = false;
572
 
573
         opt_ElementTypes.Clear();
574
 
575
         if (options_string != null)
576
         {
577
            // iterate through the string array obtained from the EA_DocGen element
578
            foreach(string s in options_string)
579
            {
2094 ghuddy 580
               if (s.StartsWith(optstr_ElementTypes))
2088 ghuddy 581
               {
582
                  parsingElementTypes = true;
583
                  continue;
584
               }
585
               else if (   (parsingElementTypes == true) 
586
                        && (s.Length >= 1)
587
                        && (s.Substring(0,1) == "[") )
588
               {
589
                  // we have gone past the element types and reached another section in EA_DocGen
590
                  // so there is no point in continuing. Exit the loop
591
                  break;
592
               }
593
 
594
               if (parsingElementTypes == true)
595
               {
596
                  string trimmed_s = s.Trim();
597
                  if (trimmed_s.Length > 0)
598
                  {
599
                     opt_ElementTypes.Add( s );
600
                  }
601
               }
602
            }
603
         }
604
      }
605
 
606
 
607
      /// <summary>
608
      /// This method searches the EA_DocGen string list to find the element types the user
609
      /// has specified that must be included in the document. If the element type given to
610
      /// the function is not in that list then it is excluded from the generated document.
611
      /// The notes of the EA_DocGen element are formed like a .ini file and contain sections 
612
      /// and section content along the lines of:
613
      /// 
614
      /// [sectionName]
615
      /// value
616
      /// value
617
      /// etc
618
      /// [anotherSectionName]
619
      /// value
620
      /// value
621
      /// etc
622
      /// 
623
      /// The [ElementTypes] section is the one this function is interested in
624
      /// 
625
      /// </summary>
626
      /// <param name="elementName"></param>
627
      /// <returns></returns>
2106 ghuddy 628
      public static bool elementTypeFoundInEA_DocGen(string elementType)
2088 ghuddy 629
      {
630
         if (opt_ElementTypes != null && opt_ElementTypes.Count > 0)
631
         {
632
            foreach(string s in opt_ElementTypes)
633
            {
634
               if (s.StartsWith(elementType))
635
               {
636
                  return true;
637
               }
638
            } 
639
            // elementType is not in the opt_ElementTypes list, so element is filtered out
640
            return false;
641
         }
642
         else
643
         {
644
            // opt_ElementTypes is empty so no filtering, return true 
645
            return true;
646
         }
647
      }
648
 
2116 ghuddy 649
      private static void updateEA_DocGen(ref StringBuilder sb, EA_DocGenOptions.boolean_options_e e)
2094 ghuddy 650
      {
2116 ghuddy 651
         boolopt o = (boolopt)boolopts[(int)e];
652
 
653
         sb.Append( o.optstr );
2094 ghuddy 654
         sb.Append( "=" );
2116 ghuddy 655
         sb.Append( o.value.ToString() );
2094 ghuddy 656
         sb.Append( "\r\n" );
657
      }
2088 ghuddy 658
 
2106 ghuddy 659
      private static void updateEA_DocGen(ref StringBuilder sb, int iValue, string s)
2094 ghuddy 660
      {
661
         sb.Append( s );
662
         sb.Append( "=" );
663
         sb.Append( iValue.ToString() );
664
         sb.Append( "\r\n" );
665
      }
666
 
2106 ghuddy 667
      public static void updateEA_DocGen(EA.Element ele)
2094 ghuddy 668
      {
669
         StringBuilder sb = new StringBuilder();
670
 
671
         sb.Append( optstr_GeneralOptions );
672
         sb.Append( "\r\n" );
673
 
2116 ghuddy 674
         // output discrete boolean options
675
         foreach(boolopt bo in boolopts)
676
         {
677
            updateEA_DocGen(ref sb, bo.enumVal);
678
         }
2094 ghuddy 679
 
680
         // Element type filtering options
681
         if (opt_ElementTypes.Count > 0)
682
         {
683
            sb.Append( "\r\n" );
684
            sb.Append( optstr_ElementTypes );
685
            sb.Append( "\r\n" );
686
            foreach (string s in opt_ElementTypes)
687
            {
688
               sb.Append( s );
689
               sb.Append( "\r\n" );
690
            }
691
         }
692
 
693
         ele.Notes = sb.ToString();
694
         ele.Update();
695
 
696
      }
697
 
2088 ghuddy 698
   } // end of class
699
} // end of namespace