Subversion Repositories DevTools

Rev

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

Rev 2104 Rev 2106
Line 10... Line 10...
10
   /// <summary>
10
   /// <summary>
11
   /// Summary description for EA_DocGenOptions.
11
   /// Summary description for EA_DocGenOptions.
12
   /// </summary>
12
   /// </summary>
13
   public class EA_DocGenOptions
13
   public class EA_DocGenOptions
14
   {
14
   {
-
 
15
      // Strings used in the notes section of an EA_DocGen element that persists the options.
15
      public const string optstr_GeneralOptions = "[GeneralOptions]";
16
      public static string optstr_GeneralOptions = "[GeneralOptions]";
16
      public const string optstr_ElementTypes   = "[ElementTypes]";
17
      public static string optstr_ElementTypes   = "[ElementTypes]";
17
      public const string optstr_SuppressElementDescriptionMissingWarnings = "SuppressElementDescriptionMissingWarnings";
18
      public static string optstr_SuppressElementDescriptionMissingWarnings = "SuppressElementDescriptionMissingWarnings";
18
      public const string optstr_SuppressUnAllocatedRelationshipWarnings = "SuppressUnAllocatedRelationshipWarnings";
19
      public static string optstr_SuppressUnAllocatedRelationshipWarnings = "SuppressUnAllocatedRelationshipWarnings";
19
      public const string optstr_SuppressPrivateAttributes = "SuppressPrivateAttributes";
20
      public static string optstr_SuppressPrivateAttributes = "SuppressPrivateAttributes";
20
      public const string optstr_SuppressPrivateMethods    = "SuppressPrivateMethods";
21
      public static string optstr_SuppressPrivateMethods    = "SuppressPrivateMethods";
21
      public const string optstr_SuppressPrivateClasses    = "SuppressPrivateClasses";
22
      public static string optstr_SuppressPrivateClasses    = "SuppressPrivateClasses";
22
      public const string optstr_ConsiderAPIElementsOnly   = "ConsiderAPIClassesOnly";
23
      public static string optstr_ConsiderAPIElementsOnly   = "ConsiderAPIClassesOnly";
23
      public const string optstr_ConsiderAPIPackagesOnly   = "ConsiderAPIPackagesOnly";
24
      public static string optstr_ConsiderAPIPackagesOnly   = "ConsiderAPIPackagesOnly";
24
      public const string optstr_ConsiderAPIDiagramsOnly   = "ConsiderAPIDiagramsOnly";
25
      public static string optstr_ConsiderAPIDiagramsOnly   = "ConsiderAPIDiagramsOnly";
25
      public const string optstr_RestrictForLinkedPackagesOnly = "APIPackageRestrictionForLinkedPackagesOnly";
26
      public static string optstr_RestrictForLinkedPackagesOnly = "APIPackageRestrictionForLinkedPackagesOnly";
26
 
27
 
27
 
28
 
28
      private string [] options_string = null;
29
      private static string [] options_string = null;
29
      private bool options_found = false;
30
      private static bool options_found = false;
30
 
31
 
31
      // General options
32
      // General options
32
 
33
 
33
      public bool opt_SuppressElementDescriptionMissingWarnings;
34
      public static bool opt_SuppressElementDescriptionMissingWarnings;
34
      public bool opt_SuppressUnAllocatedRelationshipWarnings;
35
      public static bool opt_SuppressUnAllocatedRelationshipWarnings;
35
 
36
 
36
 
37
 
37
      // Visibility options
38
      // Visibility options
38
      public bool opt_SuppressPrivateAttributes;
39
      public static bool opt_SuppressPrivateAttributes;
39
      public bool opt_SuppressPrivateMethods;
40
      public static bool opt_SuppressPrivateMethods;
40
      public bool opt_SuppressPrivateClasses;
41
      public static bool opt_SuppressPrivateClasses;
41
 
42
 
42
      public bool opt_ConsiderAPIElementsOnly;
43
      public static bool opt_ConsiderAPIElementsOnly;
43
      public bool opt_ConsiderAPIPackagesOnly;
44
      public static bool opt_ConsiderAPIPackagesOnly;
44
      public bool opt_ConsiderAPIDiagramsOnly;
45
      public static bool opt_ConsiderAPIDiagramsOnly;
45
      public bool opt_RestrictForLinkedPackagesOnly;
46
      public static bool opt_RestrictForLinkedPackagesOnly;
46
 
47
 
47
 
48
 
48
      // Element Types list
49
      // Element Types list
49
      public ArrayList opt_ElementTypes = null;
50
      public static ArrayList opt_ElementTypes = null;
50
 
51
 
51
 
-
 
52
      private EA_Utilities EA_Utils = null;
-
 
53
 
-
 
54
      public EA_DocGenOptions(EA_Utilities EA_UtilsRef)
52
      public static void initialise()
55
      {
53
      {
56
         EA_Utils = EA_UtilsRef;
-
 
57
         opt_ElementTypes = new ArrayList();
54
         opt_ElementTypes = new ArrayList();
58
         setDefaults();
55
         setDefaults();
59
      }
56
      }
60
 
57
 
61
 
-
 
62
      private void setDefaults()
58
      private static void setDefaults()
63
      {
59
      {
64
         opt_SuppressElementDescriptionMissingWarnings = false;
60
         opt_SuppressElementDescriptionMissingWarnings = false;
65
         opt_SuppressUnAllocatedRelationshipWarnings = false;
61
         opt_SuppressUnAllocatedRelationshipWarnings = false;
66
         opt_SuppressPrivateAttributes = false;
62
         opt_SuppressPrivateAttributes = false;
67
         opt_SuppressPrivateMethods    = false;
63
         opt_SuppressPrivateMethods    = false;
Line 79... Line 75...
79
      /// notes are empty. It serves to denote a package as a document model that is allowed
75
      /// notes are empty. It serves to denote a package as a document model that is allowed
80
      /// to be processed by this add-in.
76
      /// to be processed by this add-in.
81
      /// </summary>
77
      /// </summary>
82
      /// <param name="parentPackage"></param>
78
      /// <param name="parentPackage"></param>
83
      /// <returns></returns>
79
      /// <returns></returns>
84
      public bool lookForAndProcess_EA_DocGen_Element( EA.Package parentPackage )
80
      public static bool lookForAndProcess_EA_DocGen_Element( EA.Package parentPackage )
85
      {
81
      {
86
         options_found  = false;
82
         options_found  = false;
87
         setDefaults();
83
         setDefaults();
88
 
84
 
89
         // Look for an EA_DocGen element in this package
85
         // Look for an EA_DocGen element in this package
Line 94... Line 90...
94
               break;
90
               break;
95
         }            
91
         }            
96
         return options_found;
92
         return options_found;
97
      }
93
      }
98
 
94
 
99
      public bool lookForAndProcess_EA_DocGen_Element( EA.Element theElement )
95
      public static bool lookForAndProcess_EA_DocGen_Element( EA.Element theElement )
100
      {
96
      {
101
         options_string = null;
97
         options_string = null;
102
         options_found  = false;
98
         options_found  = false;
103
         setDefaults();
99
         setDefaults();
104
 
100
 
Line 130... Line 126...
130
 
126
 
131
         return options_found;
127
         return options_found;
132
      }
128
      }
133
 
129
 
134
 
130
 
135
      private string getOptionValueString(string optionLine)
131
      private static string getOptionValueString(string optionLine)
136
      {
132
      {
137
         string delimStr = "=";
133
         string delimStr = "=";
138
         char [] delim = delimStr.ToCharArray();
134
         char [] delim = delimStr.ToCharArray();
139
         string [] optionLineParts = optionLine.Split(delim,2);
135
         string [] optionLineParts = optionLine.Split(delim,2);
140
         if (optionLineParts.GetLength(0) == 2)
136
         if (optionLineParts.GetLength(0) == 2)
Line 148... Line 144...
148
         return null;
144
         return null;
149
      }
145
      }
150
 
146
 
151
 
147
 
152
      // Overloaded "get option value" methods
148
      // Overloaded "get option value" methods
153
      public int getOptionValue(string s, int defaultReturnValue)
149
      public static int getOptionValue(string s, int defaultReturnValue)
154
      {
150
      {
155
         int returnVal = defaultReturnValue;
151
         int returnVal = defaultReturnValue;
156
 
152
 
157
         string optionValue = getOptionValueString(s);
153
         string optionValue = getOptionValueString(s);
158
         if (optionValue != null)
154
         if (optionValue != null)
Line 167... Line 163...
167
            }
163
            }
168
         }   
164
         }   
