2 using System
.Collections
.Generic
;
8 using MonoDevelop
.Core
;
9 using MonoDevelop
.Ide
.Gui
;
10 using MonoDevelop
.Ide
.Gui
.Pads
;
11 using MonoDevelop
.Components
.Commands
;
12 using MonoDevelop
.VersionControl
.Views
;
14 using Microsoft
.TeamFoundation
.Client
;
15 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
16 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
17 using Gtk
.TeamFoundation
;
20 namespace MonoDevelop
.TeamFoundation
22 public class TeamFoundationView
: AbstractViewContent
, ICredentialsProvider
24 CredentialCache credentialCache
= new CredentialCache();
25 ExploreView exploreView
;
27 public TeamFoundationView() : base ()
29 this.ContentName
= "Team Foundation Browser";
30 this.IsViewOnly
= true;
32 exploreView
= new ExploreView(this, 50);
33 exploreView
.ShowChangeset
+= MyShowChangesetEventHandler
;
34 exploreView
.ShowFile
+= MyShowFileEventHandler
;
36 exploreView
.ShowAll();
39 public override Gtk
.Widget Control
{
40 get { return exploreView; }
43 public override void Load(string fileName
)
47 public string PromptForLogin(string uri
)
49 // first look in password cache
50 string login
= TeamFoundationSettings
.Current
.Get(uri
);
51 if (!String
.IsNullOrEmpty(login
)) return login
;
54 AuthenticationDialog dialog
= new AuthenticationDialog(uri
);
56 int rc
= dialog
.Run();
61 if (rc
!= Convert
.ToInt32(ResponseType
.Ok
)) return String
.Empty
;
65 public ICredentials
GetCredentials(Uri uri
, ICredentials failedCredentials
)
67 NetworkCredential creds
= credentialCache
.GetCredential(uri
, "NTLM");
68 if (creds
!= null) return creds
;
70 string login
= PromptForLogin(uri
.ToString());
71 creds
= new TFCredential(login
);
73 credentialCache
.Add(uri
, "NTLM", creds
);
77 public void NotifyCredentialsAuthenticated (Uri uri
)
81 void MyShowChangesetEventHandler(object sender
, ShowChangesetEventArgs args
)
83 int changesetId
= args
.ChangesetId
;
84 VersionControlServer vcs
= args
.VersionControlServer
;
85 ChangesetVersionSpec versionSpec
= new ChangesetVersionSpec(changesetId
);
87 string tname
= System
.IO
.Path
.GetTempFileName();
88 using (StreamWriter sw
= new StreamWriter(tname
))
90 DiffOptions options
= new DiffOptions();
91 options
.UseThirdPartyTool
= false;
92 options
.Flags
= DiffOptionFlags
.EnablePreambleHandling
;
93 options
.OutputType
= DiffOutputType
.Unified
;
94 options
.TargetEncoding
= Encoding
.UTF8
;
95 options
.SourceEncoding
= Encoding
.UTF8
;
96 options
.StreamWriter
= sw
;
97 options
.StreamWriter
.AutoFlush
= true;
99 DiffHelper
.ShowChangeset(vcs
, versionSpec
, false, options
);
102 Document d
= MonoDevelop
.Ide
.Gui
.IdeApp
.Workbench
.OpenDocument (tname
, true);
103 d
.FileName
= "Changeset " + changesetId
.ToString();
108 void MyShowFileEventHandler(object sender
, ShowFileEventArgs args
)
110 string serverItem
= args
.ServerItem
;
111 VersionControlServer vcs
= args
.VersionControlServer
;
113 Microsoft
.TeamFoundation
.VersionControl
.Client
.Item item
= vcs
.GetItem(serverItem
, VersionSpec
.Latest
, 0, true);
114 string tname
= System
.IO
.Path
.GetTempFileName();
115 item
.DownloadFile(tname
);
117 Document d
= MonoDevelop
.Ide
.Gui
.IdeApp
.Workbench
.OpenDocument (tname
, true);
118 d
.FileName
= serverItem
;