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 31... Line 31...
31
	/// <summary>
31
	/// <summary>
32
	/// Class containing functions that implement the EA_DocGen menu items.
32
	/// Class containing functions that implement the EA_DocGen menu items.
33
	/// </summary>
33
	/// </summary>
34
	public class EA_Utilities
34
	public class EA_Utilities
35
	{
35
	{
-
 
36
      // data used by followLink() to roll around multiple GUIDs contained in the link
36
      // Data
37
      static int lastLinkID = -1;
37
      public EA_DocGenOptions options = null;
38
      static int nextGuidIndex = 0;
38
 
39
 
39
      public GUID_Clipboard guid_clipboard = null;
-
 
40
 
40
 
41
      private EA.Repository EA_Repository = null;
-
 
42
 
-
 
43
      public EA_Finders EA_Finder = null;
-
 
44
 
41
 
45
      // Operations
42
      // Operations
46
 
43
 
47
		public EA_Utilities()
44
      public static void identifyClipboardItem()
48
		{
45
      {
49
         guid_clipboard = new GUID_Clipboard(this);
46
         object o = null;
50
 
47
 
-
 
48
         Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
-
 
49
         Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "", -1);
-
 
50
         Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Name : " + GUID_Clipboard.name, -1);
-
 
51
         Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "GUID : " + GUID_Clipboard.guid, -1);
-
 
52
         if (GUID_Clipboard.objType == EA.ObjectType.otPackage)
-
 
53
         {
-
 
54
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Type : Package", -1);
-
 
55
            o = Main.EA_Repository.GetPackageByGuid(GUID_Clipboard.guid);
-
 
56
         }
-
 
57
         else if (GUID_Clipboard.objType == EA.ObjectType.otElement)
-
 
58
         {
-
 
59
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Type : Element", -1);
-
 
60
            o = Main.EA_Repository.GetElementByGuid(GUID_Clipboard.guid);
-
 
61
         }
-
 
62
         else if (GUID_Clipboard.objType == EA.ObjectType.otDiagram)
-
 
63
         {
-
 
64
            Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Type : Diagram", -1);
-
 
65
            o = Main.EA_Repository.GetDiagramByGuid(GUID_Clipboard.guid);
-
 
66
         }
-
 
67
         if (o != null)
-
 
68
         {
51
         options = new EA_DocGenOptions(this);
69
            Main.EA_Repository.ShowInProjectView(o);
-
 
70
         }
-
 
71
      }
52
 
72
 
53
         EA_Finder = new EA_Finders();
73
      public static void updateLink()
54
		}
74
      {
-
 
75
         EA.ObjectType objType;
-
 
76
         object obj;
55
 
77
 
-
 
78
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
-
 
79
         if (objType == EA.ObjectType.otElement)
-
 
80
         {
-
 
81
            EA.Element ele = (EA.Element)obj;
56
 
82
 
-
 
83
            if (ele.Name.StartsWith(EA_Constants.EA_DocGenBaseName)
-
 
84
               && ele.Name.IndexOf("Link") > 0)
-
 
85
            {
-
 
86
               char[] sep = new char[] {'\r', '\n'};
-
 
87
               string[] strings = ele.Notes.Split(sep, 50);
-
 
88
               foreach(string s in strings)
-
 
89
               {
-
 
90
                  if (s.Length > 0 && s[0] == '{')
-
 
91
                  {
-
 
92
                     if (ele.Name.StartsWith(EA_Constants.EA_DocGenDiagramLink))
-
 
93
                     {
-
 
94
                        EA.Diagram diag = (EA.Diagram)Main.EA_Repository.GetDiagramByGuid(s);
-
 
95
                        if (diag != null)
-
 
96
                        {
-
 
97
                           ele.Name = EA_Constants.EA_DocGenDiagramLink + " - " + GetPackagePath(diag.PackageID, diag.Name);
-
 
98
                           ele.Update();
-
 
99
                           Main.EA_Repository.RefreshModelView(ele.PackageID);
-
 
100
                           Main.EA_Repository.ShowInProjectView(ele);
-
 
101
                           return;
-
 
102
                        }
-
 
103
                     }
-
 
104
                     else if (ele.Name.StartsWith(EA_Constants.EA_DocGenElementLink))
-
 
105
                     {
-
 
106
                        EA.Element e = (EA.Element)Main.EA_Repository.GetElementByGuid(s);
-
 
107
                        if (e != null)
-
 
108
                        {
-
 
109
                           ele.Name = EA_Constants.EA_DocGenElementLink + " - " + GetPackagePath(e.PackageID, e.Name);
-
 
110
                           ele.Update();
-
 
111
                           Main.EA_Repository.RefreshModelView(ele.PackageID);
-
 
112
                           Main.EA_Repository.ShowInProjectView(ele);
-
 
113
                           return;
-
 
114
                        }
-
 
115
                     }
-
 
116
                     else if (ele.Name.StartsWith(EA_Constants.EA_DocGenPackageLink))
-
 
117
                     {
-
 
118
                        EA.Package p = (EA.Package)Main.EA_Repository.GetPackageByGuid(s);
-
 
119
                        if (p != null)
-
 
120
                        {
-
 
121
                           ele.Name = EA_Constants.EA_DocGenPackageLink + " - " + GetPackagePath(p.PackageID, p.Name);
-
 
122
                           ele.Update();
-
 
123
                           Main.EA_Repository.RefreshModelView(ele.PackageID);
-
 
124
                           Main.EA_Repository.ShowInProjectView(ele);
-
 
125
                           return;
-
 
126
                        }
-
 
127
                     }
-
 
128
                     else if (ele.Name.StartsWith(EA_Constants.EA_DocGenNameLink))
-
 
129
                     {
-
 
130
                        EA.Package p = (EA.Package)Main.EA_Repository.GetPackageByGuid(s);
-
 
131
                        if (p != null)
-
 
132
                        {
-
 
133
                           ele.Name = EA_Constants.EA_DocGenNameLink + " - " + GetPackagePath(p.PackageID, p.Name);
-
 
134
                           ele.Update();
57
      public void accept_EA_RepositoryRef(EA.Repository EA_RepositoryRef)
135
                           Main.EA_Repository.RefreshModelView(ele.PackageID);
-
 
136
                           Main.EA_Repository.ShowInProjectView(ele);
-
 
137
                           return;
-
 
138
                        }
-
 
139
                     }
-
 
140
                     return;
-
 
141
                  }
-
 
142
               }
-
 
143
               MessageBox.Show("Unable to find link GUID");
-
 
144
               return;
-
 
145
            }
-
 
146
         }
-
 
147
         MessageBox.Show("You must select an EA_DocGen link element");
-
 
148
      }
-
 
149
 
-
 
150
      public static void followLink()
58
      {
151
      {
59
         EA_Repository = EA_RepositoryRef;
152
         EA.ObjectType objType;
-
 
153
         object obj;
-
 
154
 
60
         EA_Finder.accept_EA_RepositoryRef(EA_RepositoryRef);
155
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
-
 
156
         if (objType == EA.ObjectType.otElement)
-
 
157
         {
-
 
158
            EA.Element ele = (EA.Element)obj;
-
 
159
 
-
 
160
            if (ele.Name.StartsWith(EA_Constants.EA_DocGenBaseName)
-
 
161
               && ele.Name.IndexOf("Link") > 0)
-
 
162
            {
-
 
163
 
-
 
164
               if (ele.ElementID != lastLinkID)
-
 
165
               {
-
 
166
                  nextGuidIndex = 0;
-
 
167
               }
-
 
168
 
-
 
169
               char[] sep = new char[] {'\r', '\n'};
-
 
170
               string[] strings = ele.Notes.Split(sep, 50);
-
 
171
               int thisGUIDIndex = 0;
-
 
172
               for(int i=0; i < 2; i++)
-
 
173
               {
-
 
174
                  foreach(string s in strings)
-
 
175
                  {
-
 
176
                     if (s.Length > 0 && s[0] == '{')
-
 
177
                     {
-
 
178
                        if (thisGUIDIndex < nextGuidIndex)
-
 
179
                        {
-
 
180
                           thisGUIDIndex++;
-
 
181
                           continue;
-
 
182
                        }
-
 
183
 
-
 
184
                        object o = null;
-
 
185
                        if (ele.Name.StartsWith(EA_Constants.EA_DocGenDiagramLink))
-
 
186
                        {
-
 
187
                           o = Main.EA_Repository.GetDiagramByGuid(s);
-
 
188
                        }
-
 
189
                        else if (ele.Name.StartsWith(EA_Constants.EA_DocGenElementLink))
-
 
190
                        {
-
 
191
                           o = Main.EA_Repository.GetElementByGuid(s);
-
 
192
                        }
-
 
193
                        else if (ele.Name.StartsWith(EA_Constants.EA_DocGenPackageLink))
-
 
194
                        {
-
 
195
                           o = Main.EA_Repository.GetPackageByGuid(s);
-
 
196
                        }
-
 
197
                        else if (ele.Name.StartsWith(EA_Constants.EA_DocGenNameLink))
-
 
198
                        {
-
 
199
                           o = Main.EA_Repository.GetPackageByGuid(s);
-
 
200
                        }
-
 
201
                        if (o != null)
-
 
202
                        {
-
 
203
                           Main.EA_Repository.ShowInProjectView(o);
-
 
204
                           lastLinkID = ele.ElementID;
-
 
205
                           nextGuidIndex++;
-
 
206
                        }
-
 
207
                        else
-
 
208
                        {
-
 
209
                           MessageBox.Show("Unable to resolve link\r\n" + s);
-
 
210
                        }
-
 
211
                        return;
-
 
212
                     }
-
 
213
                  }
-
 
214
                  if (nextGuidIndex > 0)
-
 
215
                  {
-
 
216
                     nextGuidIndex = 0;
-
 
217
                  }
-
 
218
                  else
-
 
219
                  {
-
 
220
                     break;
-
 
221
                  }
-
 
222
               }
-
 
223
               MessageBox.Show("Unable to find link GUID");
-
 
224
               return;
-
 
225
            }
-
 
226
         }
-
 
227
         MessageBox.Show("You must select an EA_DocGen link element");
61
      }
228
      }
