Subversion Repositories DevTools

Rev

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

Rev 2102 Rev 2104
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Windows.Forms;
2
using System.Windows.Forms;
3
using System.Collections;
3
using System.Collections;
4
using System.IO;
4
using System.IO;
-
 
5
using System.Text;
5
using Word;
6
using Word;
6
 
7
 
7
namespace EA_DocGen
8
namespace EA_DocGen
8
{
9
{
9
   /// <summary>
10
   /// <summary>
Line 39... Line 40...
39
 
40
 
40
      private EA.Repository EA_Repository = null;
41
      private EA.Repository EA_Repository = null;
41
 
42
 
42
      public EA_Finders EA_Finder = null;
43
      public EA_Finders EA_Finder = null;
43
 
44
 
44
      private EA_RelationshipMatrix EA_RelMatrix = null;
-
 
45
 
-
 
46
      // Operations
45
      // Operations
47
 
46
 
48
		public EA_Utilities()
47
		public EA_Utilities()
49
		{
48
		{
50
         guid_clipboard = new GUID_Clipboard(this);
49
         guid_clipboard = new GUID_Clipboard(this);
51
 
50
 
52
         options = new EA_DocGenOptions(this);
51
         options = new EA_DocGenOptions(this);
53
 
52
 
54
         EA_Finder = new EA_Finders();
53
         EA_Finder = new EA_Finders();
55
 
-
 
56
         EA_RelMatrix = new EA_RelationshipMatrix(this);
-
 
57
		}
54
		}
58
 
55
 
59
 
56
 
60
      public void accept_EA_RepositoryRef(EA.Repository EA_RepositoryRef)
57
      public void accept_EA_RepositoryRef(EA.Repository EA_RepositoryRef)
61
      {
58
      {
62
         EA_Repository = EA_RepositoryRef;
59
         EA_Repository = EA_RepositoryRef;
63
         EA_Finder.accept_EA_RepositoryRef(EA_RepositoryRef);
60
         EA_Finder.accept_EA_RepositoryRef(EA_RepositoryRef);
64
      }
61
      }
65
 
62
 
-
 
63
 
66
      public void modifyOptions()
64
      public void modifyOptions()
67
      {
65
      {
68
         EA.ObjectType objType;
66
         EA.ObjectType objType;
69
         object obj;
67
         object obj;
70
 
68
 
Line 89... Line 87...
89
               }
87
               }
90
            }
88
            }
91
         }
89
         }
92
      }
90
      }
93
 
91
 
-
 
92
 
94
      /// <summary>
93
      /// <summary>
95
      /// Begins the document generation process, opening the dialog to capture input/output
94
      /// Begins the document generation process, opening the dialog to capture input/output
96
      /// files. the createWordDoc dialog class does most of the work ofcoarse.
95
      /// files. the createWordDoc dialog class does most of the work ofcoarse.
97
      /// </summary>
96
      /// </summary>
98
      public void createWordDoc()
97
      public void createWordDoc()
Line 344... Line 343...
344
         {
343
         {
345
            MessageBox.Show("You must select a package into which the element will be inserted");
344
            MessageBox.Show("You must select a package into which the element will be inserted");
346
         }
345
         }
347
      }
346
      }
348
 
347
 
-
 
348
 
349
      /// <summary>
349
      /// <summary>
350
      /// Using the internal add-in GUID clipboard, paste a test link element into the selected
350
      /// Using the internal add-in GUID clipboard, paste a test link element into the selected
351
      /// package.
351
      /// package.
352
      /// </summary>
352
      /// </summary>
353
      public void AddTestLinkElement()
353
      public void AddTestLinkElement()
Line 437... Line 437...
437
            MessageBox.Show("You must select a package into which the link will be inserted");
437
            MessageBox.Show("You must select a package into which the link will be inserted");
438
         }
438
         }
439
      }
439
      }
440
 
440
 
441
 
441
 
-
 
442
      public void AddNameLinkElement()
-
 
443
      {
-
 
444
         EA.ObjectType objType;
-
 
445
         object obj;
-
 
446
         objType = EA_Repository.GetTreeSelectedItem( out obj );
-
 
447
         AddNameLinkElement(obj, objType);
-
 
448
      }
-
 
449
 
-
 
450
      private void AddNameLinkElement(object obj, EA.ObjectType objType)
-
 
