Subversion Repositories DevTools

Rev

Rev 2175 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2175 Rev 2177
Line 1... Line 1...
1
//-----------------------------------------------------------------------
1
//-----------------------------------------------------------------------
2
// This is open source licensed under GPL
2
// This is open source licensed under GPL
3
//
3
//
4
//
4
//
5
using System;
5
using System;
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
using System.Threading;
12
 
12
 
13
namespace EA_ReqPro
13
namespace EA_ReqPro
14
{
14
{
15
   public class Main
15
   public class Main
16
   {
16
   {
17
      public String EA_Connect(EA.Repository Repository)
17
      public String EA_Connect(EA.Repository Repository)
18
      {
18
      {
19
         return "a string";
19
         return "a string";
20
      }
20
      }
21
 
21
 
22
      private Thread ourThread = null;
22
      private Thread ourThread = null;
23
 
23
 
24
      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;
25
      public static EA.Repository EA_Repository = null;
26
 
26
 
27
      public static int abortRequests = 0;
27
      public static int abortRequests = 0;
28
      public static bool mustAbort = false;
28
      public static bool mustAbort = false;
29
 
29
 
30
      // EA_ReqPro Menu strings
30
      // EA_ReqPro Menu strings
31
      private const string MI_Root            = "-&EA ReqPro";
31
      private const string MI_Root            = "-&EA ReqPro";
32
 
32
 
33
      private const string MI_Separator                  = "-";
33
      private const string MI_Separator                  = "-";
34
      private const string MI_ImportForTraceabilityUse   = "&Import for Traceability Use";
34
      private const string MI_ImportForTraceabilityUse   = "&Import for Traceability Use";
Line 51... Line 51...
51
                                                    MI_Separator,
51
                                                    MI_Separator,
52
                                                    MI_CreateReqDiagram,
52
                                                    MI_CreateReqDiagram,
53
                                                    MI_CreateReqDiagramUsingSrch,
53
                                                    MI_CreateReqDiagramUsingSrch,
54
                                                    MI_Separator,
54
                                                    MI_Separator,
55
                                                    MI_About };
55
                                                    MI_About };
56
 
56
 
57
      private string[] MI_AbortMenu = new string[] { MI_Abort };
57
      private string[] MI_AbortMenu = new string[] { MI_Abort };
58
 
58
 
59
 
59
 
60
      /// <summary>
60
      /// <summary>
61
      /// Called when EA initialised. Creates an output tab for the add in.
61
      /// Called when EA initialised. Creates an output tab for the add in.
62
      /// </summary>
62
      /// </summary>
63
      /// <param name="repository"></param>
63
      /// <param name="repository"></param>
64
      public void EA_OnPostInitialized(EA.Repository repository)
64
      public void EA_OnPostInitialized(EA.Repository repository)
65
      {
65
      {
66
         repository.CreateOutputTab(GUI_OUTPUT_TAB_NAME);
66
         repository.CreateOutputTab(GUI_OUTPUT_TAB_NAME);
67
         repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
67
         repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
68
      }
68
      }
69
 
69
 
70
 
70
 
71
      public void EA_Disconnect()
71
      public void EA_Disconnect()
72
      {
72
      {
73
         GC.Collect();
73
         GC.Collect();
74
         GC.WaitForPendingFinalizers();
74
         GC.WaitForPendingFinalizers();
75
      }
75
      }
76
 
76
 
77
 
77
 
78
      /// <summary>
78
      /// <summary>
79
      /// Event called when user clicks on an entry in the output
79
      /// Event called when user clicks on an entry in the output
80
      /// window. If an element has been associated with the message, it will
80
      /// window. If an element has been associated with the message, it will
81
      /// be automatically selected in the project browser.
81
      /// be automatically selected in the project browser.
82
      /// </summary>
82
      /// </summary>
83
      /// <param name="repository"></param>
83
      /// <param name="repository"></param>
84
      /// <param name="outputTabNea"></param>
84
      /// <param name="outputTabNea"></param>
85
      /// <param name="lineText"></param>
85
      /// <param name="lineText"></param>
86
      /// <param name="lineIdentifier"></param>
86
      /// <param name="lineIdentifier"></param>
87
      public void EA_OnOutputItemClicked( EA.Repository repository,
87
      public void EA_OnOutputItemClicked( EA.Repository repository,
88
                                          String outputTabName,
88
                                          String outputTabName,
89
                                          String lineText,
89
                                          String lineText,
90
                                          Int32 identifier)
90
                                          Int32 identifier)
91
      {
91
      {
92
         if ((outputTabName == GUI_OUTPUT_TAB_NAME) && (identifier > 0))
92
         if ((outputTabName == GUI_OUTPUT_TAB_NAME) && (identifier > 0))
93
         {
93
         {
94
            try
94
            try
95
            {
95
            {
96
               EA.Element element = repository.GetElementByID(identifier);
96
               EA.Element element = repository.GetElementByID(identifier);
97
               if (element.MetaType == "Package")
97
               if (element.MetaType == "Package")
98
               {
98
               {
99
                  EA.Package package = repository.GetPackageByID(element.PackageID);
99
                  EA.Package package = repository.GetPackageByID(element.PackageID);
100
                  repository.ShowInProjectView(package);
100
                  repository.ShowInProjectView(package);
101
               }
101
               }
102
               else
102
               else
103
               {
103
               {
104
                  repository.ShowInProjectView(element);
104
                  repository.ShowInProjectView(element);
105
               }
105
               }
106
            }
106
            }
107
            catch
107
            catch
108
            {
108
            {
109
               try
109
               try
110
               {
110
               {
111
                  EA.Package package = repository.GetPackageByID(identifier);
111
                  EA.Package package = repository.GetPackageByID(identifier);
112
                  repository.ShowInProjectView(package);
112
                  repository.ShowInProjectView(package);
113
               }
113
               }
114
               catch
114
               catch
115
               {
115
               {
116
                  try
116
                  try
117
                  {
117
                  {
118
                     EA.Diagram diagram = repository.GetDiagramByID(identifier);
118
                     EA.Diagram diagram = repository.GetDiagramByID(identifier);
119
                     repository.ShowInProjectView(diagram);
119
                     repository.ShowInProjectView(diagram);
120
                  }
120
                  }
121
                  catch
121
                  catch
122
                  {
122
                  {
123
                  }
123
                  }
124
               }
124
               }
125
            }
125
            }
126
            
126
            
127
         }
127
         }
128
      }
128
      }
129
 
129
 
130
 
130
 
131
      public object EA_GetMenuItems(EA.Repository repository, string location, string menu)
131
      public object EA_GetMenuItems(EA.Repository repository, string location, string menu)
132
      {
132
      {
133
         switch( menu )
133
         switch( menu )
134
         {
134
         {
135
            case "":
135
            case "":
136
               return MI_Root;
136
               return MI_Root;
137
 
137
 
138
            case MI_Root:
138
            case MI_Root:
139
               if (ourThread != null && ourThread.IsAlive == true)
139
               if (ourThread != null && ourThread.IsAlive == true)
140
               {
140
               {
141
                  return MI_AbortMenu;
141
                  return MI_AbortMenu;
142
               }
142
               }
143
               else
143
               else
144
               {
144
               {
145
                  return MI_RootMenu;
145
                  return MI_RootMenu;
146
               }
146
               }
147
         }
147
         }
148
 
148
 
149
         return "";
149
         return "";
150
      }
150
      }
151
 
151
 
152
 
152
 
153
      bool IsProjectOpen(EA.Repository Repository)
153
      bool IsProjectOpen(EA.Repository Repository)
154
      {
154
      {
155
         try
155
         try
156
         {
156
         {
157
            EA.Collection collection = Repository.Models;
157
            EA.Collection collection = Repository.Models;
158
            return true;
158
            return true;
159
         }
159
         }
160
         catch
160
         catch
161
         {
161
         {
162
            return false;
162
            return false;
163
         }
163
         }
164
      }
164
      }
165
 
165
 
166
 
166
 
167
      public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)
167
      public void EA_GetMenuState(EA.Repository repository, string location, string menuName, string itemName, ref bool isEnabled, ref bool isChecked)
168
      {
168
      {
169
         EA_Repository = repository;
169
         EA_Repository = repository;
170
 
170
 
171
         object o;
171
         object o;
172
         EA.ObjectType type;
172
         EA.ObjectType type;
173
 
173
 
174
         isChecked = false;
174
         isChecked = false;
175
 
175
 
176
 
176
 
177
         if (IsProjectOpen(repository))
177
         if (IsProjectOpen(repository))
178
         {
178
         {
179
            switch (itemName)
179
            switch (itemName)
180
            {
180
            {
181
               case MI_Abort:
181
               case MI_Abort:
182
               case MI_ImportForDocModelUse:
182
               case MI_ImportForDocModelUse:
183
               case MI_ExportToReqPro:
183
               case MI_ExportToReqPro:
184
               case MI_ExportToReqProCSV:
184
               case MI_ExportToReqProCSV:
185
               case MI_CreateReqDiagram:
185
               case MI_CreateReqDiagram:
186
               case MI_CreateReqDiagramUsingSrch:
186
               case MI_CreateReqDiagramUsingSrch:
187
               case MI_ImportForTraceabilityUse:
187
               case MI_ImportForTraceabilityUse:
188
                  isEnabled = true;
188
                  isEnabled = true;
189
                  break;
189
                  break;
190
 
190
 
191
               case MI_DisplayChangeLog:
191
               case MI_DisplayChangeLog:
192
                  type = repository.GetTreeSelectedItem(out o);
192
                  type = repository.GetTreeSelectedItem(out o);
193
                  if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Name.StartsWith("Change Log")))
193
                  if ( (type == EA.ObjectType.otElement) && (((EA.Element)o).Name.StartsWith("Change Log")))
194
                  {
194
                  {
195
                     isEnabled = true;
195
                     isEnabled = true;
196
                  }
196
                  }
197
                  else
197
                  else
198
                  {
198
                  {
199
                     isEnabled = false;
199
                     isEnabled = false;
200
                  }
200
                  }
201
                  break;
201
                  break;
202
            }
202
            }
203
         }
203
         }
204
         else
204
         else
205
         {
205
         {
206
            isEnabled = false;
206
            isEnabled = false;
207
         }
207
         }
208
      }