62
 
229
 
63
 
230
 
64
      public void modifyOptions()
231
      public static void modifyOptions()
65
      {
232
      {
66
         EA.ObjectType objType;
233
         EA.ObjectType objType;
67
         object obj;
234
         object obj;
68
 
235
 
69
         objType = EA_Repository.GetTreeSelectedItem( out obj );
236
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
70
         if (objType == EA.ObjectType.otElement)
237
         if (objType == EA.ObjectType.otElement)
71
         {
238
         {
72
            EA.Element ele = (EA.Element)obj;
239
            EA.Element ele = (EA.Element)obj;
73
 
240
 
74
            if (0 == ele.Name.CompareTo(EA_Constants.EA_DocGenBaseName))
241
            if (0 == ele.Name.CompareTo(EA_Constants.EA_DocGenBaseName))
75
            {
242
            {
76
               if (true == options.lookForAndProcess_EA_DocGen_Element( ele ))
243
               if (true == EA_DocGenOptions.lookForAndProcess_EA_DocGen_Element( ele ))
77
               {
244
               {
78
                  EA_DocGenOptionsForm dlg = new EA_DocGenOptionsForm();
245
                  EA_DocGenOptionsForm dlg = new EA_DocGenOptionsForm();
79
                  dlg.populate(EA_Repository, options);
246
                  dlg.populate();
80
                  DialogResult dlgRes = dlg.ShowDialog();
247
                  DialogResult dlgRes = dlg.ShowDialog();
81
                  if (dlgRes == DialogResult.OK)
248
                  if (dlgRes == DialogResult.OK)
82
                  {
249
                  {
83
                     dlg.read(EA_Repository, options);
250
                     dlg.read();
84
 
251
 
85
                     options.updateEA_DocGen(ele);
252
                     EA_DocGenOptions.updateEA_DocGen(ele);
86
                  }
253
                  }
87
               }
254
               }
88
            }
255
            }
89
         }
256
         }
90
      }
257
      }
Line 92... Line 259...
92
 
259
 
93
      /// <summary>
260
      /// <summary>
94
      /// Begins the document generation process, opening the dialog to capture input/output
261
      /// Begins the document generation process, opening the dialog to capture input/output
95
      /// files. the createWordDoc dialog class does most of the work ofcoarse.
262
      /// files. the createWordDoc dialog class does most of the work ofcoarse.
96
      /// </summary>
263
      /// </summary>
97
      public void createWordDoc()
264
      public static void createWordDoc()
98
      {
265
      {
99
         EA.ObjectType objType;
266
         Main.threadCreateDocDialogRunning = true;
100
         object obj;
-
 
101
 
267
 
102
         objType = EA_Repository.GetTreeSelectedItem( out obj );
-
 
103
         if (objType == EA.ObjectType.otPackage)
268
         try
104
         {
269
         {
105
            // Make sure this package has an EA_DocGen element
270
            EA.ObjectType objType;
-
 
271
            object obj;
-
 
272
 
106
            if (true == options.lookForAndProcess_EA_DocGen_Element( ((EA.Package)obj) ))
273
            objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
-
 
274
            if (objType == EA.ObjectType.otPackage)
107
            {
275
            {
-
 
276
               EA_DocGenOptions.initialise();
-
 
277
 
-
 
278
               // Make sure this package has an EA_DocGen element
-
 
279
               if (true == EA_DocGenOptions.lookForAndProcess_EA_DocGen_Element( ((EA.Package)obj) ))
-
 
280
               {
108
               // bring up the dialog for doc generation
281
                  // bring up the dialog for doc generation
109
               createWordDoc dialog = new createWordDoc(EA_Repository, ((EA.Package)obj), this);
282
                  createWordDoc dialog = new createWordDoc(((EA.Package)obj));
110
               dialog.Text = "Generate Document From Model Layout";
283
                  dialog.Text = "Generate Document From Model Layout";
-
 
284
                  dialog.textBox_template.Text    = ReadTag((EA.Package)obj, "TEMPLATE");
-
 
285
                  dialog.textBox_output_file.Text = ReadTag((EA.Package)obj, "DOCFILE");
111
               dialog.ShowDialog();
286
                  dialog.ShowDialog();
-
 
287
                  WriteTag((EA.Package)obj, "TEMPLATE", dialog.textBox_template.Text); 
-
 
288
                  WriteTag((EA.Package)obj, "DOCFILE",  dialog.textBox_output_file.Text);
-
 
289
               }
-
 
290
               else
-
 
291
               {
-
 
292
                  MessageBox.Show("EA_DocGen document model packages must contain an EA_DocGen element");
-
 
293
               }
112
            }
294
            }
113
            else
295
            else
114
            {
296
            {
115
               MessageBox.Show("EA_DocGen document model packages must contain an EA_DocGen element");
297
               MessageBox.Show("You must select a package whose content is to be formed into a document");
116
            }
298
            }
117
         }
299
         }
118
         else
300
         catch(Exception e)
119
         {
301
         {
120
            MessageBox.Show("You must select a package whose content is to be formed into a document");
302
            MessageBox.Show(e.Message);
121
         }
303
         }
-
 
304
         Main.threadCreateDocDialogRunning = false;
122
      }
305
      }
123
 
306
 
124
 
307
 
125
      /// <summary>
308
      /// <summary>
126
      /// Creates a package under the specified parent package. the package is given a tree position
309
      /// Creates a package under the specified parent package. the package is given a tree position
Line 128... Line 311...
128
      /// </summary>
311
      /// </summary>
129
      /// <param name="parentPackage"></param>
312
      /// <param name="parentPackage"></param>
130
      /// <param name="name"></param>
313
      /// <param name="name"></param>
131
      /// <param name="treePos"></param>
314
      /// <param name="treePos"></param>
132
      /// <returns></returns>
315
      /// <returns></returns>
133
      public EA.Package createPackage(EA.Package parentPackage, string name, int treePos)
316
      public static EA.Package createPackage(EA.Package parentPackage, string name, int treePos)
