6 using Microsoft
.TeamFoundation
.Client
;
7 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
8 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
10 namespace Gtk
.TeamFoundation
12 public class RepositoryView
: Gtk
.TreeView
14 private TreeStore store
= new TreeStore(typeof(string), typeof(string));
15 private ICredentialsProvider credentialsProvider
;
17 public RepositoryView(ICredentialsProvider credentialsProvider
)
19 this.credentialsProvider
= credentialsProvider
;
20 AppendColumn("name", new CellRendererText (), "text", 0);
22 WorkspaceInfo
[] infos
= Workstation
.Current
.GetAllLocalWorkspaceInfo();
23 foreach (WorkspaceInfo info
in infos
)
25 Gtk
.TreeIter serverIter
= store
.AppendValues(info
.ServerUri
.ToString(), VersionControlPath
.RootFolder
);
26 store
.AppendValues(serverIter
, "", "");
30 HeadersVisible
= false;
33 RowExpanded
+= MyRowExpandedHandler
;
36 private void MyRowExpandedHandler (object o
, RowExpandedArgs args
)
38 string path
= store
.GetValue(args
.Iter
, 1).ToString();
40 string url
= String
.Empty
;
43 TreeIter current
= args
.Iter
;
44 while (store
.IterParent(out iterParent
, current
))
48 url
= store
.GetValue(current
, 0).ToString();
50 //Console.WriteLine("path=" + path + ", url=" + url);
52 ICredentials credentials
= credentialsProvider
.GetCredentials(new Uri(url
), null);
53 TeamFoundationServer tfs
= TeamFoundationServerFactory
.GetServer(url
, credentials
);
54 VersionControlServer versionControlServer
= tfs
.GetService(typeof(VersionControlServer
)) as VersionControlServer
;
57 ItemSpec itemSpec
= new ItemSpec (path
, RecursionType
.OneLevel
);
58 ItemSet itemSet
= versionControlServer
.GetItems (itemSpec
, VersionSpec
.Latest
,
59 DeletedState
.NonDeleted
, ItemType
.Any
, false);
60 if (itemSet
.Items
.Length
== 0)
61 SetRowValue(args
.Iter
, indx
, " - item list not available - ", "");
63 foreach (Microsoft
.TeamFoundation
.VersionControl
.Client
.Item item
in itemSet
.Items
)
65 if (item
.ServerItem
== path
) continue;
67 string shortPath
= item
.ServerItem
.Substring(item
.ServerItem
.LastIndexOf('/') + 1);
68 if (item
.ItemType
== ItemType
.Folder
)
71 Gtk
.TreeIter child
= SetRowValue(args
.Iter
, indx
, shortPath
, item
.ServerItem
);
73 if (item
.ItemType
== ItemType
.Folder
)
74 store
.AppendValues(child
, "", "");
80 private Gtk
.TreeIter
SetRowValue(Gtk
.TreeIter parent
, int childIndx
,
81 string cell1
, string cell2
)
84 if (store
.IterNthChild(out child
, parent
, childIndx
))
86 store
.SetValue(child
, 0, cell1
);
87 store
.SetValue(child
, 1, cell2
);
90 child
= store
.AppendValues (parent
, cell1
, cell2
);