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 event ShowChangesetEventHandler ShowChangeset
;
55 public event ShowFileEventHandler ShowFile
;
57 public ExploreView(ICredentialsProvider credentialsProvider
,
58 int stopAfter
) : base (false, 1)
60 this.credentialsProvider
= credentialsProvider
;
62 HPaned hPaned
= new HPaned();
65 ScrolledWindow scrolledWindow
= new ScrolledWindow();
66 hPaned
.Add1(scrolledWindow
);
68 repositoryView
= new RepositoryView(credentialsProvider
);
69 scrolledWindow
.Add(repositoryView
);
71 viewChildren
= new VPaned();
73 directoryView
= new DirectoryView(this);
74 viewChildren
.Pack1(directoryView
, true, true);
76 changesetView
= new ChangesetView(this, stopAfter
);
77 viewChildren
.Pack2(changesetView
, true, true);
79 int x
, y
, width
, height
, depth
;
80 RootWindow
.GetGeometry (out x
, out y
, out width
, out height
, out depth
);
82 hPaned
.Add2(viewChildren
);
83 hPaned
.Position
= (width
- 50) / 3;
86 Statusbar sb
= new Statusbar ();
87 sb
.HasResizeGrip
= false;
88 PackEnd(sb
, false, false, 1);
91 repositoryView
.Selection
.Changed
+= OnPathSelectionChanged
;
94 public void OnShowChangeset(object sender
, ShowChangesetEventArgs args
)
96 if (ShowChangeset
!= null)
97 ShowChangeset(sender
, args
);
100 public void OnShowFile(object sender
, ShowFileEventArgs args
)
102 if (ShowFile
!= null)
103 ShowFile(sender
, args
);
106 void OnPathSelectionChanged (object o
, EventArgs args
)
111 if (!((TreeSelection
)o
).GetSelected (out model
, out iter
)) return;
114 bool not_root
= false;
115 TreeIter current
= iter
;
116 while (model
.IterParent(out iterParent
, current
))
118 current
= iterParent
;
124 string url
= (string) model
.GetValue (current
, 0);
125 ICredentials credentials
= credentialsProvider
.GetCredentials(new Uri(url
), null);
126 TeamFoundationServer tfs
= TeamFoundationServerFactory
.GetServer(url
, credentials
);
128 currentVcs
= tfs
.GetService(typeof(VersionControlServer
)) as VersionControlServer
;
129 if (currentVcs
== null) return;
131 currentSelectedPath
= (string) model
.GetValue (iter
, 1);
133 GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.Watch
);
134 directoryView
.UpdatePath(currentVcs
, currentSelectedPath
);
135 changesetView
.UpdatePath(currentVcs
, currentSelectedPath
);
136 GdkWindow
.Cursor
= null;