void UpdateTranslationsAsync(object ob) { object[] data = (object[])ob; IProgressMonitor monitor = (IProgressMonitor)data [0]; TranslationProject project = (TranslationProject)data [1]; Translation translation = (Translation)data [2]; try { project.UpdateTranslations(monitor, translation); Gtk.Application.Invoke(delegate { POEditorWidget.ReloadWidgets(); }); } catch (Exception ex) { monitor.ReportError(GettextCatalog.GetString("Translation update failed."), ex); } finally { monitor.Log.WriteLine(); monitor.Log.WriteLine(GettextCatalog.GetString("---------------------- Done ----------------------")); monitor.Dispose(); } }
// Converts a vs2003 solution to a Combine object internal Solution ImportSln(FilePath fileName) { SlnMaker slnmaker = new SlnMaker(); Solution solution = null; IProgressMonitor m = IdeApp.IsInitialized ? GuiHelper.CreateProgressMonitor() : new ConsoleProgressMonitor(); try { solution = slnmaker.MsSlnToCmbxHelper(fileName, m); } catch (Exception e) { LoggingService.LogError("exception while converting : " + e.ToString()); throw; } finally { if (m != null) { m.Dispose(); } } return(solution); }
static void WriteSummaryResults(IProgressMonitor monitor, int succeeded, int warnings, int errors) { monitor.Log.WriteLine(); int total = succeeded + warnings + errors; //this might not be correct for languages where pluralization affects the other arguments //but gettext doesn't really have an answer for sentences with multiple plurals monitor.Log.WriteLine( GettextCatalog.GetPluralString( "{0} file processed total. {1} generated successfully, {2} with warnings, {3} with errors", "{0} files processed total. {1} generated successfully, {2} with warnings, {3} with errors", total, total, succeeded, warnings, errors) ); //ends the root task monitor.EndTask(); if (errors > 0) { monitor.ReportError(GettextCatalog.GetString("Errors in file generation."), null); } else if (warnings > 0) { monitor.ReportSuccess(GettextCatalog.GetString("Warnings in file generation.")); } else { monitor.ReportSuccess(GettextCatalog.GetString("Generated files successfully.")); } monitor.Dispose(); }
public void Convert(string guiFolderName, bool makeBackup) { GtkDesignInfo info = GtkDesignInfo.FromProject(project); Stetic.Project gproject = GuiBuilderService.SteticApp.CreateProject(info); //Stetic.Project does not implement IDisposable try { string newGuiFolderName = project.BaseDirectory.Combine(guiFolderName); gproject.ConvertProject(info.SteticFile, newGuiFolderName); info.ConvertGtkFolder(guiFolderName, makeBackup); info.UpdateGtkFolder(); folderName = newGuiFolderName; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor(); try { ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration; Generator generator = new Generator(); generator.Run(monitor, project, configuration); monitor.ReportSuccess("Converting was succesfull"); } finally { monitor.Dispose(); } } finally { gproject.Dispose(); } }
public static IAsyncOperation DebugApplication(this ProjectOperations opers, string executableFile) { if (opers.CurrentRunOperation != null && !opers.CurrentRunOperation.IsCompleted) { return(opers.CurrentRunOperation); } string oldLayout = IdeApp.Workbench.CurrentLayout; IdeApp.Workbench.CurrentLayout = "Debug"; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor(); IAsyncOperation oper = DebuggingService.Run(executableFile, (IConsole)monitor); oper.Completed += delegate { monitor.Dispose(); Gtk.Application.Invoke(delegate { IdeApp.Workbench.CurrentLayout = oldLayout; }); }; opers.CurrentRunOperation = monitor.AsyncOperation; return(opers.CurrentRunOperation); }
public IDisposable Subscribe(IObserver <SearchedFile> observer) { LoggingService.Debug("Parallel FindAll starting"); var task = Task.Factory.StartNew( delegate { var list = fileList.ToList(); ThrowIfCancellationRequested(); SearchParallel(list, observer); }, TaskCreationOptions.LongRunning); task.ContinueWith( t => { LoggingService.Debug("Parallel FindAll finished " + (t.IsFaulted ? "with error" : "successfully")); if (t.Exception != null) { observer.OnError(t.Exception); } else { observer.OnCompleted(); } monitor.Dispose(); }); return(this); }
public static void Push(GitRepository repo) { var dlg = new PushDialog(repo); try { if (MessageService.RunCustomDialog(dlg) != (int)Gtk.ResponseType.Ok) { return; } string remote = dlg.SelectedRemote; string branch = dlg.SelectedRemoteBranch; IProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Pushing changes...")); System.Threading.ThreadPool.QueueUserWorkItem(delegate { try { repo.Push(monitor, remote, branch); } catch (Exception ex) { monitor.ReportError(ex.Message, ex); } finally { monitor.Dispose(); } }); } finally { dlg.Destroy(); } }
public void Dispose() { lock (monitor.SyncRoot) { monitor.Dispose(); } }
public static IAsyncOperation Package(MonoMacProject project, ConfigurationSelector configSel, MonoMacPackagingSettings settings, FilePath target) { IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor( GettextCatalog.GetString("Packaging Output"), MonoDevelop.Ide.Gui.Stock.RunProgramIcon, true, true); var t = new System.Threading.Thread(() => { try { using (mon) { BuildPackage(mon, project, configSel, settings, target); } } catch (Exception ex) { mon.ReportError("Unhandled error in packaging", null); LoggingService.LogError("Unhandled exception in packaging", ex); } finally { mon.Dispose(); } }) { IsBackground = true, Name = "Mac Packaging", }; t.Start(); return(mon.AsyncOperation); }
protected override void OnCompleted() { statusMonitor.Dispose(); if (outputPad == null) { throw GetDisposedException(); } outputPad.WriteText("\n"); foreach (string msg in SuccessMessages) { outputPad.WriteText(msg + "\n"); } foreach (string msg in Warnings) { outputPad.WriteText(msg + "\n"); } foreach (string msg in Errors) { outputPad.WriteText(msg + "\n"); } outputPad.EndProgress(); base.OnCompleted(); outputPad = null; }
void StopReporting() { if (monitor != null) { monitor.Dispose(); monitor = null; } }
void StopProgressMonitor() { if (testProgressMonitor != null) { testProgressMonitor.Dispose(); testProgressMonitor = null; } }
public void Wakeup() { try { tracker.EndTask(); tracker.Dispose(); } finally { Finished(); } }
internal static void GenerateMakefiles(SolutionItem entry, Solution solution) { if (solution == null) { AlertButton generateMakefilesButton = new AlertButton(GettextCatalog.GetString("_Generate Makefiles")); if (MessageService.AskQuestion(GettextCatalog.GetString("Generating Makefiles is not supported for single projects. Do you want to generate them for the full solution - '{0}' ?", entry.ParentSolution.Name), AlertButton.Cancel, generateMakefilesButton) == generateMakefilesButton) { solution = ((SolutionItem)entry).ParentSolution; } else { return; } } DeployContext ctx = null; IProgressMonitor monitor = null; GenerateMakefilesDialog dialog = new GenerateMakefilesDialog(solution); try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok) { return; } SolutionDeployer deployer = new SolutionDeployer(dialog.GenerateAutotools); if (deployer.HasGeneratedFiles(solution)) { string msg = GettextCatalog.GetString("{0} already exist for this solution. Would you like to overwrite them?", dialog.GenerateAutotools ? "Autotools files" : "Makefiles"); if (MonoDevelop.Ide.MessageService.AskQuestion(msg, AlertButton.Cancel, AlertButton.OverwriteFile) != AlertButton.OverwriteFile) { return; } } ctx = new DeployContext(new TarballDeployTarget(dialog.GenerateAutotools), "Linux", null); monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(true); deployer.GenerateFiles(ctx, solution, dialog.DefaultConfiguration, monitor); } finally { dialog.Destroy(); if (ctx != null) { ctx.Dispose(); } if (monitor != null) { monitor.Dispose(); } } }
private static void RunThread(string baseLayerPath, string overlayLayerPath, string resultLayerPath, OverlayType type) { //get data Layer baseLayer = GetLayer(baseLayerPath); Layer overlayLayer = GetLayer(overlayLayerPath); //create intersected data var driver = Ogr.GetDriverByName("ESRI Shapefile"); if (driver == null) { System.Environment.Exit(-1); } string[] resultPath = resultLayerPath.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries); string resultName = resultPath[resultPath.Length - 1]; using (var dsResult = driver.CreateDataSource(resultLayerPath, new string[] { })) { if (dsResult == null) { throw new Exception("Can't get to the datasoure."); } Layer resultLayer = null; for (int i = 0; i < dsResult.GetLayerCount(); i++) { resultLayer = dsResult.GetLayerByIndex(i); if (resultLayer != null && resultLayer.GetLayerDefn().GetName() == resultName) { dsResult.DeleteLayer(i); break; } } resultLayer = dsResult.CreateLayer("ResultLayer", baseLayer.GetSpatialRef(), baseLayer.GetLayerDefn().GetGeomType(), new string[] { }); if (resultLayer != null) { bool isSuccess = GIS.GDAL.Overlay.Overlay.OverlayOperate(baseLayer, overlayLayer, ref resultLayer, type, ProgressFunc); if (!isSuccess) { ///Failed } } } _cancellationSource.Cancel(); _cancellationSource.Dispose(); _progressMonitor.Dispose(); //add result layer into map AppManager app = GIS.FrameWork.Application.App; app.Map.AddLayer(resultLayerPath); WorkbenchSingleton.StatusBar.SetMessage("Ready"); }
void RestorePackages(IProgressMonitor progressMonitor, NuGetPackageRestoreCommandLine commandLine) { Runtime.ProcessService.StartConsoleProcess( commandLine.Command, commandLine.Arguments, commandLine.WorkingDirectory, progressMonitor as IConsole, (e, sender) => progressMonitor.Dispose() ); }
protected override void Run() { IProgressMonitor progressMonitor = GetRunProcessMonitor(); try { RestorePackages(progressMonitor); } catch (Exception ex) { progressMonitor.Log.WriteLine(ex.Message); progressMonitor.Dispose(); } }
void RunExternalTool(ExternalTools.ExternalTool tool, string argumentsTool) { string commandTool = StringParserService.Parse(tool.Command, IdeApp.Workbench.GetStringTagModel()); string initialDirectoryTool = StringParserService.Parse(tool.InitialDirectory, IdeApp.Workbench.GetStringTagModel()); //Execute tool IProgressMonitor progressMonitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor(); try { progressMonitor.Log.WriteLine(GettextCatalog.GetString("Running: {0} {1}", (commandTool), (argumentsTool))); progressMonitor.Log.WriteLine(); ProcessWrapper processWrapper; if (tool.UseOutputPad) { processWrapper = Runtime.ProcessService.StartProcess(commandTool, argumentsTool, initialDirectoryTool, progressMonitor.Log, progressMonitor.Log, null); } else { processWrapper = Runtime.ProcessService.StartProcess(commandTool, argumentsTool, initialDirectoryTool, null); } string processName = System.IO.Path.GetFileName(commandTool); try { processName = processWrapper.ProcessName; } catch (SystemException) { } processWrapper.WaitForOutput(); if (processWrapper.ExitCode == 0) { progressMonitor.Log.WriteLine(GettextCatalog.GetString("Process '{0}' has completed succesfully", processName)); } else { progressMonitor.Log.WriteLine(GettextCatalog.GetString("Process '{0}' has exited with error code {1}", processName, processWrapper.ExitCode)); } } catch (Exception ex) { progressMonitor.ReportError(GettextCatalog.GetString("External program execution failed.\nError while starting:\n '{0} {1}'", commandTool, argumentsTool), ex); } finally { progressMonitor.Dispose(); } }
static void ConsumeParsingQueue() { int pending = 0; IProgressMonitor monitor = null; try { Set <ProjectDom> dbsToFlush = new Set <ProjectDom> (); do { if (pending > 5 && monitor == null) { monitor = GetParseProgressMonitor(); monitor.BeginTask(GettextCatalog.GetString("Generating database"), 0); } ParsingJob job = DequeueParseJob(); if (job != null) { try { job.ParseCallback(job.File, monitor); if (job.Database != null) { dbsToFlush.Add(job.Database); } } catch (Exception ex) { if (monitor == null) { monitor = GetParseProgressMonitor(); } monitor.ReportError(null, ex); } } pending = PendingJobCount; }while (pending > 0); queueEmptied.Set(); // Flush the parsed databases foreach (ProjectDom db in dbsToFlush) { db.Flush(); } } finally { if (monitor != null) { monitor.Dispose(); } } }
public CocoStudio.Core.Document OpenDocument(FilePath file, Project project, bool bringToFront = true) { if (string.IsNullOrEmpty(file.FileName)) { return((CocoStudio.Core.Document)null); } foreach (CocoStudio.Core.Document document in this.Documents) { IBaseViewContent baseViewContent = (IBaseViewContent)null; if (document.Window.ViewContent.CanReuseView((string)file)) { baseViewContent = (IBaseViewContent)document.Window.ViewContent; } if (baseViewContent != null) { if (project != null && document.Project != project) { document.SetProject(project); } if (bringToFront) { document.Select(); document.Window.SelectWindow(); } return(document); } } IProgressMonitor statusProgressMonitor = this.ProgressMonitors.GetStatusProgressMonitor(); FileOpenInfo openFileInfo = new FileOpenInfo(file, project, bringToFront); this.RealOpenFile(statusProgressMonitor, openFileInfo); statusProgressMonitor.Dispose(); if (openFileInfo.NewContent == null) { return((CocoStudio.Core.Document)null); } CocoStudio.Core.Document doc = this.WrapDocument(openFileInfo.NewContent.WorkbenchWindow); if (doc != null && openFileInfo.BringToFront) { doc.RunWhenLoaded((System.Action)(() => { if (doc.Window == null) { return; } doc.Window.SelectWindow(); })); } doc.SetProject(project); return(doc); }
public static IAsyncOperation AttachToProcess(DebuggerEngine debugger, ProcessInfo proc) { currentEngine = debugger; session = debugger.CreateSession(); IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor(); console = monitor as IConsole; SetupSession(); session.TargetExited += delegate { monitor.Dispose(); }; session.AttachToProcess(proc, GetUserOptions()); return(monitor.AsyncOperation); }
public void Run() { ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage(); IProgressMonitor progressMonitor = CreateProgressMonitor(progressMessage); try { RestorePackages(progressMonitor, progressMessage); } catch (Exception ex) { LoggingService.LogInternalError(ex); progressMonitor.Log.WriteLine(ex.Message); progressMonitor.ReportError(progressMessage.Error, null); progressMonitor.ShowPackageConsole(); progressMonitor.Dispose(); } }
public void Run(ProgressMonitorStatusMessage progressMessage) { using (IProgressMonitor progressMonitor = CreateProgressMonitor(progressMessage)) { using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor(progressMonitor)) { try { RestorePackages(progressMonitor, progressMessage); } catch (Exception ex) { LoggingService.LogError(progressMessage.Error, ex); progressMonitor.Log.WriteLine(ex.Message); progressMonitor.ReportError(progressMessage.Error, null); progressMonitor.ShowPackageConsole(); progressMonitor.Dispose(); RestoreFailed = true; } } } }
void SignPackageDone(IProgressMonitor monitor, BuildResult result) { monitor.EndTask(); if (result != null && result.Errors.Count > 0) { var tasks = new Task [result.Errors.Count]; for (int n = 0; n < tasks.Length; n++) { tasks [n] = new Task(result.Errors [n], this); } TaskService.Errors.AddRange(tasks); TaskService.ShowErrors(); } monitor.Dispose(); }
public void Dispose() { consoleMonitor.CancelRequested -= OnCancelRequested; statusMonitor.CancelRequested -= OnCancelRequested; // Do not report warnings if there are errors otherwise the warnings will // appear at the end of the Package Console and hide the error which // should be the last line of text visible to the user. if (errors.Count == 0) { ReportAllWarningsButLastToConsole(); } ReportAllErrorsButLastToConsole(); consoleMonitor.Dispose(); statusMonitor.Dispose(); }
public IAsyncOperation Update(IProgressMonitor monitor) { System.Threading.ThreadPool.QueueUserWorkItem(delegate { string[] statuses; if (InitialUpdate) { statuses = new string [] { "NEW", "ASSIGNED", "NEEDINFO" } } ; else { statuses = new string [] { "NEW", "ASSIGNED", "NEEDINFO", "RESOLVED", "CLOSED", "VERIFIED" } }; string[] severities = new string [] { "Critical", "Major", "Normal", "Minor", "Enhancement" }; DateTime t = DateTime.Now; monitor.BeginTask("Updating from bugzilla server", 3); try { Connect(); int nb, mb; // Bugs int lastWork = -1; Bug[] data = server.GetBugsForProduct(Product, statuses, severities, lastUpdate, delegate(int total, int current) { if (lastWork == -1) { monitor.BeginStepTask("Getting bug data", total, 2); lastWork = 0; } monitor.Step(current - lastWork); lastWork = current; }); monitor.EndTask(); UpdateBugData(data, out nb, out mb); lastUpdate = t; monitor.Step(1); Save(); monitor.Step(1); monitor.ReportSuccess(string.Format("Bug list updated ({0} added, {1} modified)", nb, mb)); } catch (Exception ex) { monitor.ReportError("Update failed", ex); } finally { monitor.Dispose(); } });
void BuildDone() { lock (this) { if (buildIsDone) { return; } buildIsDone = true; } if (!buildIsCancelled) { foreach (BuildNode n in nodeDict.Values) { if (!n.buildFinished) { throw new Exception("All workers done, but a project did not finish building"); } } } string buildTime = " (" + (DateTime.Now - buildStart).ToString() + ")"; if (buildIsCancelled) { results.Result = BuildResultCode.Cancelled; ReportMessageLine("${res:MainWindow.CompilerMessages.BuildCancelled}"); } else if (rootNode.hasErrors) { results.Result = BuildResultCode.Error; ReportMessageLine("${res:MainWindow.CompilerMessages.BuildFailed}" + buildTime); } else { results.Result = BuildResultCode.Success; ReportMessageLine("${res:MainWindow.CompilerMessages.BuildFinished}" + buildTime); } cancellationRegistration.Dispose(); progressMonitor.Dispose(); ReportDone(); }
void TaskCompleted(Task task) { if (childProgressMonitor != null) { childProgressMonitor.Dispose(); } if (progressMonitor != null) { progressMonitor.Dispose(); } if (task.Exception != null) { observer.OnError(task.Exception.InnerExceptions[0]); } else { observer.OnCompleted(); } }
public void GenerateCode(string componentFile) { GtkDesignInfo info = GtkDesignInfo.FromProject(project); string gtkxFile = info.GetDesignerFileFromComponent(componentFile); if (gtkxFile != null && File.Exists(gtkxFile)) { Save(false); FileInfo fi = new FileInfo(gtkxFile); fi.LastWriteTime = DateTime.Now; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor(); try { ConfigurationSelector configuration = IdeApp.Workspace.ActiveConfiguration; Generator generator = new Generator(); generator.Run(monitor, project, configuration); } finally { monitor.Dispose(); } } }
//static void OnFileChanged (object s, ProjectFileEventArgs args) //{ // Repository repo = GetRepository (args.Project); // if (repo != null) // NotifyFileStatusChanged (repo, args.ProjectFile.FilePath, false); //} static void OnFileAdded(object s, ProjectFileEventArgs e) { FileUpdateEventArgs vargs = new FileUpdateEventArgs(); IProgressMonitor monitor = null; try { foreach (var repoFiles in e.GroupBy(i => i.Project)) { Repository repo = GetRepository(repoFiles.Key); if (repo == null) { continue; } var versionInfos = repo.GetVersionInfo(repoFiles.Select(f => f.ProjectFile.FilePath)); FilePath[] paths = versionInfos.Where(i => i.CanAdd).Select(i => i.LocalPath).ToArray(); if (paths.Length > 0) { if (monitor == null) { monitor = GetStatusMonitor(); } repo.Add(paths, false, monitor); } vargs.AddRange(repoFiles.Select(i => new FileUpdateEventInfo(repo, i.ProjectFile.FilePath, i.ProjectFile.Subtype == Subtype.Directory))); } } finally { if (monitor != null) { monitor.Dispose(); } } if (vargs.Count > 0) { NotifyFileStatusChanged(vargs); } }
void BuildDone (IProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt) { Task[] tasks = null; tt.Trace ("Begin reporting build result"); try { if (result != null) { lastResult = result; monitor.Log.WriteLine (); monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------")); tt.Trace ("Updating task service"); tasks = new Task [result.Errors.Count]; for (int n=0; n<tasks.Length; n++) { tasks [n] = new Task (result.Errors [n]); tasks [n].Owner = this; } TaskService.Errors.AddRange (tasks); TaskService.Errors.ResetLocationList (); IdeApp.Workbench.ActiveLocationList = TaskService.Errors; tt.Trace ("Reporting result"); string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount); string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount); if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) { monitor.ReportSuccess (GettextCatalog.GetString ("Build successful.")); } else if (result.ErrorCount == 0 && result.WarningCount > 0) { monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString); } else if (result.ErrorCount > 0) { monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null); } else { monitor.ReportError(GettextCatalog.GetString("Build failed."), null); } tt.Trace ("End build event"); OnEndBuild (monitor, lastResult.FailedBuildCount == 0, lastResult, entry as SolutionItem); } else { tt.Trace ("End build event"); OnEndBuild (monitor, false); } tt.Trace ("Showing results pad"); try { Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> (); switch (IdeApp.Preferences.ShowErrorPadAfterBuild) { case BuildResultStates.Always: if (!errorsPad.Visible) errorsPad.IsOpenedAutomatically = true; errorsPad.Visible = true; errorsPad.BringToFront (); break; case BuildResultStates.Never: break; case BuildResultStates.OnErrors: if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error)) goto case BuildResultStates.Always; goto case BuildResultStates.Never; case BuildResultStates.OnErrorsOrWarnings: if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning)) goto case BuildResultStates.Always; goto case BuildResultStates.Never; } } catch {} if (tasks != null) { Task jumpTask = null; switch (IdeApp.Preferences.JumpToFirstErrorOrWarning) { case JumpToFirst.Error: jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error && TaskStore.IsProjectTaskFile (t)); break; case JumpToFirst.ErrorOrWarning: jumpTask = tasks.FirstOrDefault (t => (t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning) && TaskStore.IsProjectTaskFile (t)); break; } if (jumpTask != null) { tt.Trace ("Jumping to first result position"); jumpTask.JumpToPosition (); } } } finally { monitor.Dispose (); tt.End (); } }
public void GenerateCodeCompletionDatabase(string createPath, IProgressMonitor progressMonitor) { if (progressMonitor != null) progressMonitor.BeginTask(GettextCatalog.GetString ("Generating database"), assemblyList.Length); for (int i = 0; i < assemblyList.Length; ++i) { try { AssemblyCodeCompletionDatabase db = new AssemblyCodeCompletionDatabase (codeCompletionPath, assemblyList[i], this); db.ParseAll (); db.Write (); if (progressMonitor != null) progressMonitor.Step (1); if (!ContinueWithProcess (progressMonitor)) return; } catch (Exception ex) { Runtime.LoggingService.Info (ex); } } if (progressMonitor != null) { progressMonitor.Dispose (); } }
void ExecuteSolutionItemAsync (IProgressMonitor monitor, IBuildTarget entry, ExecutionContext context) { try { OnBeforeStartProject (); entry.Execute (monitor, context, IdeApp.Workspace.ActiveConfiguration); } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Execution failed."), ex); LoggingService.LogError ("Execution failed", ex); } finally { monitor.Dispose (); } }
void SignPackageDone (IProgressMonitor monitor, BuildResult result) { monitor.EndTask (); if (result != null && result.Errors.Count > 0) { var tasks = new Task [result.Errors.Count]; for (int n = 0; n < tasks.Length; n++) { tasks [n] = new Task (result.Errors [n], this); } TaskService.Errors.AddRange (tasks); TaskService.ShowErrors (); } monitor.Dispose (); }
static void WriteSummaryResults (IProgressMonitor monitor, int succeeded, int warnings, int errors) { monitor.Log.WriteLine (); int total = succeeded + warnings + errors; //this might not be correct for languages where pluralization affects the other arguments //but gettext doesn't really have an answer for sentences with multiple plurals monitor.Log.WriteLine ( GettextCatalog.GetPluralString ( "{0} file processed total. {1} generated successfully, {2} with warnings, {3} with errors", "{0} files processed total. {1} generated successfully, {2} with warnings, {3} with errors", total, total, succeeded, warnings, errors) ); //ends the root task monitor.EndTask (); if (errors > 0) monitor.ReportError (GettextCatalog.GetString ("Errors in file generation."), null); else if (warnings > 0) monitor.ReportSuccess (GettextCatalog.GetString ("Warnings in file generation.")); else monitor.ReportSuccess (GettextCatalog.GetString ("Generated files successfully.")); monitor.Dispose (); }
static bool UpdateCompleted (IProgressMonitor monitor, AggregatedOperationMonitor aggOp, ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result, bool runMultipleFiles) { monitor.EndTask (); if (aggOp != null) aggOp.Dispose (); if (monitor.IsCancelRequested) { monitor.ReportError (GettextCatalog.GetString ("Cancelled"), null); monitor.Dispose (); return false; } string genFileName; try { bool broken = false; if (result.UnhandledException != null) { broken = true; string msg = GettextCatalog.GetString ("The '{0}' code generator crashed", file.Generator); result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg + ": " + result.UnhandledException.Message)); monitor.ReportError (msg, result.UnhandledException); LoggingService.LogError (msg, result.UnhandledException); } genFileName = result.GeneratedFilePath.IsNullOrEmpty? null : result.GeneratedFilePath.ToRelative (file.FilePath.ParentDirectory); if (!string.IsNullOrEmpty (genFileName)) { bool validName = genFileName.IndexOfAny (new [] { '/', '\\' }) < 0 && FileService.IsValidFileName (genFileName); if (!broken && !validName) { broken = true; string msg = GettextCatalog.GetString ("The '{0}' code generator output invalid filename '{1}'", file.Generator, result.GeneratedFilePath); result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg)); monitor.ReportError (msg, null); } } if (result.Errors.Count > 0) { DispatchService.GuiDispatch (delegate { foreach (CompilerError err in result.Errors) TaskService.Errors.Add (new Task (file.FilePath, err.ErrorText, err.Column, err.Line, err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error, TaskPriority.Normal, file.Project.ParentSolution, file)); }); } if (broken) return true; if (!runMultipleFiles) { if (result.Success) monitor.ReportSuccess ("Generated file successfully."); else if (result.SuccessWithWarnings) monitor.ReportSuccess ("Warnings in file generation."); else monitor.ReportError ("Errors in file generation.", null); } } finally { if (!runMultipleFiles) monitor.Dispose (); } if (result.GeneratedFilePath.IsNullOrEmpty || !File.Exists (result.GeneratedFilePath)) return true; // broadcast a change event so text editors etc reload the file FileService.NotifyFileChanged (result.GeneratedFilePath); // add file to project, update file properties, etc Gtk.Application.Invoke (delegate { bool projectChanged = false; if (genFile == null) { genFile = file.Project.AddFile (result.GeneratedFilePath, result.OverrideBuildAction); projectChanged = true; } else if (result.GeneratedFilePath != genFile.FilePath) { genFile.Name = result.GeneratedFilePath; projectChanged = true; } if (file.LastGenOutput != genFileName) { file.LastGenOutput = genFileName; projectChanged = true; } if (genFile.DependsOn != file.FilePath.FileName) { genFile.DependsOn = file.FilePath.FileName; projectChanged = true; } if (projectChanged) IdeApp.ProjectOperations.Save (file.Project); }); return true; }
void CleanDone (IProgressMonitor monitor, IBuildTarget entry, ITimeTracker tt) { tt.Trace ("Begin reporting clean result"); try { monitor.Log.WriteLine (); monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------")); tt.Trace ("Reporting result"); monitor.ReportSuccess (GettextCatalog.GetString ("Clean successful.")); OnEndClean (monitor, tt); } finally { monitor.Dispose (); tt.End (); } }
static void UpdateCompleted (IProgressMonitor monitor, AggregatedOperationMonitor aggOp, ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result) { monitor.EndTask (); aggOp.Dispose (); if (monitor.IsCancelRequested) { monitor.ReportError (GettextCatalog.GetString ("Cancelled"), null); monitor.Dispose (); return; } string genFileName; try { bool broken = false; if (result.UnhandledException != null) { broken = true; string msg = GettextCatalog.GetString ("The '{0}' code generator crashed", file.Generator); result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg + ": " + result.UnhandledException.Message)); monitor.ReportError (msg, result.UnhandledException); LoggingService.LogError (msg, result.UnhandledException); } genFileName = result.GeneratedFilePath.IsNullOrEmpty? null : result.GeneratedFilePath.ToRelative (file.FilePath.ParentDirectory); bool validName = !string.IsNullOrEmpty (genFileName) && genFileName.IndexOfAny (new char[] { '/', '\\' }) < 0 && FileService.IsValidFileName (genFileName); if (!broken && !validName) { broken = true; string msg = GettextCatalog.GetString ("The '{0}' code generator output invalid filename '{1}'", file.Generator, result.GeneratedFilePath); result.Errors.Add (new CompilerError (file.Name, 0, 0, "", msg)); monitor.ReportError (msg, null); } if (result.Errors.Count > 0) { foreach (CompilerError err in result.Errors) TaskService.Errors.Add (new Task (file.FilePath, err.ErrorText, err.Column, err.Line, err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error, TaskPriority.Normal, file.Project.ParentSolution, file)); } if (broken) return; if (result.Success) monitor.ReportSuccess ("Generated file successfully."); else monitor.ReportError ("Failed to generate file. See error pad for details.", null); } finally { monitor.Dispose (); } if (!result.GeneratedFilePath.IsNullOrEmpty && File.Exists (result.GeneratedFilePath)) { Gtk.Application.Invoke (delegate { if (genFile == null) { genFile = file.Project.AddFile (result.GeneratedFilePath); } else if (result.GeneratedFilePath != genFile.FilePath) { genFile.Name = result.GeneratedFilePath; } file.LastGenOutput = genFileName; genFile.DependsOn = file.FilePath.FileName; IdeApp.ProjectOperations.Save (file.Project); }); } }