예제 #1
0
        protected override BuildResult DoBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            // Handle pending events to ensure that files get saved right before the project is built
            DispatchService.RunPendingEvents();

            // Build projects this project is depending on
            if (alreadyBuiltProjects.Contains(ItemId))
            {
                return new BuildResult()
                       {
                           FailedBuildCount = 1, CompilerOutput = "Circular dependency detected!"
                       }
            }
            ;

            alreadyBuiltProjects.Add(ItemId);

            BuildResult bs;

            foreach (var prj in DependingProjects)
            {
                if ((bs = prj.Build(monitor, configuration)) == null || bs.Failed)
                {
                    return bs ?? new BuildResult {
                               FailedBuildCount = 1
                    }
                }
            }
            ;

            alreadyBuiltProjects.Remove(ItemId);

            return(ProjectBuilder.CompileProject(monitor, this, configuration));
        }
예제 #2
0
        protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            // Handle pending events to ensure that files get saved right before the project is built
            DispatchService.RunPendingEvents();

            progressMonitor = monitor;
            buildingResult  = new BuildResult();
            var config = GetConfiguration(configuration) as MonoNaClProjectConfiguration;

            buildingConfig = config;

            var dirInfo = new DirectoryInfo(config.OutputDirectory);

            if (!dirInfo.Exists)
            {
                Directory.CreateDirectory(config.OutputDirectory);
            }

            if (config.CompileTarget == MonoDevelop.Projects.CompileTarget.Exe)
            {
                buildNaCl(buildingResult, config, configuration);
            }
            buildCS(buildingResult, config, configuration);

            return(buildingResult);
        }
예제 #3
0
        public override void ReportError(string message, Exception ex)
        {
            if (message == null && ex != null)
            {
                message = ex.Message;
            }
            else if (message != null && ex != null)
            {
                if (!message.EndsWith("."))
                {
                    message += ".";
                }
                message += " " + ex.Message;
            }

            errorsMessages.Add(message);
            if (ex != null)
            {
                LoggingService.LogError(ex.ToString());
                errorException = ex;
            }

            if (dialog != null)
            {
                dialog.WriteText(GettextCatalog.GetString("ERROR: ") + message + "\n");
                DispatchService.RunPendingEvents();
            }
        }
예제 #4
0
        // Any native Winforms component needs to run on a thread marked as single-threaded apartment (STAThread).
        // Marking the MD's Main method with STAThread has historically shown to be a source of several problems,
        // thus we isolate the calls by creating a new thread for our calls.
        // More info here: http://blogs.msdn.com/b/jfoscoding/archive/2005/04/07/406341.aspx
        internal static bool RunWinUIMethod <T> (Func <T, bool> func, T data) where T : SelectFileDialogData
        {
            bool result = false;
            var  t      = new Thread(() =>
            {
                try {
                    result = func(data);
                }
                catch (Exception ex)
                {
                    LoggingService.LogError("Unhandled exception handling a native dialog", ex);
                }
            });

            t.Name         = "Win32 Interop Thread";
            t.IsBackground = true;
            t.SetApartmentState(ApartmentState.STA);

            t.Start();
            while (!t.Join(50))
            {
                DispatchService.RunPendingEvents();
            }

            return(result);
        }
예제 #5
0
        void IAsyncOperation.WaitForCompleted()
        {
            if (IsCompleted)
            {
                return;
            }

            if (DispatchService.IsGuiThread)
            {
                while (!IsCompleted)
                {
                    DispatchService.RunPendingEvents();
                    Thread.Sleep(100);
                }
            }
            else
            {
                lock (progressTracker) {
                    if (!progressTracker.InProgress)
                    {
                        return;
                    }
                    if (c.waitEvent == null)
                    {
                        c.waitEvent = new ManualResetEvent(false);
                    }
                }
                c.waitEvent.WaitOne();
            }
        }
예제 #6
0
 protected override void OnWriteLog(string text)
 {
     if (dialog != null)
     {
         dialog.WriteText(text);
         DispatchService.RunPendingEvents();
     }
 }
예제 #7
0
 protected override void OnProgressChanged()
 {
     if (dialog != null)
     {
         dialog.SetProgress(CurrentTaskWork);
         DispatchService.RunPendingEvents();
     }
 }
