| 0: | // CVSCheckOutDialog.cs | |
| 1: | // Copyright (C) 2000 Mike Krueger | |
| 2: | // | |
| 3: | // This program is free software; you can redistribute it and/or | |
| 4: | // modify it under the terms of the GNU General Public License | |
| 5: | // as published by the Free Software Foundation; either version 2 | |
| 6: | // of the License, or any later version. | |
| 7: | // | |
| 8: | // This program is distributed in the hope that it will be useful, | |
| 9: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11: | // GNU General Public License for more details. | |
| 12: | // | |
| 13: | // You should have received a copy of the GNU General Public License | |
| 14: | // along with this program; if not, write to the Free Software | |
| 15: | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 16: | ||
| 17: | using System; | |
| 18: | using System.IO; | |
| 19: | using System.Threading; | |
| 20: | using System.Drawing; | |
| 21: | using System.Collections; | |
| 22: | using System.ComponentModel; | |
| 23: | using System.Windows.Forms; | |
| 24: | using System.Data; | |
| 25: | ||
| 26: | using SharpDevelop.Gui; | |
| 27: | using CVS; | |
| 28: | using CVS.Commands; | |
| 29: | using CVS.Misc; | |
| 30: | ||
| 31: | namespace SharpDevelop.Gui.Dialogs { | |
| 32: | ||
| 33: | public class CVSCheckOutDialog : System.Windows.Forms.Form | |
| 34: | { | |
| 35: | private System.Windows.Forms.GroupBox groupBox2; | |
| 36: | private System.Windows.Forms.TextBox textBox1; | |
| 37: | private System.Windows.Forms.Button button1; | |
| 38: | private System.Windows.Forms.GroupBox groupBox3; | |
| 39: | private System.Windows.Forms.ComboBox comboBox2; | |
| 40: | private System.Windows.Forms.GroupBox groupBox1; | |
| 41: | private System.Windows.Forms.ComboBox comboBox1; | |
| 42: | private System.Windows.Forms.Button startButton; | |
| 43: | private System.Windows.Forms.Button cancelButton; | |
| 44: | private System.Windows.Forms.Label label1; | |
| 45: | private System.Windows.Forms.Button helpButton; | |
| 46: | MainWindow mainwindow; | |
| 47: | ||
| 48: | public CVSCheckOutDialog(MainWindow mainwindow) | |
| 49: | { | |
| 50: | this.mainwindow = mainwindow; | |
| 51: | InitializeComponent(); | |
| 52: | Owner = mainwindow; | |
| 53: | } | |
| 54: | ||
| 55: | void BrowseDirectories(object sender, EventArgs e) | |
| 56: | { | |
| 57: | FolderDialog fd = new FolderDialog(); | |
| 58: | if(fd.DisplayDialog() == DialogResult.OK) { | |
| 59: | textBox1.Text = fd.Path; | |
| 60: | } | |
| 61: | } | |
| 62: | ||
| 63: | ||
| 64: | string SearchFile(string path, string pattern) | |
| 65: | { | |
| 66: | string[] files = Directory.GetFiles(path, pattern); | |
| 67: | ||
| 68: | if (files.Length > 0) | |
| 69: | return files[0]; | |
| 70: | ||
| 71: | string[] directories = Directory.GetDirectories(path); | |
| 72: | foreach (string dir in directories) { | |
| 73: | string back = SearchFile(dir, pattern); | |
| 74: | if (back != null) | |
| 75: | return back; | |
| 76: | } | |
| 77: | return null; | |
| 78: | } | |
| 79: | ||
| 80: | string password; | |
| 81: | public string Project = null; | |
| 82: | CVSServerConnection con = new CVSServerConnection(); | |
| 83: | ||
| 84: | void CheckoutThread() | |
| 85: | { | |
| 86: | startButton.Enabled = false; | |
| 87: | cancelButton.Enabled = false; | |
| 88: | WorkingDirectory workingdirectory = new WorkingDirectory(new CvsRoot(comboBox2.Text), textBox1.Text, comboBox1.Text); | |
| 89: | ||
| 90: | con.Connect(workingdirectory, password); | |
| 91: | ||
| 92: | ||
| 93: | new CheckoutModuleCommand(workingdirectory).Execute(con); | |
| 94: | // :pserver:omni_brain@localhost:/cvsroot/sharpdevelop | |
| 95: | string filename = SearchFile(textBox1.Text, "*.prjx"); | |
| 96: | if (filename != null) { | |
| 97: | Project = filename; | |
| 98: | } else { | |
| 99: | MessageBox.Show("No SharpDevelop project found.\nBut contents checked out.", "Warning"); | |
| 100: | } | |
| 101: | ||
| 102: | DialogResult = DialogResult.OK; | |
| 103: | startButton.Enabled = true; | |
| 104: | cancelButton.Enabled = true; | |
| 105: | con.MessageEvent -= oevent; | |
| 106: | od.Close(); | |
| 107: | od.Dispose(); | |
| 108: | } | |
| 109: | ||
| 110: | MessageEventHandler oevent; | |
| 111: | OutputDialog od; | |
| 112: | void CheckOutEvent(object sender, EventArgs e) | |
| 113: | { | |
| 114: | PasswordAuthentificationDialog pad = new PasswordAuthentificationDialog("Enter you CVS authorization password"); | |
| 115: | ||
| 116: | if (pad.ShowDialog() == DialogResult.OK) { | |
| 117: | password = pad.Password; | |
| 118: | od = new OutputDialog(); | |
| 119: | od.Show(); | |
| 120: | oevent = new MessageEventHandler(od.OEvent); | |
| 121: | con.MessageEvent += oevent; | |
| 122: | Thread t = new Thread(new ThreadStart(CheckoutThread)); | |
| 123: | t.Start(); | |
| 124: | } | |
| 125: | pad.Dispose(); | |
| 126: | } | |
| 127: | ||
| 128: | private void InitializeComponent() | |
| 129: | { | |
| 130: | this.groupBox2 = new System.Windows.Forms.GroupBox(); | |
| 131: | this.textBox1 = new System.Windows.Forms.TextBox(); | |
| 132: | this.button1 = new System.Windows.Forms.Button(); | |
| 133: | this.groupBox3 = new System.Windows.Forms.GroupBox(); | |
| 134: | this.comboBox2 = new System.Windows.Forms.ComboBox(); | |
| 135: | this.groupBox1 = new System.Windows.Forms.GroupBox(); | |
| 136: | this.comboBox1 = new System.Windows.Forms.ComboBox(); | |
| 137: | this.startButton = new System.Windows.Forms.Button(); | |
| 138: | this.cancelButton = new System.Windows.Forms.Button(); | |
| 139: | this.label1 = new System.Windows.Forms.Label(); | |
| 140: | this.helpButton = new System.Windows.Forms.Button(); | |
| 141: | this.groupBox2.SuspendLayout(); | |
| 142: | this.groupBox3.SuspendLayout(); | |
| 143: | this.groupBox1.SuspendLayout(); | |
| 144: | this.SuspendLayout(); | |
| 145: | ||
| 146: | // | |
| 147: | // groupBox2 | |
| 148: | // | |
| 149: | this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {this.button1, | |
| 150: | this.textBox1}); | |
| 151: | this.groupBox2.Location = new System.Drawing.Point(8, 120); | |
| 152: | this.groupBox2.Name = "groupBox2"; | |
| 153: | this.groupBox2.Size = new System.Drawing.Size(352, 48); | |
| 154: | this.groupBox2.TabIndex = 1; | |
| 155: | this.groupBox2.TabStop = false; | |
| 156: | this.groupBox2.Text = "Local folder to checkout to:"; | |
| 157: | ||
| 158: | // | |
| 159: | // textBox1 | |
| 160: | // | |
| 161: | this.textBox1.Location = new System.Drawing.Point(8, 16); | |
| 162: | this.textBox1.Name = "textBox1"; | |
| 163: | this.textBox1.Size = new System.Drawing.Size(256, 20); | |
| 164: | this.textBox1.TabIndex = 0; | |
| 165: | this.textBox1.Text = ""; | |
| 166: | // | |
| 167: | // button1 | |
| 168: | // | |
| 169: | this.button1.Location = new System.Drawing.Point(272, 16); | |
| 170: | this.button1.Name = "button1"; | |
| 171: | this.button1.TabIndex = 1; | |
| 172: | this.button1.Text = "Browse..."; | |
| 173: | button1.Click += new EventHandler(BrowseDirectories); | |
| 174: | // | |
| 175: | // groupBox3 | |
| 176: | // | |
| 177: | this.groupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {this.comboBox2}); | |
| 178: | this.groupBox3.Location = new System.Drawing.Point(8, 8); | |
| 179: | this.groupBox3.Name = "groupBox3"; | |
| 180: | this.groupBox3.Size = new System.Drawing.Size(352, 48); | |
| 181: | this.groupBox3.TabIndex = 0; | |
| 182: | this.groupBox3.TabStop = false; | |
| 183: | this.groupBox3.Text = "Enter the CVSROOT:"; | |
| 184: | // | |
| 185: | // comboBox2 | |
| 186: | // | |
| 187: | this.comboBox2.DropDownWidth = 336; | |
| 188: | this.comboBox2.Location = new System.Drawing.Point(8, 16); | |
| 189: | this.comboBox2.Name = "comboBox2"; | |
| 190: | this.comboBox2.Size = new System.Drawing.Size(336, 21); | |
| 191: | this.comboBox2.TabIndex = 0; | |
| 192: | // | |
| 193: | // groupBox1 | |
| 194: | // | |
| 195: | this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {this.comboBox1}); | |
| 196: | this.groupBox1.Location = new System.Drawing.Point(8, 64); | |
| 197: | this.groupBox1.Name = "groupBox1"; | |
| 198: | this.groupBox1.Size = new System.Drawing.Size(352, 48); | |
| 199: | this.groupBox1.TabIndex = 0; | |
| 200: | this.groupBox1.TabStop = false; | |
| 201: | this.groupBox1.Text = "Enter the module name and path on the server :"; | |
| 202: | // | |
| 203: | // comboBox1 | |
| 204: | // | |
| 205: | this.comboBox1.DropDownWidth = 336; | |
| 206: | this.comboBox1.Location = new System.Drawing.Point(8, 16); | |
| 207: | this.comboBox1.Name = "comboBox1"; | |
| 208: | this.comboBox1.Size = new System.Drawing.Size(336, 21); | |
| 209: | this.comboBox1.TabIndex = 0; | |
| 210: | ||
| 211: | // | |
| 212: | // startButton | |
| 213: | // | |
| 214: | this.startButton.Location = new System.Drawing.Point(128, 192); | |
| 215: | this.startButton.Name = "startButton"; | |
| 216: | this.startButton.TabIndex = 2; | |
| 217: | this.startButton.Text = "Start"; | |
| 218: | // this.startButton.DialogResult = DialogResult.OK; | |
| 219: | this.startButton.Click += new EventHandler(CheckOutEvent); | |
| 220: | ||
| 221: | // | |
| 222: | // cancelButton | |
| 223: | // | |
| 224: | this.cancelButton.Location = new System.Drawing.Point(208, 192); | |
| 225: | this.cancelButton.Name = "cancelButton"; | |
| 226: | this.cancelButton.TabIndex = 3; | |
| 227: | this.cancelButton.Text = "Cancel"; | |
| 228: | this.cancelButton.DialogResult = DialogResult.Cancel; | |
| 229: | ||
| 230: | // | |
| 231: | // label1 | |
| 232: | // | |
| 233: | this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; | |
| 234: | this.label1.Location = new System.Drawing.Point(8, 184); | |
| 235: | this.label1.Name = "label1"; | |
| 236: | this.label1.Size = new System.Drawing.Size(352, 2); | |
| 237: | this.label1.TabIndex = 4; | |
| 238: | ||
| 239: | // | |
| 240: | // helpButton | |
| 241: | // | |
| 242: | this.helpButton.Location = new System.Drawing.Point(288, 192); | |
| 243: | this.helpButton.Name = "helpButton"; | |
| 244: | this.helpButton.TabIndex = 5; | |
| 245: | this.helpButton.Text = "Help"; | |
| 246: | ||
| 247: | // | |
| 248: | // Form1 | |
| 249: | // | |
| 250: | this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); | |
| 251: | this.ClientSize = new System.Drawing.Size(370, 223); | |
| 252: | this.Controls.AddRange(new System.Windows.Forms.Control[] { this.helpButton, | |
| 253: | this.label1, | |
| 254: | this.cancelButton, | |
| 255: | this.startButton, | |
| 256: | this.groupBox3, | |
| 257: | this.groupBox2, | |
| 258: | this.groupBox1}); | |
| 259: | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; | |
| 260: | this.MaximizeBox = MinimizeBox = false; | |
| 261: | ShowInTaskbar = false; | |
| 262: | StartPosition = FormStartPosition.CenterParent; | |
| 263: | Icon = null; | |
| 264: | this.Text = "CVS Project checkout"; | |
| 265: | this.groupBox2.ResumeLayout(false); | |
| 266: | this.groupBox3.ResumeLayout(false); | |
| 267: | this.groupBox1.ResumeLayout(false); | |
| 268: | this.ResumeLayout(false); | |
| 269: | } | |
| 270: | } | |
| 271: | } |
This page was automatically generated by SharpDevelop.