Subversion Repositories DevTools

Rev

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

Rev 2145 Rev 2151
Line 6... Line 6...
6
using System.Text;
6
using System.Text;
7
using System.Globalization;
7
using System.Globalization;
8
using System.Collections;
8
using System.Collections;
9
using System.Windows.Forms;
9
using System.Windows.Forms;
10
using ReqPro40;
10
using ReqPro40;
-
 
11
using System.Threading;
11
 
12
 
12
namespace EA_ReqPro
13
namespace EA_ReqPro
13
{
14
{
14
   public class Main
15
   public class Main
15
   {
16
   {
16
      public String EA_Connect(EA.Repository Repository)
17
      public String EA_Connect(EA.Repository Repository)
17
      {
18
      {
18
         return "a string";
19
         return "a string";
19
      }
20
      }
20
 
21
 
-
 
22
      private Thread ourThread = null;
21
 
23
 
22
      public readonly static String GUI_OUTPUT_TAB_NAME = "EA_ReqPro";
24
      public readonly static String GUI_OUTPUT_TAB_NAME = "EA_ReqPro";
-
 
25
      public static EA.Repository EA_Repository = null;
23
 
26
 
24
 
-
 
-
 
27
      public static bool mustAbort = false;
25
 
28
 
26
      /// <summary>
29
      /// <summary>
27
      /// Called when EA initialised. Creates an output tab for the add in.
30
      /// Called when EA initialised. Creates an output tab for the add in.
28
      /// </summary>
31
      /// </summary>
29
      /// <param name="repository"></param>
32
      /// <param name="repository"></param>
Line 77... Line 80...
77
      }
80
      }
78
 
81
 
79
 
82
 
80
      public object EA_GetMenuItems(EA.Repository repository, string location, string menu)
83
      public object EA_GetMenuItems(EA.Repository repository, string location, string menu)
81
      {
84
      {
-
 
85
         string[] ar;
-
 
86
 
82
         switch( menu )
87
         switch( menu )
83
         {
88
         {
84
            case "":
89
            case "":
85
               return "-&EA_ReqPro";
90
               return "-&EA_ReqPro";
86
 
91
 
87
            case "-&EA_ReqPro":
92
            case "-&EA_ReqPro":
-
 
93
               if (ourThread != null && ourThread.IsAlive == true)
88
            {
94
               {
-
 
95
                  ar = new string[] {"&Abort Import"};
89
               string[] ar = {
96
                  return ar;
-
 
97
               }
-
 
98
               else
-
 
99
               {
-
 
100
                  ar = new string[]{
90
                                "&Import for Traceability Use",
101
                                   "&Import for Traceability Use",
91
                                "&Display Change Log",
102
                                   "&Display Change Log",
92
                                "&Import for Document Model Use",
103
                                   "&Import for Document Model Use",
93
                                "&Export to ReqPro Compatible CSV File",
104
                                   "&Export to ReqPro Compatible CSV File",
94
                                "&Create Requirement Diagram",
105
                                   "&Create Requirement Diagram",
95
                             };
106
                  };
96
               return ar;
107
                  return ar;
97
            }
108
               }
98
         }
109
         }
-
 
110
 
99
         return "";
111
         return "";
100
      }
112
      }
101
 
113
 
102
 
114
 
103
      bool IsProjectOpen(EA.Repository Repository)
115
      bool IsProjectOpen(EA.Repository Repository)
Line 114... Line 126...
114
      }
126
      }
115
 
127
 
116
 
128
 
117
      public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)
129
      public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)