208
      }
209
 
209
 
210
 
210
 
211
      public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName)
211
      public void EA_MenuClick(EA.Repository repository, string location, string menu, string itemName)
212
      {
212
      {
213
         EA_Repository = repository;
213
         EA_Repository = repository;
214
 
214
 
215
         switch( itemName )
215
         switch( itemName )
216
         {
216
         {
217
            // This menu option appears only when a thread is active. It allows the user to initiate
217
            // This menu option appears only when a thread is active. It allows the user to initiate
218
            // an abort of the thread.
218
            // an abort of the thread.
219
            case MI_Abort:
219
            case MI_Abort:
220
               if (ourThread != null && ourThread.IsAlive == true)
220
               if (ourThread != null && ourThread.IsAlive == true)
221
               {
221
               {
222
                  if (abortRequests > 0)
222
                  if (abortRequests > 0)
223
                  {
223
                  {
224
                     // if user has made a second abort request, it is probably because the thread does not
224
                     // if user has made a second abort request, it is probably because the thread does not
225
                     // appear to be aborting. This can happen sometimes. I have noticed occasional lockups,
225
                     // appear to be aborting. This can happen sometimes. I have noticed occasional lockups,
226
                     // and every time this happens, the thread seems to be locked up in a call to an EA
226
                     // and every time this happens, the thread seems to be locked up in a call to an EA
227
                     // automation interface function, so perhaps there is some wierd interaction between
227
                     // automation interface function, so perhaps there is some wierd interaction between
228
                     // the thread and the use of the menu in the main EA process? Anyway, lets try to abort
228
                     // the thread and the use of the menu in the main EA process? Anyway, lets try to abort
229
                     // the thread now because it does not appear as if it is going to quit gracefully.
229
                     // the thread now because it does not appear as if it is going to quit gracefully.
230
                     ourThread.Abort();
230
                     ourThread.Abort();
231
                     ReqProDatabase.close();
231
                     ReqProDatabase.close();
232
                     break;
232
                     break;
233
                  }
233
                  }
234
                  else
234
                  else
235
                  {
235
                  {
236
                     // try to quit gracefully.
236
                     // try to quit gracefully.
237
                     mustAbort = true;
237
                     mustAbort = true;
238
                     abortRequests++;
238
                     abortRequests++;
239
                  }
239
                  }
240
               }
240
               }
241
               break;
241
               break;
242
 
242
 
243
            case MI_ImportForTraceabilityUse:
243
            case MI_ImportForTraceabilityUse:
244
               if (ourThread == null || ourThread.IsAlive == false)
244
               if (ourThread == null || ourThread.IsAlive == false)
245
               {
245
               {
246
                  ourThread = new Thread(new ThreadStart(ImportReqProDatabase_Thread));
246
                  ourThread = new Thread(new ThreadStart(ImportReqProDatabase_Thread));
247
                  ourThread.ApartmentState = ApartmentState.STA;
247
                  ourThread.SetApartmentState(ApartmentState.STA);
248
                  ourThread.Start();
248
                  ourThread.Start();
249
               }
249
               }
250
               break;
250
               break;
251
 
251
 
252
            case MI_ImportForDocModelUse:
252
            case MI_ImportForDocModelUse:
253
               if (ourThread == null || ourThread.IsAlive == false)
253
               if (ourThread == null || ourThread.IsAlive == false)
254
               {
254
               {
255
                  ourThread = new Thread(new ThreadStart(CopyReqProDatabase_Thread));
255
                  ourThread = new Thread(new ThreadStart(CopyReqProDatabase_Thread));
256
                  ourThread.ApartmentState = ApartmentState.STA;
256
                  ourThread.SetApartmentState(ApartmentState.STA);
257
                  ourThread.Start();
257
                  ourThread.Start();
258
               }
258
               }
259
               break;
259
               break;
260
 
260
 
261
            case MI_ExportToReqPro:
261
            case MI_ExportToReqPro:
262
               if (ourThread == null || ourThread.IsAlive == false)
262
               if (ourThread == null || ourThread.IsAlive == false)
263
               {
263
               {
264
                  ourThread = new Thread(new ThreadStart(ExportToReqPro_Thread));
264
                  ourThread = new Thread(new ThreadStart(ExportToReqPro_Thread));
265
                  ourThread.ApartmentState = ApartmentState.STA;
265
                  ourThread.SetApartmentState(ApartmentState.STA);
266
                  ourThread.Start();
266
                  ourThread.Start();
267
               }
267
               }
268
               break;
268
               break;
269
 
269
 
270
            case MI_ExportToReqProCSV:
270
            case MI_ExportToReqProCSV:
271
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
271
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
272
               repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
272
               repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
273
               ExportToReqProCSVForm export_dlg = new ExportToReqProCSVForm();
273
               ExportToReqProCSVForm export_dlg = new ExportToReqProCSVForm();
274
               DialogResult dlgRes = export_dlg.ShowDialog();
274
               DialogResult dlgRes = export_dlg.ShowDialog();
275
               if (dlgRes == DialogResult.OK)
275
               if (dlgRes == DialogResult.OK)
276
               {
276
               {
277
                  export_dlg.Export();
277
                  export_dlg.Export();
278
               }
278
               }
279
               break;
279
               break;
280
 
280
 
281
            case MI_DisplayChangeLog:
281
            case MI_DisplayChangeLog:
282
            {
282
            {
283
               ImportReqProDatabase import_parser = new ImportReqProDatabase();
283
               ImportReqProDatabase import_parser = new ImportReqProDatabase();
284
               EA.Element changeLog = (EA.Element)repository.GetTreeSelectedObject();
284
               EA.Element changeLog = (EA.Element)repository.GetTreeSelectedObject();
285
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
285
               repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
286
               import_parser.displayChangeLog(changeLog);
286
               import_parser.displayChangeLog(changeLog);
287
               break;
287
               break;
288
            }
288
            }
289
 
289
 
290
            case MI_CreateReqDiagram:
290
            case MI_CreateReqDiagram:
291
            {
291
            {
292
               ArrayList allowedElementTypes = new ArrayList();
292
               ArrayList allowedElementTypes = new ArrayList();
293
               allowedElementTypes.Add("Requirement");
293
               allowedElementTypes.Add("Requirement");
294
               //allowedElementTypes.Add("UseCase");
294
               //allowedElementTypes.Add("UseCase");
295
               EA_ElementAccumulator reqLister = new EA_ElementAccumulator(allowedElementTypes);
295
               EA_ElementAccumulator reqLister = new EA_ElementAccumulator(allowedElementTypes);
296
               EA.Package thePackage = (EA.Package)repository.GetTreeSelectedObject();
296
               EA.Package thePackage = (EA.Package)repository.GetTreeSelectedObject();
297
               EA_Parsing.findAndProcessPackageElements( thePackage, reqLister, true );
297
               EA_Parsing.findAndProcessPackageElements( thePackage, reqLister, true );
298
               createRequirementDiagram(thePackage, reqLister.Elements);
298
               createRequirementDiagram(thePackage, reqLister.Elements);
299
               break;
299
               break;
300
            }
300
            }
301
 
301
 
302
            case MI_CreateReqDiagramUsingSrch:
302
            case MI_CreateReqDiagramUsingSrch:
303
            {
303
            {
304
               QueryForm qf = new QueryForm();
304
               QueryForm qf = new QueryForm();
305
               DialogResult qf_dlgRes = qf.ShowDialog();
305
               DialogResult qf_dlgRes = qf.ShowDialog();
306
               if (qf_dlgRes == DialogResult.OK)
306
               if (qf_dlgRes == DialogResult.OK)
307
               {
307
               {
308
                  EA.Package thePackage = (EA.Package)repository.GetTreeSelectedObject();
308
                  EA.Package thePackage = (EA.Package)repository.GetTreeSelectedObject();
309
                  EA.Collection c = EA_Repository.GetElementsByQuery(qf.textBox_query_name.Text, qf.textBox_search_term.Text);
309
                  EA.Collection c = EA_Repository.GetElementsByQuery(qf.textBox_query_name.Text, qf.textBox_search_term.Text);
310
                  createRequirementDiagram(thePackage, c);
310
                  createRequirementDiagram(thePackage, c);
311
               }
311
               }
312
               break;
312
               break;
313
            }
313
            }
314
 
314
 
315
            case MI_About:
315
            case MI_About:
316
               AboutForm anAbout = new AboutForm();
316
               AboutForm anAbout = new AboutForm();
317
               anAbout.ShowDialog();
317
               anAbout.ShowDialog();
318
               break;
318
               break;
319
         }
319
         }
320
      }
320
      }
