Example #1
0
        public static void SwitchToBranch(GitRepository repo, string branch)
        {
            MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor(true, false, false, true);

            try
            {
                IdeApp.Workbench.AutoReloadDocuments = true;
                IdeApp.Workbench.LockGui();
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        repo.SwitchToBranch(monitor, branch);
                    }
                    catch (Exception ex)
                    {
                        monitor.ReportError("Branch switch failed", ex);
                    }
                    finally
                    {
                        monitor.Dispose();
                    }
                });
                monitor.AsyncOperation.WaitForCompleted();
            }
            finally
            {
                IdeApp.Workbench.AutoReloadDocuments = false;
                IdeApp.Workbench.UnlockGui();
            }
        }
Example #2
0
        protected override void Run()
        {
            var            stashes = Repository.GetStashes();
            NewStashDialog dlg     = new NewStashDialog();

            if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
            {
                string comment = dlg.Comment;
                MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor(true, false, false, true);
                var statusTracker = IdeApp.Workspace.GetFileStatusTracker();
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        using (var gm = new GitMonitor(monitor))
                            stashes.Create(gm, comment);
                    } catch (Exception ex) {
                        MessageService.ShowException(ex);
                    }
                    finally {
                        monitor.Dispose();
                        statusTracker.NotifyChanges();
                    }
                });
            }
            dlg.Destroy();
        }
Example #3
0
        public static IAsyncOperation ApplyStash(Stash s)
        {
            MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor(true, false, false, true);
            var statusTracker = IdeApp.Workspace.GetFileStatusTracker();

            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    NGit.Api.MergeCommandResult result;
                    using (var gm = new GitMonitor(monitor))
                        result = s.Apply(gm);
                    ReportStashResult(monitor, result);
                }
                catch (Exception ex)
                {
                    string msg = GettextCatalog.GetString("Stash operation failed.");
                    monitor.ReportError(msg, ex);
                }
                finally
                {
                    monitor.Dispose();
                    statusTracker.NotifyChanges();
                }
            });
            return(monitor.AsyncOperation);
        }
        public IProgressMonitor ImportResourcesAsync(ResourceFolder parent, IEnumerable <string> pathes, List <ResourceItem> resourceItems, System.Action <IProgressMonitor> continueAction = null)
        {
            MessageDialogProgressMonitor monitor     = Services.ProgressMonitors.GetMessageDialogProgreeMonitor();
            CancellationTokenSource      tokenSource = new CancellationTokenSource();
            CancellationToken            token       = tokenSource.Token;
            Task task = Task.Factory.StartNew((System.Action)(() =>
            {
                IEnumerable <ResourceItem> collection = (IEnumerable <ResourceItem>) this.ImportResources(parent, pathes, (IProgressMonitor)monitor, token, (HashSet <string>)null);
                if (resourceItems == null || collection == null)
                {
                    return;
                }
                resourceItems.AddRange(collection);
            }), token);

            monitor.CancelRequested += (MonitorHandler)(m => tokenSource.Cancel());
            task.ContinueWith((System.Action <Task>)(a =>
            {
                Services.ProjectOperations.CurrentSelectedSolution.Save(Services.ProgressMonitors.Default);
                if (continueAction != null)
                {
                    continueAction((IProgressMonitor)monitor);
                }
                int num = (int)GLib.Timeout.Add(0U, (TimeoutHandler)(() =>
                {
                    monitor.Dispose();
                    if (monitor != null && monitor.Errors.Count == 0 && monitor.Warnings.Count == 0)
                    {
                        monitor.CloseDialogs();
                    }
                    return(false);
                }));
            }));
            return((IProgressMonitor)monitor);
        }
        protected override void Run()
        {
            var stashes = Repository.GetStashes();
            MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor(true, false, false, true);
            var statusTracker = IdeApp.Workspace.GetFileStatusTracker();

            ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    NGit.Api.MergeCommandResult result;
                    using (var gm = new GitMonitor(monitor))
                        result = stashes.Pop(gm);
                    GitService.ReportStashResult(monitor, result);
                }
                catch (Exception ex)
                {
                    MessageService.ShowException(ex);
                }
                finally
                {
                    monitor.Dispose();
                    statusTracker.NotifyChanges();
                }
            });
        }
        public List <ResourceItem> MessgeDialogImprotResource(ResourceFolder parent, IEnumerable <string> pathes)
        {
            MessageDialogProgressMonitor dialogProgreeMonitor = Services.ProgressMonitors.GetMessageDialogProgreeMonitor();
            ImportResourceResult         dic = FileOptionHelp.CopyToDic(parent, pathes, (IProgressMonitor)dialogProgreeMonitor, CancellationToken.None, (IEnumerable <string>)null);

            dialogProgreeMonitor.Dispose();
            if (dialogProgreeMonitor != null && dialogProgreeMonitor.Errors.Count == 0 && dialogProgreeMonitor.Warnings.Count == 0)
            {
                dialogProgreeMonitor.CloseDialogs();
            }
            IEnumerable <ResourceItem> addItems = dic.AddResourcePanelItems.Union <ResourceItem>((IEnumerable <ResourceItem>)dic.ImportResources);

            Services.EventsService.GetEvent <AddResourcesEvent>().Publish(new AddResourcesArgs(parent, addItems, true));
            return(dic.ImportResources);
        }
Example #7
0
        protected override void Run()
        {
            var monitor       = new MessageDialogProgressMonitor(true, false, false, true);
            var statusTracker = IdeApp.Workspace.GetFileStatusTracker();

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    GitService.ReportStashResult(Repository.PopStash(monitor, 0));
                } catch (Exception ex) {
                    MessageService.ShowError(GettextCatalog.GetString("Stash operation failed"), ex);
                }
                finally {
                    monitor.Dispose();
                    statusTracker.Dispose();
                }
            });
        }
