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(string), typeof(string));
43 private ICredentialsProvider credentialsProvider
;
46 public RepositoryView(ICredentialsProvider credentialsProvider
)
48 this.credentialsProvider
= credentialsProvider
;
49 AppendColumn("Repository", new CellRendererText (), "text", 0);
51 WorkspaceInfo
[] infos
= Workstation
.Current
.GetAllLocalWorkspaceInfo();
52 foreach (WorkspaceInfo info
in infos
)
54 Gtk
.TreeIter serverIter
= store
.AppendValues(info
.ServerUri
.ToString(), VersionControlPath
.RootFolder
);
55 store
.AppendValues(serverIter
, "", "");
59 HeadersVisible
= true;
64 protected override void PopulateRowChildren (TreeIter iter
)
66 string path
= store
.GetValue(iter
, 1).ToString();
68 string url
= String
.Empty
;
71 TreeIter current
= iter
;
72 while (store
.IterParent(out iterParent
, current
))
77 url
= store
.GetValue(current
, 0).ToString();
79 ICredentials credentials
= credentialsProvider
.GetCredentials(new Uri(url
), null);
80 TeamFoundationServer tfs
= TeamFoundationServerFactory
.GetServer(url
, credentials
);
81 VersionControlServer versionControlServer
= tfs
.GetService(typeof(VersionControlServer
)) as VersionControlServer
;
84 ItemSpec itemSpec
= new ItemSpec (path
, RecursionType
.OneLevel
);
85 ItemSet itemSet
= versionControlServer
.GetItems (itemSpec
, VersionSpec
.Latest
,
86 DeletedState
.NonDeleted
, ItemType
.Folder
, false);
87 if (itemSet
.Items
.Length
== 0)
88 SetRowValue(store
, iter
, indx
, " - item list not available - ", "");
90 foreach (Microsoft
.TeamFoundation
.VersionControl
.Client
.Item item
in itemSet
.Items
)
92 if (item
.ServerItem
== path
) continue;
94 string shortPath
= item
.ServerItem
.Substring(item
.ServerItem
.LastIndexOf('/') + 1);
95 Gtk
.TreeIter child
= SetRowValue(store
, iter
, indx
, shortPath
, item
.ServerItem
);
97 store
.AppendValues(child
, "", "");
102 protected override void ShowPopupMenu(TreePath path
)
106 ActionGroup
group = new ActionGroup ("Popup");
108 Action addrepo
= new Action ("addrepo", "Add Repository",
109 "Copy comment task", Gtk
.Stock
.Add
);
110 addrepo
.Activated
+= new EventHandler (OnAddRepository
);
111 group.Add (addrepo
, "<Control><Mod2>a");
113 Action columns
= new Action ("columns", "Columns");
114 group.Add (columns
, null);
116 ToggleAction columnLine
= new ToggleAction ("columnLine", "Line",
117 "Toggle visibility of Line column", null);
118 //columnLine.Toggled += new EventHandler (OnColumnVisibilityChanged);
119 // columnsActions[columnLine] = (int)Columns.Line;
120 group.Add (columnLine
);
122 UIManager uiManager
= new UIManager ();
123 uiManager
.InsertActionGroup (group, 0);
125 string uiStr
= "<ui><popup name='popup'>"
126 + "<menuitem action='addrepo'/>"
128 + "<menu action='columns'>"
129 + "<menuitem action='columnLine' />"
133 uiManager
.AddUiFromString (uiStr
);
134 menu
= (Menu
)uiManager
.GetWidget ("/popup");
141 store
.GetIter(out iter
, path
);
142 string tfpath
= store
.GetValue(iter
, 1).ToString();;
143 Console
.WriteLine(tfpath
);
149 void OnAddRepository(object sender
, EventArgs args
)
151 RepositoryDialog dialog
= new RepositoryDialog();