451
      {
-
 
452
         if (objType == EA.ObjectType.otPackage)
-
 
453
         {
-
 
454
            object newobj = null;
-
 
455
 
-
 
456
            if (guid_clipboard.objType == EA.ObjectType.otPackage)
-
 
457
            {
-
 
458
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenNameLink + " - " + guid_clipboard.name, EA_Constants.EA_DocGenElementType);
-
 
459
               if (newobj != null)
-
 
460
               {
-
 
461
                  StringBuilder sb = new StringBuilder();
-
 
462
                  sb.Append(guid_clipboard.name);
-
 
463
                  sb.Append("\r\n");
-
 
464
                  sb.Append(guid_clipboard.guid);
-
 
465
                  sb.Append("\r\n");
-
 
466
                  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");
-
 
468
                  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");
-
 
470
                  sb.Append("### the names of the packages you wish to pull in to the\r\n");
-
 
471
                  sb.Append("### document model.\r\n");
-
 
472
                  sb.Append("package=\r\n");
-
 
473
                  sb.Append("package=\r\n");
-
 
474
                  sb.Append("package=\r\n");
-
 
475
 
-
 
476
                  ((EA.Element)newobj).Notes = sb.ToString();
-
 
477
                  ((EA.Element)newobj).Update();
-
 
478
               }            
-
 
479
            }
-
 
480
         }
-
 
481
         else
-
 
482
         {
-
 
483
            MessageBox.Show("You must select a package into which the name link will be inserted");
-
 
484
         }
-
 
485
      }
-
 
486
 
-
 
487
 
442
      public void AddTableElement()
488
      public void AddTableElement()
443
      {
489
      {
444
         EA.ObjectType objType;
490
         EA.ObjectType objType;
445
         object obj;
491
         object obj;
446
 
492
 
Line 453... Line 499...
453
            if (newobj != null)
499
            if (newobj != null)
454
            {
500
            {
455
               ((EA.Element)newobj).Notes = "title=insertYourTitleHere\r\n"
501
               ((EA.Element)newobj).Notes = "title=insertYourTitleHere\r\n"
456
                                          + "columns=2\r\n"
502
                                          + "columns=2\r\n"
457
                                          + "seperator=,\r\n"
503
                                          + "seperator=,\r\n"
-
 
504
                                          + "indent=1\r\n"
-
 
505
                                          + "widths=column1Width,column2Width\r\n"
458
                                          + "column1Title,column2Title\r\n"
506
                                          + "column1Title,column2Title\r\n"
459
                                          + "cellcontent,cellcontent\r\n"
507
                                          + "cellcontent,cellcontent\r\n"
-
 
508
                                          + "cellcontent,cellcontent\r\n"
-
 
509
                                          + "cellcontent,cellcontent\r\n"
460
                                          + "etc,etc";
510
                                          + "etc,etc";
461
               ((EA.Element)newobj).Update();
511
               ((EA.Element)newobj).Update();
462
            }
512
            }
463
         }
513
         }
464
         else
514
         else
Line 498... Line 548...
498
         object obj;
548
         object obj;
499
 
549
 
500
         objType = EA_Repository.GetTreeSelectedItem( out obj );
550
         objType = EA_Repository.GetTreeSelectedItem( out obj );
501
         if (objType == EA.ObjectType.otPackage)
551
         if (objType == EA.ObjectType.otPackage)
502
         {
552
         {
503
            object newobj = null;
553
            RelationshipMatrixType dlg = new RelationshipMatrixType();
504
 
-
 
505
            newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenRelationshipMatrix, EA_Constants.EA_DocGenElementType);
554
            DialogResult dlgRes = dlg.ShowDialog();
506
            if (newobj != null)
555
            if (dlgRes == DialogResult.OK)
507
            {
556
            {
-
 
557
               object newobj = null;
-
 
558
               newobj = ((EA.Package)obj).Elements.AddNew(EA_Constants.EA_DocGenRelationshipMatrix, EA_Constants.EA_DocGenElementType);
-
 
559
               if (newobj != null)
-
 
560
               {
508
               ((EA.Element)newobj).Notes  = EA_RelMatrix.optionTemplateForRelationshipMatrix();
561
                  ((EA.Element)newobj).Notes  = EA_RelationshipMatrix.optionTemplateForRelationshipMatrix(dlg.style());
509
               ((EA.Element)newobj).Update();
562
                  ((EA.Element)newobj).Update();
-
 
563
               }
510
            }
564
            }
511
         }
565
         }
512
         else
566
         else
513
         {
567
         {
514
            MessageBox.Show("You must select a package into which the RelationshipMatrix Element will be inserted");
568
            MessageBox.Show("You must select a package into which the RelationshipMatrix Element will be inserted");
Line 698... Line 752...
698
            }
752
            }
699
         }