Example #8
0
        protected override void Run()
        {
            var dlg = new NewStashDialog();

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    string comment       = dlg.Comment;
                    var    monitor       = new MessageDialogProgressMonitor(true, false, false, true);
                    var    statusTracker = IdeApp.Workspace.GetFileStatusTracker();
                    ThreadPool.QueueUserWorkItem(delegate {
                        try {
                            Stash stash;
                            if (Repository.TryCreateStash(monitor, comment, out stash))
                            {
                                string msg;
                                if (stash != null)
                                {
                                    msg = GettextCatalog.GetString("Changes successfully stashed");
                                }
                                else
                                {
                                    msg = GettextCatalog.GetString("No changes were available to stash");
                                }

                                DispatchService.GuiDispatch(delegate {
                                    IdeApp.Workbench.StatusBar.ShowMessage(msg);
                                });
                            }
                        } catch (Exception ex) {
                            MessageService.ShowError(GettextCatalog.GetString("Stash operation failed"), ex);
                        }
                        finally {
                            monitor.Dispose();
                            statusTracker.Dispose();
                        }
                    });
                }
            } finally {
                dlg.Destroy();
                dlg.Dispose();
            }
        }
Example #9
0
        protected override void Run()
        {
            var monitor = new MessageDialogProgressMonitor(true, false, false, true);

            FileService.FreezeEvents();
            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    GitService.ReportStashResult(Repository.PopStash(monitor, 0));
                } catch (Exception ex) {
                    MessageService.ShowError(GettextCatalog.GetString("Stash operation failed"), ex);
                }
                finally {
                    monitor.Dispose();
                    Runtime.RunInMainThread(delegate {
                        FileService.ThawEvents();
                    });
                }
            });
        }
Example #10
0
        public static IAsyncOperation ApplyStash(GitRepository repo, int s)
        {
            var monitor       = new MessageDialogProgressMonitor(true, false, false, true);
            var statusTracker = IdeApp.Workspace.GetFileStatusTracker();

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    ReportStashResult(repo.ApplyStash(monitor, s));
                } catch (Exception ex) {
                    string msg = GettextCatalog.GetString("Stash operation failed.");
                    monitor.ReportError(msg, ex);
                }
                finally {
                    monitor.Dispose();
                    statusTracker.Dispose();
                }
            });
            return(monitor.AsyncOperation);
        }
Example #11
0
        public static Task <bool> ApplyStash(GitRepository repo, int s)
        {
            var monitor = new MessageDialogProgressMonitor(true, false, false, true);
            var t       = Task.Run(delegate {
                try {
                    var res = repo.ApplyStash(monitor, s);
                    ReportStashResult(repo, res, null);
                    return(res == StashApplyStatus.Applied);
                } catch (Exception ex) {
                    string msg = GettextCatalog.GetString("Stash operation failed.");
                    monitor.ReportError(msg, ex);
                    return(false);
                }
                finally {
                    monitor.Dispose();
                }
            });

            return(t);
        }
Example #12
0
        public static async Task <bool> SwitchToBranchAsync(GitRepository repo, string branch)
        {
            var monitor = new MessageDialogProgressMonitor(true, false, false, true);

            try {
                IdeApp.Workbench.AutoReloadDocuments = true;
                IdeApp.Workbench.LockGui();
                try {
                    return(await repo.SwitchToBranchAsync(monitor, branch));
                } catch (Exception ex) {
                    monitor.ReportError(GettextCatalog.GetString("Branch switch failed"), ex);
                    return(false);
                } finally {
                    monitor.Dispose();
                }
            } finally {
                IdeApp.Workbench.AutoReloadDocuments = false;
                IdeApp.Workbench.UnlockGui();
            }
        }
Example #13
0
        public static void SwitchToBranch(GitRepository repo, string branch)
        {
            var monitor = new MessageDialogProgressMonitor(true, false, false, true);

            try {
                IdeApp.Workbench.AutoReloadDocuments = true;
                IdeApp.Workbench.LockGui();
                Task.Run(delegate {
                    try {
                        repo.SwitchToBranch(monitor, branch);
                    } catch (Exception ex) {
                        monitor.ReportError("Branch switch failed", ex);
                    } finally {
                        monitor.Dispose();
                    }
                }).Wait();
            } finally {
                IdeApp.Workbench.AutoReloadDocuments = false;
                IdeApp.Workbench.UnlockGui();
            }
        }
Example #14
0
        async void OnContinueButtonClicked(object sender, EventArgs e)
        {
            if (_controller.SelectedSample == null)
            {
                return;
            }

            ProgressMonitor progressMonitor = new MessageDialogProgressMonitor(true, false, true, true);

            Loading(true);

            var projectPath = await _controller.DownloadSampleAsync(progressMonitor);

            Loading(false);

            if (string.IsNullOrWhiteSpace(projectPath))
            {
                var errorMessage = "An error has occurred downloading the sample.";
                progressMonitor.ReportError(errorMessage);
                MessageService.ShowError(errorMessage);
            }
            else
            {
                progressMonitor.ReportSuccess("Sample downloaded.");
            }

            progressMonitor.EndTask();
            progressMonitor.Dispose();

            bool downloaded = !string.IsNullOrWhiteSpace(projectPath);

            if (downloaded)
            {
                Respond(Command.Ok);
                Close();

                await _controller.OpenSolutionAsync(projectPath);
            }
        }