~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-03-29 23:36:33 UTC
  • mto: (1.5.1 sid)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: james.westby@ubuntu.com-20080329233633-l550uuwvfh1e68at
Tags: upstream-1.0+dfsg
ImportĀ upstreamĀ versionĀ 1.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        {
52
52
                static GuiBuilderProjectPad widgetTreePad;
53
53
                static string GuiBuilderLayout = "GUI Builder";
 
54
                
 
55
#if DUMMY_STRINGS_FOR_TRANSLATION_DO_NOT_COMPILE
 
56
                private void DoNotCompile ()
 
57
                {
 
58
                        //The default GUI Builder layout, translated indirectly because it's used as an ID
 
59
                        GettextCatalog.GetString ("GUI Builder");
 
60
                }
 
61
#endif
 
62
                
54
63
                static string defaultLayout;
55
 
        
 
64
                
56
65
                static Stetic.Application steticApp;
57
66
                
58
67
                static bool generating;
350
359
                                        IdeApp.ProjectOperations.ParserDatabase.UpdateFile (project, fileName, ((StringWriter)fileStream).ToString ());
351
360
                        }
352
361
 
 
362
                        FileService.NotifyFileChanged (fileName);
353
363
                        return fileName;
354
364
                }
355
365
                
404
414
                        
405
415
                        bool canGenerateInProcess = IsolationMode != Stetic.IsolationMode.None || info.GuiBuilderProject.SteticProject.CanGenerateCode;
406
416
                        
407
 
                        // Run the generation in another thread to avoid freezing the GUI
408
 
                        System.Threading.ThreadPool.QueueUserWorkItem ( delegate {
409
 
                                try {
410
 
                                        if (!canGenerateInProcess) {
 
417
                        if (!canGenerateInProcess) {
 
418
                                // Run the generation in another thread to avoid freezing the GUI
 
419
                                System.Threading.ThreadPool.QueueUserWorkItem ( delegate {
 
420
                                        try {
411
421
                                                // Generate the code in another process if stetic is not isolated
412
422
                                                CodeGeneratorProcess cob = (CodeGeneratorProcess) Runtime.ProcessService.CreateExternalProcessObject (typeof (CodeGeneratorProcess), false);
413
423
                                                using (cob) {
414
424
                                                        generationResult = cob.GenerateCode (projects, info.GenerateGettext, info.GettextClass, info.GeneratePartialClasses);
415
425
                                                }
416
 
                                        } else {
417
 
                                                // No need to create another process, since stetic has its own backend process
418
 
                                                // or the widget libraries have no custom wrappers
419
 
                                                Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
420
 
                                                options.UseGettext = info.GenerateGettext;
421
 
                                                options.GettextClass = info.GettextClass;
422
 
                                                options.UsePartialClasses = info.GeneratePartialClasses;
423
 
                                                options.GenerateSingleFile = false;
424
 
                                                generationResult = SteticApp.GenerateProjectCode (options, info.GuiBuilderProject.SteticProject);
 
426
                                        } catch (Exception ex) {
 
427
                                                generatedException = ex;
 
428
                                        } finally {
 
429
                                                generating = false;
425
430
                                        }
 
431
                                });
 
432
                        
 
433
                                while (generating) {
 
434
                                        DispatchService.RunPendingEvents ();
 
435
                                        System.Threading.Thread.Sleep (100);
 
436
                                }
 
437
                        } else {
 
438
                                // No need to create another process, since stetic has its own backend process
 
439
                                // or the widget libraries have no custom wrappers
 
440
                                try {
 
441
                                        Stetic.GenerationOptions options = new Stetic.GenerationOptions ();
 
442
                                        options.UseGettext = info.GenerateGettext;
 
443
                                        options.GettextClass = info.GettextClass;
 
444
                                        options.UsePartialClasses = info.GeneratePartialClasses;
 
445
                                        options.GenerateSingleFile = false;
 
446
                                        generationResult = SteticApp.GenerateProjectCode (options, info.GuiBuilderProject.SteticProject);
426
447
                                } catch (Exception ex) {
427
448
                                        generatedException = ex;
428
 
                                } finally {
429
 
                                        generating = false;
430
449
                                }
431
 
                        });
432
 
                        
433
 
                        while (generating) {
434
 
                                DispatchService.RunPendingEvents ();
435
 
                                System.Threading.Thread.Sleep (100);
 
450
                                generating = false;
436
451
                        }
437
452
                        
438
453
                        if (generatedException != null) {
445
460
                                
446
461
                        CodeDomProvider provider = project.LanguageBinding.GetCodeDomProvider ();
447
462
                        if (provider == null)
448
 
                                throw new UserException ("Code generation not supported in language: " + project.LanguageName);
 
463
                                throw new UserException ("Code generation not supported for language: " + project.LanguageName);
449
464
                        
450
465
                        string basePath = Path.GetDirectoryName (info.SteticGeneratedFile);
451
466
                        string ext = Path.GetExtension (info.SteticGeneratedFile);
461
476
                                        provider.GenerateCodeFromCompileUnit (unit, fileStream, new CodeGeneratorOptions ());
462
477
                                } finally {
463
478
                                        fileStream.Close ();
 
479
                                        FileService.NotifyFileChanged (fname);
464
480
                                }
465
481
                        }
466
482