예제 #8
0
        public IEnumerable <SearchResult> FindAll(Scope scope, IProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter)
        {
            if (filter.RegexSearch)
            {
                RegexOptions regexOptions = RegexOptions.Compiled;
                if (!filter.CaseSensitive)
                {
                    regexOptions |= RegexOptions.IgnoreCase;
                }
                regex = new Regex(pattern, regexOptions);
            }
            else
            {
                CompilePattern(pattern, filter);
            }
            IsRunning         = true;
            FoundMatchesCount = SearchedFilesCount = 0;

            monitor.BeginTask(scope.GetDescription(filter, pattern, replacePattern), 100);
            try {
                int totalWork = scope.GetTotalWork(filter);
                int step      = Math.Max(1, totalWork / 100);
                foreach (FileProvider provider in scope.GetFiles(monitor, filter))
                {
                    if (monitor.IsCancelRequested)
                    {
                        break;
                    }
                    SearchedFilesCount++;
                    if (!string.IsNullOrEmpty(replacePattern))
                    {
                        provider.BeginReplace();
                    }
                    foreach (SearchResult result in FindAll(monitor, provider, pattern, replacePattern, filter))
                    {
                        if (monitor.IsCancelRequested)
                        {
                            break;
                        }
                        FoundMatchesCount++;
                        yield return(result);
                    }
                    if (!string.IsNullOrEmpty(replacePattern))
                    {
                        provider.EndReplace();
                    }
                    if (SearchedFilesCount % step == 0)
                    {
                        monitor.Step(1);
                    }
                    DispatchService.RunPendingEvents();
                }
            } finally {
                monitor.EndTask();
                IsRunning = false;
            }
        }
 protected override void OnEndTask(string name, int totalWork, int stepWork)
 {
     if (dialog != null)
     {
         dialog.EndTask();
     }
     DispatchService.RunPendingEvents();
     base.OnEndTask(name, totalWork, stepWork);
 }
 protected override void OnProgressChanged()
 {
     if (dialog != null)
     {
         dialog.Message  = CurrentTask;
         dialog.Progress = GlobalWork;
         DispatchService.RunPendingEvents();
     }
 }
 protected override void OnErrorReported(string message, Exception exception)
 {
     if (dialog != null)
     {
         dialog.WriteText(GettextCatalog.GetString("ERROR: ") + Errors [Errors.Length - 1] + "\n");
         DispatchService.RunPendingEvents();
     }
     base.OnErrorReported(message, exception);
 }
예제 #12
0
 public override void EndTask()
 {
     if (dialog != null)
     {
         dialog.EndTask();
     }
     base.EndTask();
     DispatchService.RunPendingEvents();
 }
 protected override void OnWarningReported(string message)
 {
     if (dialog != null)
     {
         dialog.WriteText(GettextCatalog.GetString("WARNING: ") + message + "\n");
         DispatchService.RunPendingEvents();
     }
     base.OnWarningReported(message);
 }
예제 #14
0
 public override void ReportWarning(string message)
 {
     if (dialog != null)
     {
         dialog.WriteText(GettextCatalog.GetString("WARNING: ") + message + "\n");
         DispatchService.RunPendingEvents();
     }
     warningMessages.Add(message);
 }
예제 #15
0
        // Executes the query outside of a syncEvent wait so it is safe to call from
        // inside an ExecuteOnIdleAndWait
        internal AppResult[] ExecuteQueryNoWait(AppQuery query)
        {
            AppResult[] resultSet = query.Execute();
            Sync(() => {
                DispatchService.RunPendingEvents();
                return(true);
            });

            return(resultSet);
        }
