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();
                }
            });
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 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);
        }
		protected virtual void OnButton24Clicked (object sender, System.EventArgs e)
		{
			var dialog = new SelectFileDialog (GettextCatalog.GetString ("Add items to toolbox")) {
				SelectMultiple = true,
				TransientFor = this,
			};
			dialog.AddFilter (null, "*.dll");
			if (dialog.Run ()) {
				indexModified = true;
				// Add the new files to the index
				using (var monitor = new MessageDialogProgressMonitor (true, false, false, true)) {
					monitor.BeginTask (GettextCatalog.GetString ("Looking for components..."), dialog.SelectedFiles.Length);
					foreach (string s in dialog.SelectedFiles) {
						var cif = index.AddFile (s);
						monitor.Step (1);
						if (cif != null) {
							// Select all new items by default
							foreach (var it in cif.Components)
								currentItems.Add (it, it);
						}
						else
							MessageService.ShowWarning (GettextCatalog.GetString ("The file '{0}' does not contain any component.", s));
					}
				}
				Fill ();
			}
		}
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
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();
                }
            });
        }
Exemplo n.º 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();
                    });
                }
            });
        }
Exemplo n.º 10
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();
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public async Task <bool> Initialize(IToolboxConsumer currentConsumer)
        {
            using (ProgressMonitor monitor = new MessageDialogProgressMonitor(true, true, false, true)) {
                index = await DesignerSupport.Service.ToolboxService.GetComponentIndex(monitor);

                if (monitor.CancellationToken.IsCancellationRequested)
                {
                    return(false);
                }
            }

            List <string> list = new List <string> ();

            foreach (ComponentIndexFile ifile in index.Files)
            {
                foreach (ItemToolboxNode co in ifile.Components)
                {
                    if (!list.Contains(co.ItemDomain))
                    {
                        list.Add(co.ItemDomain);
                    }
                }
            }

            string defaultDomain = null;

            if (currentConsumer != null)
            {
                defaultDomain = currentConsumer.DefaultItemDomain;
            }

            for (int n = 0; n < list.Count; n++)
            {
                string s = list [n];
                comboType.AppendText(s);
                if (s == defaultDomain)
                {
                    comboType.Active = n + 1;
                }
            }
            return(true);
        }
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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();
            }
        }
Exemplo n.º 16
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);
            }
        }
Exemplo n.º 17
0
        public override List <Change> PerformChanges(RefactoringOptions options, object prop)
        {
            string        newName = (string)prop;
            List <Change> changes = new List <Change>();

            using (var dialogProgressMonitor = new MessageDialogProgressMonitor(true, false, false, true)) {
                var references = finder.FindReferences((NamespaceResolveResult)options.ResolveResult, dialogProgressMonitor);
                if (references == null)
                {
                    return(changes);
                }
                foreach (MemberReference memberReference in references)
                {
                    TextReplaceChange textReplaceChange = new TextReplaceChange();
                    textReplaceChange.FileName     = (string)memberReference.FileName;
                    textReplaceChange.Offset       = memberReference.Position;
                    textReplaceChange.RemovedChars = memberReference.Name.Length;
                    textReplaceChange.InsertedText = newName;
                    textReplaceChange.Description  = string.Format(GettextCatalog.GetString("Replace '{0}' with '{1}'"), (object)memberReference.Name, (object)newName);
                    changes.Add((Change)textReplaceChange);
                }
            }
            return(changes);
        }
		public ComponentSelectorDialog (IToolboxConsumer currentConsumer)
		{
			using (IProgressMonitor monitor = new MessageDialogProgressMonitor (true, true, false, true)) {
				index = DesignerSupport.Service.ToolboxService.GetComponentIndex (monitor);
			}
			
			this.Build();
			
			store = new TreeStore (typeof(bool), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(ItemToolboxNode), typeof(bool), typeof(int));
			
			TreeViewColumn col;
			col = new TreeViewColumn ();
			Gtk.CellRendererToggle crt = new CellRendererToggle ();
			col.PackStart (crt, false);
			col.AddAttribute (crt, "active", ColChecked);
			col.AddAttribute (crt, "visible", ColShowCheck);
			crt.Toggled += OnToggleItem;
			col.SortColumnId = ColChecked;
			listView.AppendColumn (col);
			
			col = new TreeViewColumn ();
			col.Spacing = 3;
			col.Title = GettextCatalog.GetString ("Name");
			var crp = new CellRendererPixbuf ();
			CellRendererText crx = new CellRendererText ();
			crx.Width = 150;
			col.PackStart (crp, false);
			col.PackStart (crx, false);
			col.AddAttribute (crp, "pixbuf", ColIcon);
			col.AddAttribute (crp, "visible", ColShowCheck);
			col.AddAttribute (crx, "text", ColName);
			col.AddAttribute (crx, "weight", ColBold);
			listView.AppendColumn (col);
			col.Resizable = true;
			col.SortColumnId = ColName;
			
			col = listView.AppendColumn (GettextCatalog.GetString ("Library"), new CellRendererText (), "text", ColLibrary);
			col.Resizable = true;
			col.SortColumnId = ColLibrary;
			
			col = listView.AppendColumn (GettextCatalog.GetString ("Location"), new CellRendererText (), "text", ColPath);
			col.Resizable = true;
			col.SortColumnId = ColPath;
			
			store.SetSortColumnId (ColName, SortType.Ascending);
			listView.SearchColumn = ColName;
			listView.Model = store;
			
			foreach (ItemToolboxNode it in DesignerSupport.Service.ToolboxService.UserItems)
				currentItems [it] = it;
			
			List<string> list = new List<string> ();
			foreach (ComponentIndexFile ifile in index.Files) {
				foreach (ItemToolboxNode co in ifile.Components) {
					if (!list.Contains (co.ItemDomain))
						list.Add (co.ItemDomain);
				}
			}
			
			string defaultDomain = null;
			if (currentConsumer != null)
				defaultDomain = currentConsumer.DefaultItemDomain;
			
			comboType.AppendText (GettextCatalog.GetString ("All"));
			comboType.Active = 0;

			for (int n=0; n<list.Count; n++) {
				string s = list [n];
				comboType.AppendText (s);
				if (s == defaultDomain)
					comboType.Active = n+1;
			}
		}