321
 
321
 
322
      private void createRequirementDiagram(EA.Package containerPackage, EA.Collection c)
322
      private void createRequirementDiagram(EA.Package containerPackage, EA.Collection c)
323
      {
323
      {
324
         EA.Diagram newDiagram = (EA.Diagram)containerPackage.Diagrams.AddNew("Requirements","Logical");
324
         EA.Diagram newDiagram = (EA.Diagram)containerPackage.Diagrams.AddNew("Requirements","Logical");
325
         newDiagram.Update();
325
         newDiagram.Update();
326
         containerPackage.Update();
326
         containerPackage.Update();
327
 
327
 
328
         foreach (EA.Element element in c)
328
         foreach (EA.Element element in c)
329
         {
329
         {
330
            EA.DiagramObject newDiagramObject = (EA.DiagramObject)newDiagram.DiagramObjects.AddNew("l=1;r=10;t=1;b=1", "");
330
            EA.DiagramObject newDiagramObject = (EA.DiagramObject)newDiagram.DiagramObjects.AddNew("l=1;r=10;t=1;b=1", "");
331
            newDiagramObject.ElementID = element.ElementID;
331
            newDiagramObject.ElementID = element.ElementID;
332
            newDiagramObject.Update();
332
            newDiagramObject.Update();
333
         }
333
         }
334
         newDiagram.DiagramObjects.Refresh();
334
         newDiagram.DiagramObjects.Refresh();
335
         containerPackage.Update();
335
         containerPackage.Update();
336
         EA_Repository.GetProjectInterface().LayoutDiagramEx( newDiagram.DiagramGUID,
336
         EA_Repository.GetProjectInterface().LayoutDiagramEx( newDiagram.DiagramGUID,
337
            EA.ConstLayoutStyles.lsDiagramDefault, 4, 20, 20, false);
337
            EA.ConstLayoutStyles.lsDiagramDefault, 4, 20, 20, false);
338
      }
338
      }
