static void WriteSummaryResults(ProgressMonitor 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(); }
internal static void Report(ProgressMonitor monitor, List <Diagnostic> allDiagnostics, Projects.WorkspaceObject parent) { monitor.BeginTask(GettextCatalog.GetString("Reporting results..."), allDiagnostics.Count); TaskService.Errors.Clear(); TaskService.Errors.AddRange(allDiagnostics.Select(diagnostic => { var startLinePosition = diagnostic.Location.GetLineSpan().StartLinePosition; return(new TaskListEntry( diagnostic.Location.SourceTree.FilePath, diagnostic.GetMessage(), startLinePosition.Character + 1, startLinePosition.Line + 1, GetSeverity(diagnostic), TaskPriority.Normal, parent, null, diagnostic.Descriptor.Category )); })); monitor.EndTask(); if (!allDiagnostics.Any()) { monitor.ReportSuccess(GettextCatalog.GetString("Analysis successful.")); } else { ShowAnalyzationResults(); } }
public void CreateSchemaCommand() { try { TaskService.Errors.Clear(); string xml = Editor.Text; using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) { XmlDocument doc = XmlEditorService.ValidateWellFormedness(monitor, xml, FileName); if (doc == null) { return; } monitor.BeginTask(GettextCatalog.GetString("Creating schema..."), 0); try { string schema = XmlEditorService.CreateSchema(Editor, xml); string fileName = XmlEditorService.GenerateFileName(FileName, "{0}.xsd"); IdeApp.Workbench.NewDocument(fileName, "application/xml", schema); monitor.ReportSuccess(GettextCatalog.GetString("Schema created.")); } catch (Exception ex) { string msg = GettextCatalog.GetString("Error creating XML schema."); LoggingService.LogError(msg, ex); monitor.ReportError(msg, ex); } } } catch (Exception ex) { MessageService.ShowError(ex.Message); } }
public void Dispose() { monitor?.EndTask(); monitor?.ReportSuccess("Done."); monitor?.Dispose(); monitor = null; }
void CheckForPackageUpdates( ProgressMonitor progressMonitor, ProgressMonitorStatusMessage progressMessage, PackageUpdatesEventMonitor eventMonitor) { updatedPackagesInSolution.CheckForUpdates(); if (updatedPackagesInSolution.AnyUpdates()) { progressMonitor.ReportSuccess(GettextCatalog.GetString("Package updates are available.")); } else if (eventMonitor.WarningReported) { progressMonitor.ReportWarning(progressMessage.Warning); } else { progressMonitor.ReportSuccess(progressMessage.Success); } }
public void ReportResult(ProgressMonitorStatusMessage progressMessage) { if (HasWarnings) { progressMonitor.ReportWarning(progressMessage.Warning); } else { progressMonitor.ReportSuccess(progressMessage.Success); } }
public async Task SaveAsync () { ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true); try { await SaveAsync (monitor); monitor.ReportSuccess (GettextCatalog.GetString ("Workspace saved.")); } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex); } finally { monitor.Dispose (); } }
public void RunXslTransformCommand() { if (string.IsNullOrEmpty(stylesheetFileName)) { stylesheetFileName = XmlEditorService.BrowseForStylesheetFile(); if (string.IsNullOrEmpty(stylesheetFileName)) { return; } } using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) { try { string xsltContent; try { xsltContent = GetFileContent(stylesheetFileName); } catch (System.IO.IOException) { monitor.ReportError( GettextCatalog.GetString("Error reading file '{0}'.", stylesheetFileName), null); return; } System.Xml.Xsl.XslCompiledTransform xslt = XmlEditorService.ValidateStylesheet(monitor, xsltContent, stylesheetFileName); if (xslt == null) { return; } XmlDocument doc = XmlEditorService.ValidateXml(monitor, Editor.Text, FileName); if (doc == null) { return; } string newFileName = XmlEditorService.GenerateFileName(FileName, "-transformed{0}.xml"); monitor.BeginTask(GettextCatalog.GetString("Executing transform..."), 1); using (XmlTextWriter output = XmlEditorService.CreateXmlTextWriter(Editor)) { xslt.Transform(doc, null, output); IdeApp.Workbench.NewDocument( newFileName, "application/xml", output.ToString()); } monitor.ReportSuccess(GettextCatalog.GetString("Transform completed.")); monitor.EndTask(); } catch (Exception ex) { string msg = GettextCatalog.GetString("Could not run transform."); monitor.ReportError(msg, ex); monitor.EndTask(); } } }
protected override void Run() { ProgressMonitor monitor = Monitor; foreach (VersionControlItemList list in items.SplitByRepository()) { list[0].Repository.Add(list.Paths, true, monitor); } Gtk.Application.Invoke((o, args) => { VersionControlService.NotifyFileStatusChanged(items); }); monitor.ReportSuccess(GettextCatalog.GetString("Add operation completed.")); }
public void RunXslTransformCommand() { if (string.IsNullOrEmpty(stylesheetFileName)) { stylesheetFileName = XmlEditorService.BrowseForStylesheetFile(); if (string.IsNullOrEmpty(stylesheetFileName)) { return; } } using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) { try { string xsltContent; try { xsltContent = GetFileContent(stylesheetFileName); } catch (IOException) { monitor.ReportError( GettextCatalog.GetString("Error reading file '{0}'.", stylesheetFileName), null); return; } (var xslt, var errors) = XmlEditorService.CompileStylesheet(xsltContent, stylesheetFileName); if (xslt == null) { monitor.ReportError(GettextCatalog.GetString("Failed to compile stylesheet")); return; } string newFileName = XmlEditorService.GenerateFileName(FileName, "-transformed{0}.xml"); monitor.BeginTask(GettextCatalog.GetString("Executing transform..."), 1); var output = new EncodedStringWriter(Encoding.UTF8); using (XmlReader input = XmlReader.Create(new StringReader(Editor.Text), null, FileName)) { using (XmlTextWriter writer = XmlEditorService.CreateXmlTextWriter(Editor, output)) { xslt.Transform(input, writer); } } IdeApp.Workbench.NewDocument(newFileName, "application/xml", output.ToString()); monitor.ReportSuccess(GettextCatalog.GetString("Transform completed.")); monitor.EndTask(); } catch (Exception ex) { string msg = GettextCatalog.GetString("Could not run transform."); monitor.ReportError(msg, ex); monitor.EndTask(); } } }
void ReportOutcome( ProcessAsyncOperation operation, ProgressMonitor progressMonitor, ProgressMonitorStatusMessage progressMessage) { if (!operation.Task.IsFaulted && operation.ExitCode == 0) { progressMonitor.ReportSuccess(progressMessage.Success); } else { progressMonitor.ReportError(progressMessage.Error, null); progressMonitor.ShowPackageConsole(); } }
public void ReportResult(ProgressMonitorStatusMessage progressMessage) { if (HasWarnings) { progressMonitor.ReportWarning(progressMessage.Warning); } else { progressMonitor.ReportSuccess(progressMessage.Success); } if (taskCompletionSource != null) { taskCompletionSource.TrySetResult(true); } }
async Task CheckCompatibility() { PackageCompatibilityChecker checker = CreatePackageCompatibilityChecker(); await checker.CheckProjectPackages(project); if (checker.AnyPackagesRequireReinstallation()) { MarkPackagesForReinstallation(checker); ReportPackageReinstallationWarning(checker); } else { if (checker.PackagesMarkedForReinstallationInPackageReferenceFile()) { MarkPackagesForReinstallation(checker); } progressMonitor.ReportSuccess(progressMessage.Success); } }
void RestorePackages(ProgressMonitor progressMonitor, ProgressMonitorStatusMessage progressMessage) { var msbuildTargetsMonitor = new MSBuildTargetsRestoredMonitor(packageManagementEvents); using (msbuildTargetsMonitor) { var action = new RestorePackagesAction(solution, packageManagementEvents); if (project != null) { action.Project = project; } action.Execute(); } RefreshProjectReferences(msbuildTargetsMonitor.AnyMSBuildTargetsRestored); ForceCreationOfSharedRepositoriesConfigFile(); progressMonitor.ReportSuccess(progressMessage.Success); packageManagementEvents.OnPackagesRestored(); }
public static async Task SaveSolutionAsync(this Solution solution) { ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor(true); try { await solution.SaveAsync(monitor); monitor.ReportSuccess(GettextCatalog.GetString("Success.")); } catch (Exception ex) { monitor.ReportError(GettextCatalog.GetString("Save failed."), ex); } finally { monitor.Dispose(); } }
protected async override Task <BuildResult> OnClean(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.CleanTargetName)) { return(await base.OnClean(monitor, configuration, operationContext)); } monitor.BeginTask(GettextCatalog.GetString("Cleaning project"), 1); try { string baseDir = Project.BaseDirectory; ProcessWrapper process = Runtime.ProcessService.StartProcess("make", data.CleanTargetName, baseDir, monitor.Log, monitor.Log, null); await process.Task; if (process.ExitCode > 0) { throw new Exception(GettextCatalog.GetString("An unspecified error occurred while running '{0}'", "make " + data.CleanTargetName)); } monitor.Step(1); } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString("Project could not be cleaned: "), e); var res = new BuildResult(); res.AddError(GettextCatalog.GetString("Project could not be cleaned: ") + e.Message); return(res); } finally { monitor.EndTask(); } monitor.ReportSuccess(GettextCatalog.GetString("Project successfully cleaned")); return(BuildResult.CreateSuccess()); }
public void OnRestoreFinished(bool success) { concurrentRestoreCount--; if (!success) { this.success = false; } if (concurrentRestoreCount <= 0) { if (this.success) { currentProgressMonitor.ReportSuccess(GettextCatalog.GetString("Dependencies restored successfully.")); } else { currentProgressMonitor.ReportError(GettextCatalog.GetString("Could not restore dependencies.")); } currentProgressMonitor.Dispose(); currentProgressMonitor = null; } }
public Translation AddNewTranslation(string isoCode, ProgressMonitor monitor) { try { Translation tr = new Translation(this, isoCode); translations.Add(tr); string templateFile = Path.Combine(this.BaseDirectory, "messages.po"); string translationFile = GetFileName(isoCode); if (!File.Exists(templateFile)) { CreateDefaultCatalog(monitor); } File.Copy(templateFile, translationFile); monitor.ReportSuccess(String.Format(GettextCatalog.GetString("Language '{0}' successfully added."), isoCode)); monitor.Step(1); SaveAsync(monitor); return(tr); } catch (Exception e) { monitor.ReportError(String.Format(GettextCatalog.GetString("Language '{0}' could not be added: "), isoCode), e); return(null); } finally { monitor.EndTask(); } }
protected void ShowSucess(string log) { _monitor.ReportSuccess(log); }
static bool UpdateCompleted(ProgressMonitor monitor, ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result, bool runMultipleFiles) { monitor.EndTask(); if (monitor.CancellationToken.IsCancellationRequested) { 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 + Environment.NewLine + result.UnhandledException.StackTrace)); 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) { Runtime.RunInMainThread(delegate { foreach (CompilerError err in result.Errors) { TaskService.Errors.Add(new TaskListEntry(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(async(o, args) => { 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) { await IdeApp.ProjectOperations.SaveAsync(file.Project); } }); return(true); }
public void ReportResult(ProgressMonitorStatusMessage progressMessage) { monitor.ReportSuccess(progressMessage.Success); }
async Task<bool> BackgroundLoadWorkspace (ProgressMonitor monitor, FilePath file, bool loadPreferences, bool reloading, ITimeTracker timer) { WorkspaceItem item = null; try { if (reloading) SetReloading (true); if (!File.Exists (file)) { monitor.ReportError (GettextCatalog.GetString ("File not found: {0}", file), null); return false; } if (!Services.ProjectService.IsWorkspaceItemFile (file)) { if (!Services.ProjectService.IsSolutionItemFile (file)) { monitor.ReportError (GettextCatalog.GetString ("File is not a project or solution: {0}", file), null); return false; } // It is a project, not a solution. Try to create a dummy solution and add the project to it timer.Trace ("Getting wrapper solution"); item = await IdeApp.Services.ProjectService.GetWrapperSolution (monitor, file); } if (item == null) { timer.Trace ("Reading item"); item = await Services.ProjectService.ReadWorkspaceItem (monitor, file); if (monitor.CancellationToken.IsCancellationRequested) return false; } timer.Trace ("Registering to recent list"); DesktopService.RecentFiles.AddProject (item.FileName, item.Name); } catch (Exception ex) { LoggingService.LogError ("Load operation failed", ex); monitor.ReportError ("Load operation failed.", ex); if (item != null) item.Dispose (); return false; } finally { if (reloading) SetReloading (false); } using (monitor) { // Add the item in the GUI thread. It is not safe to do it in the background thread. if (!monitor.CancellationToken.IsCancellationRequested) { item.SetShared (); Items.Add (item); } else { item.Dispose (); return false; } if (IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem == null) IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem = GetAllSolutions ().FirstOrDefault (); if (Items.Count == 1 && loadPreferences) { timer.Trace ("Restoring workspace preferences"); await RestoreWorkspacePreferences (item); } timer.Trace ("Reattaching documents"); ReattachDocumentProjects (null); monitor.ReportSuccess (GettextCatalog.GetString ("Solution loaded.")); timer.Trace ("Reattaching documents"); ReattachDocumentProjects (null); monitor.ReportSuccess (GettextCatalog.GetString ("Solution loaded.")); } return true; }
public static void ReportNoDeclarationFound(this ProgressMonitor monitor) { monitor.ReportSuccess(GettextCatalog.GetString("No declaration found.")); }
public static void ReportNoReferencesFound(this ProgressMonitor monitor) { monitor.ReportSuccess(GettextCatalog.GetString("No references found.")); }
public static void ReportNothingToRename(this ProgressMonitor monitor) { monitor.ReportSuccess(GettextCatalog.GetString("Nothing to rename.")); }
public bool Deploy(DeployContext ctx, Solution solution, string defaultConf, string targetDir, bool generateFiles, ProgressMonitor monitor) { if (generateFiles) { if (!GenerateFiles(ctx, solution, defaultConf, monitor)) { return(false); } } monitor.BeginTask(GettextCatalog.GetString("Deploying Solution to Tarball"), 3); try { string baseDir = Path.GetDirectoryName(solution.FileName); ProcessWrapper ag_process = Runtime.ProcessService.StartProcess("sh", generateAutotools ? "autogen.sh" : "configure", baseDir, monitor.Log, monitor.Log, null); ag_process.WaitForOutput(); if (ag_process.ExitCode > 0) { throw new Exception(GettextCatalog.GetString("An unspecified error occurred while running '{0}'", generateAutotools ? "autogen.sh" : "configure")); } monitor.Step(1); using (var sw = new StringWriter()) { using (var chainedOutput = new LogTextWriter()) { chainedOutput.ChainWriter(monitor.Log); chainedOutput.ChainWriter(sw); using (ProcessWrapper process = Runtime.ProcessService.StartProcess("make", "dist", baseDir, chainedOutput, monitor.Log, null)) { process.WaitForOutput(); chainedOutput.UnchainWriter(monitor.Log); chainedOutput.UnchainWriter(sw); if (process.ExitCode > 0) { throw new Exception(GettextCatalog.GetString("An unspecified error occurred while running '{0}'", "make dist")); } } monitor.Step(1); // FIXME: hackish way to get the created tarball's filename string output = sw.ToString(); int targz = output.LastIndexOf("tar.gz"); int begin = output.LastIndexOf('>', targz); string filename = output.Substring(begin + 1, (targz - begin) + 5).Trim(); FileService.CopyFile(Path.Combine(baseDir, filename), Path.Combine(targetDir, filename)); monitor.Step(1); } } } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString("Solution could not be deployed: "), e); return(false); } finally { monitor.EndTask(); } monitor.ReportSuccess(GettextCatalog.GetString("Solution was successfully deployed.")); return(true); }
public bool GenerateFiles(DeployContext ctx, Solution solution, string defaultConf, ProgressMonitor monitor) { string filesString = generateAutotools ? "Autotools files" : "Makefiles"; monitor.BeginTask(GettextCatalog.GetString("Generating {0} for Solution {1}", filesString, solution.Name), 1); try { solution_dir = Path.GetDirectoryName(solution.FileName); string[] configs = new string [solution.Configurations.Count]; for (int ii = 0; ii < configs.Length; ii++) { configs [ii] = solution.Configurations[ii].Id; } MakefileType mt = generateAutotools ? MakefileType.AutotoolsMakefile : MakefileType.SimpleMakefile; context = new AutotoolsContext(ctx, solution_dir, configs, mt); context.TargetSolution = solution; context.Switches = switchs; IMakefileHandler handler = AutotoolsContext.GetMakefileHandler(solution.RootFolder, mt); if (handler == null) { throw new Exception(string.Format( "{0} does not currently support generating {1} for one (or more) child projects.", filesString, BrandingService.ApplicationName )); } solution_name = solution.Name; solution_version = AutotoolsContext.EscapeStringForAutoconf(solution.Version, true); if (string.IsNullOrEmpty(solution_version)) { solution_version = "0.1"; } Makefile makefile = handler.Deploy(context, solution.RootFolder, monitor); string path = Path.Combine(solution_dir, "Makefile"); if (generateAutotools) { context.AddAutoconfFile(path); CreateAutoGenDotSH(context, monitor); CreateConfigureDotAC(solution, defaultConf, monitor, context); CreateMacros(); } else { CreateConfigureScript(solution, defaultConf, context, monitor); monitor.Log.WriteLine(GettextCatalog.GetString("Creating rules.make")); string rules_make_path = Path.Combine(solution_dir, "rules.make"); File.Copy(Path.Combine(context.TemplateDir, "rules.make"), rules_make_path, true); context.AddGeneratedFile(rules_make_path); } CreateMakefileInclude(context, monitor); AddTopLevelMakefileVars(makefile, monitor); if (generateAutotools) { path = path + ".am"; } StreamWriter writer = new StreamWriter(path); makefile.Write(writer); writer.Close(); context.AddGeneratedFile(path); monitor.ReportSuccess(GettextCatalog.GetString("{0} were successfully generated.", filesString)); monitor.Step(1); } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString("{0} could not be generated: ", filesString), e); LoggingService.LogError(GettextCatalog.GetString("{0} could not be generated: ", filesString), e); DeleteGeneratedFiles(context); return(false); } finally { monitor.EndTask(); } return(true); }
public void CheckForUpdatesCompleted() { ProgressMonitor.ReportSuccess(projectsWithUpdatedPackages.Any()); updatedPackagesInSolution.CheckForUpdatesCompleted(this); }