コード例 #1
0
 public void Add(string path)
 {
     DispatchService.GuiSyncDispatch(() => {
         project.AddReference(path);
         project.Save();
     });
 }
コード例 #2
0
        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();
             }
         }
     }
 }
コード例 #4
0
		public virtual void Remove ()
		{
			DispatchService.GuiSyncDispatch (() => {
				containingProject.RemoveProjectItem (this);
				containingProject.Save ();
			});
		}
コード例 #5
0
        public static ResolutionContext CreateCurrentContext()
        {
            Document doc = null;

            DispatchService.GuiSyncDispatch(() => doc = IdeApp.Workbench.ActiveDocument);
            return(CreateContext(doc));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public override void Send(SendOrPostCallback d, object state)
 {
     DispatchService.GuiSyncDispatch(delegate
     {
         d(state);
     });
 }
コード例 #8
0
        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;
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 static void SetDebugLayout()
 {
     // Dispatch synchronously to avoid start/stop races
     DispatchService.GuiSyncDispatch(delegate {
         IdeApp.Workbench.CurrentLayout = "Debug";
         IdeApp.Workbench.ShowCommandBar("Debug");
     });
 }
コード例 #11
0
		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);
     }
 }
コード例 #13
0
		public void Save (string fileName = null)
		{
			DispatchService.GuiSyncDispatch (() => {
				MonoDevelop.Ide.Gui.Document document = containingProject.GetOpenFile (FileName);
				if (document != null) {
					document.Save ();
				}
			});
		}
コード例 #14
0
        public override string GetSaveLocation()
        {
            string location = null;

            DispatchService.GuiSyncDispatch(new MessageHandler(delegate() {
                location = GetSaveLocation("HeapBuddy Snapshots", null);
            }));
            return(location);
        }
コード例 #15
0
        //		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);
        }
コード例 #16
0
 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());
            });
        }
コード例 #18
0
 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);
            });
        }
コード例 #20
0
 protected override void Run()
 {
     try {
         IPackageManagementProject project = PackageManagementServices.Solution.GetActiveProject();
         RestoreBeforeUpdateAction.Restore(project, () => {
             DispatchService.GuiSyncDispatch(() => Update(project));
         });
     } catch (Exception ex) {
         ShowStatusBarError(ex);
     }
 }
コード例 #21
0
 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;
         }
     });
 }
コード例 #22
0
        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;
            }
        }
コード例 #23
0
 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;
     });
 }
コード例 #24
0
 public void Write(string text, ScriptingStyle style)
 {
     DispatchService.GuiSyncDispatch(() => {
         if (style == ScriptingStyle.Prompt)
         {
             ConfigurePromptString();
             Prompt(false);
         }
         else
         {
             WriteOutput(text);
         }
     });
 }
コード例 #25
0
        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);
        }
コード例 #26
0
        public int GetMaximumVisibleColumns()
        {
            int maxVisibleColumns = 160;

            DispatchService.GuiSyncDispatch(() => {
                int windowWidth = Allocation.Width;

                if (windowWidth > 0)
                {
                    maxVisibleColumns = windowWidth / 5;
                }
            });

            return(maxVisibleColumns);
        }
コード例 #27
0
 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);
     }
 }
コード例 #28
0
        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);
        }
コード例 #29
0
            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();
            }
コード例 #30
0
        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);
        }