339
 
339
 
340
      private void createRequirementDiagram(EA.Package containerPackage, ArrayList elements)
340
      private void createRequirementDiagram(EA.Package containerPackage, ArrayList elements)
341
      {
341
      {
342
         EA.Diagram newDiagram = (EA.Diagram)containerPackage.Diagrams.AddNew("Requirements","Logical");
342
         EA.Diagram newDiagram = (EA.Diagram)containerPackage.Diagrams.AddNew("Requirements","Logical");
343
         newDiagram.Update();
343
         newDiagram.Update();
344
         containerPackage.Update();
344
         containerPackage.Update();
345
 
345
 
346
         foreach (EA.Element element in elements)
346
         foreach (EA.Element element in elements)
347
         {
347
         {
348
            EA.DiagramObject newDiagramObject = (EA.DiagramObject)newDiagram.DiagramObjects.AddNew("l=1;r=10;t=1;b=1", "");
348
            EA.DiagramObject newDiagramObject = (EA.DiagramObject)newDiagram.DiagramObjects.AddNew("l=1;r=10;t=1;b=1", "");
349
            newDiagramObject.ElementID = element.ElementID;
349
            newDiagramObject.ElementID = element.ElementID;
350
            newDiagramObject.Update();
350
            newDiagramObject.Update();
351
         }
351
         }
352
         newDiagram.DiagramObjects.Refresh();
352
         newDiagram.DiagramObjects.Refresh();
353
         containerPackage.Update();
353
         containerPackage.Update();
354
         EA_Repository.GetProjectInterface().LayoutDiagramEx( newDiagram.DiagramGUID,
354
         EA_Repository.GetProjectInterface().LayoutDiagramEx( newDiagram.DiagramGUID,
355
            EA.ConstLayoutStyles.lsDiagramDefault, 4, 20, 20, false);
355
            EA.ConstLayoutStyles.lsDiagramDefault, 4, 20, 20, false);
356
      }
356
      }
