3 using System
.Collections
;
4 using System
.Collections
.Generic
;
8 using Microsoft
.TeamFoundation
.Client
;
9 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
10 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
12 public class ChangesetView
: Gtk
.VPaned
, IExploreViewChild
14 private Gtk
.ListStore changesetListStore
;
15 private Gtk
.ListStore changesetDetailStore
;
16 private Driver driver
;
17 private Gtk
.TextBuffer textBuffer
;
18 private Gtk
.TreeView changesetList
;
19 private Gtk
.TreeView changesetDetail
;
20 private int stopAfter
;
22 public void InitializeChangesetList()
24 changesetList
= new Gtk
.TreeView();
26 changesetList
.AppendColumn ("Id", new Gtk
.CellRendererText (), "text", 0);
27 changesetList
.AppendColumn ("Owner", new Gtk
.CellRendererText (), "text", 1);
28 changesetList
.AppendColumn ("Date", new Gtk
.CellRendererText (), "text", 2);
29 changesetList
.AppendColumn ("Comment", new Gtk
.CellRendererText (), "text", 3);
31 changesetListStore
= new Gtk
.ListStore (typeof(string), typeof(string), typeof(string), typeof(string));
32 changesetList
.Model
= changesetListStore
;
33 changesetList
.Selection
.Changed
+= OnSelectionChanged
;
36 public void InitializeChangesetDetail()
38 changesetDetail
= new Gtk
.TreeView();
40 changesetDetail
.AppendColumn ("Type", new Gtk
.CellRendererText (), "text", 0);
41 changesetDetail
.AppendColumn ("File", new Gtk
.CellRendererText (), "text", 1);
43 changesetDetailStore
= new Gtk
.ListStore (typeof(string), typeof(string));
44 changesetDetail
.Model
= changesetDetailStore
;
47 public ChangesetView(Driver driver
, int stopAfter
)
50 this.stopAfter
= stopAfter
;
52 InitializeChangesetList();
53 InitializeChangesetDetail();
55 #if HAVE_ATLEAST_GTK_210
56 changesetList
.EnableGridLines
= TreeViewGridLines
.Vertical
;
57 changesetDetail
.EnableGridLines
= TreeViewGridLines
.Horizontal
;
60 ScrolledWindow scrolledWindow1
= new ScrolledWindow();
61 scrolledWindow1
.Add(changesetList
);
63 int x
, y
, width
, height
, depth
;
64 RootWindow
.GetGeometry (out x
, out y
, out width
, out height
, out depth
);
65 scrolledWindow1
.SetSizeRequest (Convert
.ToInt32((width
- 50) * 0.6) , (height
-40)/2);
66 Add1(scrolledWindow1
);
68 ScrolledWindow scrolledWindow2
= new ScrolledWindow();
69 Add2(scrolledWindow2
);
71 scrolledWindow2
.Add(changesetDetail
);
74 protected DiffOptions
GetDiffOptions(StreamWriter writer
)
76 DiffOptions options
= new DiffOptions();
77 options
.UseThirdPartyTool
= false;
78 options
.Flags
= DiffOptionFlags
.EnablePreambleHandling
;
79 options
.OutputType
= DiffOutputType
.Unified
;
80 options
.TargetEncoding
= Encoding
.UTF8
;
81 options
.SourceEncoding
= Encoding
.UTF8
;
82 options
.StreamWriter
= writer
;
83 options
.StreamWriter
.AutoFlush
= true;
88 void OnSelectionChanged (object o
, EventArgs args
)
93 TreeSelection treeSelection
= o
as TreeSelection
;
94 if (!(treeSelection
.GetSelected (out model
, out iter
))) return;
96 changesetDetailStore
.Clear();
98 int cid
= Convert
.ToInt32(model
.GetValue (iter
, 0));
99 Changeset changeset
= driver
.VersionControlServer
.GetChangeset(cid
, true, false);
101 StringBuilder sb
= new StringBuilder();
102 foreach (Change change
in changeset
.Changes
)
104 changesetDetailStore
.AppendValues(Command
.ChangeTypeToString(change
.ChangeType
), change
.Item
.ServerItem
);
108 void OnSelectionChanged2 (object o
, EventArgs args
)
113 TreeSelection treeSelection
= o
as TreeSelection
;
114 if (!(treeSelection
.GetSelected (out model
, out iter
))) return;
116 string cid
= (string) model
.GetValue (iter
, 0);
117 ChangesetVersionSpec versionSpec
= new ChangesetVersionSpec(cid
);
119 Toplevel
.GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.Watch
);
121 string tname
= System
.IO
.Path
.GetTempFileName();
122 using (StreamWriter sw
= new StreamWriter(tname
))
124 DiffHelper
.ShowChangeset(driver
.VersionControlServer
, versionSpec
,
125 false, GetDiffOptions(sw
));
128 using (StreamReader sr
= new StreamReader(tname
))
130 textBuffer
.Text
= sr
.ReadToEnd();
133 Toplevel
.GdkWindow
.Cursor
= new Gdk
.Cursor(Gdk
.CursorType
.LeftPtr
);
137 public void UpdatePath(string path
)
139 if (String
.IsNullOrEmpty(path
)) return;
140 changesetListStore
.Clear();
142 bool detailed
= false;
143 IEnumerable changeSets
= driver
.VersionControlServer
.QueryHistory(path
, VersionSpec
.Latest
, 0, RecursionType
.Full
, null,
144 null, null, stopAfter
, detailed
, false, false);
146 foreach (Changeset changeSet
in changeSets
)
148 changesetListStore
.AppendValues(changeSet
.ChangesetId
.ToString(),
150 changeSet
.CreationDate
.ToString("d"),
154 // this would be nice be seems to cause a segfault
155 //changesetList.ColumnsAutosize();