Subversion Repositories DevTools

Rev

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