357
 
357
 
358
 
358
 
359
      /// <summary>
359
      /// <summary>
360
      /// Thread function for import for traceability use operation
360
      /// Thread function for import for traceability use operation
361
      /// </summary>
361
      /// </summary>
362
      private static void ImportReqProDatabase_Thread()
362
      private static void ImportReqProDatabase_Thread()
363
      {
363
      {
364
         bool cancelled = false;
364
         bool cancelled = false;
365
         mustAbort = false;
365
         mustAbort = false;
366
         abortRequests = 0;
366
         abortRequests = 0;
367
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
367
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
368
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
368
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
369
         ImportReqProDatabase import_parser = new ImportReqProDatabase();
369
         ImportReqProDatabase import_parser = new ImportReqProDatabase();
370
         import_parser.prompt_and_parse(ReqProDB_Artifact.MODE.TRACEABILITY, out cancelled);
370
         import_parser.prompt_and_parse(ReqProDB_Artifact.MODE.TRACEABILITY, out cancelled);
371
         if (mustAbort)
371
         if (mustAbort)
372
         {
372
         {
373
            EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME, "Import Aborted", -1);
373
            EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME, "Import Aborted", -1);
374
            MessageBoxEx.Show("Import Aborted", "Progress");
374
            MessageBoxEx.Show("Import Aborted", "Progress");
375
         }
375
         }
