Subversion Repositories DevTools

Rev

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

Rev 2114 Rev 2122
Line 39... Line 39...
39
 
39
 
40
 
40
 
41
 
41
 
42
      // Operations
42
      // Operations
43
 
43
 
-
 
44
      public static EA.Package findNamedPackage(EA.Package current_pkg, string package_path)
-
 
45
      {
-
 
46
         string[] package_names = package_path.Split("\\".ToCharArray());
-
 
47
 
-
 
48
         if (current_pkg.Name.Equals(package_names[0]))
-
 
49
         {
-
 
50
            if (package_names.GetLength(0) > 1)
-
 
51
            {
-
 
52
               // prepare the package path for the possible recursion by removing the token we have just
-
 
53
               // matched (plus any '\' char which is assumed to be present) from the fron of the string.
-
 
54
               package_path = package_path.Remove(0, package_names[0].Length + 1);
-
 
55
            }
-
 
56
            else
-
 
57
            {
-
 
58
               // package_path has no more items in it, and we have matched the first item, so we are done
-
 
59
               // Exit returning the current package
-
 
60
               return current_pkg;
-
 
61
            }
-
 
62
         }
-
 
63
 
-
 
64
         foreach(EA.Package subPackage in current_pkg.Packages)
-
 
65
         {
-
 
66
            EA.Package returned_package = findNamedPackage(subPackage, package_path);
-
 
67
            if (returned_package != null)
-
 
68
            {
-
 
69
               return returned_package;
-
 
70
            }
-
 
71
         }
-
 
72
 
-
 
73
         return null;
-
 
74
      }
-
 
75
 
-
 
76
 
44
      public static void identifyClipboardItem()
77
      public static void identifyClipboardItem()
45
      {
78
      {
46
         object o = null;
79
         object o = null;
47
 
80
 
48
         Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
81
         Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
Line 226... Line 259...
226
         }
259
         }
227
         MessageBox.Show("You must select an EA_DocGen link element");
260
         MessageBox.Show("You must select an EA_DocGen link element");
228
      }
261
      }
229
 
262
 
230
 
263
 
-
 
264
      public static EA.Package get_selected_package()
-
 
265
      {
-
 
266
         object o;
-
 
267
         EA.ObjectType type;
-
 
268
 
-
 
269
         type = Main.EA_Repository.GetTreeSelectedItem(out o);
-
 
270
         if (type == EA.ObjectType.otElement)
-
 
271
         {
-
 
272
            return Main.EA_Repository.GetPackageByID(((EA.Element)o).PackageID);
-
 
273
         }
-
 
274
         else if (type == EA.ObjectType.otDiagram)
-
 
275
         {
-
 
276
            return Main.EA_Repository.GetPackageByID(((EA.Diagram)o).PackageID);
-
 
277
         }
-
 
278
         else if (type == EA.ObjectType.otPackage)
-
 
279
         {
-
 
280
            return (EA.Package)o;
-
 
281
         }
-
 
282
         return null;
-
 
283
      }
-
 
284
 
-
 
285
 
-
 
286
 
231
      public static void modifyOptions()
287
      public static void modifyOptions()
232
      {
288
      {
233
         EA.ObjectType objType;
289
         EA.ObjectType objType;
234
         object obj;
290
         object obj;
235
 
291
 
Line 267... Line 323...
267
      {
323
      {
268
         Main.threadCreateDocDialogRunning = true;
324
         Main.threadCreateDocDialogRunning = true;
269
 
325
 
270
         try
326
         try
271
         {
327
         {
272
            EA.ObjectType objType;
328
            // Get the package in or under which the EA project browser selection exists
273
            object obj;
329
            EA.Package pkg = EA_Utilities.get_selected_package();
274
 
330
 
275
            objType = Main.EA_Repository.GetTreeSelectedItem( out obj );
-
 
276
            if (objType == EA.ObjectType.otPackage)
-
 
277
            {
-
 
278
               EA_DocGenOptions.initialise();
331
            EA_DocGenOptions.initialise();
279
 
332
 
280
               // Make sure this package has an EA_DocGen element
333
            // Make sure this package has an EA_DocGen element
281
               if (true == EA_DocGenOptions.lookForAndProcess_EA_DocGen_Element( ((EA.Package)obj) ))
334
            pkg = EA_DocGenOptions.lookForAndProcess_EA_DocGen_Element(pkg);
-
 
335
            if (pkg != null)
282
               {
336
            {
283
                  // bring up the dialog for doc generation
337
               // bring up the dialog for doc generation
284
                  createWordDoc dialog = new createWordDoc(((EA.Package)obj));
338
               createWordDoc dialog = new createWordDoc(pkg);
285
                  dialog.Text = "Generate Document From Model Layout";
339
               dialog.Text = "Generate Document From Model Layout";
286
                  dialog.textBox_template.Text    = ReadTag((EA.Package)obj, "TEMPLATE");
340
               dialog.textBox_template.Text    = ReadTag(pkg, "TEMPLATE");
287
                  dialog.textBox_output_file.Text = ReadTag((EA.Package)obj, "DOCFILE");
341
               dialog.textBox_output_file.Text = ReadTag(pkg, "DOCFILE");
288
                  dialog.ShowDialog();
342
               dialog.ShowDialog();
289
                  WriteTag((EA.Package)obj, "TEMPLATE", dialog.textBox_template.Text); 
343
               WriteTag(pkg, "TEMPLATE", dialog.textBox_template.Text); 
290
                  WriteTag((EA.Package)obj, "DOCFILE",  dialog.textBox_output_file.Text);
344
               WriteTag(pkg, "DOCFILE",  dialog.textBox_output_file.Text);
291
               }
-
 
292
               else
-
 
293
               {
-
 
294
                  MessageBox.Show("EA_DocGen document model packages must contain an EA_DocGen element");
-
 
295
               }
-
 
296
            }
345
            }
297
            else
346
            else
298
            {
347
            {
299
               MessageBox.Show("You must select a package whose content is to be formed into a document");
348
               MessageBox.Show("ERROR, failed to find EA_DocGen element.");
300
            }
349
            }
-
 
350
            
301
         }
351
         }
302
         catch(Exception e)
352
         catch(Exception e)
303
         {
353
         {
304
            MessageBox.Show(e.Message);
354
            MessageBox.Show(e.Message);
305
         }
355
         }