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.
33 using Microsoft
.TeamFoundation
.Client
;
34 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
35 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
37 namespace Gtk
.TeamFoundation
39 public interface IExploreViewChild
41 void UpdatePath(VersionControlServer vcs
, string path
);
44 public class ExploreView
: Gtk
.VBox
46 private RepositoryView repositoryView
;
47 private ChangesetView changesetView
;
48 private DirectoryView directoryView
;
49 private VPaned viewChildren
;
50 private string currentSelectedPath
;
51 private VersionControlServer currentVcs
;
52 private ICredentialsProvider credentialsProvider
;
54 public ExploreView(ICredentialsProvider credentialsProvider
,
55 int stopAfter
) : base (false, 1)
57 this.credentialsProvider
= credentialsProvider
;
59 HPaned hPaned
= new HPaned();
62 ScrolledWindow scrolledWindow
= new ScrolledWindow();
63 hPaned
.Add1(scrolledWindow
);
65 repositoryView
= new RepositoryView(credentialsProvider
);
66 scrolledWindow
.Add(repositoryView
);
68 viewChildren
= new VPaned();
70 directoryView
= new DirectoryView();
71 viewChildren
.Add(directoryView
);
73 changesetView
= new ChangesetView(stopAfter
);
74 viewChildren
.Add(changesetView
);
76 int x
, y
, width
, height
, depth
;
77 RootWindow
.GetGeometry (out x
, out y
, out width
, out height
, out depth
);
79 hPaned
.Add2(viewChildren
);
80 hPaned
.Position
= (width
- 50) / 3;
83 Statusbar sb
= new Statusbar ();
84 sb
.HasResizeGrip
= false;
85 PackEnd(sb
, false, false, 1);
88 repositoryView
.Selection
.Changed
+= OnPathSelectionChanged
;
91 void OnPathSelectionChanged (object o
, EventArgs args
)
96 if (!((TreeSelection
)o
).GetSelected (out model
, out iter
)) return;
99 bool not_root
= false;
100 TreeIter current
= iter
;
101 while (model
.IterParent(out iterParent
, current
))
103 current
= iterParent
;
109 string url
= (string) model
.GetValue (current
, 0);
110 ICredentials credentials
= credentialsProvider
.GetCredentials(new Uri(url
), null);
111 TeamFoundationServer tfs
= TeamFoundationServerFactory
.GetServer(url
, credentials
);
112 currentVcs
= tfs
.GetService(typeof(VersionControlServer
)) as VersionControlServer
;
114 currentSelectedPath
= (string) model
.GetValue (iter
, 1);
115 UpdateChildPath(directoryView
);
116 UpdateChildPath(changesetView
);
120 protected void UpdateChildPath(IExploreViewChild child
)
122 if (currentVcs
== null) return;
123 GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.Watch
);
124 child
.UpdatePath(currentVcs
, currentSelectedPath
);
125 GdkWindow
.Cursor
= null;