Ejemplo n.º 1
0
        async void HandleTreeviewFilesDiffLineActivated(object sender, EventArgs e)
        {
            TreePath[] paths = treeviewFiles.Selection.GetSelectedRows();

            if (paths.Length != 1)
            {
                return;
            }

            TreeIter iter;

            changedpathstore.GetIter(out iter, paths[0]);

            string fileName = (string)changedpathstore.GetValue(iter, colPath);
            int    line     = diffRenderer.GetSelectedLine(paths[0]);

            if (line == -1)
            {
                line = 1;
            }

            var proj = IdeApp.Workspace.GetProjectsContainingFile(fileName).FirstOrDefault();
            var doc  = await IdeApp.Workbench.OpenDocument(fileName, proj, line, 0, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer);

            doc?.GetContent <VersionControlDocumentController> ()?.ShowDiffView(await SelectedRevision.GetPreviousAsync(), SelectedRevision, line);
        }
Ejemplo n.º 2
0
 void OnOpen()
 {
     string[] files = GetCurrentFiles();
     if (files.Length == 0)
     {
         return;
     }
     else if (files.Length == 1)
     {
         TreePath[] rows = filelist.Selection.GetSelectedRows();
         int        line = -1;
         if (rows.Length == 1 && rows [0].Depth == 2)
         {
             line = diffRenderer.GetSelectedLine(rows[0]);
         }
         IdeApp.Workbench.OpenDocument(files [0], line, 0);
     }
     else
     {
         AlertButton openAll = new AlertButton(GettextCatalog.GetString("_Open All"));
         if (MessageService.AskQuestion(GettextCatalog.GetString("Do you want to open all {0} files?", files.Length), AlertButton.Cancel, openAll) == openAll)
         {
             for (int n = 0; n < files.Length; n++)
             {
                 IdeApp.Workbench.OpenDocument(files[n], n == 0);
             }
         }
     }
 }
Ejemplo n.º 3
0
		void HandleTreeviewFilesDiffLineActivated (object sender, EventArgs e)
		{
			TreePath[] paths = treeviewFiles.Selection.GetSelectedRows ();
			
			if (paths.Length != 1)
				return;
			
			TreeIter iter;
			changedpathstore.GetIter (out iter, paths[0]);
			
			string fileName = (string)changedpathstore.GetValue (iter, colPath);
			int line = diffRenderer.GetSelectedLine (paths[0]);
			var doc = IdeApp.Workbench.OpenDocument (fileName, line, 0, OpenDocumentOptions.Default | OpenDocumentOptions.OnlyInternalViewer);
			int i = 1;
			foreach (var content in doc.Window.SubViewContents) {
				DiffView diffView = content as DiffView;
				if (diffView != null) {
					doc.Window.SwitchView (i);
					diffView.ComparisonWidget.info.RunAfterUpdate (delegate {
						diffView.ComparisonWidget.SetRevision (diffView.ComparisonWidget.OriginalEditor, SelectedRevision.GetPrevious ());
						diffView.ComparisonWidget.SetRevision (diffView.ComparisonWidget.DiffEditor, SelectedRevision);
						
						diffView.ComparisonWidget.DiffEditor.Caret.Location = new Mono.TextEditor.DocumentLocation (line, 1);
						diffView.ComparisonWidget.DiffEditor.CenterToCaret ();
					});
					break;
				}
				i++;
			}
		}