48
49
colCommit.Visible = false;
50
51
object[] exts = AddinManager.GetExtensionObjects ("/MonoDevelop/VersionControl/CommitDialogExtensions", false);
52
bool separatorRequired = false;
51
54
foreach (object ob in exts) {
52
55
CommitDialogExtension ext = ob as CommitDialogExtension;
54
57
MessageService.ShowError ("Commit extension type " + ob.GetType() + " must be a subclass of CommitDialogExtension");
57
vboxExtensions.PackEnd (ext, false, false, 0);
58
ext.Initialize (changeSet);
60
ext.AllowCommitChanged += HandleAllowCommitChanged;
60
if (ext.Initialize (changeSet)) {
61
if (separatorRequired) {
62
HSeparator sep = new HSeparator ();
64
vboxExtensions.PackEnd (sep, false, false, 0);
66
vboxExtensions.PackEnd (ext, false, false, 0);
68
ext.AllowCommitChanged += HandleAllowCommitChanged;
69
separatorRequired = true;
62
73
HandleAllowCommitChanged (null, null);
75
86
selected.Add (info.LocalPath);
78
if (changeSet.GlobalComment.Length == 0) {
89
if (string.IsNullOrEmpty (changeSet.GlobalComment)) {
79
90
AuthorInformation aInfo;
80
91
CommitMessageFormat fmt = VersionControlService.GetCommitMessageFormat (changeSet, out aInfo);
81
92
Message = changeSet.GenerateGlobalComment (fmt, aInfo);
84
95
Message = changeSet.GlobalComment;
86
97
textview.Buffer.Changed += OnTextChanged;
99
// Focus the text view and move the insert point to the begining. Makes it easier to insert
101
textview.Buffer.MoveMark (textview.Buffer.InsertMark, textview.Buffer.StartIter);
102
textview.Buffer.MoveMark (textview.Buffer.SelectionBound, textview.Buffer.StartIter);
103
textview.GrabFocus ();
89
106
void HandleAllowCommitChanged (object sender, EventArgs e)
97
114
protected override void OnResponse (Gtk.ResponseType type)
99
if (type == Gtk.ResponseType.Ok) {
101
// Update the change set
102
ArrayList todel = new ArrayList ();
103
foreach (ChangeSetItem it in changeSet.Items) {
104
if (!selected.Contains (it.LocalPath))
105
todel.Add (it.LocalPath);
107
foreach (string file in todel)
108
changeSet.RemoveFile (file);
109
changeSet.GlobalComment = Message;
111
// Perform the commit
114
for (n=0; n<extensions.Count; n++) {
115
CommitDialogExtension ext = (CommitDialogExtension) extensions [n];
118
res = ext.OnBeginCommit (changeSet);
119
} catch (Exception ex) {
120
MessageService.ShowException (ex);
125
// Commit failed. Rollback the previous extensions
126
for (int m=0; m<n; m++) {
127
ext = (CommitDialogExtension) extensions [m];
129
ext.OnEndCommit (changeSet, false);
116
if (type != Gtk.ResponseType.Ok) {
137
117
changeSet.GlobalComment = oldMessage;
139
119
base.OnResponse (type);
122
protected void OnButtonCommitClicked (object sender, System.EventArgs e)
124
// Update the change set
125
ArrayList todel = new ArrayList ();
126
foreach (ChangeSetItem it in changeSet.Items) {
127
if (!selected.Contains (it.LocalPath))
128
todel.Add (it.LocalPath);
130
foreach (string file in todel)
131
changeSet.RemoveFile (file);
132
changeSet.GlobalComment = Message;
134
// Perform the commit
137
for (n=0; n<extensions.Count; n++) {
138
CommitDialogExtension ext = (CommitDialogExtension) extensions [n];
141
res = ext.OnBeginCommit (changeSet);
142
} catch (Exception ex) {
143
MessageService.ShowException (ex);
146
System.Console.WriteLine ("RES: " + res);
148
// Commit failed. Rollback the previous extensions
149
for (int m=0; m<n; m++) {
150
ext = (CommitDialogExtension) extensions [m];
152
ext.OnEndCommit (changeSet, false);
159
Respond (Gtk.ResponseType.Ok);
142
162
void OnTextChanged (object s, EventArgs args)