5 // Joel Reed (joelwreed@gmail.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using Microsoft
.TeamFoundation
.Client
;
35 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
36 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
38 namespace Gtk
.TeamFoundation
40 public class RepositoryView
: TreeViewBase
42 private TreeStore store
= new TreeStore(typeof(Gdk
.Pixbuf
), typeof(string), typeof(string));
43 private ICredentialsProvider credentialsProvider
;
44 private RepositoryMenu menu
= new RepositoryMenu();
45 private Gdk
.Pixbuf repositoryPixbuf
;
47 public RepositoryView(ICredentialsProvider credentialsProvider
)
49 this.credentialsProvider
= credentialsProvider
;
50 repositoryPixbuf
= Gdk
.Pixbuf
.LoadFromResource("repository.png");
52 TreeViewColumn column
= new TreeViewColumn ();
53 CellRendererText crt
= new CellRendererText();
54 CellRendererPixbuf crp
= new CellRendererPixbuf();
55 column
.Title
= "Repository";
56 column
.PackStart(crp
, false);
57 column
.PackStart(crt
, true);
58 column
.AddAttribute(crp
, "pixbuf", 0);
59 column
.AddAttribute(crt
, "text", 1);
62 WorkspaceInfo
[] infos
= Workstation
.Current
.GetAllLocalWorkspaceInfo();
63 foreach (WorkspaceInfo info
in infos
)
65 Gtk
.TreeIter serverIter
= store
.AppendValues(repositoryPixbuf
, info
.ServerUri
.ToString(), VersionControlPath
.RootFolder
);
66 store
.AppendValues(serverIter
, null, "", "");
70 HeadersVisible
= true;
75 protected override void PopulateRowChildren (TreeIter iter
)
77 string path
= store
.GetValue(iter
, 2).ToString();
79 string url
= String
.Empty
;
82 TreeIter current
= iter
;
83 while (store
.IterParent(out iterParent
, current
))
88 url
= store
.GetValue(current
, 1).ToString();
90 ICredentials credentials
= credentialsProvider
.GetCredentials(new Uri(url
), null);
91 TeamFoundationServer tfs
= TeamFoundationServerFactory
.GetServer(url
, credentials
);
92 VersionControlServer versionControlServer
= tfs
.GetService(typeof(VersionControlServer
)) as VersionControlServer
;
95 ItemSpec itemSpec
= new ItemSpec(path
, RecursionType
.OneLevel
);
96 ItemSet itemSet
= versionControlServer
.GetItems(itemSpec
, VersionSpec
.Latest
,
97 DeletedState
.NonDeleted
, ItemType
.Folder
, false);
98 if (itemSet
.Items
.Length
== 0)
99 SetRowValue(store
, iter
, indx
, null, " - item list not available - ", "");
101 foreach (Microsoft
.TeamFoundation
.VersionControl
.Client
.Item item
in itemSet
.Items
)
103 if (item
.ServerItem
== path
) continue;
105 string shortPath
= item
.ServerItem
.Substring(item
.ServerItem
.LastIndexOf('/') + 1);
106 Gtk
.TreeIter child
= SetRowValue(store
, iter
, indx
, null, shortPath
, item
.ServerItem
);
108 store
.AppendValues(child
, null, "", "");
113 protected override void ShowPopupMenu(TreePath path
)
115 string tfpath
= String
.Empty
;
120 store
.GetIter(out iter
, path
);
121 tfpath
= store
.GetValue(iter
, 2).ToString();;
122 Console
.WriteLine(tfpath
);
128 void OnAddRepository(object sender
, EventArgs args
)
130 RepositoryDialog dialog
= new RepositoryDialog();