Exemplo n.º 19
0
        public override List <Change> PerformChanges(RefactoringOptions options, object prop)
        {
            RenameProperties properties       = (RenameProperties)prop;
            List <Change>    result           = new List <Change> ();
            IEnumerable <MemberReference> col = null;

            using (var monitor = new MessageDialogProgressMonitor(true, false, false, true)) {
                col = ReferenceFinder.FindReferences(options.SelectedItem, properties.IncludeOverloads, monitor);
                if (col == null)
                {
                    return(result);
                }

                if (properties.RenameFile && options.SelectedItem is IType)
                {
                    var cls            = ((IType)options.SelectedItem).GetDefinition();
                    int currentPart    = 1;
                    var alreadyRenamed = new HashSet <string> ();
                    foreach (var part in cls.Parts)
                    {
                        if (alreadyRenamed.Contains(part.Region.FileName))
                        {
                            continue;
                        }
                        alreadyRenamed.Add(part.Region.FileName);

                        string oldFileName = System.IO.Path.GetFileNameWithoutExtension(part.Region.FileName);
                        string newFileName;
                        var    newName = properties.NewName;
                        if (string.IsNullOrEmpty(oldFileName) || string.IsNullOrEmpty(newName))
                        {
                            continue;
                        }
                        if (oldFileName.ToUpper() == newName.ToUpper() || oldFileName.ToUpper().EndsWith("." + newName.ToUpper(), StringComparison.Ordinal))
                        {
                            continue;
                        }
                        int idx = oldFileName.IndexOf(cls.Name, StringComparison.Ordinal);
                        if (idx >= 0)
                        {
                            newFileName = oldFileName.Substring(0, idx) + newName + oldFileName.Substring(idx + cls.Name.Length);
                        }
                        else
                        {
                            newFileName = currentPart != 1 ? newName + currentPart : newName;
                            currentPart++;
                        }

                        int t = 0;
                        while (System.IO.File.Exists(GetFullFileName(newFileName, part.Region.FileName, t)))
                        {
                            t++;
                        }
                        result.Add(new RenameFileChange(part.Region.FileName, GetFullFileName(newFileName, part.Region.FileName, t)));
                    }
                }

                foreach (var memberRef in col)
                {
                    TextReplaceChange change = new TextReplaceChange();
                    change.FileName     = memberRef.FileName;
                    change.Offset       = memberRef.Offset;
                    change.RemovedChars = memberRef.Length;
                    change.InsertedText = properties.NewName;
                    change.Description  = string.Format(GettextCatalog.GetString("Replace '{0}' with '{1}'"), memberRef.GetName(), properties.NewName);
                    result.Add(change);
                }
            }
            return(result);
        }