Subversion Repositories DevTools

Rev

Rev 2139 | Rev 2145 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2139 ghuddy 1
//-----------------------------------------------------------------------
2
// This is open source licensed under GPL
3
//
4
//
5
using System;
6
using System.Text;
7
using System.Globalization;
2141 ghuddy 8
using System.Collections;
2139 ghuddy 9
using System.Windows.Forms;
10
using ReqPro40;
11
 
12
namespace EA_ReqPro
13
{
14
   public class Main
15
   {
2141 ghuddy 16
      public String EA_Connect(EA.Repository Repository)
2139 ghuddy 17
      {
18
         return "a string";
19
      }
20
 
21
 
2141 ghuddy 22
      public readonly static String GUI_OUTPUT_TAB_NAME = "EA_ReqPro";
2139 ghuddy 23
 
24
 
25
 
2141 ghuddy 26
      /// <summary>
27
      /// Called when EA initialised. Creates an output tab for the add in.
28
      /// </summary>
29
      /// <param name="repository"></param>
30
      public void EA_OnPostInitialized(EA.Repository repository)
31
      {
32
         repository.CreateOutputTab(GUI_OUTPUT_TAB_NAME);
33
         repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
34
      }
35
 
36
 
37
      public void EA_Disconnect()
38
      {
39
         GC.Collect();
40
         GC.WaitForPendingFinalizers();
41
      }
2139 ghuddy 42
 
43
 
2141 ghuddy 44
      /// <summary>
45
      /// Event called when user clicks on an entry in the output
46
      /// window. If an element has been associated with the message, it will
47
      /// be automatically selected in the project browser.
48
      /// </summary>
49
      /// <param name="repository"></param>
50
      /// <param name="outputTabNea"></param>
51
      /// <param name="lineText"></param>
52
      /// <param name="lineIdentifier"></param>
53
      public void EA_OnOutputItemClicked( EA.Repository repository,
54
                                          String outputTabName,
55
                                          String lineText,
56
                                          Int32 identifier)
57
      {
58
         if ((outputTabName == GUI_OUTPUT_TAB_NAME) && (identifier > 0))
59
         {
60
            try
61
            {
62
               EA.Element element = repository.GetElementByID(identifier);
63
               repository.ShowInProjectView(element);
64
            }
65
            catch
66
            {
67
               try
68
               {
69
                  EA.Package package = repository.GetPackageByID(identifier);
70
                  repository.ShowInProjectView(package);
71
               }
72
               catch
73
               {
74
               }
75
            }
76
         }
77
      }
2139 ghuddy 78
 
2141 ghuddy 79
 
80
      public object EA_GetMenuItems(EA.Repository repository, string location, string menu)
2139 ghuddy 81
      {
82
         switch( menu )
83
         {
84
            case "":
85
               return "-&EA_ReqPro";
86
 
2141 ghuddy 87
            case "-&Traceability Use":
88
            {
89
               string[] ar = {
90
                                "&Prepare Package for Traceability Use",
91
                                "&Import for Traceability Use",
92
                                "&Display Change Log",
93
               };
94
               return ar;            }
2139 ghuddy 95
 
96
            case "-&EA_ReqPro":
2141 ghuddy 97
            {
98
               string[] ar = {
99
                                "-&Traceability Use",
100
                                "&Import for Document Model Use",
101
                                "&Export to ReqPro Compatible CSV File",
2139 ghuddy 102
                             };
103
               return ar;
2141 ghuddy 104
            }
2139 ghuddy 105
         }
106
         return "";
107
      }
108
 
109
 
110
      bool IsProjectOpen(EA.Repository Repository)
111
      {
112
         try
113
         {
114
            EA.Collection collection = Repository.Models;
115
            return true;
116
         }
117
         catch
118
         {
119
            return false;
120
         }
121
      }
122
 
123
 
124
      public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)
125
      {
126
         object o;
127
         EA.ObjectType type;
128
 
129
         isChecked = false;
130
 
131
         if (IsProjectOpen(repository))
132
         {
133
            switch (itemName)
134
            {
2141 ghuddy 135
               case "&Import for Document Model Use":
136
               case "&Prepare Package for Traceability Use":
137
               case "&Export to ReqPro Compatible CSV File":
2139 ghuddy 138
                  type = repository.GetTreeSelectedItem(out o);
139
                  if (type == EA.ObjectType.otPackage)
140
                  {
141
                     isEnabled = true;
142
                  }
143
                  else
144
                  {
145
                     isEnabled = false;
146
                  }
147
                  break;
148
 
2141 ghuddy 149
               case "-&Traceability Use":
150
                  isEnabled = true;
151
                  break;
152
 
153
               case "&Import for Traceability Use":
2139 ghuddy 154
                  type = repository.GetTreeSelectedItem(out o);
155
                  if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Stereotype == "ReqProDB"))
156
                  {
157
                     isEnabled = true;
158
                  }
159
                  else
160
                  {
161
                     isEnabled = false;
162
                  }
163
                  break;
164
 
2141 ghuddy 165
               case "&Display Change Log":
166
                  type = repository.GetTreeSelectedItem(out o);
167
                  if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Name == "Change Log"))
2139 ghuddy 168
                  {
169
                     isEnabled = true;
170
                  }
171
                  else
172
                  {
173
                     isEnabled = false;
174
                  }
175
                  break;
176
 
177
            }
178
         }
179
         else
180
         {
181
            isEnabled = false;
182
         }
183
      }
184
 
185
 
186
      public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName)
187
      {
188
         switch( itemName )
189
         {
2141 ghuddy 190
            case "&Prepare Package for Traceability Use":
191
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
192
               ReqProDB_Artifact RQ_Artifact = new ReqProDB_Artifact();
193
               RQ_Artifact.AssociatePackageToReqProDatabase(repository);
2139 ghuddy 194
               break;
195
 
2141 ghuddy 196
            case "&Import for Traceability Use":
197
            {
198
               ImportReqProDatabase import_parser = new ImportReqProDatabase(repository);
199
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
200
               import_parser.parse(repository); 
2139 ghuddy 201
               break;
2141 ghuddy 202
            }
2139 ghuddy 203
 
2141 ghuddy 204
            case "&Import for Document Model Use":
205
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
206
               CopyReqProDatabase copy_parser = new CopyReqProDatabase(repository);
207
               copy_parser.prompt_and_parse(repository);
2139 ghuddy 208
               break;
209
 
2141 ghuddy 210
            case "&Export to ReqPro Compatible CSV File":
211
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
212
               ExportToReqProCSVForm export_dlg = new ExportToReqProCSVForm();
213
               DialogResult dlgRes = export_dlg.ShowDialog();
214
               if (dlgRes == DialogResult.OK)
2139 ghuddy 215
               {
2141 ghuddy 216
                  export_dlg.Export(repository);
2139 ghuddy 217
               }
2141 ghuddy 218
               break;
2139 ghuddy 219
 
2141 ghuddy 220
            case "&Display Change Log":
2139 ghuddy 221
            {
2141 ghuddy 222
               ImportReqProDatabase import_parser = new ImportReqProDatabase(repository);
223
               EA.Element changeLog = (EA.Element)repository.GetTreeSelectedObject();
224
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
225
               import_parser.displayChangeLog(repository, changeLog);
226
               break;
2139 ghuddy 227
            }
228
         }
229
      }
230
 
231
 
232
   }
233
}