Added:
trunk/VSTools/Editors/EditColumnDialog.Designer.cs
trunk/VSTools/Editors/EditColumnDialog.cs
trunk/VSTools/Editors/EditColumnDialog.resx
Modified:
trunk/VSTools/Editors/BaseEditor.cs
trunk/VSTools/Editors/SqlTextEditor.cs
trunk/VSTools/Editors/TableEditor.cs
trunk/VSTools/Editors/TriggerEditor.cs
trunk/VSTools/MyExplorerWindow.cs
trunk/VSTools/MyVSTools.csproj
trunk/VSTools/Nodes/ColumnNode.cs
trunk/VSTools/Nodes/ExplorerNode.cs
trunk/VSTools/Nodes/FunctionNode.cs
trunk/VSTools/Nodes/FunctionsNode.cs
trunk/VSTools/Nodes/ProcedureNode.cs
trunk/VSTools/Nodes/ProceduresNode.cs
trunk/VSTools/Nodes/TableNode.cs
trunk/VSTools/Nodes/TablesNode.cs
trunk/VSTools/Nodes/TriggerNode.cs
trunk/VSTools/Nodes/ViewNode.cs
trunk/VSTools/Nodes/ViewsNode.cs
Log:
1. Added EditColumnDialog control
2. Major cleanups in node derived classes
3. Moving the node classes away from storing the IS row and to holding just member fields
that are populated by the row
Table editing is still not functional yet though you can pull up the columns in the column
editor and commit the changes.
I still do not have refresh of the server tree working correctly.
Modified: trunk/VSTools/Editors/BaseEditor.cs
===================================================================
--- trunk/VSTools/Editors/BaseEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/BaseEditor.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -10,7 +10,7 @@
namespace MySql.VSTools
{
- public class BaseEditor : UserControl, IVsPersistDocData, IPersistFileFormat,
+ internal class BaseEditor : UserControl, IVsPersistDocData, IPersistFileFormat,
IVsDocDataFileChangeControl, IOleCommandTarget,
IVsWindowPane
{
@@ -21,12 +21,14 @@
protected IVsHierarchy hierarchy;
protected uint itemID;
private bool guard;
+ protected ExplorerNode editingNode;
private ServiceProvider vsServiceProvider = null;
- public BaseEditor()
+ public BaseEditor(ExplorerNode node)
: base()
{
+ editingNode = node;
}
protected void Init()
@@ -50,7 +52,7 @@
get { return cookie; }
}
- protected bool IsDirty
+ public bool IsDirty
{
get { return isDirty; }
set { isDirty = value; }
@@ -423,16 +425,7 @@
int IVsWindowPane.ClosePane()
{
-/* string filename2;
- uint flags, readLocks, editLocks, itemId;
- IVsHierarchy pHeir;
- IntPtr punkData;
- int result = rdt.GetDocumentInfo(cookie, out flags, out readLocks, out
editLocks,
- out filename2, out pHeir, out itemId, out punkData);
- result = rdt.UnlockDocument((uint)_VSRDTFLAGS.RDT_Unlock_PromptSave,
- Cookie);
- result = rdt.GetDocumentInfo(cookie, out flags, out readLocks, out editLocks,
- out filename2, out pHeir, out itemId, out punkData);*/
+ editingNode.CloseEditor();
this.Dispose(true);
return VSConstants.S_OK;
}
Added: trunk/VSTools/Editors/EditColumnDialog.Designer.cs
===================================================================
--- trunk/VSTools/Editors/EditColumnDialog.Designer.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/EditColumnDialog.Designer.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -0,0 +1,302 @@
+namespace MySql.VSTools
+{
+ partial class EditColumnDialog
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.columnName = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.columnType = new System.Windows.Forms.ComboBox();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.autoincrement = new System.Windows.Forms.CheckBox();
+ this.allowNull = new System.Windows.Forms.CheckBox();
+ this.zerofill = new System.Windows.Forms.CheckBox();
+ this.unsigned = new System.Windows.Forms.CheckBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.charSet = new System.Windows.Forms.ComboBox();
+ this.collation = new System.Windows.Forms.ComboBox();
+ this.label5 = new System.Windows.Forms.Label();
+ this.defaultValue = new System.Windows.Forms.TextBox();
+ this.label6 = new System.Windows.Forms.Label();
+ this.comment = new System.Windows.Forms.TextBox();
+ this.cancelbtn = new System.Windows.Forms.Button();
+ this.okbtn = new System.Windows.Forms.Button();
+ this.groupBox1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(49, 15);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(38, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Name:";
+ //
+ // columnName
+ //
+ this.columnName.Location = new System.Drawing.Point(93, 12);
+ this.columnName.Name = "columnName";
+ this.columnName.Size = new System.Drawing.Size(169, 20);
+ this.columnName.TabIndex = 1;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(53, 41);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(34, 13);
+ this.label2.TabIndex = 2;
+ this.label2.Text = "Type:";
+ //
+ // columnType
+ //
+ this.columnType.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.columnType.FormattingEnabled = true;
+ this.columnType.Items.AddRange(new object[] {
+ "BINARY",
+ "BLOB",
+ "CHAR",
+ "DATE",
+ "DATETIME",
+ "DECIMAL",
+ "DOUBLE",
+ "ENUM",
+ "FLOAT",
+ "INTEGER",
+ "DECIMAL",
+ "REAL",
+ "SET",
+ "TEXT",
+ "TIME",
+ "TIMESTAMP",
+ "VARBINARY",
+ "VARCHAR",
+ "YEAR"});
+ this.columnType.Location = new System.Drawing.Point(93, 38);
+ this.columnType.Name = "columnType";
+ this.columnType.Size = new System.Drawing.Size(169, 21);
+ this.columnType.TabIndex = 3;
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.autoincrement);
+ this.groupBox1.Controls.Add(this.allowNull);
+ this.groupBox1.Controls.Add(this.zerofill);
+ this.groupBox1.Controls.Add(this.unsigned);
+ this.groupBox1.Location = new System.Drawing.Point(280, 15);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(200, 98);
+ this.groupBox1.TabIndex = 4;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Options";
+ //
+ // autoincrement
+ //
+ this.autoincrement.AutoSize = true;
+ this.autoincrement.Location = new System.Drawing.Point(85, 44);
+ this.autoincrement.Name = "autoincrement";
+ this.autoincrement.Size = new System.Drawing.Size(94, 17);
+ this.autoincrement.TabIndex = 3;
+ this.autoincrement.Text = "Autoincrement";
+ this.autoincrement.UseVisualStyleBackColor = true;
+ //
+ // allowNull
+ //
+ this.allowNull.AutoSize = true;
+ this.allowNull.Location = new System.Drawing.Point(85, 20);
+ this.allowNull.Name = "allowNull";
+ this.allowNull.Size = new System.Drawing.Size(72, 17);
+ this.allowNull.TabIndex = 2;
+ this.allowNull.Text = "Allow Null";
+ this.allowNull.UseVisualStyleBackColor = true;
+ //
+ // zerofill
+ //
+ this.zerofill.AutoSize = true;
+ this.zerofill.Location = new System.Drawing.Point(7, 44);
+ this.zerofill.Name = "zerofill";
+ this.zerofill.Size = new System.Drawing.Size(63, 17);
+ this.zerofill.TabIndex = 1;
+ this.zerofill.Text = "Zero Fill";
+ this.zerofill.UseVisualStyleBackColor = true;
+ //
+ // unsigned
+ //
+ this.unsigned.AutoSize = true;
+ this.unsigned.Location = new System.Drawing.Point(7, 20);
+ this.unsigned.Name = "unsigned";
+ this.unsigned.Size = new System.Drawing.Size(71, 17);
+ this.unsigned.TabIndex = 0;
+ this.unsigned.Text = "Unsigned";
+ this.unsigned.UseVisualStyleBackColor = true;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(12, 68);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(75, 13);
+ this.label3.TabIndex = 5;
+ this.label3.Text = "Character Set:";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(37, 96);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(50, 13);
+ this.label4.TabIndex = 6;
+ this.label4.Text = "Collation:";
+ //
+ // charSet
+ //
+ this.charSet.FormattingEnabled = true;
+ this.charSet.Location = new System.Drawing.Point(93, 65);
+ this.charSet.Name = "charSet";
+ this.charSet.Size = new System.Drawing.Size(169, 21);
+ this.charSet.TabIndex = 7;
+ //
+ // collation
+ //
+ this.collation.FormattingEnabled = true;
+ this.collation.Location = new System.Drawing.Point(93, 92);
+ this.collation.Name = "collation";
+ this.collation.Size = new System.Drawing.Size(169, 21);
+ this.collation.TabIndex = 8;
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(13, 123);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(74, 13);
+ this.label5.TabIndex = 9;
+ this.label5.Text = "Default Value:";
+ //
+ // defaultValue
+ //
+ this.defaultValue.Location = new System.Drawing.Point(93, 120);
+ this.defaultValue.Name = "defaultValue";
+ this.defaultValue.Size = new System.Drawing.Size(387, 20);
+ this.defaultValue.TabIndex = 10;
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(33, 152);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(54, 13);
+ this.label6.TabIndex = 11;
+ this.label6.Text = "Comment:";
+ //
+ // comment
+ //
+ this.comment.Location = new System.Drawing.Point(93, 147);
+ this.comment.Multiline = true;
+ this.comment.Name = "comment";
+ this.comment.Size = new System.Drawing.Size(387, 74);
+ this.comment.TabIndex = 12;
+ //
+ // cancelbtn
+ //
+ this.cancelbtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancelbtn.Location = new System.Drawing.Point(405, 227);
+ this.cancelbtn.Name = "cancelbtn";
+ this.cancelbtn.Size = new System.Drawing.Size(75, 23);
+ this.cancelbtn.TabIndex = 13;
+ this.cancelbtn.Text = "Cancel";
+ this.cancelbtn.UseVisualStyleBackColor = true;
+ //
+ // okbtn
+ //
+ this.okbtn.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.okbtn.Location = new System.Drawing.Point(324, 227);
+ this.okbtn.Name = "okbtn";
+ this.okbtn.Size = new System.Drawing.Size(75, 23);
+ this.okbtn.TabIndex = 14;
+ this.okbtn.Text = "OK";
+ this.okbtn.UseVisualStyleBackColor = true;
+ this.okbtn.Click += new System.EventHandler(this.okbtn_Click);
+ //
+ // EditColumnDialog
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(492, 262);
+ this.Controls.Add(this.okbtn);
+ this.Controls.Add(this.cancelbtn);
+ this.Controls.Add(this.comment);
+ this.Controls.Add(this.label6);
+ this.Controls.Add(this.defaultValue);
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.collation);
+ this.Controls.Add(this.charSet);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.columnType);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.columnName);
+ this.Controls.Add(this.label1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "EditColumnDialog";
+ this.Text = "Edit Column";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox columnName;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.ComboBox columnType;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.ComboBox charSet;
+ private System.Windows.Forms.ComboBox collation;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.TextBox defaultValue;
+ private System.Windows.Forms.CheckBox autoincrement;
+ private System.Windows.Forms.CheckBox allowNull;
+ private System.Windows.Forms.CheckBox zerofill;
+ private System.Windows.Forms.CheckBox unsigned;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.TextBox comment;
+ private System.Windows.Forms.Button cancelbtn;
+ private System.Windows.Forms.Button okbtn;
+ }
+}
\ No newline at end of file
Added: trunk/VSTools/Editors/EditColumnDialog.cs
===================================================================
--- trunk/VSTools/Editors/EditColumnDialog.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/EditColumnDialog.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace MySql.VSTools
+{
+ internal partial class EditColumnDialog : Form
+ {
+ private ColumnNode node;
+
+ public EditColumnDialog(ColumnNode nodeToEdit)
+ {
+ node = nodeToEdit;
+ InitializeComponent();
+
+ columnName.Text = node.Caption;
+ columnType.SelectedItem = node.Typename;
+ charSet.SelectedItem = node.CharacterSet;
+ collation.SelectedItem = node.Collation;
+ defaultValue.Text = node.DefaultValue;
+ comment.Text = node.Comment;
+ unsigned.Checked = node.IsUnsigned;
+ zerofill.Checked = node.IsZeroFill;
+ autoincrement.Checked = node.IsAutoIncrement;
+ allowNull.Checked = node.AllowNulls;
+ }
+
+ private void okbtn_Click(object sender, EventArgs e)
+ {
+ node.Caption = columnName.Text;
+ if (columnType.SelectedIndex != -1)
+ node.Typename = columnType.SelectedItem.ToString();
+ if (charSet.SelectedIndex != -1)
+ node.CharacterSet = charSet.SelectedItem.ToString();
+ if (collation.SelectedIndex != -1)
+ node.Collation = collation.SelectedItem.ToString();
+ node.DefaultValue = defaultValue.Text;
+ node.Comment = comment.Text;
+ node.IsUnsigned = unsigned.Checked;
+ node.IsZeroFill = zerofill.Checked;
+ node.IsAutoIncrement = autoincrement.Checked;
+ node.AllowNulls = allowNull.Checked;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/VSTools/Editors/EditColumnDialog.resx
===================================================================
--- trunk/VSTools/Editors/EditColumnDialog.resx 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/EditColumnDialog.resx 2006-04-25 00:25:41 UTC (rev 230)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader,
System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter,
System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long
string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color,
System.Drawing">Blue</data>
+ <data name="Bitmap1"
mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing"
mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the
.NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0"
msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"
msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"
/>
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Modified: trunk/VSTools/Editors/SqlTextEditor.cs
===================================================================
--- trunk/VSTools/Editors/SqlTextEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/SqlTextEditor.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -14,7 +14,7 @@
/// <summary>
/// Summary description for StoredProcedureEditor.
/// </summary>
- public class SqlTextEditor : BaseEditor
+ internal class SqlTextEditor : BaseEditor
{
private System.Windows.Forms.RichTextBox sqlText;
/// <summary>
@@ -22,14 +22,11 @@
/// </summary>
private System.ComponentModel.Container components = null;
- //private ServerConfig config;
private string spName;
private string dbName;
- private bool changed;
private EnvDTE.DTE dte;
- public SqlTextEditor(string name, string database, string body,
- DbConnection conn)
+ public SqlTextEditor(ExplorerNode node, string body) : base(node)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
@@ -37,8 +34,8 @@
if (DesignMode) return;
base.Init();
- spName = name;
- dbName = database;
+ spName = node.Caption;
+ dbName = node.Schema;
sqlText.Text = body;
// set text editor font
@@ -171,36 +168,5 @@
IsDirty = true;
}
-/* protected override void PostCreateInit()
- {
- base.PostCreateInit();
-
- if (!CanEdit())
- sqlText.ReadOnly = true;
- }
- */
-/* private void saveBtn_Click(object sender, System.EventArgs e)
- {
- //string connStr = config.GetConnectString(false);
- MySqlConnection conn = new MySqlConnection(connStr);
- try
- {
- conn.Open();
- conn.ChangeDatabase(dbName);
- string sql = "DROP PROCEDURE IF EXISTS " + spName + "; " + sqlText.Text;
- MySqlCommand cmd = new MySqlCommand(sql, conn);
- cmd.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error creating stored procedure: " + ex.Message);
- }
- finally
- {
- if (conn != null)
- conn.Close();
- }
- }*/
-
}
}
Modified: trunk/VSTools/Editors/TableEditor.cs
===================================================================
--- trunk/VSTools/Editors/TableEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/TableEditor.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -18,7 +18,7 @@
private Font wingDingFont;
private ArrayList columns;
- public TableEditor(TableNode table)
+ public TableEditor(TableNode table) : base(table)
{
InitializeComponent();
@@ -70,15 +70,16 @@
item.ImageIndex = 0;
item.UseItemStyleForSubItems = false;
item.SubItems.Add(node.Typename);
- item.SubItems.Add(node.LengthAsString);
+ item.SubItems.Add(node.CharacterMaxLength == -1 ? String.Empty :
+ node.CharacterMaxLength.ToString());
ListViewItem.ListViewSubItem sub = item.SubItems.Add(
- node.CanBeNull ? "u" : "");
+ node.AllowNulls ? "u" : "");
sub.ForeColor = Color.DarkBlue;
sub.Font = wingDingFont;
sub = item.SubItems.Add(node.IsBinary ? "u" : "");
sub.ForeColor = Color.DarkBlue;
sub.Font = wingDingFont;
- sub = item.SubItems.Add(node.ZeroFill ? "u" : "");
+ sub = item.SubItems.Add(node.IsZeroFill ? "u" : "");
sub.Font = wingDingFont;
sub.ForeColor = Color.DarkBlue;
sub = item.SubItems.Add(node.CharacterSet);
@@ -94,10 +95,30 @@
void columnList_DoubleClick(object sender, System.EventArgs e)
{
if (columnList.SelectedIndices.Count == 0) return;
- ColumnNode selectedNode = (ColumnNode)columns[columnList.SelectedIndices[0]];
- EditColumnDialog dlg = new EditColumnDialog(selectedNode);
+ int selIndex = columnList.SelectedIndices[0];
+ ListViewItem selItem = columnList.Items[selIndex];
+ ColumnNode selNode = (ColumnNode)columns[selIndex];
+ EditColumnDialog dlg = new EditColumnDialog(selNode);
+
+ // if the user canceled the operation, then return
if (DialogResult.Cancel == dlg.ShowDialog())
return;
+
+ // if the user didn't change anything, then just return
+ if (!selNode.IsDirty) return;
+
+ // update the list item
+ selItem.Text = selNode.Caption;
+ if (selNode.IsPrimary)
+ selItem.ImageIndex = 0;
+ selItem.SubItems[1].Text = selNode.Typename;
+ selItem.SubItems[2].Text = selNode.CharacterMaxLength == -1 ? String.Empty :
+ selNode.CharacterMaxLength.ToString();
+ selItem.SubItems[3].Text = selNode.AllowNulls ? "u" : "";
+ selItem.SubItems[4].Text = selNode.IsBinary ? "u" : "";
+ selItem.SubItems[5].Text = selNode.IsZeroFill ? "u" : "";
+ selItem.SubItems[6].Text = selNode.CharacterSet;
+ selItem.SubItems[7].Text = selNode.Collation;
}
Modified: trunk/VSTools/Editors/TriggerEditor.cs
===================================================================
--- trunk/VSTools/Editors/TriggerEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Editors/TriggerEditor.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -10,21 +10,18 @@
{
internal partial class TriggerEditor : BaseEditor
{
- private TriggerNode triggerNode;
-
- public TriggerEditor(TriggerNode node)
+ public TriggerEditor(TriggerNode node) : base(node)
{
InitializeComponent();
if (DesignMode) return;
base.Init();
- triggerNode = node;
- if (triggerNode == null) return;
- sql.Text = triggerNode.Body;
- triggername.Text = triggerNode.Caption;
- schema.Text = triggerNode.Schema;
- when.SelectedItem = triggerNode.ActionTime;
- action.SelectedItem = triggerNode.Action;
+ if (node == null) return;
+ sql.Text = node.Body;
+ triggername.Text = node.Caption;
+ schema.Text = node.Schema;
+ when.SelectedItem = node.ActionTime;
+ action.SelectedItem = node.Action;
IsDirty = false;
}
Modified: trunk/VSTools/MyExplorerWindow.cs
===================================================================
--- trunk/VSTools/MyExplorerWindow.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/MyExplorerWindow.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -9,6 +9,7 @@
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using System.ComponentModel.Design;
+using Microsoft.VisualStudio;
namespace MySql.VSTools
{
@@ -40,7 +41,7 @@
public MyToolWindow() :
base(null)
{
- this.ToolClsid =
Microsoft.VisualStudio.VSConstants.CLSID_VsUIHierarchyWindow;
+ this.ToolClsid = VSConstants.CLSID_VsUIHierarchyWindow;
this.ToolBar = new CommandID(GuidList.guidMyVSToolsCmdSet,
PkgCmdIDList.cmdidMyExplorerToolbar);
// Set the window title reading it from the resources.
@@ -142,7 +143,8 @@
(int)(__UIHWINFLAGS.UIHWF_ForceSingleSelect |
__UIHWINFLAGS.UIHWF_DoNotSortRootNodes |
__UIHWINFLAGS.UIHWF_SupportToolWindowToolbars |
- __UIHWINFLAGS.UIHWF_LinesAtRoot),
+ __UIHWINFLAGS.UIHWF_LinesAtRoot |
+ __UIHWINFLAGS.UIHWF_RouteCmdidDelete),
out tmpClientFrame);
(this.Frame as IVsWindowFrame).Show();
Modified: trunk/VSTools/MyVSTools.csproj
===================================================================
--- trunk/VSTools/MyVSTools.csproj 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/MyVSTools.csproj 2006-04-25 00:25:41 UTC (rev 230)
@@ -89,10 +89,10 @@
<Compile Include="..\\mysqlclient\\common\\dbConnectionString.cs" />
<Compile Include="..\\mysqlclient\\common\\utility.cs" />
<Compile Include="DebugTrace.cs" />
- <Compile Include="EditColumnDialog.cs">
+ <Compile Include="Editors\EditColumnDialog.cs">
<SubType>Form</SubType>
</Compile>
- <Compile Include="EditColumnDialog.Designer.cs">
+ <Compile Include="Editors\EditColumnDialog.Designer.cs">
<DependentUpon>EditColumnDialog.cs</DependentUpon>
</Compile>
<Compile Include="Editor.cs">
@@ -171,7 +171,7 @@
<SubType>Designer</SubType>
<DependentUpon>ConnectionDlg.cs</DependentUpon>
</EmbeddedResource>
- <EmbeddedResource Include="EditColumnDialog.resx">
+ <EmbeddedResource Include="Editors\EditColumnDialog.resx">
<SubType>Designer</SubType>
<DependentUpon>EditColumnDialog.cs</DependentUpon>
</EmbeddedResource>
Modified: trunk/VSTools/Nodes/ColumnNode.cs
===================================================================
--- trunk/VSTools/Nodes/ColumnNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/ColumnNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -3,68 +3,147 @@
using System.Text;
using System.Windows.Forms;
using System.Data;
+using System.Globalization;
namespace MySql.VSTools
{
internal class ColumnNode : ExplorerNode
{
- private DataRow columnDef;
+ private string type;
+ private int maxLen = -1;
+ private bool isPrimary;
+ private bool allowNulls;
+ private bool isBinary;
+ private bool isZeroFill;
+ private string charSet;
+ private string collation;
+ private string defaultValue;
+ private string comment;
+ private bool isUnsigned;
+ private bool isAutoincrement;
+ private bool isDirty;
public ColumnNode(ExplorerNode parent, DataRow row)
: base(parent, row["COLUMN_NAME"].ToString())
{
- columnDef = row;
+ string extra = row["EXTRA"].ToString().ToLower(CultureInfo.InvariantCulture);
+ type = row["DATA_TYPE"].ToString();
+ ConvertTypeName();
+ string temp = row["CHARACTER_MAXIMUM_LENGTH"].ToString();
+ if (temp != "NULL" && temp.Length > 0)
+ maxLen = Int32.Parse(temp);
+ isPrimary = row["COLUMN_KEY"].ToString().IndexOf("PRI") != -1;
+ allowNulls = row["IS_NULLABLE"].Equals("YES");
+ isBinary = extra.IndexOf("binary") != -1;
+ isZeroFill = extra.IndexOf("zero") != -1;
+ charSet = row["CHARACTER_SET_NAME"].ToString();
+ collation = row["COLLATION_NAME"].ToString();
+ //TODO: ask Gluh about this
+ defaultValue = row["COLUMN_DEFAULT"].ToString();
+ comment = row["COLUMN_COMMENT"].ToString();
+ isUnsigned = type.IndexOf("unsigned") != -1;
+ isAutoincrement = extra.IndexOf("auto_increment") != -1;
}
#region Properties
+ public bool IsDirty
+ {
+ get { return isDirty; }
+ set { isDirty = value; }
+ }
+
+ public override string Caption
+ {
+ get { return caption; }
+ set { isDirty |= (value != caption); caption = value; }
+ }
+
public string Typename
{
- get { return columnDef["DATA_TYPE"].ToString().ToUpper(); }
+ get { return type; }
+ set { isDirty |= (value != type); type = value; }
}
- public string LengthAsString
+ public int CharacterMaxLength
{
- get
- {
- string len = columnDef["CHARACTER_MAXIMUM_LENGTH"].ToString();
- if (len == "NULL") return String.Empty;
- return len;
- }
+ get { return maxLen; }
+ set { isDirty |= (value != maxLen); maxLen = value; }
}
public bool IsPrimary
{
- get { return columnDef["COLUMN_KEY"].ToString().IndexOf("PRI") != -1; }
+ get { return isPrimary; }
+ set { isDirty |= (value != isPrimary); isPrimary = value; }
}
- public bool CanBeNull
+ public bool AllowNulls
{
- get { return columnDef["IS_NULLABLE"].Equals("YES"); }
+ get { return allowNulls; }
+ set { isDirty |= (value != allowNulls); allowNulls = value; }
}
public bool IsBinary
{
- get { return columnDef["EXTRA"].ToString().IndexOf("binary") != -1; }
+ get { return isBinary; }
+ set { isDirty |= (value != isBinary); isBinary = value; }
}
- public bool ZeroFill
+ public bool IsZeroFill
{
- get { return columnDef["EXTRA"].ToString().IndexOf("zero") != -1; }
+ get { return isZeroFill; }
+ set { isDirty |= (value != isZeroFill); isZeroFill = value; }
}
+ public bool IsUnsigned
+ {
+ get { return isUnsigned; }
+ set { isDirty |= (value != isUnsigned); isUnsigned = value; }
+ }
+
+ public bool IsAutoIncrement
+ {
+ get { return isAutoincrement; }
+ set { isDirty |= (value != isAutoincrement); isAutoincrement = value; }
+ }
+
public string CharacterSet
{
- get { return columnDef["CHARACTER_SET_NAME"].ToString(); }
+ get { return charSet; }
+ set { isDirty |= (value != charSet); charSet = value; }
}
public string Collation
{
- get { return columnDef["COLLATION_NAME"].ToString(); }
+ get { return collation; }
+ set { isDirty |= (value != collation); collation = value; }
}
+ public string DefaultValue
+ {
+ get { return defaultValue; }
+ set { isDirty |= (value != defaultValue); defaultValue = value; }
+ }
+
+ public string Comment
+ {
+ get { return comment; }
+ set { isDirty |= (value != comment); comment = value; }
+ }
+
#endregion
+ private void ConvertTypeName()
+ {
+ type = type.ToUpper(CultureInfo.InvariantCulture);
+ switch (type)
+ {
+ case "INT":
+ type = "INTEGER";
+ break;
+ }
+ }
+
public override uint MenuId
{
get { return PkgCmdIDList.ColumnCtxtMenu; }
Modified: trunk/VSTools/Nodes/ExplorerNode.cs
===================================================================
--- trunk/VSTools/Nodes/ExplorerNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/ExplorerNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -10,6 +10,7 @@
using System.Reflection;
using System.Globalization;
using System.Security.Policy;
+using System.Collections;
namespace MySql.VSTools
{
@@ -17,7 +18,7 @@
{
private HierNode hierNode;
private ExplorerNode parent;
- private string caption;
+ protected string caption;
private uint itemId;
private bool isExpanded;
private ExplorerNode nextSibling;
@@ -25,6 +26,7 @@
protected bool populated;
protected BaseEditor activeEditor;
protected bool isNew;
+ protected ArrayList newNodes;
public ExplorerNode(ExplorerNode parent, string caption)
{
@@ -32,13 +34,20 @@
this.caption = caption;
isExpanded = false;
populated = false;
+ newNodes = new ArrayList();
}
public virtual string Caption
{
get { return caption; }
+ set { caption = value; }
}
+ public virtual string Schema
+ {
+ get { return GetDatabaseNode().Caption; }
+ }
+
public ExplorerNode Parent
{
get { return parent; }
@@ -71,6 +80,11 @@
public abstract uint IconIndex { get; }
public abstract bool Expandable { get; }
+ protected virtual string GetDeleteSql()
+ {
+ return String.Empty;
+ }
+
internal virtual BaseEditor GetEditor()
{
return null;
@@ -116,6 +130,12 @@
public void AddChild(ExplorerNode node)
{
+ for (int i=0; i < newNodes.Count; i++)
+ {
+ if (newNodes[i] != node) continue;
+ newNodes.RemoveAt(i);
+ break;
+ }
IndexChild(node);
LinkChild(node);
}
@@ -178,6 +198,32 @@
return hierNode;
}
+ protected void Delete()
+ {
+ // first make sure the user is sure
+ if (MessageBox.Show(
+ String.Format(MyVSTools.GetResourceString("DeleteConfirm"),
+ Caption),
+ MyVSTools.GetResourceString("DeleteConfirmTitle"),
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question) == DialogResult.No)
+ return;
+
+ string sql = GetDeleteSql();
+ try
+ {
+ ExecuteNonQuery(sql);
+ //delete was successful, remove this node
+ Parent.RemoveChild(this);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message,
+ String.Format(MyVSTools.GetResourceString("UnableToDeleteTitle"),
+ Caption), MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
protected DatabaseNode GetDatabaseNode()
{
ExplorerNode node = this;
@@ -240,6 +286,24 @@
winFrame.Show();
}
+ protected string GetDefaultName(string baseName)
+ {
+ // first determine a default name
+ int num = 1;
+ string name = String.Format("{0}{1}", baseName,
num).ToLower(CultureInfo.InvariantCulture);
+ ExplorerNode node = FirstChild;
+ int i = 0;
+ while (node != null)
+ {
+ if (node.Caption.ToLower(CultureInfo.InvariantCulture) == name)
+ name = String.Format("{0}{1}", baseName,
++num).ToLower(CultureInfo.InvariantCulture);
+ node = node.NextSibling;
+ if (node == null && i < newNodes.Count)
+ node = (ExplorerNode)newNodes[i++];
+ }
+ return name;
+ }
+
protected void ExecuteNonQuery(string sql)
{
DbConnection connection = GetOpenConnection();
@@ -258,6 +322,28 @@
public virtual void DoCommand(int commandId)
{
+ switch (commandId)
+ {
+ case PkgCmdIDList.cmdidRefresh:
+ Refresh();
+ break;
+ case PkgCmdIDList.cmdidDelete:
+ Delete();
+ break;
+ }
}
+
+ protected virtual void Refresh()
+ {
+ populated = false;
+ while (firstChild != null)
+ RemoveChild(firstChild);
+ Populate();
+ }
+
+ public void CloseEditor()
+ {
+ activeEditor = null;
+ }
}
}
Modified: trunk/VSTools/Nodes/FunctionNode.cs
===================================================================
--- trunk/VSTools/Nodes/FunctionNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/FunctionNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -9,14 +9,21 @@
{
internal class FunctionNode : ExplorerNode
{
- DataRow funcDef;
+ private string body;
public FunctionNode(ExplorerNode parent, string name, DataRow row)
: base(parent, name)
{
- funcDef = row;
+ if (row != null)
+ body = String.Format("DROP FUNCTION {0}.{1}; {2}",
+ Schema, Caption, row["ROUTINE_DEFINITION"].ToString());
+ else
+ body = String.Format("CREATE FUNCTION {0}.{1} RETURNS /*INT*/
AS\r\nBEGIN\r\nEND",
+ Schema, Caption);
}
+ #region Properties
+
public override bool Expandable
{
get { return false; }
@@ -31,19 +38,42 @@
{
get { return 5; }
}
-
- public override void Populate()
+
+ #endregion
+
+ public override void DoCommand(int commandId)
{
+ switch (commandId)
+ {
+ case PkgCmdIDList.cmdidOpen:
+ OpenEditor();
+ break;
+ }
}
-/* private void Open()
+ protected override string GetDeleteSql()
{
- SqlTextEditor editor = new SqlTextEditor(
- Caption, funcDef["ROUTINE_SCHEMA"].ToString(),
- funcDef["ROUTINE_DEFINITION"].ToString(),
- GetOpenConnection());
- OpenEditor(editor);
+ return String.Format("DROP FUNCTION {0}.{1}", Schema, Caption);
}
- */
+
+ public override bool Save()
+ {
+ try
+ {
+ ExecuteNonQuery((activeEditor as SqlTextEditor).SqlText);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ return false;
+ }
+ }
+
+ internal override BaseEditor GetEditor()
+ {
+ activeEditor = new SqlTextEditor(this, body);
+ return activeEditor;
+ }
}
}
Modified: trunk/VSTools/Nodes/FunctionsNode.cs
===================================================================
--- trunk/VSTools/Nodes/FunctionsNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/FunctionsNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -14,6 +14,8 @@
{
}
+ #region Properties
+
public override uint IconIndex
{
get { return 1; }
@@ -29,6 +31,29 @@
get { return PkgCmdIDList.FunctionsCtxtMenu; }
}
+ #endregion
+
+ public override void DoCommand(int commandId)
+ {
+ switch (commandId)
+ {
+ case PkgCmdIDList.cmdidAddNewFunction:
+ AddNewFunction();
+ break;
+ default:
+ base.DoCommand(commandId);
+ break;
+ }
+ }
+
+ private void AddNewFunction()
+ {
+ string newName = GetDefaultName("Function");
+ FunctionNode node = new FunctionNode(this, newName, null);
+ IndexChild(node);
+ node.OpenEditor();
+ }
+
public override void Populate()
{
if (populated) return;
Modified: trunk/VSTools/Nodes/ProcedureNode.cs
===================================================================
--- trunk/VSTools/Nodes/ProcedureNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/ProcedureNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -10,25 +10,20 @@
internal class ProcedureNode : ExplorerNode
{
private string body;
- private string schema;
- private SqlTextEditor editor;
public ProcedureNode(ExplorerNode parent, string caption, DataRow row)
: base(parent, caption)
{
- schema = row["ROUTINE_SCHEMA"].ToString();
- body = row["ROUTINE_DEFINITION"].ToString();
+ if (row != null)
+ body = String.Format("DROP PROCEDURE {0}.{1}; {2}",
+ Schema, Caption, row["ROUTINE_DEFINITION"].ToString());
+ else
+ body = String.Format("CREATE PROCEDURE {0}.{1} AS\r\nBEGIN\r\nEND",
+ Schema, Caption);
}
- public ProcedureNode(ExplorerNode parent, string caption, string body)
- : base(parent, caption)
- {
- this.body = body;
- schema = GetDatabaseNode().Caption;
- ItemId = VSConstants.VSITEMID_NIL;
- }
+ #region Properties
-
public override uint MenuId
{
get { return PkgCmdIDList.ProcedureCtxtMenu; }
@@ -44,17 +39,12 @@
get { return false; }
}
- public override void Populate()
- {
- }
+ #endregion
public override void DoCommand(int commandId)
{
switch (commandId)
{
- case PkgCmdIDList.cmdidDelete:
- Delete();
- break;
case PkgCmdIDList.cmdidOpen:
OpenEditor();
break;
@@ -68,7 +58,7 @@
{
try
{
- ExecuteNonQuery(editor.SqlText);
+ ExecuteNonQuery((activeEditor as SqlTextEditor).SqlText);
return true;
}
catch (Exception ex)
@@ -78,38 +68,15 @@
}
}
- private void Delete()
+ internal override BaseEditor GetEditor()
{
- // first make sure the user is sure
- if (MessageBox.Show(
- String.Format(MyVSTools.GetResourceString("DeleteConfirm"),
- Caption),
- MyVSTools.GetResourceString("DeleteConfirmTitle"),
- MessageBoxButtons.YesNo,
- MessageBoxIcon.Question) == DialogResult.No)
- return;
-
- string sql = String.Format("DROP PROCEDURE {0}.{1}", schema, Caption);
- try
- {
- ExecuteNonQuery(sql);
- //delete was successful, remove this node
- Parent.RemoveChild(this);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message,
- String.Format(MyVSTools.GetResourceString("UnableToDeleteTitle"),
- Caption), MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
+ activeEditor = new SqlTextEditor(this, body);
+ return activeEditor;
}
- internal override BaseEditor GetEditor()
+ protected override string GetDeleteSql()
{
- editor = new SqlTextEditor(
- Caption, GetDatabaseNode().Caption, body, GetOpenConnection());
- return editor;
+ return String.Format("DROP PROCEDURE {0}.{1}", Schema, Caption);
}
-
}
}
Modified: trunk/VSTools/Nodes/ProceduresNode.cs
===================================================================
--- trunk/VSTools/Nodes/ProceduresNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/ProceduresNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -14,6 +14,8 @@
{
}
+ #region Properties
+
public override uint IconIndex
{
get { return 1; }
@@ -29,6 +31,8 @@
get { return PkgCmdIDList.ProceduresCtxtMenu; }
}
+ #endregion
+
public override void DoCommand(int commandId)
{
switch (commandId)
@@ -36,32 +40,16 @@
case PkgCmdIDList.cmdidAddNewProcedure:
AddNewProcedure();
break;
+ default:
+ base.DoCommand(commandId);
+ break;
}
}
private void AddNewProcedure()
{
-
- int i = 1;
- while (true)
- {
- string nameToCheck = "StoredProdedure" + i;
- ExplorerNode proc = FirstChild;
- while (proc != null)
- {
- if (proc.Caption == nameToCheck) break;
- proc = proc.NextSibling;
- }
- if (proc == null) break;
- i++;
- }
-
- string name = "StoredProcedure" + i;
- string defaultBody = "CREATE PROCEDURE " + name +
- "()" + Environment.NewLine +
- "BEGIN" + Environment.NewLine + "END" +
- Environment.NewLine;
- ProcedureNode node = new ProcedureNode(this, name, defaultBody);
+ string newName = GetDefaultName("Procedure");
+ ProcedureNode node = new ProcedureNode(this, newName, null);
IndexChild(node);
node.OpenEditor();
}
Modified: trunk/VSTools/Nodes/TableNode.cs
===================================================================
--- trunk/VSTools/Nodes/TableNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/TableNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -80,11 +80,28 @@
get { return Int32.Parse(tableDef["AVG_ROW_LENGTH"].ToString()); }
}
+ public override uint MenuId
+ {
+ get { return PkgCmdIDList.TableCtxtMenu; }
+ }
+ public override uint IconIndex
+ {
+ get { return 2; }
+ }
+
+ public override bool Expandable
+ {
+ get { return true; }
+ }
+
#endregion
public ArrayList GetColumns()
{
+ if (!populated)
+ Populate();
+
ArrayList cols = new ArrayList();
ExplorerNode col = FirstChild;
while (col != null)
@@ -96,28 +113,11 @@
return cols;
}
- public override uint MenuId
- {
- get { return PkgCmdIDList.TableCtxtMenu; }
- }
- public override uint IconIndex
- {
- get { return 2; }
- }
-
- public override bool Expandable
- {
- get { return true; }
- }
-
public override void DoCommand(int commandId)
{
switch (commandId)
{
- case PkgCmdIDList.cmdidDelete:
- Delete();
- break;
case PkgCmdIDList.cmdidOpenTableDef:
OpenEditor();
break;
Modified: trunk/VSTools/Nodes/TablesNode.cs
===================================================================
--- trunk/VSTools/Nodes/TablesNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/TablesNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -14,6 +14,8 @@
{
}
+ #region Properties
+
public override uint IconIndex
{
get { return 1; }
@@ -29,18 +31,22 @@
get { return PkgCmdIDList.TablesCtxtMenu; }
}
+ #endregion
+
public override void DoCommand(int commandId)
{
switch (commandId)
{
case PkgCmdIDList.cmdidAddNewTable:
- OpenNewTableEditor();
- return;
+ AddNewTable();
+ break;
+ default:
+ base.DoCommand(commandId);
+ break;
}
- base.DoCommand(commandId);
}
- public void OpenNewTableEditor()
+ private void AddNewTable()
{
//OpenEditor(typeof(EditorPane));
}
@@ -64,7 +70,6 @@
catch (Exception ex)
{
MessageBox.Show(ex.Message);
- // return false;
}
}
Modified: trunk/VSTools/Nodes/TriggerNode.cs
===================================================================
--- trunk/VSTools/Nodes/TriggerNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/TriggerNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -115,9 +115,28 @@
private void Delete()
{
- ExecuteNonQuery(String.Format("DROP TRIGGER {0}.{1}",
- GetDatabaseNode().Caption, Caption));
- Parent.RemoveChild(this);
+ // first make sure the user is sure
+ if (MessageBox.Show(
+ String.Format(MyVSTools.GetResourceString("DeleteConfirm"),
+ Caption),
+ MyVSTools.GetResourceString("DeleteConfirmTitle"),
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question) == DialogResult.No)
+ return;
+
+ string sql = String.Format("DROP TRIGGER {0}.{1}", Schema, Caption);
+ try
+ {
+ ExecuteNonQuery(sql);
+ //delete was successful, remove this node
+ Parent.RemoveChild(this);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message,
+ String.Format(MyVSTools.GetResourceString("UnableToDeleteTitle"),
+ Caption), MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
internal override BaseEditor GetEditor()
Modified: trunk/VSTools/Nodes/ViewNode.cs
===================================================================
--- trunk/VSTools/Nodes/ViewNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/ViewNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -10,17 +10,32 @@
{
internal class ViewNode : ExplorerNode
{
- private DataRow viewDef;
+ private string body;
public ViewNode(ExplorerNode parent, string name, DataRow row)
: base(parent, name)
{
- viewDef = row;
+ if (row != null)
+ body = String.Format("ALTER VIEW {0}.{1} AS {2}",
+ Schema, Caption, row["VIEW_DEFINITION"].ToString());
+ else
+ body = String.Format("CREATE VIEW {0}.{1} AS ",
+ Schema, Caption);
+ isNew = row == null ? true : false;
}
+ #region Properties
+
+ public string Body
+ {
+ get { return body; }
+ }
+
+ #endregion
+
public override bool Expandable
{
- get { return false; }
+ get { return true; }
}
public override uint MenuId
@@ -35,16 +50,98 @@
public override void DoCommand(int commandId)
{
+ switch (commandId)
+ {
+ case PkgCmdIDList.cmdidAddNewView:
+ (Parent as ViewsNode).AddNewView();
+ break;
+ case PkgCmdIDList.cmdidOpen:
+ OpenEditor();
+ break;
+ case PkgCmdIDList.cmdidDelete:
+ Delete();
+ break;
+ }
}
- public override void Populate()
+ private void Delete()
{
+ // first make sure the user is sure
+ if (MessageBox.Show(
+ String.Format(MyVSTools.GetResourceString("DeleteConfirm"),
+ Caption),
+ MyVSTools.GetResourceString("DeleteConfirmTitle"),
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question) == DialogResult.No)
+ return;
+
+ string sql = String.Format("DROP VIEW {0}.{1}", Schema, Caption);
+ try
+ {
+ ExecuteNonQuery(sql);
+ //delete was successful, remove this node
+ Parent.RemoveChild(this);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message,
+ String.Format(MyVSTools.GetResourceString("UnableToDeleteTitle"),
+ Caption), MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
}
+ public override bool Save()
+ {
+ SqlTextEditor editor = (activeEditor as SqlTextEditor);
+ body = editor.SqlText;
+ ViewsNode parentTable = (Parent as ViewsNode);
+ try
+ {
+ ExecuteNonQuery(body);
+ if (isNew)
+ parentTable.AddChild(this);
+ activeEditor.IsDirty = false;
+ return true;
+ }
+ catch (Exception ex)
+ {
+ if (isNew)
+ MessageBox.Show("Error creating view: " + ex.Message);
+ else
+ MessageBox.Show("Error updating view: " + ex.Message);
+ return false;
+ }
+ }
+
internal override BaseEditor GetEditor()
{
- return new SqlTextEditor(Caption, "db", "body", GetOpenConnection());
+ activeEditor = new SqlTextEditor(this, body);
+ return activeEditor;
}
+ public override void Populate()
+ {
+ if (populated) return;
+ DbConnection conn = GetOpenConnection();
+ string[] restrictions = new string[4];
+ restrictions[1] = Schema;
+ restrictions[2] = Caption;
+ DataTable columns = conn.GetSchema("columns", restrictions);
+ foreach (DataRow column in columns.Rows)
+ AddChild(new ColumnNode(this, column));
+ populated = true;
+ try
+ {
+ restrictions[2] = null;
+ restrictions[3] = Caption;
+ DataTable triggers = conn.GetSchema("triggers", restrictions);
+ foreach (DataRow trigger in triggers.Rows)
+ AddChild(new TriggerNode(this, trigger));
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ }
}
}
Modified: trunk/VSTools/Nodes/ViewsNode.cs
===================================================================
--- trunk/VSTools/Nodes/ViewsNode.cs 2006-04-24 18:21:51 UTC (rev 229)
+++ trunk/VSTools/Nodes/ViewsNode.cs 2006-04-25 00:25:41 UTC (rev 230)
@@ -29,6 +29,26 @@
get { return PkgCmdIDList.ViewsCtxtMenu; }
}
+ public override void DoCommand(int commandId)
+ {
+ switch (commandId)
+ {
+ case PkgCmdIDList.cmdidAddNewView:
+ AddNewView();
+ break;
+ }
+ }
+
+ public void AddNewView()
+ {
+ string newName = GetDefaultName("View");
+
+ ViewNode newNode = new ViewNode(this, newName, null);
+ newNodes.Add(newNode);
+ IndexChild(newNode);
+ newNode.OpenEditor();
+ }
+
public override void Populate()
{
if (populated) return;
| Thread |
|---|
| • Connector/NET commit: r230 - in trunk/VSTools: . Editors Nodes | rburnett | 25 Apr |