| 2088 |
ghuddy |
1 |
using System;
|
|
|
2 |
using System.Windows.Forms;
|
|
|
3 |
using System.Collections;
|
|
|
4 |
using System.IO;
|
|
|
5 |
using Word;
|
|
|
6 |
|
|
|
7 |
namespace EA_DocGen
|
|
|
8 |
{
|
|
|
9 |
/// <summary>
|
|
|
10 |
/// A Base Class designed to work with the findAndProcessPackageElements method.
|
|
|
11 |
/// Users will normally derive their own classes from this and add real functionality
|
|
|
12 |
/// to the over-ridable methods the base class provides.
|
|
|
13 |
/// </summary>
|
|
|
14 |
public class EA_UtilitiesRecursionWorker
|
|
|
15 |
{
|
|
|
16 |
public EA_UtilitiesRecursionWorker()
|
|
|
17 |
{
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public virtual void processElement( EA.Element theElement )
|
|
|
21 |
{
|
|
|
22 |
}
|
|
|
23 |
public virtual void processPackage( EA.Package thePackage )
|
|
|
24 |
{
|
|
|
25 |
}
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
/// <summary>
|
|
|
29 |
/// Class containing functions that implement the EA_DocGen menu items.
|
|
|
30 |
/// </summary>
|
|
|
31 |
public class EA_Utilities
|
|
|
32 |
{
|
|
|
33 |
// Data
|
|
|
34 |
public EA_DocGenOptions options = null;
|
|
|
35 |
|
|
|
36 |
public GUID_Clipboard guid_clipboard = null;
|
|
|
37 |
|
|
|
38 |
private EA.Repository EA_Repository = null;
|
|
|
39 |
|
|
|
40 |
public EA_Finders EA_Finder = null;
|
|
|
41 |
|
|
|
42 |
private EA_RelationshipMatrix EA_RelMatrix = null;
|
|
|
43 |
|
|
|
44 |
// Operations
|
|
|
45 |
|
|
|
46 |
public EA_Utilities()
|
|
|
47 |
{
|
|
|
48 |
guid_clipboard = new GUID_Clipboard(this);
|
|
|
49 |
|
|
|
50 |
options = new EA_DocGenOptions(this);
|
|
|
51 |
|
|
|
52 |
EA_Finder = new EA_Finders();
|
|
|
53 |
|
|
|
54 |
EA_RelMatrix = new EA_RelationshipMatrix(this);
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
public void accept_EA_RepositoryRef(EA.Repository EA_RepositoryRef)
|
|
|
58 |
{
|
|
|
59 |
EA_Repository = EA_RepositoryRef;
|
|
|
60 |
EA_Finder.accept_EA_RepositoryRef(EA_RepositoryRef);
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
/// <summary>
|
|
|
67 |
/// Begins the document generation process, opening the dialog to capture input/output
|
|
|
68 |
/// files. the createWordDoc dialog class does most of the work ofcoarse.
|
|
|
69 |
/// </summary>
|
|
|
70 |
public void createWordDoc()
|
|
|
71 |
{
|
|
|
72 |
EA.ObjectType objType;
|
|
|
73 |
object obj;
|
|
|
74 |
|
|
|
75 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
76 |
if (objType == EA.ObjectType.otPackage)
|
|
|
77 |
{
|
|
|
78 |
// Make sure this package has an EA_DocGen element
|
|
|
79 |
if (true == options.lookForAndProcess_EA_DocGen_Element( ((EA.Package)obj) ))
|
|
|
80 |
{
|
|
|
81 |
// bring up the dialog for doc generation
|
|
|
82 |
createWordDoc dialog = new createWordDoc(EA_Repository, ((EA.Package)obj), this);
|
|
|
83 |
dialog.Text = "Generate Document From Model Layout";
|
|
|
84 |
dialog.ShowDialog(); }
|
|
|
85 |
else
|
|
|
86 |
{
|
|
|
87 |
MessageBox.Show("EA_DocGen document model packages must contain an EA_DocGen element");
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
else
|
|
|
91 |
{
|
|
|
92 |
MessageBox.Show("You must select a package whose content is to be formed into a document");
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
/// <summary>
|
|
|
103 |
/// Creates a package under the specified parent package. the package is given a tree position
|
|
|
104 |
/// as specified in order for it to be ordered in the model as the caller requires.
|
|
|
105 |
/// </summary>
|
|
|
106 |
/// <param name="parentPackage"></param>
|
|
|
107 |
/// <param name="name"></param>
|
|
|
108 |
/// <param name="treePos"></param>
|
|
|
109 |
/// <returns></returns>
|
|
|
110 |
public EA.Package createPackage(EA.Package parentPackage, string name, int treePos)
|
|
|
111 |
{
|
|
|
112 |
EA.Package newobj = (EA.Package)parentPackage.Packages.AddNew(name, "Package");
|
|
|
113 |
newobj.TreePos = treePos;
|
|
|
114 |
newobj.Update();
|
|
|
115 |
return newobj;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
/// <summary>
|
|
|
120 |
/// Generate a package hierarchy that reflects the document layout of BMS-00289, the
|
|
|
121 |
/// ERG Product Software Design Document.
|
|
|
122 |
/// </summary>
|
|
|
123 |
public void create_BMS00289_Layout()
|
|
|
124 |
{
|
|
|
125 |
EA.ObjectType objType;
|
|
|
126 |
object obj;
|
|
|
127 |
|
|
|
128 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
129 |
if (objType == EA.ObjectType.otPackage)
|
|
|
130 |
{
|
|
|
131 |
if ( ((EA.Package)obj).Packages.Count == 0
|
|
|
132 |
&& ((EA.Package)obj).Elements.Count == 0
|
|
|
133 |
&& ((EA.Package)obj).Diagrams.Count == 0 )
|
|
|
134 |
{
|
|
|
135 |
EA.Package parentPackage = ((EA.Package)obj);
|
|
|
136 |
|
|
|
137 |
EA.Package newobj = null;
|
|
|
138 |
EA.Package newobj2 = null;
|
|
|
139 |
EA.Package newobj3 = null;
|
|
|
140 |
EA.Package newobj4 = null;
|
|
|
141 |
EA.Package newobj5 = null;
|
|
|
142 |
|
|
|
143 |
newobj = createPackage(parentPackage, "Introduction", 1);
|
|
|
144 |
newobj2 = createPackage(newobj, "Purpose", 1);
|
|
|
145 |
newobj2 = createPackage(newobj, "Scope", 2);
|
|
|
146 |
newobj2 = createPackage(newobj, "Terminology", 3);
|
|
|
147 |
newobj2 = createPackage(newobj, "References", 4);
|
|
|
148 |
|
|
|
149 |
newobj = createPackage(parentPackage, "Design Assumptions And Constraints", 2);
|
|
|
150 |
|
|
|
151 |
newobj = createPackage(parentPackage, "System Overview", 3);
|
|
|
152 |
|
|
|
153 |
newobj = createPackage(parentPackage, "High Level Design", 4);
|
|
|
154 |
newobj2 = createPackage(newobj, "Software Architecture", 1);
|
|
|
155 |
newobj2 = createPackage(newobj, "External Interfaces", 2);
|
|
|
156 |
newobj2 = createPackage(newobj, "Internal Interfaces", 3);
|
|
|
157 |
newobj2 = createPackage(newobj, "Memory And Processing Time Allocation", 4);
|
|
|
158 |
newobj2 = createPackage(newobj, "Operational Modes", 5);
|
|
|
159 |
newobj2 = createPackage(newobj, "Component Descriptions", 6);
|
|
|
160 |
|
|
|
161 |
newobj = createPackage(parentPackage, "Detailed Design", 5);
|
|
|
162 |
|
|
|
163 |
newobj = createPackage(parentPackage, "Unit Test Design",6);
|
|
|
164 |
|
|
|
165 |
newobj2 = createPackage(newobj, "Test Data", 1);
|
|
|
166 |
newobj2 = createPackage(newobj, "Test Stubs", 2);
|
|
|
167 |
newobj2 = createPackage(newobj, "Other Elements", 3);
|
|
|
168 |
newobj2 = createPackage(newobj, "Unit Test Traceability To Design", 4);
|
|
|
169 |
newobj2 = createPackage(newobj, "Test Suites and Test Cases", 5);
|
|
|
170 |
newobj3 = createPackage(newobj2, "Test Suite Name", 1);
|
|
|
171 |
newobj4 = createPackage(newobj3, "Test Name", 1);
|
|
|
172 |
newobj5 = createPackage(newobj4, "Description", 1);
|
|
|
173 |
newobj5 = createPackage(newobj4, "Inputs", 2);
|
|
|
174 |
newobj5 = createPackage(newobj4, "Expected Outputs", 3);
|
|
|
175 |
|
|
|
176 |
newobj = createPackage(parentPackage, "Requirements Traceability", 7);
|
|
|
177 |
|
|
|
178 |
// create an EA_DocGen element
|
|
|
179 |
EA.Element newElement = (EA.Element)parentPackage.Elements.AddNew( "EA_DocGen", "InformationItem" );
|
|
|
180 |
newElement.Update();
|
|
|
181 |
|
|
|
182 |
parentPackage.Packages.Refresh();
|
|
|
183 |
|
|
|
184 |
// refresh project browser view
|
|
|
185 |
EA_Repository.RefreshModelView(parentPackage.PackageID);
|
|
|
186 |
}
|
|
|
187 |
else
|
|
|
188 |
{
|
|
|
189 |
MessageBox.Show("Can only insert layout into an empty package");
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
else
|
|
|
193 |
{
|
|
|
194 |
MessageBox.Show("You must select a package into which the layout will be inserted");
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
/// <summary>
|
|
|
201 |
/// This function works its way up the parental hierarchy to the root model, collecting the
|
|
|
202 |
/// strings names of each package and prepending them to a string accumulator with a view to
|
|
|
203 |
/// obtaing the full path of an element,diagram, or package.
|
|
|
204 |
/// </summary>
|
|
|
205 |
/// <param name="parentId"></param>
|
|
|
206 |
/// <param name="instr"></param>
|
|
|
207 |
/// <returns></returns>
|
|
|
208 |
public string GetPackagePath( int parentId, string instr )
|
|
|
209 |
{
|
|
|
210 |
if (parentId != 0)
|
|
|
211 |
{
|
|
|
212 |
EA.Package pkg;
|
|
|
213 |
pkg = EA_Repository.GetPackageByID( parentId );
|
|
|
214 |
if (pkg != null)
|
|
|
215 |
{
|
|
|
216 |
instr = pkg.Name + "/" + instr;
|
|
|
217 |
instr = GetPackagePath(pkg.ParentID, instr);
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
return instr;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
private void copy_GUID_to_clipboard(object obj, EA.ObjectType objType, bool confirm)
|
|
|
226 |
{
|
|
|
227 |
guid_clipboard.copy(obj, objType, confirm);
|
|
|
228 |
}
|
|
|
229 |
|
|
|
230 |
/// <summary>
|
|
|
231 |
/// For the selected item, copy its GUID to the internal add-in GUID clipboard and the
|
|
|
232 |
/// global external clipboard. Also copy to the internal add-in GUID clipboard, the name of
|
|
|
233 |
/// the element and its type. This will support the AddLinkElement() method.
|
|
|
234 |
/// </summary>
|
|
|
235 |
public void copy_GUID_to_clipboard()
|
|
|
236 |
{
|
|
|
237 |
EA.ObjectType objType;
|
|
|
238 |
object obj;
|
|
|
239 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
240 |
guid_clipboard.copy(obj, objType, true);
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
private void AddLinkElement(object obj, EA.ObjectType objType)
|
|
|
246 |
{
|
|
|
247 |
if (objType == EA.ObjectType.otPackage)
|
|
|
248 |
{
|
|
|
249 |
object newobj = null;
|
|
|
250 |
|
|
|
251 |
if (guid_clipboard.objType == EA.ObjectType.otPackage)
|
|
|
252 |
{
|
|
|
253 |
newobj = ((EA.Package)obj).Elements.AddNew("EA_DocGenPackageLink - " + guid_clipboard.name, "InformationItem");
|
|
|
254 |
}
|
|
|
255 |
else if (guid_clipboard.objType == EA.ObjectType.otDiagram)
|
|
|
256 |
{
|
|
|
257 |
newobj = ((EA.Package)obj).Elements.AddNew("EA_DocGenDiagramLink - " + guid_clipboard.name, "InformationItem");
|
|
|
258 |
}
|
|
|
259 |
else if (guid_clipboard.objType == EA.ObjectType.otElement)
|
|
|
260 |
{
|
|
|
261 |
newobj = ((EA.Package)obj).Elements.AddNew("EA_DocGenElementLink - " + guid_clipboard.name, "InformationItem");
|
|
|
262 |
}
|
|
|
263 |
else if (guid_clipboard.objType == EA.ObjectType.otAttribute)
|
|
|
264 |
{
|
|
|
265 |
MessageBox.Show("Attribute links are not currently supported");
|
|
|
266 |
}
|
|
|
267 |
else if (guid_clipboard.objType == EA.ObjectType.otMethod)
|
|
|
268 |
{
|
|
|
269 |
MessageBox.Show("Method links are not currently supported");
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
if (newobj != null)
|
|
|
273 |
{
|
|
|
274 |
((EA.Element)newobj).Notes = guid_clipboard.name + "\r\n" + guid_clipboard.guid;
|
|
|
275 |
((EA.Element)newobj).Update();
|
|
|
276 |
}
|
|
|
277 |
}
|
|
|
278 |
else
|
|
|
279 |
{
|
|
|
280 |
MessageBox.Show("You must select a package into which the link will be inserted");
|
|
|
281 |
}
|
|
|
282 |
}
|
|
|
283 |
|
|
|
284 |
/// <summary>
|
|
|
285 |
/// Using the internal add-in GUID clipboard, paste a link element into the selected
|
|
|
286 |
/// package.
|
|
|
287 |
/// </summary>
|
|
|
288 |
public void AddLinkElement()
|
|
|
289 |
{
|
|
|
290 |
EA.ObjectType objType;
|
|
|
291 |
object obj;
|
|
|
292 |
|
|
|
293 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
294 |
|
|
|
295 |
AddLinkElement(obj, objType);
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
public void GeneratePackagesFromElementList()
|
|
|
300 |
{
|
|
|
301 |
EA.ObjectType objType;
|
|
|
302 |
object obj;
|
|
|
303 |
|
|
|
304 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
305 |
if (objType == EA.ObjectType.otPackage)
|
|
|
306 |
{
|
|
|
307 |
if (guid_clipboard.objType == EA.ObjectType.otPackage)
|
|
|
308 |
{
|
|
|
309 |
EA.Package theFoundPackage = EA_Finder.findPackageInRepositoryByGUID(guid_clipboard.guid);
|
|
|
310 |
if (theFoundPackage != null)
|
|
|
311 |
{
|
|
|
312 |
EA.Package srcPackage = theFoundPackage;
|
|
|
313 |
EA.Package destPackage = ((EA.Package)obj);
|
|
|
314 |
|
|
|
315 |
foreach( EA.Element srcElement in srcPackage.Elements)
|
|
|
316 |
{
|
|
|
317 |
if (false == EA_Finder.elementNameExistsInPackage(destPackage, srcElement.Name.ToString()))
|
|
|
318 |
{
|
|
|
319 |
createPackage(destPackage, srcElement.Name.ToString(), 1);
|
|
|
320 |
}
|
|
|
321 |
}
|
|
|
322 |
}
|
|
|
323 |
}
|
|
|
324 |
else
|
|
|
325 |
{
|
|
|
326 |
MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
|
|
|
327 |
}
|
|
|
328 |
}
|
|
|
329 |
else
|
|
|
330 |
{
|
|
|
331 |
MessageBox.Show("You must select a Destination Package into which the Generated Packages will be inserted");
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
public void GenerateSubPackageLinks()
|
|
|
337 |
{
|
|
|
338 |
EA.ObjectType objType;
|
|
|
339 |
object obj;
|
|
|
340 |
|
|
|
341 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
342 |
if (objType == EA.ObjectType.otPackage)
|
|
|
343 |
{
|
|
|
344 |
if (guid_clipboard.objType == EA.ObjectType.otPackage)
|
|
|
345 |
{
|
|
|
346 |
EA.Package theFoundPackage = EA_Finder.findPackageInRepositoryByGUID(guid_clipboard.guid);
|
|
|
347 |
if (theFoundPackage != null)
|
|
|
348 |
{
|
|
|
349 |
EA.Package srcPackage = theFoundPackage;
|
|
|
350 |
EA.Package destPackage = ((EA.Package)obj);
|
|
|
351 |
|
|
|
352 |
foreach( EA.Package subPackage in srcPackage.Packages)
|
|
|
353 |
{
|
|
|
354 |
copy_GUID_to_clipboard( (object)subPackage, EA.ObjectType.otPackage, false);
|
|
|
355 |
AddLinkElement( (object)destPackage, EA.ObjectType.otPackage);
|
|
|
356 |
}
|
|
|
357 |
}
|
|
|
358 |
}
|
|
|
359 |
else
|
|
|
360 |
{
|
|
|
361 |
MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
else
|
|
|
365 |
{
|
|
|
366 |
MessageBox.Show("You must select a Destination Package into which the Sub-Package Links will be inserted");
|
|
|
367 |
}
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
|
|
|
371 |
public void GenerateElementLinks()
|
|
|
372 |
{
|
|
|
373 |
EA.ObjectType objType;
|
|
|
374 |
object obj;
|
|
|
375 |
|
|
|
376 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
377 |
if (objType == EA.ObjectType.otPackage)
|
|
|
378 |
{
|
|
|
379 |
if (guid_clipboard.objType == EA.ObjectType.otPackage)
|
|
|
380 |
{
|
|
|
381 |
EA.Package theFoundPackage = EA_Finder.findPackageInRepositoryByGUID(guid_clipboard.guid);
|
|
|
382 |
if (theFoundPackage != null)
|
|
|
383 |
{
|
|
|
384 |
EA.Package srcPackage = theFoundPackage;
|
|
|
385 |
EA.Package destPackage = ((EA.Package)obj);
|
|
|
386 |
|
|
|
387 |
foreach( EA.Element subElement in srcPackage.Elements)
|
|
|
388 |
{
|
|
|
389 |
copy_GUID_to_clipboard( (object)subElement, EA.ObjectType.otElement, false);
|
|
|
390 |
AddLinkElement( (object)destPackage, EA.ObjectType.otPackage);
|
|
|
391 |
}
|
|
|
392 |
}
|
|
|
393 |
}
|
|
|
394 |
else
|
|
|
395 |
{
|
|
|
396 |
MessageBox.Show("You must first copy a Source Package GUID to the clipboard");
|
|
|
397 |
}
|
|
|
398 |
}
|
|
|
399 |
else
|
|
|
400 |
{
|
|
|
401 |
MessageBox.Show("You must select a Destination Package into which the Element Links will be inserted");
|
|
|
402 |
}
|
|
|
403 |
}
|
|
|
404 |
|
|
|
405 |
|
|
|
406 |
public void AddTableElement()
|
|
|
407 |
{
|
|
|
408 |
EA.ObjectType objType;
|
|
|
409 |
object obj;
|
|
|
410 |
|
|
|
411 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
412 |
if (objType == EA.ObjectType.otPackage)
|
|
|
413 |
{
|
|
|
414 |
object newobj = null;
|
|
|
415 |
|
|
|
416 |
newobj = ((EA.Package)obj).Elements.AddNew("EA_DocGenTable", "InformationItem");
|
|
|
417 |
if (newobj != null)
|
|
|
418 |
{
|
|
|
419 |
((EA.Element)newobj).Notes = "title=insertYourTitleHere\r\n"
|
|
|
420 |
+ "columns=2\r\n"
|
|
|
421 |
+ "seperator=,\r\n"
|
|
|
422 |
+ "column1Title,column2Title\r\n"
|
|
|
423 |
+ "cellcontent,cellcontent\r\n"
|
|
|
424 |
+ "etc,etc";
|
|
|
425 |
((EA.Element)newobj).Update();
|
|
|
426 |
}
|
|
|
427 |
}
|
|
|
428 |
else
|
|
|
429 |
{
|
|
|
430 |
MessageBox.Show("You must select a package into which the Table Element will be inserted");
|
|
|
431 |
}
|
|
|
432 |
}
|
|
|
433 |
|
|
|
434 |
|
|
|
435 |
public void AddTextElement()
|
|
|
436 |
{
|
|
|
437 |
EA.ObjectType objType;
|
|
|
438 |
object obj;
|
|
|
439 |
|
|
|
440 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
441 |
if (objType == EA.ObjectType.otPackage)
|
|
|
442 |
{
|
|
|
443 |
object newobj = null;
|
|
|
444 |
|
|
|
445 |
newobj = ((EA.Package)obj).Elements.AddNew("EA_DocGenText", "InformationItem");
|
|
|
446 |
if (newobj != null)
|
|
|
447 |
{
|
|
|
448 |
((EA.Element)newobj).Notes = "Add your text here.";
|
|
|
449 |
((EA.Element)newobj).Update();
|
|
|
450 |
}
|
|
|
451 |
}
|
|
|
452 |
else
|
|
|
453 |
{
|
|
|
454 |
MessageBox.Show("You must select a package into which the Text Element will be inserted");
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
public void AddRelationshipMatrixElement()
|
|
|
459 |
{
|
|
|
460 |
EA.ObjectType objType;
|
|
|
461 |
object obj;
|
|
|
462 |
|
|
|
463 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
464 |
if (objType == EA.ObjectType.otPackage)
|
|
|
465 |
{
|
|
|
466 |
object newobj = null;
|
|
|
467 |
|
|
|
468 |
newobj = ((EA.Package)obj).Elements.AddNew("EA_DocGenRelationshipMatrix", "InformationItem");
|
|
|
469 |
if (newobj != null)
|
|
|
470 |
{
|
|
|
471 |
((EA.Element)newobj).Notes = EA_RelMatrix.optionTemplateForRelationshipMatrix();
|
|
|
472 |
((EA.Element)newobj).Update();
|
|
|
473 |
}
|
|
|
474 |
}
|
|
|
475 |
else
|
|
|
476 |
{
|
|
|
477 |
MessageBox.Show("You must select a package into which the RelationshipMatrix Element will be inserted");
|
|
|
478 |
}
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
/// <summary>
|
|
|
482 |
/// This function is designed to parse EA models/packages in a predefined way, whilst allowing
|
|
|
483 |
/// a user to specify what processing is to be done upon or with each element found.
|
|
|
484 |
/// </summary>
|
|
|
485 |
/// <param name="thePackage"></param>
|
|
|
486 |
/// <param name="worker"></param>
|
|
|
487 |
/// <param name="recurse"></param>
|
|
|
488 |
public void findAndProcessPackageElements( EA.Package thePackage, EA_UtilitiesRecursionWorker worker, bool recurse)
|
|
|
489 |
{
|
|
|
490 |
worker.processPackage( thePackage );
|
|
|
491 |
|
|
|
492 |
foreach (EA.Element theElement in thePackage.Elements)
|
|
|
493 |
{
|
|
|
494 |
worker.processElement( theElement );
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
if (recurse == true)
|
|
|
498 |
{
|
|
|
499 |
foreach (EA.Package subPackage in thePackage.Packages)
|
|
|
500 |
{
|
|
|
501 |
// RECURSION
|
|
|
502 |
findAndProcessPackageElements( subPackage, worker, true);
|
|
|
503 |
}
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
|
511 |
#region Temporary or experimental code
|
|
|
512 |
|
|
|
513 |
|
|
|
514 |
|
|
|
515 |
/// <summary>
|
|
|
516 |
/// Parse a package structure in a similar way to that taken when users are generating a word
|
|
|
517 |
/// document, only here we simply write diagnostic text to the output tab.
|
|
|
518 |
/// </summary>
|
|
|
519 |
/// <param name="thePackage"></param>
|
|
|
520 |
/// <param name="recurse_level"></param>
|
|
|
521 |
private void parse_package(EA.Package thePackage, int recurse_level)
|
|
|
522 |
{
|
|
|
523 |
recurse_level++;
|
|
|
524 |
|
|
|
525 |
EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,
|
|
|
526 |
"Level:"
|
|
|
527 |
+ recurse_level.ToString()
|
|
|
528 |
+ ", ParentID:"
|
|
|
529 |
+ thePackage.ParentID.ToString()
|
|
|
530 |
+ ", PackageID:"
|
|
|
531 |
+ thePackage.PackageID.ToString()
|
|
|
532 |
+ ", PACKAGE: "
|
|
|
533 |
+ thePackage.Name, -1);
|
|
|
534 |
|
|
|
535 |
// default handling of diagrams
|
|
|
536 |
foreach(EA.Diagram theDiagram in thePackage.Diagrams)
|
|
|
537 |
{
|
|
|
538 |
EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,
|
|
|
539 |
"Level:"
|
|
|
540 |
+ recurse_level.ToString()
|
|
|
541 |
+ ", ParentID:"
|
|
|
542 |
+ theDiagram.ParentID.ToString()
|
|
|
543 |
+ ", PackageID:"
|
|
|
544 |
+ theDiagram.PackageID.ToString()
|
|
|
545 |
+ ", DiagramID:"
|
|
|
546 |
+ theDiagram.DiagramID.ToString()
|
|
|
547 |
+ " DIAGRAM: "
|
|
|
548 |
+ theDiagram.Name, -1);
|
|
|
549 |
}
|
|
|
550 |
|
|
|
551 |
EA_ElementSorter elementSorter = new EA_ElementSorter(thePackage);
|
|
|
552 |
EA.Element theElement = null;
|
|
|
553 |
int theElementsRelativeLevel = 0;
|
|
|
554 |
if (true == elementSorter.getFirst(ref theElement, ref theElementsRelativeLevel))
|
|
|
555 |
{
|
|
|
556 |
do
|
|
|
557 |
{
|
|
|
558 |
int theElementsRecurseLevel = recurse_level + theElementsRelativeLevel;
|
|
|
559 |
|
|
|
560 |
EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME,
|
|
|
561 |
"Level:"
|
|
|
562 |
+ theElementsRecurseLevel.ToString()
|
|
|
563 |
+ ", "
|
|
|
564 |
+ theElement.TreePos.ToString()
|
|
|
565 |
+ ", ParentID:"
|
|
|
566 |
+ theElement.ParentID.ToString()
|
|
|
567 |
+ ", PackageID:"
|
|
|
568 |
+ theElement.PackageID.ToString()
|
|
|
569 |
+ ", ElementID:"
|
|
|
570 |
+ theElement.ElementID.ToString()
|
|
|
571 |
+ ", ELEMENT: "
|
|
|
572 |
+ theElement.Name, -1);
|
|
|
573 |
|
|
|
574 |
} while (true == elementSorter.getNext(ref theElement, ref theElementsRelativeLevel));
|
|
|
575 |
}
|
|
|
576 |
|
|
|
577 |
foreach(EA.Package lowerLevelPackage in thePackage.Packages)
|
|
|
578 |
{
|
|
|
579 |
parse_package(lowerLevelPackage, recurse_level);
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
recurse_level--;
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
|
|
|
586 |
/// <summary>
|
|
|
587 |
/// Parses a specified package in a similar way to what would be done if a user were generating
|
|
|
588 |
/// a word document, but here do nothing except write diagnostic text to the output tab.
|
|
|
589 |
/// </summary>
|
|
|
590 |
public void showDiscoveryOrder()
|
|
|
591 |
{
|
|
|
592 |
EA.ObjectType objType;
|
|
|
593 |
object obj;
|
|
|
594 |
|
|
|
595 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
596 |
if (objType == EA.ObjectType.otPackage)
|
|
|
597 |
{
|
|
|
598 |
EA.Package EA_ParentPackage = ((EA.Package)obj);
|
|
|
599 |
|
|
|
600 |
EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Showing Object Discovery order for " + EA_ParentPackage.Name, -1);
|
|
|
601 |
|
|
|
602 |
foreach(EA.Package thePackage in EA_ParentPackage.Packages)
|
|
|
603 |
{
|
|
|
604 |
parse_package(thePackage, 0);
|
|
|
605 |
}
|
|
|
606 |
}
|
|
|
607 |
else
|
|
|
608 |
{
|
|
|
609 |
MessageBox.Show("You must select a package to parse");
|
|
|
610 |
}
|
|
|
611 |
}
|
|
|
612 |
|
|
|
613 |
|
|
|
614 |
public void SaveVersionControlledPackage()
|
|
|
615 |
{
|
|
|
616 |
EA.ObjectType objType;
|
|
|
617 |
object obj;
|
|
|
618 |
|
|
|
619 |
objType = EA_Repository.GetTreeSelectedItem( out obj );
|
|
|
620 |
if (objType == EA.ObjectType.otPackage)
|
|
|
621 |
{
|
|
|
622 |
EA.Package EA_Package = ((EA.Package)obj);
|
|
|
623 |
|
|
|
624 |
if (EA_Package.IsControlled == true)
|
|
|
625 |
{
|
|
|
626 |
EA.Project EA_Project = EA_Repository.GetProjectInterface();
|
|
|
627 |
|
|
|
628 |
EA_Project.SaveControlledPackage( EA_Package.PackageGUID );
|
|
|
629 |
|
|
|
630 |
//EA_Project.SaveControlledPackage( EA_Project.GUIDtoXML( EA_Package.PackageGUID ) );
|
|
|
631 |
}
|
|
|
632 |
else
|
|
|
633 |
{
|
|
|
634 |
MessageBox.Show("The package selected is not version controlled");
|
|
|
635 |
}
|
|
|
636 |
}
|
|
|
637 |
else
|
|
|
638 |
{
|
|
|
639 |
MessageBox.Show("You must select a package");
|
|
|
640 |
}
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
|
|
|
644 |
#endregion
|
|
|
645 |
}
|
|
|
646 |
|
|
|
647 |
|
|
|
648 |
}
|