169
         return returnVal;
165
         return returnVal;
170
      }
166
      }
171
 
167
 
172
      public double getOptionValue(string s, double defaultReturnValue)
168
      public static double getOptionValue(string s, double defaultReturnValue)
173
      {
169
      {
174
         double returnVal = defaultReturnValue;
170
         double returnVal = defaultReturnValue;
175
 
171
 
176
         string optionValue = getOptionValueString(s);
172
         string optionValue = getOptionValueString(s);
177
         if (optionValue != null)
173
         if (optionValue != null)
Line 186... Line 182...
186
            }
182
            }
187
         }   
183
         }   
188
         return returnVal;
184
         return returnVal;
189
      }
185
      }
190
 
186
 
191
      public bool getOptionValue(string s, bool defaultReturnValue)
187
      public static bool getOptionValue(string s, bool defaultReturnValue)
192
      {
188
      {
193
         bool returnVal = defaultReturnValue;
189
         bool returnVal = defaultReturnValue;
194
 
190
 
195
         string optionValue = getOptionValueString(s);
191
         string optionValue = getOptionValueString(s);
196
         if (optionValue != null)
192
         if (optionValue != null)
Line 206... Line 202...
206
         }   
202
         }   
207
         return returnVal;
203
         return returnVal;
208
      }