예제 #16
0
 protected void RunPendingEvents()
 {
     if (!runningPendingEvents)
     {
         try {
             runningPendingEvents = true;
             DispatchService.RunPendingEvents();
         } finally {
             runningPendingEvents = false;
         }
     }
 }
 protected override void OnProgressChanged()
 {
     if (showTaskTitles)
     {
         statusBar.ShowMessage(icon, CurrentTask);
     }
     if (!UnknownWork)
     {
         statusBar.SetProgressFraction(GlobalWork);
     }
     DispatchService.RunPendingEvents();
 }
 public MultiTaskDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, IDictionary <string, string> taskLabelAliases)
 {
     if (showProgress)
     {
         dialog = new MultiTaskProgressDialog(allowCancel, showDetails, taskLabelAliases);
         MessageService.PlaceDialog(dialog, MessageService.RootWindow);
         dialog.Show();
         dialog.AsyncOperation = AsyncOperation;
         DispatchService.RunPendingEvents();
         this.showDetails = showDetails;
     }
 }
 public MessageDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, bool hideWhenDone) : base(Runtime.MainSynchronizationContext)
 {
     if (showProgress)
     {
         dialog         = new ProgressDialog(MessageService.RootWindow, allowCancel, showDetails);
         dialog.Message = "";
         MessageService.PlaceDialog(dialog, MessageService.RootWindow);
         dialog.Show();
         dialog.CancellationTokenSource = CancellationTokenSource;
         DispatchService.RunPendingEvents();
         this.hideWhenDone = hideWhenDone;
         this.showDetails  = showDetails;
     }
 }
 public MessageDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, bool hideWhenDone)
 {
     if (showProgress)
     {
         dialog         = new ProgressDialog(allowCancel, showDetails);
         dialog.Message = "";
         MessageService.PlaceDialog(dialog, MessageService.RootWindow);
         dialog.Show();
         dialog.AsyncOperation = AsyncOperation;
         DispatchService.RunPendingEvents();
         this.hideWhenDone = hideWhenDone;
         this.showDetails  = showDetails;
     }
 }
        protected override void OnErrorReported(string message, Exception ex)
        {
            errorsMessages.Add(message);
            if (ex != null)
            {
                LoggingService.LogError(ex.ToString());
                errorException = ex;
            }

            if (dialog != null)
            {
                dialog.WriteText(GettextCatalog.GetString("ERROR: ") + ErrorHelper.GetErrorMessage(message, ex) + "\n");
                DispatchService.RunPendingEvents();
            }
            base.OnErrorReported(message, ex);
        }
예제 #22
0
        public void AddTasks(IEnumerable <Task> tasks)
        {
            int n = 1;

            foreach (Task t in tasks)
            {
                AddTaskInternal(t);
                if ((n++ % 100) == 0)
                {
                    // Adding many tasks is a bit slow, so refresh the
                    // ui at every block of 100.
                    DispatchService.RunPendingEvents();
                }
            }
            filter.Refilter();
        }
 public MessageDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, bool hideWhenDone, Components.Window parent)
     : base(Runtime.MainSynchronizationContext)
 {
     if (showProgress)
     {
         var parentWindow = parent ?? DesktopService.GetFocusedTopLevelWindow();
         dialog         = new ProgressDialog(parentWindow, allowCancel, showDetails);
         dialog.Message = "";
         MessageService.PlaceDialog(dialog, parentWindow);
         dialog.Show();
         dialog.CancellationTokenSource = CancellationTokenSource;
         DispatchService.RunPendingEvents();
         this.hideWhenDone = hideWhenDone;
         this.showDetails  = showDetails;
     }
 }
예제 #24
0
 public MultiTaskDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, IDictionary <string, string> taskLabelAliases)
 {
     if (showProgress)
     {
         var parent = MessageService.GetDefaultModalParent();
         dialog = new MultiTaskProgressDialog(allowCancel, showDetails, taskLabelAliases)
         {
             DestroyWithParent = true,
             Modal             = true,
             TransientFor      = parent,
         };
         MessageService.PlaceDialog(dialog, parent);
         Mono.TextEditor.GtkWorkarounds.PresentWindowWithNotification(dialog);
         dialog.AsyncOperation = AsyncOperation;
         DispatchService.RunPendingEvents();
         this.showDetails = showDetails;
     }
 }