118
      {
130
      {
-
 
131
         EA_Repository = repository;
-
 
132
 
119
         object o;
133
         object o;
120
         EA.ObjectType type;
134
         EA.ObjectType type;
121
 
135
 
122
         isChecked = false;
136
         isChecked = false;
123
 
137
 
-
 
138
 
124
         if (IsProjectOpen(repository))
139
         if (IsProjectOpen(repository))
125
         {
140
         {
126
            switch (itemName)
141
            switch (itemName)
127
            {
142
            {
-
 
143
               case "&Abort Import":
128
               case "&Import for Document Model Use":
144
               case "&Import for Document Model Use":
129
               case "&Export to ReqPro Compatible CSV File":
145
               case "&Export to ReqPro Compatible CSV File":
130
               case "&Create Requirement Diagram":
146
               case "&Create Requirement Diagram":
131
               case "&Import for Traceability Use":
147
               case "&Import for Traceability Use":
132
                  isEnabled = true;
148
                  isEnabled = true;
Line 153... Line 169...
153
      }
169
      }
154
 
170
 
155
 
171
 
156
      public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName)
172
      public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName)
157
      {
173
      {
-
 
174
         EA_Repository = repository;
-
 
175
 
158
         switch( itemName )
176
         switch( itemName )
159
         {
177
         {
-
 
178
            case "&Abort Import":
-
 
179
               if (ourThread != null && ourThread.IsAlive == true)
-
 
180
               {
-
 
181
                  mustAbort = true;
-
 
182
               }
-
 
183
               break;
-
 
184
 
160
            case "&Import for Traceability Use":
185
            case "&Import for Traceability Use":
-
 
186
               if (ourThread == null || ourThread.IsAlive == false)
161
            {
187
               {
162
               ImportReqProDatabase import_parser = new ImportReqProDatabase(repository);
188
                  ourThread = new Thread(new ThreadStart(ImportReqProDatabase_Thread));
163
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
189
                  ourThread.ApartmentState = ApartmentState.STA;
164
               import_parser.prompt_and_parse(repository, ReqProDB_Artifact.MODE.TRACEABILITY); 
190
                  ourThread.Start();
-
 
191
               }
165
               break;
192
               break;
166
            }
-
 
167
 
193
 
168
            case "&Import for Document Model Use":
194
            case "&Import for Document Model Use":
169
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
195
               if (ourThread == null || ourThread.IsAlive == false)
-
 
196
               {
170
               CopyReqProDatabase copy_parser = new CopyReqProDatabase(repository);
197
                  ourThread = new Thread(new ThreadStart(CopyReqProDatabase_Thread));
171
               copy_parser.prompt_and_parse(repository, ReqProDB_Artifact.MODE.DOC_MODEL);
198
                  ourThread.ApartmentState = ApartmentState.STA;
-
 
199
                  ourThread.Start();
-
 
200
               }
172
               break;
201
               break;
173
 
202
 
174
            case "&Export to ReqPro Compatible CSV File":
203
            case "&Export to ReqPro Compatible CSV File":
175
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
204
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
-
 
205
               repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
176
               ExportToReqProCSVForm export_dlg = new ExportToReqProCSVForm();
206
               ExportToReqProCSVForm export_dlg = new ExportToReqProCSVForm();
177
               DialogResult dlgRes = export_dlg.ShowDialog();
207
               DialogResult dlgRes = export_dlg.ShowDialog();
178
               if (dlgRes == DialogResult.OK)
208
               if (dlgRes == DialogResult.OK)
179
               {
209
               {
180
                  export_dlg.Export(repository);
210
                  export_dlg.Export();
181
               }
211
               }
182
               break;
212
               break;
183
 
213
 
184
            case "&Display Change Log":
214
            case "&Display Change Log":
185
            {
215
            {
186
               ImportReqProDatabase import_parser = new ImportReqProDatabase(repository);
216
               ImportReqProDatabase import_parser = new ImportReqProDatabase();
187
               EA.Element changeLog = (EA.Element)repository.GetTreeSelectedObject();
217
               EA.Element changeLog = (EA.Element)repository.GetTreeSelectedObject();
188
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
218
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
189
               import_parser.displayChangeLog(repository, changeLog);
219
               import_parser.displayChangeLog(changeLog);
190
               break;
220
               break;
191
            }
221
            }
192
 
222
 
193
            case "&Create Requirement Diagram":
223
            case "&Create Requirement Diagram":
194
            {
224
            {
195
               EA_Utilities EA_Utils = new EA_Utilities(repository);
225
               EA_Utilities EA_Utils = new EA_Utilities();
196
               ArrayList allowedElementTypes = new ArrayList();
226
               ArrayList allowedElementTypes = new ArrayList();
197
               allowedElementTypes.Add("Requirement");
227
               allowedElementTypes.Add("Requirement");
198
               //allowedElementTypes.Add("UseCase");
228
               //allowedElementTypes.Add("UseCase");
199
               ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
229
               ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
200
               EA.Package thePackage = (EA.Package)repository.GetTreeSelectedObject();
230
               EA.Package thePackage = (EA.Package)repository.GetTreeSelectedObject();
Line 218... Line 248...
218
            }
248
            }
219
 
249
 
220
         }
250
         }
221
      }
251
      }
222
 
252
 
-
 
253
      private static void ImportReqProDatabase_Thread()
-
 
254
      {
-
 
255
         mustAbort = false;
-
 
256
         ImportReqProDatabase import_parser = new ImportReqProDatabase();
-
 
257
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
-
 
258
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
-
 
259
         import_parser.prompt_and_parse(ReqProDB_Artifact.MODE.TRACEABILITY); 
-
 
260
         if (mustAbort)
-
 
261
            MessageBoxEx.Show("Import Aborted");
-
 
262
      }
-
 
263
 
-
 
264
      private static void CopyReqProDatabase_Thread()
-
 
265
      {
-
 
266
         mustAbort = false;
-
 
267
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
-
 
268
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
-
 
269
         CopyReqProDatabase copy_parser = new CopyReqProDatabase();
-
 
270
         copy_parser.prompt_and_parse(ReqProDB_Artifact.MODE.DOC_MODEL);
-
 
271
         if (mustAbort)
-
 
272
            MessageBoxEx.Show("Import Aborted");
-
 
273
      }
223
 
274
 
224
   }
275
   }
225
}
276
}