204
      }
209
 
205
 
210
 
206
 
211
      public string getOptionValue(string s, string defaultReturnValue)
207
      public static string getOptionValue(string s, string defaultReturnValue)
212
      {
208
      {
213
         string returnVal = defaultReturnValue;
209
         string returnVal = defaultReturnValue;
214
 
210
 
215
         string optionValue = getOptionValueString(s);
211
         string optionValue = getOptionValueString(s);
216
         if (optionValue != null)
212
         if (optionValue != null)
Line 219... Line 215...
219
         }   
215
         }   
220
         return returnVal;
216
         return returnVal;
221
      }
217
      }
222
 
218
 
223
 
219
 
224
      public char getOptionValue(string s, char defaultReturnValue)
220
      public static char getOptionValue(string s, char defaultReturnValue)
225
      {
221
      {
226
         char returnVal = defaultReturnValue;
222
         char returnVal = defaultReturnValue;
227
 
223
 
228
         string optionValue = getOptionValueString(s);
224
         string optionValue = getOptionValueString(s);
229
         if (optionValue != null && optionValue.Length > 0)
225
         if (optionValue != null && optionValue.Length > 0)
Line 237... Line 233...
237
 
233
 
238
      /// <summary>
234
      /// <summary>
239
      /// Method to extract all the general options from the string array obtained from
235
      /// Method to extract all the general options from the string array obtained from
240
      /// the EA_DocGen element
236
      /// the EA_DocGen element
241
      /// </summary>
237
      /// </summary>
242
      private void extractGeneralOptions()
238
      private static void extractGeneralOptions()
243
      {
239
      {
244
         bool parsingGenOpts = false;
240
         bool parsingGenOpts = false;
245
 
241
 
246
         if (options_string != null)
242
         if (options_string != null)
247
         {
243
         {
Line 260... Line 256...
260
                  // we have gone past the general options and reached another section in EA_DocGen
256
                  // we have gone past the general options and reached another section in EA_DocGen
261
                  // so there is no point in continuing. Exit the loop
257
                  // so there is no point in continuing. Exit the loop
262
                  break;
258
                  break;
263
               }
259
               }
264
 
260
 
-
 
261
               // BIG WARNING
-
 
262
               // if any option string is a substring of another option string, then the longest of the
-
 
263
               // two must appear first in this if-then-else sequence.
-
 
264
 
265
               if (parsingGenOpts == true)
265
               if (parsingGenOpts == true)
266
               {
266
               {
267
                  if (s.StartsWith(optstr_SuppressElementDescriptionMissingWarnings))
267
                  if (s.StartsWith(optstr_SuppressElementDescriptionMissingWarnings))
268
                  {
268
                  {
269
                     opt_SuppressElementDescriptionMissingWarnings = getOptionValue(s, opt_SuppressElementDescriptionMissingWarnings);
269
                     opt_SuppressElementDescriptionMissingWarnings = getOptionValue(s, opt_SuppressElementDescriptionMissingWarnings);
Line 306... Line 306...
306
            }         
306
            }         
307
         }
307
         }
308
      }
308
      }
309
 
309
 
310
 
310
 
311
      private void extractElementTypes()
311
      private static void extractElementTypes()
312
      {
312
      {
313
         bool parsingElementTypes = false;
313
         bool parsingElementTypes = false;
314
 
314
 
315
         opt_ElementTypes.Clear();
315
         opt_ElementTypes.Clear();
316
 
316
 
Line 365... Line 365...
365
      /// The [ElementTypes] section is the one this function is interested in
365
      /// The [ElementTypes] section is the one this function is interested in
366
      /// 
366
      /// 
367
      /// </summary>
367
      /// </summary>
368
      /// <param name="elementName"></param>
368
      /// <param name="elementName"></param>
369
      /// <returns></returns>
369
      /// <returns></returns>
370
      public bool elementTypeFoundInEA_DocGen(string elementType)
370
      public static bool elementTypeFoundInEA_DocGen(string elementType)
371
      {
371
      {
372
         if (opt_ElementTypes != null && opt_ElementTypes.Count > 0)
372
         if (opt_ElementTypes != null && opt_ElementTypes.Count > 0)
373
         {
373
         {
374
            foreach(string s in opt_ElementTypes)
374
            foreach(string s in opt_ElementTypes)
375
            {
375
            {
Line 386... Line 386...
386
            // opt_ElementTypes is empty so no filtering, return true 
386
            // opt_ElementTypes is empty so no filtering, return true 
387
            return true;
387
            return true;
388
         }
388
         }
389
      }
389
      }
390
 
390
 
391
      private void updateEA_DocGen(ref StringBuilder sb, bool bValue, string s)
391
      private static void updateEA_DocGen(ref StringBuilder sb, bool bValue, string s)
392
      {
392
      {
393
         sb.Append( s );
393
         sb.Append( s );
394
         sb.Append( "=" );
394
         sb.Append( "=" );
395
         sb.Append( bValue.ToString() );
395
         sb.Append( bValue.ToString() );
396
         sb.Append( "\r\n" );
396
         sb.Append( "\r\n" );
397
      }
397
      }
398
 
398
 
399
      private void updateEA_DocGen(ref StringBuilder sb, int iValue, string s)
399
      private static void updateEA_DocGen(ref StringBuilder sb, int iValue, string s)
400
      {
400
      {
401
         sb.Append( s );
401
         sb.Append( s );
402
         sb.Append( "=" );
402
         sb.Append( "=" );
403
         sb.Append( iValue.ToString() );
403
         sb.Append( iValue.ToString() );
404
         sb.Append( "\r\n" );
404
         sb.Append( "\r\n" );
405
      }
405
      }
406
 
406
 
407
      public void updateEA_DocGen(EA.Element ele)
407
      public static void updateEA_DocGen(EA.Element ele)
408
      {
408
      {
409
         StringBuilder sb = new StringBuilder();
409
         StringBuilder sb = new StringBuilder();
410
 
410
 
411
         sb.Append( optstr_GeneralOptions );
411
         sb.Append( optstr_GeneralOptions );
412
         sb.Append( "\r\n" );
412
         sb.Append( "\r\n" );