376
         else if (cancelled)
376
         else if (cancelled)
377
         {
377
         {
378
            Main.WriteOutput("Import Cancelled",-1);
378
            Main.WriteOutput("Import Cancelled",-1);
379
         }
379
         }
380
         abortRequests = 0;
380
         abortRequests = 0;
381
         ReqProDatabase.close();
381
         ReqProDatabase.close();
382
      }
382
      }
383
 
383
 
384
      /// <summary>
384
      /// <summary>
385
      /// Thread function for import for document model use operation
385
      /// Thread function for import for document model use operation
386
      /// </summary>
386
      /// </summary>
387
      private static void CopyReqProDatabase_Thread()
387
      private static void CopyReqProDatabase_Thread()
388
      {
388
      {
389
         bool cancelled = false;
389
         bool cancelled = false;
390
         mustAbort = false;
390
         mustAbort = false;
391
         abortRequests = 0;
391
         abortRequests = 0;
392
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
392
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
393
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
393
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
394
         CopyReqProDatabase copy_parser = new CopyReqProDatabase();
394
         CopyReqProDatabase copy_parser = new CopyReqProDatabase();
395
         copy_parser.prompt_and_parse(ReqProDB_Artifact.MODE.DOC_MODEL, out cancelled);
395
         copy_parser.prompt_and_parse(ReqProDB_Artifact.MODE.DOC_MODEL, out cancelled);
396
         if (mustAbort)
396
         if (mustAbort)
397
         {
397
         {
398
            EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME, "Import Aborted", -1);
398
            EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME, "Import Aborted", -1);
399
            MessageBoxEx.Show("Import Aborted", "Progress");
399
            MessageBoxEx.Show("Import Aborted", "Progress");
400
         }
400
         }