753
         }
700
      }
754
      }
701
 
755
 
702
 
756
 
703
 
-
 
704
      public string ReadTag(EA.Element theElement, string tagName)
757
      public string ReadTag(EA.Element theElement, string tagName)
705
      {
758
      {
706
         string result;
759
         string result;
707
 
760
 
708
         EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
761
         EA.TaggedValue tag = (EA.TaggedValue)theElement.TaggedValues.GetByName(tagName);
Line 743... Line 796...
743
         }
796
         }
744
         return result;
797
         return result;
745
      }
798
      }
746
 
799
 
747
 
800
 
-
 
801
      public void RemoveAPIStereotypeFromContent()
-
 
802
      {
-
 
803
         EA.ObjectType objType;
-
 
804
         object obj;
-
 
805
         objType = EA_Repository.GetTreeSelectedItem( out obj );
-
 
806
         if (objType == EA.ObjectType.otPackage)
-
 
807
         {
-
 
808
            RemoveAPIStereotypeFromContent((EA.Package)obj);
-
 
809
            EA_Repository.RefreshModelView(((EA.Package)obj).PackageID);
-
 
810
         }
-
 
811
         else if (objType == EA.ObjectType.otDiagram)
-
 
812
         {
-
 
813
            RemoveAPIStereotypeFromDiagram((EA.Diagram)obj);
-
 
814
            EA_Repository.RefreshModelView(((EA.Diagram)obj).PackageID);
-
 
815
         }
-
 
816
         else if (objType == EA.ObjectType.otElement)
-
 
817
         {
-
 
818
            RemoveAPIStereotypeFromContent((EA.Element)obj);
-
 
819
            EA_Repository.RefreshModelView(((EA.Element)obj).PackageID);
-
 
820
         }
-
 
821
      }
-
 
822
 
-
 
823
      private void RemoveAPIStereotypeFromPackage(EA.Package thePackage)
-
 
824
      {
-
 
825
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace(",API","");
-
 
826
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace("API,","");
-
 
827
         thePackage.StereotypeEx = thePackage.StereotypeEx.Replace("API","");
-
 
828
         thePackage.Update();
-
 
829
      }
-
 
830
 
-
 
831
      private void RemoveAPIStereotypeFromDiagram(EA.Diagram theDiagram)
-
 
832
      {
-
 
833
         // diagrams only use one stereotype, not a list of them
-
 
834
         if (theDiagram.Stereotype.Equals("API"))
-
 
835
         {
-
 
836
            theDiagram.Stereotype = "";
-
 
837
            theDiagram.Update();
-
 
838
         }
-
 
839
      }
-
 
840
 
-
 
841
      private void RemoveAPIStereotypeFromElement(EA.Element theElement)
-
 
842
      {
-
 
843
         theElement.StereotypeEx = theElement.StereotypeEx.Replace(",API","");
-
 
844
         theElement.StereotypeEx = theElement.StereotypeEx.Replace("API,","");
-
 
845
         theElement.StereotypeEx = theElement.StereotypeEx.Replace("API","");
-
 
846
         theElement.Update();
-
 
847
      }
-
 
848
 
-
 
849
      private void RemoveAPIStereotypeFromContent(EA.Package thePackage)
-
 
850
      {
-
 
851
         RemoveAPIStereotypeFromPackage(thePackage);
-
 
852
 
-
 
853
         foreach(EA.Diagram diagram in thePackage.Diagrams)
-
 
854
         {
-
 
855
            RemoveAPIStereotypeFromDiagram(diagram);
-
 
856
         }
-
 
857
 
-
 
858
         foreach(EA.Element element in thePackage.Elements)
-
 
859
         {
-
 
860
            RemoveAPIStereotypeFromElement(element);
-
 
861
         }
-
 
862
 
-
 
863
         foreach(EA.Package package in thePackage.Packages)
-
 
864
         {
-
 
865
            RemoveAPIStereotypeFromContent(package); // recursion
-
 
866
         }
-
 
867
      }
-
 
868
 
-
 
869
      private void RemoveAPIStereotypeFromContent(EA.Element theElement)
-
 
870
      {
-
 
871
         RemoveAPIStereotypeFromElement(theElement);
-
 
872
 
-
 
873
         foreach(EA.Diagram diagram in theElement.Diagrams)
-
 
874
         {
-
 
875
            RemoveAPIStereotypeFromDiagram(diagram);
-
 
876
         }
-
 
877
 
-
 
878
         foreach(EA.Element element in theElement.Elements)
-
 
879
         {
-
 
880
            RemoveAPIStereotypeFromContent(element); // recursion
-
 
881
         }
-
 
882
      }