예제 #25
0
        public virtual void Dispose()
        {
            DispatchService.RunPendingEvents();

            lock (progressTracker) {
                progressTracker.Done();
                if (c.waitEvent != null)
                {
                    c.waitEvent.Set();
                }
            }
            try {
                OnCompleted();
            } catch (Exception ex) {
                string msg = "Unhandled exception in monitor cancel event handler";
                LoggingService.LogInternalError(msg, ex);
            }
        }
 public MultiTaskDialogProgressMonitor(bool showProgress, bool allowCancel, bool showDetails, IDictionary <string, string> taskLabelAliases) : base(Runtime.MainSynchronizationContext)
 {
     if (showProgress)
     {
         var parent = MessageService.GetDefaultModalParent();
         dialog = new MultiTaskProgressDialog(allowCancel, showDetails, taskLabelAliases)
         {
             DestroyWithParent = true,
             Modal             = true,
             TransientFor      = parent,
         };
         MessageService.PlaceDialog(dialog, parent);
         GtkWorkarounds.PresentWindowWithNotification(dialog);
         dialog.CancellationTokenSource = CancellationTokenSource;
         DispatchService.RunPendingEvents();
         this.showDetails = showDetails;
     }
 }
        ITreeNavigator SearchMember(ITreeNavigator nav, string helpUrl)
        {
            do
            {
                if (IsMatch(nav, helpUrl))
                {
                    return(nav);
                }
                if (!SkipChildren(nav, helpUrl) && nav.HasChildren())
                {
                    DispatchService.RunPendingEvents();
                    nav.MoveToFirstChild();
                    ITreeNavigator result = SearchMember(nav, helpUrl);
                    if (result != null)
                    {
                        return(result);
                    }

                    if (!nav.MoveToParent())
                    {
                        return(null);
                    }
                    try {
                        if (nav.DataItem is DomCecilType && nav.Options["PublicApiOnly"])
                        {
                            nav.Options["PublicApiOnly"] = false;
                            nav.MoveToFirstChild();
                            result = SearchMember(nav, helpUrl);
                            if (result != null)
                            {
                                return(result);
                            }
                            nav.MoveToParent();
                        }
                    } catch (Exception) {
                        return(null);
                    }
                }
            } while (nav.MoveNext());
            return(null);
        }
예제 #28
0
        internal static CheckResult CheckBeforeDebugging(IBuildTarget target)
        {
            if (IdeApp.Preferences.BuildBeforeExecuting)
            {
                return(CheckResult.BuildBeforeRun);
            }

            if (!IdeApp.Workspace.NeedsBuilding())
            {
                return(CheckResult.Run);
            }

            AlertButton bBuild = new AlertButton(GettextCatalog.GetString("Build"));
            AlertButton bRun   = new AlertButton(Gtk.Stock.Execute, true);
            AlertButton res    = MessageService.AskQuestion(
                GettextCatalog.GetString("Outdated Debug Information"),
                GettextCatalog.GetString("The project you are executing has changes done after the last time it was compiled. The debug information may be outdated. Do you want to continue?"),
                2,
                AlertButton.Cancel,
                bBuild,
                bRun);

            // This call is a workaround for bug #6907. Without it, the main monodevelop window is left it a weird
            // drawing state after the message dialog is shown. This may be a gtk/mac issue. Still under research.
            DispatchService.RunPendingEvents();

            if (res == AlertButton.Cancel)
            {
                return(CheckResult.Cancel);
            }
            else if (res == bRun)
            {
                return(CheckResult.Run);
            }
            else
            {
                return(CheckResult.BuildBeforeRun);
            }
        }