401
         else if (cancelled)
401
         else if (cancelled)
402
         {
402
         {
403
            Main.WriteOutput("Import Cancelled",-1);
403
            Main.WriteOutput("Import Cancelled",-1);
404
         }
404
         }
405
         abortRequests = 0;
405
         abortRequests = 0;
406
         ReqProDatabase.close();
406
         ReqProDatabase.close();
407
      }
407
      }
408
 
408
 
409
      /// <summary>
409
      /// <summary>
410
      /// Thread function for export to reqpro database operation
410
      /// Thread function for export to reqpro database operation
411
      /// </summary>
411
      /// </summary>
412
      private static void ExportToReqPro_Thread()
412
      private static void ExportToReqPro_Thread()
413
      {
413
      {
414
         bool cancelled = false;
414
         bool cancelled = false;
415
         mustAbort = false;
415
         mustAbort = false;
416
         abortRequests = 0;
416
         abortRequests = 0;
417
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
417
         EA_Repository.EnsureOutputVisible(GUI_OUTPUT_TAB_NAME);
418
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
418
         EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME,"",-1);
419
         ExportToReqProDatabase export_parser = new ExportToReqProDatabase();
419
         ExportToReqProDatabase export_parser = new ExportToReqProDatabase();
420
         export_parser.prompt_and_parse(ReqProDB_Artifact.MODE.EXPORT, out cancelled);
420
         export_parser.prompt_and_parse(ReqProDB_Artifact.MODE.EXPORT, out cancelled);
421
         if (mustAbort)
421
         if (mustAbort)
422
         {
422
         {
423
            EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME, "Export Aborted", -1);
423
            EA_Repository.WriteOutput(GUI_OUTPUT_TAB_NAME, "Export Aborted", -1);
424
            MessageBoxEx.Show("Export Aborted", "Progress");
424
            MessageBoxEx.Show("Export Aborted", "Progress");
425
         }
425
         }
426
         else if (cancelled)
426
         else if (cancelled)
427
         {
427
         {
428
            Main.WriteOutput("Export Cancelled",-1);
428
            Main.WriteOutput("Export Cancelled",-1);
429
         }
429
         }
430
         abortRequests = 0;
430
         abortRequests = 0;
431
         ReqProDatabase.close();
431
         ReqProDatabase.close();
432
      }
432
      }
433
 
433
 
434
      public static void MessageBoxException(Exception exc)
434
      public static void MessageBoxException(Exception exc)
435
      {
435
      {
436
         MessageBoxException(exc, "Exception");
436
         MessageBoxException(exc, "Exception");
437
      }
437
      }
438
 
438
 
439
      public static void MessageBoxException(Exception exc, string caption)
439
      public static void MessageBoxException(Exception exc, string caption)
440
      {
440
      {
441
         MessageBoxEx.Show(exc.ToString(), caption, MessageBoxIcon.Error);
441
         MessageBoxEx.Show(exc.ToString(), caption, MessageBoxIcon.Error);
442
      }
442
      }
443
 
443
 
444
      public static void WriteOutput(string s, int id)
444
      public static void WriteOutput(string s, int id)
445
      {
445
      {
446
         EA_Repository.WriteOutput( GUI_OUTPUT_TAB_NAME, s, id);
446
         EA_Repository.WriteOutput( GUI_OUTPUT_TAB_NAME, s, id);
447
      }
447
      }
448
 
448
 
449
      public static void ClearOutput()
449
      public static void ClearOutput()
450
      {
450
      {
451
         EA_Repository.ClearOutput(GUI_OUTPUT_TAB_NAME);
451
         EA_Repository.ClearOutput(GUI_OUTPUT_TAB_NAME);
452
      }
452
      }
453
      public static void WriteSeperator()
453
      public static void WriteSeperator()
454
      {
454
      {
455
         EA_Repository.WriteOutput( GUI_OUTPUT_TAB_NAME, "----------------------------------------------------------------------------------------------------------------------", -1);
455
         EA_Repository.WriteOutput( GUI_OUTPUT_TAB_NAME, "----------------------------------------------------------------------------------------------------------------------", -1);
456
      }
456
      }
457
   }
457
   }
458
}
458
}