134
      {
317
      {
135
         EA.Package newobj = (EA.Package)parentPackage.Packages.AddNew(name, "Package");
318
         EA.Package newobj = (EA.Package)parentPackage.Packages.AddNew(name, "Package");
136
         newobj.TreePos = treePos;
319
         newobj.TreePos = treePos;
137
         newobj.Update();
320
         newobj.Update();
138
         return newobj;
321
         return newobj;
Line 141... Line 324...
141
 
324
 
142
      /// <summary>
325
      /// <summary>
143
      /// Generate a package hierarchy that reflects the document layout of BMS-00289, the
326
      /// Generate a package hierarchy that reflects the document layout of BMS-00289, the
144
      /// ERG Product Software Design Document.
327
      /// ERG Product Software Design Document.
145
      /// </summary>
328
      /// </summary>
146
      public void create_BMS00289_Layout()
329
      public static void create_BMS00289_Layout()
147
      {
330
      {
148
         EA.ObjectType objType;
331
         EA.ObjectType objType;
149
         object obj;
332
         object obj;
150
 
333
 
151
         objType = EA_Repository.GetTreeSelectedItem( out obj );
334
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
152
         if (objType == EA.ObjectType.otPackage)
335
         if (objType == EA.ObjectType.otPackage)
153
         {
336
         {
154
            if (  ((EA.Package)obj).Packages.Count == 0
337
            if (  ((EA.Package)obj).Packages.Count == 0
155
               && ((EA.Package)obj).Elements.Count == 0
338
               && ((EA.Package)obj).Elements.Count == 0
156
               && ((EA.Package)obj).Diagrams.Count == 0 )
339
               && ((EA.Package)obj).Diagrams.Count == 0 )
Line 204... Line 387...
204
               newElement.Update();
387
               newElement.Update();
205
 
388
 
206
               parentPackage.Packages.Refresh();
389
               parentPackage.Packages.Refresh();
207
 
390
 
208
               // refresh project browser view
391
               // refresh project browser view
209
               EA_Repository.RefreshModelView(parentPackage.PackageID);
392
               Main.EA_Repository.RefreshModelView(parentPackage.PackageID);
210
            }
393
            }
211
            else
394
            else
212
            {
395
            {
213
               MessageBox.Show("Can only insert layout into an empty package");
396
               MessageBox.Show("Can only insert layout into an empty package");
214
            }
397
            }
Line 221... Line 404...
221
 
404
 
222
 
405
 
223
      /// <summary>
406
      /// <summary>
224
      /// Generate a package hierarchy that reflects a basic document layout.
407
      /// Generate a package hierarchy that reflects a basic document layout.
225
      /// </summary>
408
      /// </summary>
226
      public void create_basic_Layout()
409
      public static void create_basic_Layout()
227
      {
410
      {
228
         EA.ObjectType objType;
411
         EA.ObjectType objType;
229
         object obj;
412
         object obj;
230
 
413
 
231
         objType = EA_Repository.GetTreeSelectedItem( out obj );
414
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
232
         if (objType == EA.ObjectType.otPackage)
415
         if (objType == EA.ObjectType.otPackage)
233
         {
416
         {
234
            if (  ((EA.Package)obj).Packages.Count == 0
417
            if (  ((EA.Package)obj).Packages.Count == 0
235
               && ((EA.Package)obj).Elements.Count == 0
418
               && ((EA.Package)obj).Elements.Count == 0
236
               && ((EA.Package)obj).Diagrams.Count == 0 )
419
               && ((EA.Package)obj).Diagrams.Count == 0 )
Line 260... Line 443...
260
               newElement.Update();
443
               newElement.Update();
261
 
444
 
262
               parentPackage.Packages.Refresh();
445
               parentPackage.Packages.Refresh();
263
 
446
 
264
               // refresh project browser view
447
               // refresh project browser view
265
               EA_Repository.RefreshModelView(parentPackage.PackageID);
448
               Main.EA_Repository.RefreshModelView(parentPackage.PackageID);
266
            }
449
            }
267
            else
450
            else
268
            {
451
            {
269
               MessageBox.Show("Can only insert layout into an empty package");
452
               MessageBox.Show("Can only insert layout into an empty package");
270
            }
453
            }
Line 282... Line 465...
282
      /// obtaing the full path of an element,diagram, or package.
465
      /// obtaing the full path of an element,diagram, or package.
283
      /// </summary>
466
      /// </summary>
284
      /// <param name="parentId"></param>
467
      /// <param name="parentId"></param>
285
      /// <param name="instr"></param>
468
      /// <param name="instr"></param>
286
      /// <returns></returns>
469
      /// <returns></returns>
287
      public string GetPackagePath( int parentId, string instr )
470
      public static string GetPackagePath( int parentId, string instr )
288
      {
471
      {
289
         if (parentId != 0)
472
         if (parentId != 0)
290
         {
473
         {
291
            EA.Package pkg;
474
            EA.Package pkg;
292
            pkg = EA_Repository.GetPackageByID( parentId );
475
            pkg = Main.EA_Repository.GetPackageByID( parentId );
293
            if (pkg != null)
476
            if (pkg != null)
294
            {
477
            {
295
               instr = pkg.Name + "/" + instr;
478
               instr = pkg.Name + "/" + instr;
296
               instr = GetPackagePath(pkg.ParentID, instr);
479
               instr = GetPackagePath(pkg.ParentID, instr);
297
            }
480
            }
298
         }
481
         }
299
         return instr;
482
         return instr;
300
      }
483
      }
301
 
484
 
302
 
485
 
303
      private void copy_GUID_to_clipboard(object obj, EA.ObjectType objType, bool confirm)
486
      private static void copy_GUID_to_clipboard(object obj, EA.ObjectType objType, bool confirm)
304
      {
487
      {
305
         guid_clipboard.copy(obj, objType, confirm);
488
         GUID_Clipboard.copy(obj, objType, confirm);
306
      }
489
      }
307
 
490
 
308
 
491
 
309
      /// <summary>
492
      /// <summary>
310
      /// For the selected item, copy its GUID to the internal add-in GUID clipboard and the
493
      /// For the selected item, copy its GUID to the internal add-in GUID clipboard and the
311
      /// global external clipboard. Also copy to the internal add-in GUID clipboard, the name of
494
      /// global external clipboard. Also copy to the internal add-in GUID clipboard, the name of
312
      /// the element and its type. This will support the AddLinkElement() method.
495
      /// the element and its type. This will support the AddLinkElement() method.
313
      /// </summary>
496
      /// </summary>
314
      public void copy_GUID_to_clipboard()
497
      public static void copy_GUID_to_clipboard()
315
      {
498
      {
316
         EA.ObjectType objType;
499
         EA.ObjectType objType;
317
         object obj;
500
         object obj;
318
         objType = EA_Repository.GetTreeSelectedItem( out obj );
501
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
319
         guid_clipboard.copy(obj, objType, true);
502
         GUID_Clipboard.copy(obj, objType, true);
320
      }
503
      }
321
 
504
 
322
 
505
 
323
      public void AddTestTraceabilityElement()
506
      public static void AddTestTraceabilityElement()
324
      {
507
      {
325
         EA.ObjectType objType;
508
         EA.ObjectType objType;
326
         object obj;
509
         object obj;
327
         objType = EA_Repository.GetTreeSelectedItem( out obj );
510
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
328
         AddTestTraceabilityElement(obj, objType);
511
         AddTestTraceabilityElement(obj, objType);
329
      }
512
      }
330
      public void AddTestTraceabilityElement(object obj, EA.ObjectType objType)
513
      public static void AddTestTraceabilityElement(object obj, EA.ObjectType objType)
331
      {
514
      {
332
         if (objType == EA.ObjectType.otPackage)
515
         if (objType == EA.ObjectType.otPackage)
333
         {
516
         {
334
            object newobj = null;
517
            object newobj = null;
335
 
518
 
Line 348... Line 531...
348
 
531
 
349
      /// <summary>
532
      /// <summary>
350
      /// Using the internal add-in GUID clipboard, paste a test link element into the selected
533
      /// Using the internal add-in GUID clipboard, paste a test link element into the selected
351
      /// package.
534
      /// package.
352
      /// </summary>
535
      /// </summary>
353
      public void AddTestLinkElement()
536
      public static void AddTestLinkElement()
354
      {
537
      {
355
         EA.ObjectType objType;
538
         EA.ObjectType objType;
356
         object obj;
539
         object obj;
357
         objType = EA_Repository.GetTreeSelectedItem( out obj );
540
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
358
         AddTestLinkElement(obj, objType);
541
         AddTestLinkElement(obj, objType);
359
      }
542
      }
360
 
543
 
361
      private void AddTestLinkElement(object obj, EA.ObjectType objType)
544
      private static void AddTestLinkElement(object obj, EA.ObjectType objType)
362
      {
545
      {
363
         if (objType == EA.ObjectType.otPackage)
546
         if (objType == EA.ObjectType.otPackage)
364
         {
547
         {
365
            object newobj = null;
548
            object newobj = null;
366
 
549
 
367
            if (   guid_clipboard.objType == EA.ObjectType.otElement
550
            if (   GUID_Clipboard.objType == EA.ObjectType.otElement
368
                || guid_clipboard.objType == EA.ObjectType.otPackage)
551
                || GUID_Clipboard.objType == EA.ObjectType.otPackage)
369
            {
552
            {
370
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenTestLink + " - " + guid_clipboard.name, EA_Constants.EA_DocGenElementType);
553
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenTestLink + " - " + GUID_Clipboard.name, EA_Constants.EA_DocGenElementType);
371
 
554
 
372
               if (newobj != null)
555
               if (newobj != null)
373
               {
556
               {
374
                  ((EA.Element)newobj).Notes = guid_clipboard.name + "\r\n" + guid_clipboard.guid;
557
                  ((EA.Element)newobj).Notes = GUID_Clipboard.name + "\r\n" + GUID_Clipboard.guid;
375
                  ((EA.Element)newobj).Update();
558
                  ((EA.Element)newobj).Update();
376
               }
559
               }
377
            }
560
            }
378
            else
561
            else
379
            {
562
            {
Line 389... Line 572...
389
 
572
 
390
      /// <summary>
573
      /// <summary>
391
      /// Using the internal add-in GUID clipboard, paste a link element into the selected
574
      /// Using the internal add-in GUID clipboard, paste a link element into the selected
392
      /// package.
575
      /// package.
393
      /// </summary>
576
      /// </summary>
394
      public void AddLinkElement()
577
      public static void AddLinkElement()
395
      {
578
      {
396
         EA.ObjectType objType;
579
         EA.ObjectType objType;
397
         object obj;
580
         object obj;
398
         objType = EA_Repository.GetTreeSelectedItem( out obj );
581
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
399
         AddLinkElement(obj, objType);
582
         AddLinkElement(obj, objType);
400
      }
583
      }
401
 
584
 
402
      private void AddLinkElement(object obj, EA.ObjectType objType)
585
      private static void AddLinkElement(object obj, EA.ObjectType objType)
403
      {
586
      {
404
         if (objType == EA.ObjectType.otPackage)
587
         if (objType == EA.ObjectType.otPackage)
405
         {
588
         {
406
            object newobj = null;
589
            object newobj = null;
407
 
590
 
408
            if (guid_clipboard.objType == EA.ObjectType.otPackage)
591
            if (GUID_Clipboard.objType == EA.ObjectType.otPackage)
409
            {
592
            {
410
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenPackageLink + " - " + guid_clipboard.name, EA_Constants.EA_DocGenElementType);
593
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenPackageLink + " - " + GUID_Clipboard.name, EA_Constants.EA_DocGenElementType);
411
            }
594
            }
412
            else if (guid_clipboard.objType == EA.ObjectType.otDiagram)
595
            else if (GUID_Clipboard.objType == EA.ObjectType.otDiagram)
413
            {
596
            {
414
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenDiagramLink + " - " + guid_clipboard.name, EA_Constants.EA_DocGenElementType);
597
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenDiagramLink + " - " + GUID_Clipboard.name, EA_Constants.EA_DocGenElementType);
415
            }
598
            }
416
            else if (guid_clipboard.objType == EA.ObjectType.otElement)
599
            else if (GUID_Clipboard.objType == EA.ObjectType.otElement)
417
            {
600
            {
418
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenElementLink + " - " + guid_clipboard.name, EA_Constants.EA_DocGenElementType);
601
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenElementLink + " - " + GUID_Clipboard.name, EA_Constants.EA_DocGenElementType);
419
            }
602
            }
420
            else if (guid_clipboard.objType == EA.ObjectType.otAttribute)
603
            else if (GUID_Clipboard.objType == EA.ObjectType.otAttribute)
421
            {
604
            {
422
               MessageBox.Show("Attribute links are not currently supported");
605
               MessageBox.Show("Attribute links are not currently supported");
423
            }
606
            }
424
            else if (guid_clipboard.objType == EA.ObjectType.otMethod)
607
            else if (GUID_Clipboard.objType == EA.ObjectType.otMethod)
425
            {
608
            {
426
               MessageBox.Show("Method links are not currently supported");
609
               MessageBox.Show("Method links are not currently supported");
427
            }
610
            }
428
 
611
 
429
            if (newobj != null)
612
            if (newobj != null)
430
            {
613
            {
431
               ((EA.Element)newobj).Notes = guid_clipboard.name + "\r\n" + guid_clipboard.guid;
614
               ((EA.Element)newobj).Notes = GUID_Clipboard.name + "\r\n" + GUID_Clipboard.guid;
432
               ((EA.Element)newobj).Update();
615
               ((EA.Element)newobj).Update();
433
            }
616
            }
434
         }
617
         }
435
         else
618
         else
436
         {
619
         {
437
            MessageBox.Show("You must select a package into which the link will be inserted");
620
            MessageBox.Show("You must select a package into which the link will be inserted");
438
         }
621
         }
439
      }
622
      }
440
 
623
 
441
 
624
 
442
      public void AddNameLinkElement()
625
      public static void AddNameLinkElement()
443
      {
626
      {
444
         EA.ObjectType objType;
627
         EA.ObjectType objType;
445
         object obj;
628
         object obj;
446
         objType = EA_Repository.GetTreeSelectedItem( out obj );
629
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
447
         AddNameLinkElement(obj, objType);
630
         AddNameLinkElement(obj, objType);
448
      }
631
      }
449
 
632
 
450
      private void AddNameLinkElement(object obj, EA.ObjectType objType)
633
      private static void AddNameLinkElement(object obj, EA.ObjectType objType)
451
      {
634
      {
452
         if (objType == EA.ObjectType.otPackage)
635
         if (objType == EA.ObjectType.otPackage)
453
         {
636
         {
454
            object newobj = null;
637
            object newobj = null;
455
 
638
 
456
            if (guid_clipboard.objType == EA.ObjectType.otPackage)
639
            if (GUID_Clipboard.objType == EA.ObjectType.otPackage)
457
            {
640
            {
458
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenNameLink + " - " + guid_clipboard.name, EA_Constants.EA_DocGenElementType);
641
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenNameLink + " - " + GUID_Clipboard.name, EA_Constants.EA_DocGenElementType);
459
               if (newobj != null)
642
               if (newobj != null)
460
               {
643
               {
461
                  StringBuilder sb = new StringBuilder();
644
                  StringBuilder sb = new StringBuilder();
462
                  sb.Append(guid_clipboard.name);
645
                  sb.Append(GUID_Clipboard.name);
463
                  sb.Append("\r\n");
646
                  sb.Append("\r\n");
464
                  sb.Append(guid_clipboard.guid);
647
                  sb.Append(GUID_Clipboard.guid);
465
                  sb.Append("\r\n");
648
                  sb.Append("\r\n");
466
                  sb.Append("### Add as many package names as you like below here.\r\n");
649
                  sb.Append("### Add as many package names as you like below here.\r\n");
467
                  sb.Append("### Each should be of the form: package=name\r\n");
650
                  sb.Append("### Each should be of the form: package=name\r\n");
468
                  sb.Append("### Delete any unused package= lines from these notes.\r\n");
651
                  sb.Append("### Delete any unused package= lines from these notes.\r\n");
469
                  sb.Append("### The names are case sensitive and must match exactly\r\n");
652
                  sb.Append("### The names are case sensitive and must match exactly\r\n");
Line 483... Line 666...
483
            MessageBox.Show("You must select a package into which the name link will be inserted");
666
            MessageBox.Show("You must select a package into which the name link will be inserted");
484
         }
667
         }
485
      }
668
      }
486
 
669
 
487
 
670
 
488
      public void AddTableElement()
671
      public static void AddTableElement()
489
      {
672
      {
490
         EA.ObjectType objType;
673
         EA.ObjectType objType;
491
         object obj;
674
         object obj;
492
 
675
 
493
         objType = EA_Repository.GetTreeSelectedItem( out obj );
676
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
494
         if (objType == EA.ObjectType.otPackage)
677
         if (objType == EA.ObjectType.otPackage)
495
         {
678
         {
496
            object newobj = null;
679
            object newobj = null;
497
 
680
 
498
            newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenTable, EA_Constants.EA_DocGenElementType);
681
            newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenTable, EA_Constants.EA_DocGenElementType);
Line 516... Line 699...
516
            MessageBox.Show("You must select a package into which the Table Element will be inserted");
699
            MessageBox.Show("You must select a package into which the Table Element will be inserted");
517
         }
700
         }
518
      }
701
      }
519
 
702
 
520
 
703
 
521
      public void AddTextElement()
704
      public static void AddTextElement()
522
      {
705
      {
523
         EA.ObjectType objType;
706
         EA.ObjectType objType;
524
         object obj;
707
         object obj;
525
 
708
 
526
         objType = EA_Repository.GetTreeSelectedItem( out obj );
709
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
527
         if (objType == EA.ObjectType.otPackage)
710
         if (objType == EA.ObjectType.otPackage)
528
         {
711
         {
529
            object newobj = null;
712
            object newobj = null;
530
 
713
 
531
            newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenText, EA_Constants.EA_DocGenElementType);
714
            newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenText, EA_Constants.EA_DocGenElementType);
Line 540... Line 723...
540
            MessageBox.Show("You must select a package into which the Text Element will be inserted");
723
            MessageBox.Show("You must select a package into which the Text Element will be inserted");
541
         }
724
         }
542
      }
725
      }
543
 
726
 
544
 
727
 
545
      public void AddRelationshipMatrixElement()
728
      public static void AddRelationshipMatrixElement()
546
      {
729
      {
547
         EA.ObjectType objType;
730
         EA.ObjectType objType;
548
         object obj;
731
         object obj;
549
 
732
 
550
         objType = EA_Repository.GetTreeSelectedItem( out obj );
733
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
551
         if (objType == EA.ObjectType.otPackage)
734
         if (objType == EA.ObjectType.otPackage)
552
         {
735
         {
553
            RelationshipMatrixType dlg = new RelationshipMatrixType();
736
            RelationshipMatrixType dlg = new RelationshipMatrixType();
554
            DialogResult dlgRes = dlg.ShowDialog();
737
            DialogResult dlgRes = dlg.ShowDialog();
555
            if (dlgRes == DialogResult.OK)
738
            if (dlgRes == DialogResult.OK)
Line 568... Line 751...
568
            MessageBox.Show("You must select a package into which the RelationshipMatrix Element will be inserted");
751
            MessageBox.Show("You must select a package into which the RelationshipMatrix Element will be inserted");
569
         }
752
         }
570
      }
753
      }
571
 
754
 
572
 
755
 
573
      public void GeneratePackagesFromElementList()
756
      public static void GeneratePackagesFromElementList()
574
      {
757
      {
575
         EA.ObjectType objType;
758
         EA.ObjectType objType;
576
         object obj;
759
         object obj;
577
 
760
 
578
         objType = EA_Repository.GetTreeSelectedItem( out obj );
761
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
579
         if (objType == EA.ObjectType.otPackage)
762
         if (objType == EA.ObjectType.otPackage)
580
         {
763
         {
581
            if (guid_clipboard.objType == EA.ObjectType.otPackage)
764
            if (GUID_Clipboard.objType == EA.ObjectType.otPackage)
582
            {
765
            {
583
               EA.Package theFoundPackage = EA_Finder.findPackageInRepositoryByGUID(guid_clipboard.guid);
766
               EA.Package theFoundPackage = Main.EA_Repository.GetPackageByGuid(GUID_Clipboard.guid);
584
               if (theFoundPackage != null)
767
               if (theFoundPackage != null)
585
               {
768
               {
586
                  EA.Package srcPackage = theFoundPackage;
769
                  EA.Package srcPackage = theFoundPackage;
587
                  EA.Package destPackage = ((EA.Package)obj);
770
                  EA.Package destPackage = ((EA.Package)obj);
588
 
771
 
589
                  foreach( EA.Element srcElement in srcPackage.Elements)
772
                  foreach( EA.Element srcElement in srcPackage.Elements)
590
                  {
773
                  {
591
                     if (false == EA_Finder.elementNameExistsInPackage(destPackage, srcElement.Name.ToString()))
774
                     if (false == EA_Finders.elementNameExistsInPackage(destPackage, srcElement.Name.ToString()))
592
                     {
775
                     {
593
                        createPackage(destPackage, srcElement.Name.ToString(), 1);
776
                        createPackage(destPackage, srcElement.Name.ToString(), 1);
594
                     }
777
                     }
595
                  }
778
                  }
596
               }
779
               }
Line 605... Line 788...
605
            MessageBox.Show("You must select a Destination Package into which the Generated Packages will be inserted");
788
            MessageBox.Show("You must select a Destination Package into which the Generated Packages will be inserted");
606
         }
789
         }
607
      }
790
      }
608
 
791
 
609
 
792
 
610
      public void GenerateSubPackageLinks()
793
      public static void GenerateSubPackageLinks()
611
      {
794
      {
612
         EA.ObjectType objType;
795
         EA.ObjectType objType;
613
         object obj;
796
         object obj;
614
 
797
 
615
         objType = EA_Repository.GetTreeSelectedItem( out obj );
798
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
616
         if (objType == EA.ObjectType.otPackage)
799
         if (objType == EA.ObjectType.otPackage)
617
         {
800
         {
618
            if (guid_clipboard.objType == EA.ObjectType.otPackage)
801
            if (GUID_Clipboard.objType == EA.ObjectType.otPackage)
619
            {
802
            {
620
               EA.Package theFoundPackage = EA_Finder.findPackageInRepositoryByGUID(guid_clipboard.guid);
803
               EA.Package theFoundPackage = Main.EA_Repository.GetPackageByGuid(GUID_Clipboard.guid);
621
               if (theFoundPackage != null)
804
               if (theFoundPackage != null)
622
               {
805
               {
623
                  EA.Package srcPackage = theFoundPackage;
806
                  EA.Package srcPackage = theFoundPackage;
624
                  EA.Package destPackage = ((EA.Package)obj);
807
                  EA.Package destPackage = ((EA.Package)obj);
625
 
808
 
-
 
809
                  GUID_Clipboard.push();
-
 
810
 
626
                  foreach( EA.Package subPackage in srcPackage.Packages)
811
                  foreach( EA.Package subPackage in srcPackage.Packages)
627
                  {
812
                  {
628
                     copy_GUID_to_clipboard( (object)subPackage, EA.ObjectType.otPackage, false);
813
                     copy_GUID_to_clipboard( (object)subPackage, EA.ObjectType.otPackage, false);
629
                     AddLinkElement( (object)destPackage, EA.ObjectType.otPackage);
814
                     AddLinkElement( (object)destPackage, EA.ObjectType.otPackage);
630
                  }
815
                  }
-
 
816
 
-
 
817
                  GUID_Clipboard.pop();
631
               }
818
               }
632
            }
819
            }
633
            else
820
            else
634
            {
821
            {
635
               MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
822
               MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
Line 640... Line 827...
640
            MessageBox.Show("You must select a Destination Package into which the Sub-Package Links will be inserted");
827
            MessageBox.Show("You must select a Destination Package into which the Sub-Package Links will be inserted");
641
         }
828
         }
642
      }
829
      }
643
 
830
 
644
 
831
 
645
      public void GenerateElementLinks()
832
      public static void GenerateElementLinks()
646
      {
833
      {
647
         EA.ObjectType objType;
834
         EA.ObjectType objType;
648
         object obj;
835
         object obj;
649
 
836
 
650
         objType = EA_Repository.GetTreeSelectedItem( out obj );
837
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
651
         if (objType == EA.ObjectType.otPackage)
838
         if (objType == EA.ObjectType.otPackage)
652
         {
839
         {
653
            if (guid_clipboard.objType == EA.ObjectType.otPackage)
840
            if (GUID_Clipboard.objType == EA.ObjectType.otPackage)
654
            {
841
            {
655
               EA.Package theFoundPackage = EA_Finder.findPackageInRepositoryByGUID(guid_clipboard.guid);
842
               EA.Package theFoundPackage = Main.EA_Repository.GetPackageByGuid(GUID_Clipboard.guid);
656
               if (theFoundPackage != null)
843
               if (theFoundPackage != null)
657
               {
844
               {
658
                  EA.Package srcPackage = theFoundPackage;
845
                  EA.Package srcPackage = theFoundPackage;
659
                  EA.Package destPackage = ((EA.Package)obj);
846
                  EA.Package destPackage = ((EA.Package)obj);
660
 
847
 
-
 
848
                  GUID_Clipboard.push();
-
 
849
 
661
                  foreach( EA.Element subElement in srcPackage.Elements)
850
                  foreach( EA.Element subElement in srcPackage.Elements)
662
                  {
851
                  {
663
                     copy_GUID_to_clipboard( (object)subElement, EA.ObjectType.otElement, false);
852
                     copy_GUID_to_clipboard( (object)subElement, EA.ObjectType.otElement, false);
664
                     AddLinkElement( (object)destPackage, EA.ObjectType.otPackage);
853
                     AddLinkElement( (object)destPackage, EA.ObjectType.otPackage);
665
                  }
854
                  }
-
 
855
 
-
 
856
                  GUID_Clipboard.pop();
666
               }
857
               }
667
            }
858
            }
668
            else
859
            else
669
            {
860
            {
670
               MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
861
               MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
Line 681... Line 872...
681
      /// a user to specify what processing is to be done upon or with each element found.
872
      /// a user to specify what processing is to be done upon or with each element found.
682
      /// </summary>
873
      /// </summary>
683
      /// <param name="thePackage"></param>
874
      /// <param name="thePackage"></param>
684
      /// <param name="worker"></param>
875
      /// <param name="worker"></param>
685
      /// <param name="recurse"></param>
876
      /// <param name="recurse"></param>
686
      public void findAndProcessPackageElements( EA.Package thePackage, EA_UtilitiesRecursionWorker worker, bool recurse)
877
      public static void findAndProcessPackageElements( EA.Package thePackage, EA_UtilitiesRecursionWorker worker, bool recurse)
687
      {
878
      {
688
         worker.processPackage( thePackage );
879
         worker.processPackage( thePackage );
689
 
880
 
690
         foreach (EA.Element theElement in thePackage.Elements)
881
         foreach (EA.Element theElement in thePackage.Elements)
691
         {
882
         {
Line 702... Line 893...
702
         }
893
         }
703
 
894
 
704
      }
895
      }
705
 
896
 
706
 
897
 
707
      public void addDocumentReference()
898
      public static void addDocumentReference()
708
      {
899
      {
709
         EA.ObjectType objType;
900
         EA.ObjectType objType;
710
         object obj;
901
         object obj;
711
 
902
 
712
         objType = EA_Repository.GetTreeSelectedItem( out obj );
903
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
713
         if (objType == EA.ObjectType.otPackage)
904
         if (objType == EA.ObjectType.otPackage)
714
         {
905
         {
715
            DocReferenceForm dlg = new DocReferenceForm();
906
            DocReferenceForm dlg = new DocReferenceForm();
716
            DialogResult dlgRes = dlg.ShowDialog();
907
            DialogResult dlgRes = dlg.ShowDialog();
717
            if (dlgRes == DialogResult.OK)
908
            if (dlgRes == DialogResult.OK)
Line 727... Line 918...
727
            }
918
            }
728
         }
919
         }
729
      }
920
      }
730
 
921
 
731
 
922
 
732
      public void addTerminology()
923
      public static void addTerminology()
733
      {
924
      {
734
         EA.ObjectType objType;
925
         EA.ObjectType objType;
735
         object obj;
926
         object obj;
736
 
927
 
737
         objType = EA_Repository.GetTreeSelectedItem( out obj );
928
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
738
         if (objType == EA.ObjectType.otPackage)
929
         if (objType == EA.ObjectType.otPackage)
739
         {
930
         {
740
            TerminologyForm dlg = new TerminologyForm();
931
            TerminologyForm dlg = new TerminologyForm();
741
            DialogResult dlgRes = dlg.ShowDialog();
932
            DialogResult dlgRes = dlg.ShowDialog();
742
            if (dlgRes == DialogResult.OK)
933
            if (dlgRes == DialogResult.OK)
Line 752... Line 943...
752
            }
943
            }
753
         }
944
         }
754
      }
945
      }
755
 
946
 
756
 
947
 
-
 
948
      public static string ReadTag(EA.Package thePackage, string tagName)
-
 
949
      {
-
 
950
         EA.Element theElement = Main.EA_Repository.GetElementByGuid(thePackage.PackageGUID);
-
 
951
         if (theElement != null)
-
 
952
         {
-
 
953
            return ReadTag(theElement, tagName);
-
 
954
         }
-
 
955
         return "";
-
 
956
      }
-
 
957
 
757
      public string ReadTag(EA.Element theElement, string tagName)
958
      public static string ReadTag(EA.Element theElement, string tagName)
758
      {
959
      {
759
         string result;
960
         string result;
760
 
961
 
761
         EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
962
         EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
762
         if (null != tag)
963
         if (null != tag)
Line 768... Line 969...
768
            result = "";
969
            result = "";
769
         }
970
         }
770
         return result;
971
         return result;
771
      }
972
      }
772
 
973
 
-
 
974
      public static bool WriteTag(EA.Package thePackage, string tagName, string value)
-
 
975
      {
-
 
976
         EA.Element theElement = Main.EA_Repository.GetElementByGuid(thePackage.PackageGUID);
-
 
977
         if (theElement != null)
-
 
978
         {
-
 
979
            return WriteTag(theElement, tagName, value);
-
 
980
         }
-
 
981
         return false;
-
 
982
      }
773
 
983
 
774
      public bool WriteTag(EA.Element theElement, string tagName, string value)
984
      public static bool WriteTag(EA.Element theElement, string tagName, string value)
775
      {
985
      {
776
         bool result;
986
         bool result;
777
         EA.TaggedValue tag;
987
         EA.TaggedValue tag;
778
            
988
            
779
         tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
989
         tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
Line 796... Line 1006...
796
         }
1006
         }
797
         return result;
1007
         return result;
798
      }
1008
      }
799
 
1009
 
800
 
1010
 
801
      public void RemoveAPIStereotypeFromContent()
1011
      public static void RemoveAPIStereotypeFromContent()
802
      {
1012
      {
803
         EA.ObjectType objType;
1013
         EA.ObjectType objType;
804
         object obj;
1014
         object obj;
805
         objType = EA_Repository.GetTreeSelectedItem( out obj );
1015
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
806
         if (objType == EA.ObjectType.otPackage)
1016
         if (objType == EA.ObjectType.otPackage)
807
         {
1017
         {
808
            RemoveAPIStereotypeFromContent((EA.Package)obj);
1018
            RemoveAPIStereotypeFromContent((EA.Package)obj);
809
            EA_Repository.RefreshModelView(((EA.Package)obj).PackageID);
1019
            Main.EA_Repository.RefreshModelView(((EA.Package)obj).PackageID);
810
         }
1020
         }
811
         else if (objType == EA.ObjectType.otDiagram)
1021
         else if (objType == EA.ObjectType.otDiagram)
812
         {
1022
         {
813
            RemoveAPIStereotypeFromDiagram((EA.Diagram)obj);
1023
            RemoveAPIStereotypeFromDiagram((EA.Diagram)obj);
814
            EA_Repository.RefreshModelView(((EA.Diagram)obj).PackageID);
1024
            Main.EA_Repository.RefreshModelView(((EA.Diagram)obj).PackageID);
815
         }
1025
         }
816
         else if (objType == EA.ObjectType.otElement)
1026
         else if (objType == EA.ObjectType.otElement)
817
         {
1027
         {
818
            RemoveAPIStereotypeFromContent((EA.Element)obj);
1028
            RemoveAPIStereotypeFromContent((EA.Element)obj);
819
            EA_Repository.RefreshModelView(((EA.Element)obj).PackageID);
1029
            Main.EA_Repository.RefreshModelView(((EA.Element)obj).PackageID);
820
         }
1030
         }
821
      }
1031
      }
822
 
1032
 
823
      private void RemoveAPIStereotypeFromPackage(EA.Package thePackage)
1033
      private static void RemoveAPIStereotypeFromPackage(EA.Package thePackage)
824
      {
1034
      {
825
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace(",API","");
1035
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace(",API","");
826
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace("API,","");
1036
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace("API,","");
827
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace("API","");
1037
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace("API","");
828
         thePackage.Update();
1038
         thePackage.Update();
829
      }
1039
      }
830
 
1040
 
831
      private void RemoveAPIStereotypeFromDiagram(EA.Diagram theDiagram)
1041
      private static void RemoveAPIStereotypeFromDiagram(EA.Diagram theDiagram)
832
      {
1042
      {
833
         // diagrams only use one stereotype, not a list of them
1043
         // diagrams only use one stereotype, not a list of them
834
         if (theDiagram.Stereotype.Equals("API"))
1044
         if (theDiagram.Stereotype.Equals("API"))
835
         {
1045
         {
836
            theDiagram.Stereotype = "";
1046
            theDiagram.Stereotype = "";
837
            theDiagram.Update();
1047
            theDiagram.Update();
838
         }
1048
         }
839
      }
1049
      }
840
 
1050
 
841
      private void RemoveAPIStereotypeFromElement(EA.Element theElement)
1051
      private static void RemoveAPIStereotypeFromElement(EA.Element theElement)
842
      {
1052
      {
843
         theElement.StereotypeEx = theElement.StereotypeEx.Replace(",API","");
1053
         theElement.StereotypeEx = theElement.StereotypeEx.Replace(",API","");
844
         theElement.StereotypeEx = theElement.StereotypeEx.Replace("API,","");
1054
         theElement.StereotypeEx = theElement.StereotypeEx.Replace("API,","");
845
         theElement.StereotypeEx = theElement.StereotypeEx.Replace("API","");
1055
         theElement.StereotypeEx = theElement.StereotypeEx.Replace("API","");
846
         theElement.Update();
1056
         theElement.Update();
847
      }
1057
      }
848
 
1058
 
849
      private void RemoveAPIStereotypeFromContent(EA.Package thePackage)
1059
      private static void RemoveAPIStereotypeFromContent(EA.Package thePackage)
850
      {
1060
      {
851
         RemoveAPIStereotypeFromPackage(thePackage);
1061
         RemoveAPIStereotypeFromPackage(thePackage);
852
 
1062
 
853
         foreach(EA.Diagram diagram in thePackage.Diagrams)
1063
         foreach(EA.Diagram diagram in thePackage.Diagrams)
854
         {
1064
         {
Line 864... Line 1074...
864
         {
1074
         {
865
            RemoveAPIStereotypeFromContent(package); // recursion
1075
            RemoveAPIStereotypeFromContent(package); // recursion
866
         }
1076
         }
867
      }
1077
      }
868
 
1078
 
869
      private void RemoveAPIStereotypeFromContent(EA.Element theElement)
1079
      private static void RemoveAPIStereotypeFromContent(EA.Element theElement)
870
      {
1080
      {
871
         RemoveAPIStereotypeFromElement(theElement);
1081
         RemoveAPIStereotypeFromElement(theElement);
872
 
1082
 
873
         foreach(EA.Diagram diagram in theElement.Diagrams)
1083
         foreach(EA.Diagram diagram in theElement.Diagrams)
874
         {
1084
         {
Line 880... Line 1090...
880
            RemoveAPIStereotypeFromContent(element); // recursion
1090
            RemoveAPIStereotypeFromContent(element); // recursion
881
         }
1091
         }
882
      }
1092
      }
883
 
1093
 
884
 
1094
 
885
      public void MarkContentWithAPIStereotype()
1095
      public static void MarkContentWithAPIStereotype()
886
      {
1096
      {
887
         EA.ObjectType objType;
1097
         EA.ObjectType objType;
888
         object obj;
1098
         object obj;
889
         objType = EA_Repository.GetTreeSelectedItem( out obj );
1099
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
890
         if (objType == EA.ObjectType.otPackage)
1100
         if (objType == EA.ObjectType.otPackage)
891
         {
1101
         {
892
            MarkContentWithAPIStereotype((EA.Package)obj);
1102
            MarkContentWithAPIStereotype((EA.Package)obj);
893
            EA_Repository.RefreshModelView(((EA.Package)obj).PackageID);
1103
            Main.EA_Repository.RefreshModelView(((EA.Package)obj).PackageID);
894
         }
1104
         }
895
         else if (objType == EA.ObjectType.otDiagram)
1105
         else if (objType == EA.ObjectType.otDiagram)
896
         {
1106
         {
897
            MarkDiagramWithAPIStereotype((EA.Diagram)obj);
1107
            MarkDiagramWithAPIStereotype((EA.Diagram)obj);
898
            EA_Repository.RefreshModelView(((EA.Diagram)obj).PackageID);
1108
            Main.EA_Repository.RefreshModelView(((EA.Diagram)obj).PackageID);
899
         }
1109
         }
900
         else if (objType == EA.ObjectType.otElement)
1110
         else if (objType == EA.ObjectType.otElement)
901
         {
1111
         {
902
            MarkContentWithAPIStereotype((EA.Element)obj);
1112
            MarkContentWithAPIStereotype((EA.Element)obj);
903
            EA_Repository.RefreshModelView(((EA.Element)obj).PackageID);
1113
            Main.EA_Repository.RefreshModelView(((EA.Element)obj).PackageID);
904
         }
1114
         }
905
      }
1115
      }
906
 
1116
 
907
      private void MarkPackageWithAPIStereotype(EA.Package thePackage)
1117
      private static void MarkPackageWithAPIStereotype(EA.Package thePackage)
908
      {
1118
      {
909
         if (thePackage.StereotypeEx.IndexOf("API") < 0)
1119
         if (thePackage.StereotypeEx.IndexOf("API") < 0)
910
         {
1120
         {
911
            if (thePackage.StereotypeEx.Length > 0)
1121
            if (thePackage.StereotypeEx.Length > 0)
912
               thePackage.StereotypeEx += ",API";
1122
               thePackage.StereotypeEx += ",API";
Line 914... Line 1124...
914
               thePackage.StereotypeEx = "API";
1124
               thePackage.StereotypeEx = "API";
915
            thePackage.Update();
1125
            thePackage.Update();
916
         }
1126
         }
917
      }
1127
      }
918
 
1128
 
919
      private void MarkDiagramWithAPIStereotype(EA.Diagram theDiagram)
1129
      private static void MarkDiagramWithAPIStereotype(EA.Diagram theDiagram)
920
      {
1130
      {
921
         // diagrams only use one stereotype, not a list of them
1131
         // diagrams only use one stereotype, not a list of them
922
         theDiagram.Stereotype = "API";
1132
         theDiagram.Stereotype = "API";
923
         theDiagram.Update();
1133
         theDiagram.Update();
924
      }
1134
      }
925
 
1135
 
926
      private void MarkElementWithAPIStereotype(EA.Element theElement)
1136
      private static void MarkElementWithAPIStereotype(EA.Element theElement)
927
      {
1137
      {
928
         if (theElement.StereotypeEx.IndexOf("API") < 0)
1138
         if (theElement.StereotypeEx.IndexOf("API") < 0)
929
         {
1139
         {
930
            if (theElement.StereotypeEx.Length > 0)
1140
            if (theElement.StereotypeEx.Length > 0)
931
               theElement.StereotypeEx += ",API";
1141
               theElement.StereotypeEx += ",API";
Line 933... Line 1143...
933
               theElement.Stereotype = "API";
1143
               theElement.Stereotype = "API";
934
            theElement.Update();
1144
            theElement.Update();
935
         }
1145
         }
936
      }
1146
      }
937
 
1147
 
938
      private void MarkContentWithAPIStereotype(EA.Package thePackage)
1148
      private static void MarkContentWithAPIStereotype(EA.Package thePackage)
939
      {
1149
      {
940
         MarkPackageWithAPIStereotype(thePackage);
1150
         MarkPackageWithAPIStereotype(thePackage);
941
 
1151
 
942
         foreach(EA.Diagram diagram in thePackage.Diagrams)
1152
         foreach(EA.Diagram diagram in thePackage.Diagrams)
943
         {
1153
         {
Line 953... Line 1163...
953
         {
1163
         {
954
            MarkContentWithAPIStereotype(package); // recursion
1164
            MarkContentWithAPIStereotype(package); // recursion
955
         }
1165
         }
956
      }
1166
      }
957
 
1167
 
958
      private void MarkContentWithAPIStereotype(EA.Element theElement)
1168
      private static void MarkContentWithAPIStereotype(EA.Element theElement)
959
      {
1169
      {
960
         MarkElementWithAPIStereotype(theElement);
1170
         MarkElementWithAPIStereotype(theElement);
961
 
1171
 
962
         foreach(EA.Diagram diagram in theElement.Diagrams)
1172
         foreach(EA.Diagram diagram in theElement.Diagrams)
963
         {
1173
         {
Line 973... Line 1183...
973
 
1183
 
974
 
1184
 
975
      #region Temporary or experimental code
1185
      #region Temporary or experimental code
976
 
1186
 
977
 
1187
 
978
      private void parse_element(int parentId, EA.Element theElement, int recurse_level)
1188
      private static void parse_element(int parentId, EA.Element theElement, int recurse_level)
979
      {
1189
      {
980
         //if (parentId == 0 || parentId == theElement.ParentID)
-
 
981
         {
-
 
982
            EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1190
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
983
               "ParentId:"
1191
            "ParentId:"
984
               + parentId.ToString()
1192
            + parentId.ToString()
985
               + ", Level:"
1193
            + ", Level:"
986
               + recurse_level.ToString()
1194
            + recurse_level.ToString()
987
               + ", TreePos:"
1195
            + ", TreePos:"
988
               + theElement.TreePos.ToString() 
1196
            + theElement.TreePos.ToString() 
989
               + ", ELE-ParentID:"
1197
            + ", ELE-ParentID:"
990
               + theElement.ParentID.ToString()
1198
            + theElement.ParentID.ToString()
991
               + ", ELE-PackageID:"
1199
            + ", ELE-PackageID:"
992
               + theElement.PackageID.ToString()
1200
            + theElement.PackageID.ToString()
993
               + ", ELE-ElementID:"
1201
            + ", ELE-ElementID:"
994
               + theElement.ElementID.ToString()
1202
            + theElement.ElementID.ToString()
995
               + ",  ELE-Name: " 
1203
            + ",  ELE-Name: " 
996
               + theElement.Name, -1);
1204
            + theElement.Name, -1);
997
         
1205
         
998
            foreach(EA.Diagram theDiagram in theElement.Diagrams)
1206
         foreach(EA.Diagram theDiagram in theElement.Diagrams)
999
            {
1207
         {
1000
               EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1208
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1001
                  "Level:"
1209
               "Level:"
1002
                  + recurse_level.ToString() 
1210
               + recurse_level.ToString() 
1003
                  + ", ParentID:"
1211
               + ", ParentID:"
1004
                  + theDiagram.ParentID.ToString()
1212
               + theDiagram.ParentID.ToString()
1005
                  + ", PackageID:"
1213
               + ", PackageID:"
1006
                  + theDiagram.PackageID.ToString()
1214
               + theDiagram.PackageID.ToString()
1007
                  + ", DiagramID:"
1215
               + ", DiagramID:"
1008
                  + theDiagram.DiagramID.ToString()
1216
               + theDiagram.DiagramID.ToString()
1009
                  + "  DIAGRAM: " 
1217
               + "  DIAGRAM: " 
1010
                  + theDiagram.Name, -1);
1218
               + theDiagram.Name, -1);
1011
            }
1219
         }
1012
 
1220
 
1013
            foreach(EA.Element subElement in theElement.Elements)
1221
         foreach(EA.Element subElement in theElement.Elements)
1014
            {
1222
         {
1015
               parse_element(theElement.ElementID, subElement, recurse_level+1);
1223
            parse_element(theElement.ElementID, subElement, recurse_level+1);
1016
            }
-
 
1017
         }
1224
         }
1018
      }
1225
      }
1019
 
1226
 
1020
 
1227
 
1021
      /// <summary>
1228
      /// <summary>
1022
      /// Parse a package structure in a similar way to that taken when users are generating a word
1229
      /// Parse a package structure in a similar way to that taken when users are generating a word
1023
      /// document, only here we simply write diagnostic text to the output tab.
1230
      /// document, only here we simply write diagnostic text to the output tab.
1024
      /// </summary>
1231
      /// </summary>
1025
      /// <param name="thePackage"></param>
1232
      /// <param name="thePackage"></param>
1026
      /// <param name="recurse_level"></param>
1233
      /// <param name="recurse_level"></param>
1027
      private void parse_package(EA.Package thePackage, int recurse_level)
1234
      private static void parse_package(EA.Package thePackage, int recurse_level)
1028
      {
1235
      {
1029
         EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1236
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1030
                                      "Level:"
1237
                                      "Level:"
1031
                                    + recurse_level.ToString() 
1238
                                    + recurse_level.ToString() 
1032
                                    + ", ParentID:"
1239
                                    + ", ParentID:"
1033
                                    + thePackage.ParentID.ToString()
1240
                                    + thePackage.ParentID.ToString()
1034
                                    + ", PackageID:"
1241
                                    + ", PackageID:"
Line 1039... Line 1246...
1039
         // default handling of diagrams
1246
         // default handling of diagrams
1040
         foreach(EA.Diagram theDiagram in thePackage.Diagrams)
1247
         foreach(EA.Diagram theDiagram in thePackage.Diagrams)
1041
         {
1248
         {
1042
            if (theDiagram.ParentID == 0)
1249
            if (theDiagram.ParentID == 0)
1043
            {
1250
            {
1044
               EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1251
               Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
1045
                  "Level:"
1252
                  "Level:"
1046
                  + recurse_level.ToString() 
1253
                  + recurse_level.ToString() 
1047
                  + ", ParentID:"
1254
                  + ", ParentID:"
1048
                  + theDiagram.ParentID.ToString()
1255
                  + theDiagram.ParentID.ToString()
1049
                  + ", PackageID:"
1256
                  + ", PackageID:"
Line 1059... Line 1266...
1059
         {
1266
         {
1060
            if (subElement.ParentID == 0 || thePackage.PackageID == subElement.ParentID)
1267
            if (subElement.ParentID == 0 || thePackage.PackageID == subElement.ParentID)
1061
               parse_element(thePackage.PackageID, subElement, recurse_level+1);
1268
               parse_element(thePackage.PackageID, subElement, recurse_level+1);
1062
         }
1269
         }
1063
 
1270
 
1064
//         EA_ElementSorter elementSorter = new EA_ElementSorter(thePackage);
-
 
1065
//         EA.Element theElement = null;
-
 
1066
//         int theElementsRelativeLevel = 0;
-
 
1067
//         if (true == elementSorter.getFirst(ref theElement, ref theElementsRelativeLevel))
-
 
1068
//         {
-
 
1069
//            do
-
 
1070
//            {
-
 
1071
//               int theElementsRecurseLevel = recurse_level + theElementsRelativeLevel;
-
 
1072
//
-
 
1073
//               EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, 
-
 
1074
//                    "Level:"
-
 
1075
//                  + theElementsRecurseLevel.ToString()
-
 
1076
//                  + ", "
-
 
1077
//                  + theElement.TreePos.ToString() 
-
 
1078
//                  + ", ParentID:"
-
 
1079
//                  + theElement.ParentID.ToString()
-
 
1080
//                  + ", PackageID:"
-
 
1081
//                  + theElement.PackageID.ToString()
-
 
1082
//                  + ", ElementID:"
-
 
1083
//                  + theElement.ElementID.ToString()
-
 
1084
//                  + ",  ELEMENT: " 
-
 
1085
//                  + theElement.Name, -1);
-
 
1086
//
-
 
1087
//            } while (true == elementSorter.getNext(ref theElement, ref theElementsRelativeLevel));
-
 
1088
//         }
-
 
1089
 
-
 
1090
         foreach(EA.Package lowerLevelPackage in thePackage.Packages)
1271
         foreach(EA.Package lowerLevelPackage in thePackage.Packages)
1091
         {
1272
         {
1092
            parse_package(lowerLevelPackage, recurse_level+1);
1273
            parse_package(lowerLevelPackage, recurse_level+1);
1093
         }
1274
         }
1094
      }
1275
      }
Line 1096... Line 1277...
1096
 
1277
 
1097
      /// <summary>
1278
      /// <summary>
1098
      /// Parses a specified package in a similar way to what would be done if a user were generating
1279
      /// Parses a specified package in a similar way to what would be done if a user were generating
1099
      /// a word document, but here do nothing except write diagnostic text to the output tab.
1280
      /// a word document, but here do nothing except write diagnostic text to the output tab.
1100
      /// </summary>
1281
      /// </summary>
1101
      public void showDiscoveryOrder()
1282
      public static void showDiscoveryOrder()
1102
      {
1283
      {
1103
         EA.ObjectType objType;
1284
         EA.ObjectType objType;
1104
         object obj;
1285
         object obj;
1105
 
1286
 
1106
         objType = EA_Repository.GetTreeSelectedItem( out obj );
1287
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
1107
         if (objType == EA.ObjectType.otPackage)
1288
         if (objType == EA.ObjectType.otPackage)
1108
         {
1289
         {
1109
            EA.Package EA_ParentPackage = ((EA.Package)obj);
1290
            EA.Package EA_ParentPackage = ((EA.Package)obj);
1110
 
1291
 
-
 
1292
            Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
-
 
1293
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "", -1);
1111
            EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Showing Object Discovery order for " + EA_ParentPackage.Name, -1);
1294
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Showing Object Discovery order for " + EA_ParentPackage.Name, -1);
1112
 
1295
 
1113
            foreach(EA.Package thePackage in EA_ParentPackage.Packages)
-
 
1114
            {
-
 
1115
               parse_package(thePackage, 1);
1296
            parse_package(EA_ParentPackage, 1);
1116
            }
-
 
1117
         }
1297
         }
1118
         else
1298
         else
1119
         {
1299
         {
1120
            MessageBox.Show("You must select a package to parse");
1300
            MessageBox.Show("You must select a package to parse");
1121
         }
1301
         }
1122
      }
1302
      }
1123
 
1303
 
1124
 
1304
 
1125
      public void SaveVersionControlledPackage()
1305
      public static void SaveVersionControlledPackage()
1126
      {
1306
      {
1127
         EA.ObjectType objType;
1307
         EA.ObjectType objType;
1128
         object obj;
1308
         object obj;
1129
 
1309
 
1130
         objType = EA_Repository.GetTreeSelectedItem( out obj );
1310
         objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
1131
         if (objType == EA.ObjectType.otPackage)
1311
         if (objType == EA.ObjectType.otPackage)
1132
         {
1312
         {
1133
            EA.Package EA_Package = ((EA.Package)obj);
1313
            EA.Package EA_Package = ((EA.Package)obj);
1134
 
1314
 
1135
            if (EA_Package.IsControlled == true)
1315
            if (EA_Package.IsControlled == true)
1136
            {
1316
            {
1137
               EA.Project EA_Project = EA_Repository.GetProjectInterface();
1317
               EA.Project EA_Project = Main.EA_Repository.GetProjectInterface();
1138
 
1318
 
1139
               EA_Project.SaveControlledPackage( EA_Package.PackageGUID );
1319
               EA_Project.SaveControlledPackage( EA_Package.PackageGUID );
1140
 
1320
 
1141
               //EA_Project.SaveControlledPackage( EA_Project.GUIDtoXML( EA_Package.PackageGUID ) );
1321
               //EA_Project.SaveControlledPackage( EA_Project.GUIDtoXML( EA_Package.PackageGUID ) );
1142
            }
1322
            }