-
 
883
 
-
 
884
 
-
 
885
      public void MarkContentWithAPIStereotype()
-
 
886
      {
-
 
887
         EA.ObjectType objType;
-
 
888
         object obj;
-
 
889
         objType = EA_Repository.GetTreeSelectedItem( out obj );
-
 
890
         if (objType == EA.ObjectType.otPackage)
-
 
891
         {
-
 
892
            MarkContentWithAPIStereotype((EA.Package)obj);
-
 
893
            EA_Repository.RefreshModelView(((EA.Package)obj).PackageID);
-
 
894
         }
-
 
895
         else if (objType == EA.ObjectType.otDiagram)
-
 
896
         {
-
 
897
            MarkDiagramWithAPIStereotype((EA.Diagram)obj);
-
 
898
            EA_Repository.RefreshModelView(((EA.Diagram)obj).PackageID);
-
 
899
         }
-
 
900
         else if (objType == EA.ObjectType.otElement)
-
 
901
         {
-
 
902
            MarkContentWithAPIStereotype((EA.Element)obj);
-
 
903
            EA_Repository.RefreshModelView(((EA.Element)obj).PackageID);
-
 
904
         }
-
 
905
      }
-
 
906
 
-
 
907
      private void MarkPackageWithAPIStereotype(EA.Package thePackage)
-
 
908
      {
-
 
909
         if (thePackage.StereotypeEx.IndexOf("API") < 0)
-
 
910
         {
-
 
911
            if (thePackage.StereotypeEx.Length > 0)
-
 
912
               thePackage.StereotypeEx += ",API";
-
 
913
            else
-
 
914
               thePackage.StereotypeEx = "API";
-
 
915
            thePackage.Update();
-
 
916
         }
-
 
917
      }
-
 
918
 
-
 
919
      private void MarkDiagramWithAPIStereotype(EA.Diagram theDiagram)
-
 
920
      {
-
 
921
         // diagrams only use one stereotype, not a list of them
-
 
922
         theDiagram.Stereotype = "API";
-
 
923
         theDiagram.Update();
-
 
924
      }
-
 
925
 
-
 
926
      private void MarkElementWithAPIStereotype(EA.Element theElement)
-
 
927
      {
-
 
928
         if (theElement.StereotypeEx.IndexOf("API") < 0)
-
 
929
         {
-
 
930
            if (theElement.StereotypeEx.Length > 0)
-
 
931
               theElement.StereotypeEx += ",API";
-
 
932
            else
-
 
933
               theElement.Stereotype = "API";
-
 
934
            theElement.Update();
-
 
935
         }
-
 
936
      }
-
 
937
 
-
 
938
      private void MarkContentWithAPIStereotype(EA.Package thePackage)
-
 
939
      {
-
 
940
         MarkPackageWithAPIStereotype(thePackage);
-
 
941
 
-
 
942
         foreach(EA.Diagram diagram in thePackage.Diagrams)
-
 
943
         {
-
 
944
            MarkDiagramWithAPIStereotype(diagram);
-
 
945
         }
-
 
946
 
-
 
947
         foreach(EA.Element element in thePackage.Elements)
-
 
948
         {
-
 
949
            MarkElementWithAPIStereotype(element);
-
 
950
         }
-
 
951
 
-
 
952
         foreach(EA.Package package in thePackage.Packages)
-
 
953
         {
-
 
954
            MarkContentWithAPIStereotype(package); // recursion
-
 
955
         }
-
 
956
      }
-
 
957
 
-
 
958
      private void MarkContentWithAPIStereotype(EA.Element theElement)
-
 
959
      {
-
 
960
         MarkElementWithAPIStereotype(theElement);
-
 
961
 
-
 
962
         foreach(EA.Diagram diagram in theElement.Diagrams)
-
 
963
         {
-
 
964
            MarkDiagramWithAPIStereotype(diagram);
-
 
965
         }
-
 
966
 
-
 
967
         foreach(EA.Element element in theElement.Elements)
-
 
968
         {
-
 
969
            MarkContentWithAPIStereotype(element); // recursion
-
 
970
         }
-
 
971
      }
-
 
972
 
-
 
973
 
-
 
974
 
748
      #region Temporary or experimental code
975
      #region Temporary or experimental code
749
 
976
 
750
 
977
 
751
      private void parse_element(int parentId, EA.Element theElement, int recurse_level)
978
      private void parse_element(int parentId, EA.Element theElement, int recurse_level)
752
      {
979
      {