예제 #29
0
        public static Stetic.CodeGenerationResult GenerateSteticCode(IProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration)
        {
            if (generating || !GtkDesignInfo.HasDesignedObjects(project))
            {
                return(null);
            }

            GtkDesignInfo info = GtkDesignInfo.FromProject(project);

            info.CheckGtkFolder();

            DateTime last_gen_time = File.Exists(info.SteticGeneratedFile) ? File.GetLastWriteTime(info.SteticGeneratedFile) : DateTime.MinValue;

            bool ref_changed = false;

            foreach (ProjectReference pref in project.References)
            {
                if (!pref.IsValid)
                {
                    continue;
                }
                foreach (string filename in pref.GetReferencedFileNames(configuration))
                {
                    if (File.GetLastWriteTime(filename) > last_gen_time)
                    {
                        ref_changed = true;
                        break;
                    }
                }
                if (ref_changed)
                {
                    break;
                }
            }

            // Check if generated code is already up to date.
//			if (!ref_changed && last_gen_time >= File.GetLastWriteTime (info.SteticFile))
//				return null;

            if (info.GuiBuilderProject.HasError)
            {
                monitor.ReportError(GettextCatalog.GetString("GUI code generation failed for project '{0}'. The file '{1}' could not be loaded.", project.Name, info.SteticFile), null);
                monitor.AsyncOperation.Cancel();
                return(null);
            }

            if (info.GuiBuilderProject.IsEmpty)
            {
                return(null);
            }

            monitor.Log.WriteLine(GettextCatalog.GetString("Generating GUI code for project '{0}'...", project.Name));

            // Make sure the referenced assemblies are up to date. It is necessary to do
            // it now since they may contain widget libraries.
            project.CopySupportFiles(monitor, configuration);

            info.GuiBuilderProject.UpdateLibraries();

            ArrayList projectFolders = new ArrayList();

            projectFolders.Add(info.SteticFolder.FullPath);

            generating = true;
            Stetic.CodeGenerationResult generationResult = null;
            Exception generatedException = null;

            bool canGenerateInProcess = IsolationMode != Stetic.IsolationMode.None || info.GuiBuilderProject.SteticProject.CanGenerateCode;

            if (!canGenerateInProcess)
            {
                // Run the generation in another thread to avoid freezing the GUI
                System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        // Generate the code in another process if stetic is not isolated
                        CodeGeneratorProcess cob = (CodeGeneratorProcess)Runtime.ProcessService.CreateExternalProcessObject(typeof(CodeGeneratorProcess), false);
                        using (cob) {
                            generationResult = cob.GenerateCode(projectFolders, info.GenerateGettext, info.GettextClass, project.UsePartialTypes, info);
                        }
                    } catch (Exception ex) {
                        generatedException = ex;
                    } finally {
                        generating = false;
                    }
                });

                while (generating)
                {
                    DispatchService.RunPendingEvents();
                    System.Threading.Thread.Sleep(100);
                }
            }
            else
            {
                // No need to create another process, since stetic has its own backend process
                // or the widget libraries have no custom wrappers
                try {
                    Stetic.GenerationOptions options = new Stetic.GenerationOptions();
                    options.UseGettext   = info.GenerateGettext;
                    options.GettextClass = info.GettextClass;
                    generationResult     = SteticApp.GenerateProjectCode(options, info.GuiBuilderProject.SteticProject);
                } catch (Exception ex) {
                    generatedException = ex;
                }
                generating = false;
            }

            if (generatedException != null)
            {
                string msg = string.Empty;

                if (generatedException.InnerException != null)
                {
                    msg = string.Format("{0}\n{1}\nInner Exception {2}\n{3}",
                                        generatedException.Message,
                                        generatedException.StackTrace,
                                        generatedException.InnerException.Message,
                                        generatedException.InnerException.StackTrace);
                }
                else
                {
                    msg = string.Format("{0}\n{1}",
                                        generatedException.Message,
                                        generatedException.StackTrace);
                }

//				LoggingService.LogError ("GUI code generation failed", generatedException);
                LoggingService.LogError("GUI code generation failed: " + msg);
                throw new UserException("GUI code generation failed: " + msg);
            }

            if (generationResult == null)
            {
                return(null);
            }

            CodeDomProvider provider = project.LanguageBinding.GetCodeDomProvider();

            if (provider == null)
            {
                throw new UserException("Code generation not supported for language: " + project.LanguageName);
            }

            foreach (Stetic.SteticCompilationUnit unit in generationResult.Units)
            {
                string fname;
                if (unit.Name.Length == 0)
                {
                    fname = info.SteticGeneratedFile;
                }
                else
                {
                    fname = GetBuildCodeFileName(project,
                                                 unit.Name,
                                                 (unit.Namespace != null) ? unit.Namespace.Name : string.Empty);
                }

                StringWriter sw = new StringWriter();
                try {
                    foreach (CodeNamespace ns in unit.Namespaces)
                    {
                        ns.Comments.Add(new CodeCommentStatement("This file has been generated by the GUI designer. Do not modify."));
                    }
                    provider.GenerateCodeFromCompileUnit(unit, sw, new CodeGeneratorOptions());
                    string content = sw.ToString();
                    content = FormatGeneratedFile(fname, content, provider);
                    File.WriteAllText(fname, content);
                } finally {
                    FileService.NotifyFileChanged(fname);
                }
            }

            // Make sure the generated files are added to the project
            if (info.UpdateGtkFolder())
            {
                Gtk.Application.Invoke(delegate {
                    IdeApp.ProjectOperations.Save(project);
                });
            }

            return(generationResult);
        }
예제 #30
0
 static void RunMainLoop()
 {
     DispatchService.RunPendingEvents();
 }