public void Add(string path) { DispatchService.GuiSyncDispatch(() => { project.AddReference(path); project.Save(); }); }
static void updateTh_method() { while (true) { stateChanged.WaitOne(); while (stateChanged.WaitOne(400)) { ; } DispatchService.GuiSyncDispatch(() => { var p = Ide.IdeApp.Workbench.GetPad <MixinInsightPad>(); if (p == null) { return; } pad = p.Content as MixinInsightPad; }); if (pad != null && pad.Window.ContentVisible) { pad.Update(); } } }
public override void Execute(MonoDevelop.Core.IProgressMonitor monitor, IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration) { if (base.CanExecute(item, context, configuration)) { // It is executable by default base.Execute(monitor, item, context, configuration); return; } else if (item is IWorkspaceObject) { UnitTest test = NUnitService.Instance.FindRootTest((IWorkspaceObject)item); if (test != null) { IAsyncOperation oper = null; DispatchService.GuiSyncDispatch(delegate { oper = NUnitService.Instance.RunTest(test, context.ExecutionHandler, false); }); if (oper != null) { monitor.CancelRequested += delegate { oper.Cancel(); }; oper.WaitForCompleted(); } } } }
public virtual void Remove () { DispatchService.GuiSyncDispatch (() => { containingProject.RemoveProjectItem (this); containingProject.Save (); }); }
public static ResolutionContext CreateCurrentContext() { Document doc = null; DispatchService.GuiSyncDispatch(() => doc = IdeApp.Workbench.ActiveDocument); return(CreateContext(doc)); }
internal static CustomExecutionMode ShowParamtersDialog(CommandExecutionContext ctx, IExecutionMode mode, CustomExecutionMode currentMode) { CustomExecutionMode cmode = null; DispatchService.GuiSyncDispatch(delegate { CustomExecutionModeDialog dlg = new CustomExecutionModeDialog(); try { dlg.Initialize(ctx, mode, currentMode); if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok) { cmode = dlg.GetConfigurationData(); cmode.Project = ctx.Project; if (dlg.Save) { SaveCustomCommand(ctx.Project, cmode); } } } finally { dlg.Destroy(); } }); return(cmode); }
public override void Send(SendOrPostCallback d, object state) { DispatchService.GuiSyncDispatch(delegate { d(state); }); }
public void WriteOpenFiles() { if (filesToWrite == null) { return; } if (filesToWrite.Count == 0) { filesToWrite = null; return; } //these documents are open, so needs to run in GUI thread DispatchService.GuiSyncDispatch(delegate { foreach (KeyValuePair <FilePath, string> item in filesToWrite) { try { bool updated = false; foreach (MonoDevelop.Ide.Gui.Document doc in IdeApp.Workbench.Documents) { if (doc.FileName == item.Key) { var textFile = doc.GetContent <MonoDevelop.Projects.Text.IEditableTextFile> (); if (textFile == null) { continue; } //change the contents //FIXME: Workaround for "Bug 484574 - Setting SourceEditorView.Text doesn't mark the document as dirty" // The bug means that the docuemnt doesn't get saved or reparsed. textFile.DeleteText(0, textFile.Length); textFile.InsertText(0, item.Value); doc.Save(); updated = true; break; } } if (!updated) { var textFile = MonoDevelop.Projects.Text.TextFile.ReadFile(item.Key); textFile.Text = item.Value; textFile.Save(); } WrittenCount++; } catch (IOException ex) { monitor.ReportError( GettextCatalog.GetString("Failed to write file '{0}'.", item.Key), ex); } } }); filesToWrite = null; }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying) { bool result = false; DispatchService.GuiSyncDispatch(() => { using (var ns = new NSAutoreleasePool()) { var message = string.Format("{0} needs {1} credentials to access {2}.", BrandingService.ApplicationName, credentialType == CredentialType.ProxyCredentials ? "proxy" : "request", uri.Host); NSAlert alert = NSAlert.WithMessage("Credentials Required", "OK", "Cancel", null, message); alert.Icon = NSApplication.SharedApplication.ApplicationIconImage; NSView view = new NSView(new RectangleF(0, 0, 313, 91)); var creds = Utility.GetCredentialsForUriFromICredentials(uri, existingCredentials); var usernameLabel = new NSTextField(new RectangleF(17, 55, 71, 17)) { Identifier = "usernameLabel", StringValue = "Username:"******"Password:", Alignment = NSTextAlignment.Right, Editable = false, Bordered = false, DrawsBackground = false, Bezeled = false, Selectable = false, }; view.AddSubview(passwordLabel); var passwordInput = new NSSecureTextField(new RectangleF(93, 20, 200, 22)); passwordInput.StringValue = creds != null ? creds.Password : string.Empty; view.AddSubview(passwordInput); alert.AccessoryView = view; result = alert.RunModal() == 1; username = usernameInput.StringValue; password = passwordInput.StringValue; } }); return(result ? new NetworkCredential(username, password) : null); }
static void SetDebugLayout() { // Dispatch synchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { IdeApp.Workbench.CurrentLayout = "Debug"; IdeApp.Workbench.ShowCommandBar("Debug"); }); }
public void Delete () { DispatchService.GuiSyncDispatch (() => { containingProject.RemoveProjectItem (this); containingProject.DeleteFile (projectItem.FilePath); containingProject.Save (); }); }
public void Dispose() { foreach (GlobalAndInternalProject msbuildProjects in projects) { DispatchService.GuiSyncDispatch(() => UpdateProject(msbuildProjects)); GetGlobalProjectCollection().UnloadProject(msbuildProjects.GlobalMSBuildProject); } }
public void Save (string fileName = null) { DispatchService.GuiSyncDispatch (() => { MonoDevelop.Ide.Gui.Document document = containingProject.GetOpenFile (FileName); if (document != null) { document.Save (); } }); }
public override string GetSaveLocation() { string location = null; DispatchService.GuiSyncDispatch(new MessageHandler(delegate() { location = GetSaveLocation("HeapBuddy Snapshots", null); })); return(location); }
// internal ProjectItem FindProjectItem(string fileName) // { // SD.FileProjectItem item = DotNetProject.FindFile(fileName); // if (item != null) { // return new ProjectItem(this, item); // } // return null; // } internal MonoDevelop.Ide.Gui.Document GetOpenFile(string fileName) { MonoDevelop.Ide.Gui.Document document = null; DispatchService.GuiSyncDispatch(() => { document = IdeApp.Workbench.GetDocument(fileName); }); return(document); }
public static MeeGoDevice GetChosenDevice() { if (chosenDevice == null) { DispatchService.GuiSyncDispatch(delegate { chosenDevice = MeeGoDevicePicker.GetDevice(null); }); } return(chosenDevice); }
protected override void SetValue(object value) { int fontSize = Convert.ToInt32(value) * 1024; FontDescription fontDescription = FontService.MonospaceFont.Copy(); fontDescription.Size = fontSize; DispatchService.GuiSyncDispatch(() => { FontService.SetFont("Editor", fontDescription.ToString()); }); }
public override void Dispatch(StatefulMessageHandler cb, object ob) { if (DispatchService.IsGuiThread) { cb(ob); } else { DispatchService.GuiSyncDispatch(cb, ob); } }
void NotifyFilesChanged() { DispatchService.GuiSyncDispatch(() => { FilePath[] files = fileChangedEvents .SelectMany(fileChangedEvent => fileChangedEvent.ToArray()) .Select(fileInfo => fileInfo.FileName) .ToArray(); NotifyFilesChanged(files); }); }
protected override void Run() { try { IPackageManagementProject project = PackageManagementServices.Solution.GetActiveProject(); RestoreBeforeUpdateAction.Restore(project, () => { DispatchService.GuiSyncDispatch(() => Update(project)); }); } catch (Exception ex) { ShowStatusBarError(ex); } }
static void UnsetDebugLayout(string layout) { // Dispatch synchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { IdeApp.Workbench.HideCommandBar("Debug"); if (IdeApp.Workbench.CurrentLayout == "Debug") { IdeApp.Workbench.CurrentLayout = layout; } }); }
internal static void InternalRun(ExecutionCommand cmd, DebuggerEngine factory, IConsole c) { if (factory == null) { factory = GetFactoryForCommand(cmd); if (factory == null) { throw new InvalidOperationException("Unsupported command: " + cmd); } } if (session != null) { throw new InvalidOperationException("A debugger session is already started"); } DebuggerStartInfo startInfo = factory.CreateDebuggerStartInfo(cmd); startInfo.UseExternalConsole = c is ExternalConsole; startInfo.CloseExternalConsoleOnExit = c.CloseOnDispose; currentEngine = factory; session = factory.CreateSession(); session.ExceptionHandler = ExceptionHandler; // When using an external console, create a new internal console which will be used // to show the debugger log if (startInfo.UseExternalConsole) { console = (IConsole)IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor(); } else { console = c; } SetupSession(); // Dispatch synchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { oldLayout = IdeApp.Workbench.CurrentLayout; IdeApp.Workbench.CurrentLayout = "Debug"; }); try { session.Run(startInfo, GetUserOptions()); } catch { Cleanup(); throw; } }
static void UnsetDebugLayout() { // Dispatch synchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { IdeApp.Workbench.HideCommandBar("Debug"); if (IdeApp.Workbench.CurrentLayout == "Debug") { IdeApp.Workbench.CurrentLayout = oldLayout ?? "Solution"; } oldLayout = null; }); }
public void Write(string text, ScriptingStyle style) { DispatchService.GuiSyncDispatch(() => { if (style == ScriptingStyle.Prompt) { ConfigurePromptString(); Prompt(false); } else { WriteOutput(text); } }); }
public override bool Get(URIish uri, params CredentialItem[] items) { bool result = false; DispatchService.GuiSyncDispatch(delegate { CredentialsDialog dlg = new CredentialsDialog(uri, items); try { result = MessageService.ShowCustomDialog(dlg) == (int)Gtk.ResponseType.Ok; } finally { dlg.Destroy(); } }); return(result); }
public int GetMaximumVisibleColumns() { int maxVisibleColumns = 160; DispatchService.GuiSyncDispatch(() => { int windowWidth = Allocation.Width; if (windowWidth > 0) { maxVisibleColumns = windowWidth / 5; } }); return(maxVisibleColumns); }
protected override void Run() { try { UpdateAllPackagesInSolution updateAllPackages = CreateUpdateAllPackagesInSolution(); ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage(updateAllPackages.Projects); RestoreBeforeUpdateAction.Restore(updateAllPackages.Projects, () => { DispatchService.GuiSyncDispatch(() => { Update(updateAllPackages, progressMessage); }); }); } catch (Exception ex) { ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage(); PackageManagementServices.BackgroundPackageActionRunner.ShowError(progressMessage, ex); } }
public IEnumerable <PackageManagementPackageReference> GetInstalledPackages(Project project) { List <PackageManagementPackageReference> packageReferences = null; DispatchService.GuiSyncDispatch(() => { string url = RegisteredPackageSources.DefaultPackageSourceUrl; var repository = registeredPackageRepositories.CreateRepository(new PackageSource(url)); IPackageManagementProject packageManagementProject = solution.GetProject(repository, new DotNetProjectProxy((DotNetProject)project)); packageReferences = packageManagementProject .GetPackageReferences() .Select(packageReference => new PackageManagementPackageReference(packageReference.Id, packageReference.Version.ToString())) .ToList(); }); return(packageReferences); }
protected override void InnerRun() { int counter = 0; int totalProjects = widget.projects.Count; try { foreach (ProjectProperties projectprop in widget.projects) { CodeMetricsService.AddTypes(projectprop, widget.ctx); } foreach (ProjectProperties projectprop in widget.projects) { ObjectOrientedMetrics.EvaluateOOMetrics(widget.ctx, projectprop); ComplexityMetrics.EvaluateComplexityMetrics(widget.ctx, projectprop); CodeMetricsService.ProcessInnerTypes(projectprop); Gtk.Application.Invoke(delegate { FillTree(projectprop); }); if (base.IsStopping) { return; } lock (lockCounter) { counter++; DispatchService.GuiSyncDispatch(delegate { IdeApp.Workbench.StatusBar.SetProgressFraction(counter / (double)totalProjects); }); } } } catch (Exception e) { Console.WriteLine("Error : " + e.ToString()); base.Stop(); } Gtk.Application.Invoke(delegate { IdeApp.Workbench.StatusBar.ShowMessage("Finished calculating metrics\n"); IdeApp.Workbench.StatusBar.EndProgress(); widget.textviewReport.Buffer.Text = GettextCatalog.GetString("Finished calculating metrics\n"); widget.textviewReport.Buffer.Text += CodeMetricsService.GenerateAssemblyMetricText(); }); base.Stop(); }
public override bool Get(URIish uri, params CredentialItem[] items) { bool result = false; CredentialItem.Password passwordItem = null; CredentialItem.StringType passphraseItem = null; // We always need to run the TryGet* methods as we need the passphraseItem/passwordItem populated even // if the password store contains an invalid password/no password if (TryGetUsernamePassword(uri, items, out passwordItem) || TryGetPassphrase(uri, items, out passphraseItem)) { // If the password store has a password and we already tried using it, it could be incorrect. // If this happens, do not return true and ask the user for a new password. if (!HasReset) { return(true); } } DispatchService.GuiSyncDispatch(delegate { CredentialsDialog dlg = new CredentialsDialog(uri, items); try { result = MessageService.ShowCustomDialog(dlg) == (int)Gtk.ResponseType.Ok; } finally { dlg.Destroy(); } }); HasReset = false; if (result) { if (passwordItem != null) { PasswordService.AddWebPassword(new Uri(uri.ToString()), new string (passwordItem.GetValue())); } else if (passphraseItem != null) { PasswordService.AddWebPassword(new Uri(uri.ToString()), passphraseItem.GetValue()); } } return(result); }