first.working.version
[tfs.git] / class / Gtk.TeamFoundation / RepositoryView.cs
blob706caffb54b728833363ad0f24764616399f1d2e
1 using System;
2 using System.IO;
3 using System.Net;
4 using Gtk;
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 TreeStore store = new TreeStore(typeof(string), typeof(string));
15 ScrolledWindow scroller = new ScrolledWindow();
16 CredentialCache credentialCache = new CredentialCache();
17 IVersionControlServerFactory vcsFactory;
19 public RepositoryView(IVersionControlServerFactory vcsFactory)
21 this.vcsFactory = vcsFactory;
23 AppendColumn("name", new CellRendererText (), "text", 0);
25 WorkspaceInfo[] infos = Workstation.Current.GetAllLocalWorkspaceInfo();
26 foreach (WorkspaceInfo info in infos)
28 Gtk.TreeIter serverIter = store.AppendValues(info.ServerUri.ToString(), VersionControlPath.RootFolder);
29 store.AppendValues(serverIter, "");
32 Model = store;
33 HeadersVisible = false;
35 ShowAll();
36 RowExpanded += MyRowExpandedHandler;
39 private void MyRowExpandedHandler (object o, RowExpandedArgs args)
41 string path = store.GetValue(args.Iter, 1).ToString();
43 string url = String.Empty;
44 TreeIter iterParent;
45 if (store.IterParent(out iterParent, args.Iter))
46 url = (string) store.GetValue (iterParent, 0);
47 else
48 url = store.GetValue(args.Iter, 0).ToString();
50 VersionControlServer versionControlServer = vcsFactory.GetVersionControlServer(url);
52 int indx = 0;
53 ItemSpec itemSpec = new ItemSpec (path, RecursionType.OneLevel);
54 ItemSet itemSet = versionControlServer.GetItems (itemSpec, VersionSpec.Latest,
55 DeletedState.NonDeleted, ItemType.Any, false);
56 if (itemSet.Items.Length == 0)
57 SetRowValue(args.Iter, indx, " - item list not available - ", "");
59 foreach (Microsoft.TeamFoundation.VersionControl.Client.Item item in itemSet.Items)
61 if (item.ServerItem == VersionControlPath.RootFolder) continue;
63 string shortPath = item.ServerItem.Substring(item.ServerItem.LastIndexOf('/') + 1);
64 if (item.ItemType == ItemType.Folder)
65 shortPath += "/";
67 Gtk.TreeIter child = SetRowValue(args.Iter, indx, shortPath, item.ServerItem);
69 if (item.ItemType == ItemType.Folder)
70 store.AppendValues(child, "", "");
72 indx++;
76 private Gtk.TreeIter SetRowValue(Gtk.TreeIter parent, int childIndx,
77 string cell1, string cell2)
79 Gtk.TreeIter child;
80 if (store.IterNthChild(out child, parent, childIndx))
82 store.SetValue(child, 0, cell1);
83 store.SetValue(child, 1, cell2);
85 else
86 child = store.AppendValues (parent, cell1, cell2);
88 return child;