Subversion Repositories DevTools

Rev

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

Rev 2088 Rev 2094
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Windows.Forms;
2
using System.Windows.Forms;
3
using System.IO;
3
using System.IO;
4
using System.Collections;
4
using System.Collections;
-
 
5
using System.Collections.Specialized;
-
 
6
using System.Text;
5
 
7
 
6
namespace EA_DocGen
8
namespace EA_DocGen
7
{
9
{
8
   /// <summary>
10
   /// <summary>
9
   /// Summary description for EA_DocGenOptions.
11
   /// Summary description for EA_DocGenOptions.
10
   /// </summary>
12
   /// </summary>
11
   public class EA_DocGenOptions
13
   public class EA_DocGenOptions
12
   {
14
   {
-
 
15
      public const string optstr_GeneralOptions = "[GeneralOptions]";
-
 
16
      public const string optstr_ElementTypes   = "[ElementTypes]";
-
 
17
      public const string optstr_ElementHeadingStyleTransitionsToNumParaAtLevel = "ElementHeadingStyleTransitionsToNumParaAtLevel";
-
 
18
      public const string optstr_DisplayRequirementElementsAsSections = "DisplayRequirementElementsAsSections";
-
 
19
      public const string optstr_RequirementElementDisplayFormat      = "RequirementElementDisplayFormat";
-
 
20
      public const string optstr_DisplayRequirementsWithStatus        = "DisplayRequirementsWithStatus";
-
 
21
      public const string optstr_SuppressElementDescriptionMissingWarnings = "SuppressElementDescriptionMissingWarnings";
-
 
22
      public const string optstr_SuppressPrivateAttributres = "SuppressPrivateAttributres";
-
 
23
      public const string optstr_SuppressPrivateMethods     = "SuppressPrivateMethods";
-
 
24
      public const string optstr_SuppressPrivateClasses     = "SuppressPrivateClasses";
-
 
25
 
-
 
26
 
13
      private string [] options_string = null;
27
      private string [] options_string = null;
14
      private bool options_found = false;
28
      private bool options_found = false;
15
 
29
 
16
      // General options
30
      // General options
17
      public  int opt_ElementHeadingTransitionLevel;
31
      public  int opt_ElementHeadingTransitionLevel;
18
      public bool opt_DisplayRequirementElementsAsSections;
32
      public bool opt_DisplayRequirementElementsAsSections;
19
      public string opt_RequirementElementDisplayFormat;
33
      public string opt_RequirementElementDisplayFormat;
20
 
34
 
-
 
35
      public bool opt_SuppressElementDescriptionMissingWarnings;
-
 
36
 
21
      public bool opt_DisplayRequirementsWithStatus;
37
      public bool opt_DisplayRequirementsWithStatus;
22
 
38
 
-
 
39
      // Visibility options
-
 
40
      public bool opt_SuppressPrivateAttributes = true;
-
 
41
      public bool opt_SuppressPrivateMethods     = true;
-
 
42
      public bool opt_SuppressPrivateClasses     = true;
-
 
43
 
-
 
44
 
-
 
45
 
-
 
46
 
23
      // Element Types list
47
      // Element Types list
24
      private ArrayList opt_ElementTypes = null;
48
      public ArrayList opt_ElementTypes = null;
25
 
49
 
26
 
50
 
27
      private EA_Utilities EA_Utils = null;
51
      private EA_Utilities EA_Utils = null;
28
 
52
 
29
      public EA_DocGenOptions(EA_Utilities EA_UtilsRef)
53
      public EA_DocGenOptions(EA_Utilities EA_UtilsRef)
Line 38... Line 62...
38
      {
62
      {
39
         opt_ElementHeadingTransitionLevel = 0;
63
         opt_ElementHeadingTransitionLevel = 0;
40
         opt_DisplayRequirementElementsAsSections = false;
64
         opt_DisplayRequirementElementsAsSections = false;
41
         opt_RequirementElementDisplayFormat = "[REQUIREMENT: %s]";
65
         opt_RequirementElementDisplayFormat = "[REQUIREMENT: %s]";
42
         opt_DisplayRequirementsWithStatus = true;
66
         opt_DisplayRequirementsWithStatus = true;
-
 
67
         opt_SuppressElementDescriptionMissingWarnings = false;
43
      }
68
      }
44
 
69
 
45
 
70
 
46
      /// <summary>
71
      /// <summary>
47
      /// Looks for the EA_DocGen element in the selected package. To generate a document
72
      /// Looks for the EA_DocGen element in the selected package. To generate a document
Line 51... Line 76...
51
      /// </summary>
76
      /// </summary>
52
      /// <param name="parentPackage"></param>
77
      /// <param name="parentPackage"></param>
53
      /// <returns></returns>
78
      /// <returns></returns>
54
      public bool lookForAndProcess_EA_DocGen_Element( EA.Package parentPackage )
79
      public bool lookForAndProcess_EA_DocGen_Element( EA.Package parentPackage )
55
      {
80
      {
56
         options_string = null;
-
 
57
         options_found  = false;
81
         options_found  = false;
58
         setDefaults();
82
         setDefaults();
59
 
83
 
60
         // Look for an EA_DocGen element in this package
84
         // Look for an EA_DocGen element in this package
61
         foreach(EA.Element theElement in parentPackage.Elements)
85
         foreach(EA.Element theElement in parentPackage.Elements)
62
         {
86
         {
63
            // Special handling for the EA_DocGen element designed to control this document
87
            options_found = lookForAndProcess_EA_DocGen_Element(theElement);
-
 
88
            if (options_found)
64
            // generator
89
               break;
-
 
90
         }            
-
 
91
         return options_found;
-
 
92
      }
-
 
93
 
65
            if (theElement.Name.ToString() == "EA_DocGen")
94
      public bool lookForAndProcess_EA_DocGen_Element( EA.Element theElement )
66
            {
95
      {
-
 
96
         options_string = null;
67
               options_found = true;
97
         options_found  = false;
-
 
98
         setDefaults();
68
 
99
 
-
 
100
         // Special handling for the EA_DocGen element designed to control this document
-
 
101
         // generator
-
 
102
         if (0 == theElement.Name.CompareTo(EA_Constants.EA_DocGenBaseName))
-
 
103
         {
-
 
104
            options_found = true;
-
 
105
 
69
               // Extract the content of the EA_DocGen element notes section, into a list of
106
            // Extract the content of the EA_DocGen element notes section, into a list of
70
               // strings.
107
            // strings.
71
               string delimStr = "\n";
108
            string delimStr = "\n";
72
               char [] delim = delimStr.ToCharArray();
109
            char [] delim = delimStr.ToCharArray();
73
               options_string = theElement.Notes.ToString().Split(delim,200);
110
            options_string = theElement.Notes.ToString().Split(delim,200);
74
               
111
               
75
               int i = 0;
112
            int i = 0;
76
               foreach(string s in options_string)
113
            foreach(string s in options_string)
77
               {
114
            {
78
                  options_string[i] = s.Trim();
115
               options_string[i] = s.Trim();
79
                  i++;
116
               i++;
80
               }
117
            }
81
 
118
 
82
               // Extract general options from the list of strings
119
            // Extract general options from the list of strings
83
               extractGeneralOptions();
120
            extractGeneralOptions();
84
 
121
 
85
               // Extract element types list from the list of strings
122
            // Extract element types list from the list of strings
86
               extractElementTypes();
123
            extractElementTypes();
87
               break;
-
 
88
            }
-
 
89
         }            
-
 
90
         
124
         }
91
 
125
 
92
         return options_found;
126
         return options_found;
93
      }
127
      }
94
 
128
 
95
 
129
 
Line 189... Line 223...
189
         if (options_string != null)
223
         if (options_string != null)
190
         {
224
         {
191
            // iterate through the string array obtained from the EA_DocGen element
225
            // iterate through the string array obtained from the EA_DocGen element
192
            foreach(string s in options_string)
226
            foreach(string s in options_string)
193
            {
227
            {
194
               if (s.StartsWith("[GeneralOptions]"))
228
               if (s.StartsWith(optstr_GeneralOptions))
195
               {
229
               {
196
                  parsingGenOpts = true;
230
                  parsingGenOpts = true;
197
                  continue;
231
                  continue;
198
               }
232
               }
199
               else if (   (parsingGenOpts == true) 
233
               else if (   (parsingGenOpts == true) 
Line 205... Line 239...
205
                  break;
239
                  break;
206
               }
240
               }
207
 
241
 
208
               if (parsingGenOpts == true)
242
               if (parsingGenOpts == true)
209
               {
243
               {
210
                  if (s.StartsWith("ElementHeadingStyleTransitionsToNumParaAtLevel"))
244
                  if (s.StartsWith(optstr_ElementHeadingStyleTransitionsToNumParaAtLevel))
211
                  {
245
                  {
212
                     opt_ElementHeadingTransitionLevel = getOptionValue(s, opt_ElementHeadingTransitionLevel);
246
                     opt_ElementHeadingTransitionLevel = getOptionValue(s, opt_ElementHeadingTransitionLevel);
213
                  }
247
                  }
214
                  else if (s.StartsWith("DisplayRequirementElementsAsSections"))
248
                  else if (s.StartsWith(optstr_DisplayRequirementElementsAsSections))
215
                  {
249
                  {
216
                     opt_DisplayRequirementElementsAsSections = getOptionValue(s, opt_DisplayRequirementElementsAsSections);
250
                     opt_DisplayRequirementElementsAsSections = getOptionValue(s, opt_DisplayRequirementElementsAsSections);
217
                  }
251
                  }
218
                  else if (s.StartsWith("RequirementElementDisplayFormat"))
252
                  else if (s.StartsWith(optstr_RequirementElementDisplayFormat))
219
                  {
253
                  {
220
                     opt_RequirementElementDisplayFormat = getOptionValue(s, opt_RequirementElementDisplayFormat);
254
                     opt_RequirementElementDisplayFormat = getOptionValue(s, opt_RequirementElementDisplayFormat);
221
                  }
255
                  }
222
                  else if (s.StartsWith("DisplayRequirementsWithStatus"))
256
                  else if (s.StartsWith(optstr_DisplayRequirementsWithStatus))
223
                  {
257
                  {
224
                     opt_DisplayRequirementsWithStatus = getOptionValue(s, opt_DisplayRequirementsWithStatus);
258
                     opt_DisplayRequirementsWithStatus = getOptionValue(s, opt_DisplayRequirementsWithStatus);
225
                  }
259
                  }
-
 
260
                  else if (s.StartsWith(optstr_SuppressElementDescriptionMissingWarnings))
-
 
261
                  {
-
 
262
                     opt_SuppressElementDescriptionMissingWarnings = getOptionValue(s, opt_SuppressElementDescriptionMissingWarnings);
-
 
263
                  }
-
 
264
                  else if (s.StartsWith(optstr_SuppressPrivateClasses))
-
 
265
                  {
-
 
266
                     opt_SuppressPrivateClasses = getOptionValue(s, opt_SuppressPrivateClasses);
-
 
267
                  }
-
 
268
                  else if (s.StartsWith(optstr_SuppressPrivateAttributres))
-
 
269
                  {
-
 
270
                     opt_SuppressPrivateAttributes = getOptionValue(s, opt_SuppressPrivateAttributes);
-
 
271
                  }
-
 
272
                  else if (s.StartsWith(optstr_SuppressPrivateMethods))
-
 
273
                  {
-
 
274
                     opt_SuppressPrivateMethods = getOptionValue(s, opt_SuppressPrivateMethods);
-
 
275
                  }
226
 
276
 
227
 
277
 
228
                  // add others here
278
                  // add others here
229
 
279
 
230
               }
280
               }
Line 242... Line 292...
242
         if (options_string != null)
292
         if (options_string != null)
243
         {
293
         {
244
            // iterate through the string array obtained from the EA_DocGen element
294
            // iterate through the string array obtained from the EA_DocGen element
245
            foreach(string s in options_string)
295
            foreach(string s in options_string)
246
            {
296
            {
247
               if (s.StartsWith("[ElementTypes]"))
297
               if (s.StartsWith(optstr_ElementTypes))
248
               {
298
               {
249
                  parsingElementTypes = true;
299
                  parsingElementTypes = true;
250
                  continue;
300
                  continue;
251
               }
301
               }
252
               else if (   (parsingElementTypes == true) 
302
               else if (   (parsingElementTypes == true) 
Line 311... Line 361...
311
            // opt_ElementTypes is empty so no filtering, return true 
361
            // opt_ElementTypes is empty so no filtering, return true 
312
            return true;
362
            return true;
313
         }
363
         }
314
      }
364
      }
315
 
365
 
-
 
366
      private void updateEA_DocGen(ref StringBuilder sb, bool bValue, string s)
-
 
367
      {
-
 
368
         sb.Append( s );
-
 
369
         sb.Append( "=" );
-
 
370
         sb.Append( bValue.ToString() );
-
 
371
         sb.Append( "\r\n" );
-
 
372
      }
-
 
373
 
-
 
374
      private void updateEA_DocGen(ref StringBuilder sb, int iValue, string s)
-
 
375
      {
-
 
376
         sb.Append( s );
-
 
377
         sb.Append( "=" );
-
 
378
         sb.Append( iValue.ToString() );
-
 
379
         sb.Append( "\r\n" );
-
 
380
      }
-
 
381
 
-
 
382
      public void updateEA_DocGen(EA.Element ele)
-
 
383
      {
-
 
384
         StringBuilder sb = new StringBuilder();
-
 
385
 
-
 
386
         sb.Append( optstr_GeneralOptions );
-
 
387
         sb.Append( "\r\n" );
-
 
388
 
-
 
389
         // Requirement Display options
-
 
390
         if (opt_DisplayRequirementsWithStatus)
-
 
391
         {
-
 
392
            sb.Append( optstr_DisplayRequirementsWithStatus );
-
 
393
            sb.Append( "=true\r\n" );
-
 
394
            sb.Append( optstr_DisplayRequirementElementsAsSections );
-
 
395
            sb.Append( "=false\r\n" );
-
 
396
         }
-
 
397
         else if (opt_DisplayRequirementElementsAsSections)
-
 
398
         {
-
 
399
            sb.Append( optstr_DisplayRequirementsWithStatus );
-
 
400
            sb.Append( "=false\r\n" );
-
 
401
            sb.Append( optstr_DisplayRequirementElementsAsSections );
-
 
402
            sb.Append( "=true\r\n" );
-
 
403
         }
-
 
404
         else
-
 
405
         {
-
 
406
            sb.Append( optstr_DisplayRequirementsWithStatus );
-
 
407
            sb.Append( "=false\r\n" );
-
 
408
            sb.Append( optstr_DisplayRequirementElementsAsSections );
-
 
409
            sb.Append( "=false\r\n" );
-
 
410
            sb.Append( optstr_RequirementElementDisplayFormat );
-
 
411
            sb.Append( "=" );
-
 
412
            sb.Append( opt_RequirementElementDisplayFormat );
-
 
413
            sb.Append( "\r\n" );
-
 
414
         }
-
 
415
 
-
 
416
         // Missing Description handling options
-
 
417
         updateEA_DocGen(ref sb, opt_SuppressElementDescriptionMissingWarnings, optstr_SuppressElementDescriptionMissingWarnings);
-
 
418
 
-
 
419
         // NumPara transition option
-
 
420
         updateEA_DocGen(ref sb, opt_ElementHeadingTransitionLevel, optstr_ElementHeadingStyleTransitionsToNumParaAtLevel);
-
 
421
 
-
 
422
         // visibility options
-
 
423
         updateEA_DocGen(ref sb, opt_SuppressPrivateClasses,    optstr_SuppressPrivateClasses);
-
 
424
         updateEA_DocGen(ref sb, opt_SuppressPrivateAttributes, optstr_SuppressPrivateAttributres);
-
 
425
         updateEA_DocGen(ref sb, opt_SuppressPrivateMethods,    optstr_SuppressPrivateMethods);
-
 
426
 
-
 
427
         // Element type filtering options
-
 
428
         if (opt_ElementTypes.Count > 0)
-
 
429
         {
-
 
430
            sb.Append( "\r\n" );
-
 
431
            sb.Append( optstr_ElementTypes );
-
 
432
            sb.Append( "\r\n" );
-
 
433
            foreach (string s in opt_ElementTypes)
-
 
434
            {
-
 
435
               sb.Append( s );
-
 
436
               sb.Append( "\r\n" );
-
 
437
            }
-
 
438
         }
-
 
439
 
-
 
440
         ele.Notes = sb.ToString();
-
 
441
         ele.Update();
-
 
442
 
-
 
443
      }
316
 
444
 
317
   } // end of class
445
   } // end of class
318
} // end of namespace
446
} // end of namespace