Added:
trunk/VSTools/Editors/SqlTextEditor.cs
trunk/VSTools/Editors/SqlTextEditor.resx
trunk/VSTools/Editors/TriggerEditor.Designer.cs
trunk/VSTools/Editors/TriggerEditor.cs
Removed:
trunk/VSTools/Editors/StoredProcedureEditor.cs
trunk/VSTools/Editors/StoredProcedureEditor.resx
Modified:
trunk/VSTools/Editors/TableEditor.cs
trunk/VSTools/MyExplorerWindow.cs
trunk/VSTools/MyVSTools.csproj
trunk/VSTools/MyVSTools.csproj.user
trunk/VSTools/Nodes/ExplorerNode.cs
trunk/VSTools/Nodes/MyHierarchyNode.cs
trunk/VSTools/Nodes/TableNode.cs
trunk/VSTools/Nodes/TriggerNode.cs
trunk/VSTools/VsPkg.cs
Log:
1. Renamed StoredProcedureEditor to SqlTextEditor
2. Added new TriggerEditor
3. Implemented AddNewTrigger
4. Implemented saving trigger changes
5. Added OnItemAdded callback to the hierachy. This fixed the failure to refresh
Copied: trunk/VSTools/Editors/SqlTextEditor.cs (from rev 228, trunk/VSTools/Editors/StoredProcedureEditor.cs)
Copied: trunk/VSTools/Editors/SqlTextEditor.resx (from rev 224, trunk/VSTools/Editors/StoredProcedureEditor.resx)
Deleted: trunk/VSTools/Editors/StoredProcedureEditor.cs
===================================================================
--- trunk/VSTools/Editors/StoredProcedureEditor.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Editors/StoredProcedureEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -1,206 +0,0 @@
-using System;
-using System.Collections;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Windows.Forms;
-using System.Data.Common;
-using Microsoft.VisualStudio.Shell.Interop;
-using Microsoft.VisualStudio;
-using System.Runtime.InteropServices;
-
-namespace MySql.VSTools
-{
- /// <summary>
- /// Summary description for StoredProcedureEditor.
- /// </summary>
- public class SqlTextEditor : BaseEditor
- {
- private System.Windows.Forms.RichTextBox sqlText;
- /// <summary>
- /// Required designer variable.
- /// </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)
- {
- // This call is required by the Windows.Forms Form Designer.
- InitializeComponent();
-
- if (DesignMode) return;
- base.Init();
-
- spName = name;
- dbName = database;
- sqlText.Text = body;
-
- // set text editor font
- if (dte == null)
- dte = (EnvDTE.DTE)Marshal.GetActiveObject("VisualStudio.DTE.8.0");
- EnvDTE.Properties props = dte.get_Properties("FontsAndColors", "TextEditor");
- EnvDTE.Property family = props.Item("FontFamily");
- EnvDTE.Property size = props.Item("FontSize");
- sqlText.Font = new Font(family.Value.ToString(),
- float.Parse(size.Value.ToString()));
- }
-
- public string SqlText
- {
- get { return sqlText.Text; }
- }
-
- protected override Guid EditorGuid
- {
- get { return GuidList.guidProcedureEditor; }
- }
-
- public override string Filename
- {
- get { return dbName + "." + spName; }
- }
-
- protected override bool CanCopyAndCut
- {
- get { return sqlText.SelectedText.Length > 0; }
- }
-
- protected override bool CanPaste
- {
- get { return sqlText.CanPaste(DataFormats.GetFormat(DataFormats.Text)); }
- }
-
- protected override bool CanRedo
- {
- get { return sqlText.CanRedo; }
- }
-
- protected override bool CanUndo
- {
- get { return sqlText.CanUndo; }
- }
-
- /*public void Edit(string spName, string db, ServerConfig sc)
- {
- this.spName = spName;
- dbName = db;
- config = sc;
- string connStr = sc.GetConnectString(false);
- MySqlConnection conn = new MySqlConnection(connStr);
- try
- {
- conn.Open();
- conn.ChangeDatabase(db);
- MySqlCommand cmd = new MySqlCommand("SHOW CREATE PROCEDURE " + spName, conn);
- using (MySqlDataReader reader = cmd.ExecuteReader())
- {
- reader.Read();
- string body = reader.GetString(2);
- body = body.Replace("\n", "\r\n");
- sqlText.Text = body;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error editing stored procedure: " + ex.Message);
- }
- finally
- {
- if (conn != null)
- conn.Close();
- }
- }*/
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
-
- #region Component 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.sqlText = new System.Windows.Forms.RichTextBox();
- this.SuspendLayout();
- //
- // sqlText
- //
- this.sqlText.Dock = System.Windows.Forms.DockStyle.Fill;
- this.sqlText.Location = new System.Drawing.Point(2, 2);
- this.sqlText.Margin = new System.Windows.Forms.Padding(0);
- this.sqlText.Name = "sqlText";
- this.sqlText.Size = new System.Drawing.Size(436, 308);
- this.sqlText.TabIndex = 0;
- this.sqlText.Text = "";
- this.sqlText.TextChanged += new System.EventHandler(this.sqlText_TextChanged);
- //
- // StoredProcedureEditor
- //
- this.Controls.Add(this.sqlText);
- this.Name = "StoredProcedureEditor";
- this.Padding = new System.Windows.Forms.Padding(2);
- this.Size = new System.Drawing.Size(440, 312);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private void sqlText_TextChanged(object sender, EventArgs e)
- {
- if (!IsDirty)
- 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();
- }
- }*/
-
- }
-}
Deleted: trunk/VSTools/Editors/StoredProcedureEditor.resx
===================================================================
--- trunk/VSTools/Editors/StoredProcedureEditor.resx 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Editors/StoredProcedureEditor.resx 2006-04-24 18:21:51 UTC (rev 229)
@@ -1,120 +0,0 @@
-<?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/TableEditor.cs
===================================================================
--- trunk/VSTools/Editors/TableEditor.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Editors/TableEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -16,6 +16,7 @@
private TableNode table;
private ImageList listImages;
private Font wingDingFont;
+ private ArrayList columns;
public TableEditor(TableNode table)
{
@@ -61,8 +62,8 @@
{
columnList.Items.Clear();
- ArrayList cols = table.GetColumns();
- foreach (ColumnNode node in cols)
+ columns = table.GetColumns();
+ foreach (ColumnNode node in columns)
{
ListViewItem item = columnList.Items.Add(node.Caption);
if (node.IsPrimary)
@@ -92,8 +93,11 @@
void columnList_DoubleClick(object sender, System.EventArgs e)
{
-
- throw new System.Exception("The method or operation is not implemented.");
+ if (columnList.SelectedIndices.Count == 0) return;
+ ColumnNode selectedNode = (ColumnNode)columns[columnList.SelectedIndices[0]];
+ EditColumnDialog dlg = new EditColumnDialog(selectedNode);
+ if (DialogResult.Cancel == dlg.ShowDialog())
+ return;
}
Added: trunk/VSTools/Editors/TriggerEditor.Designer.cs
===================================================================
--- trunk/VSTools/Editors/TriggerEditor.Designer.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Editors/TriggerEditor.Designer.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -0,0 +1,178 @@
+namespace MySql.VSTools
+{
+ partial class TriggerEditor
+ {
+ /// <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 Component 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.schema = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.triggername = new System.Windows.Forms.TextBox();
+ this.when = new System.Windows.Forms.ComboBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.action = new System.Windows.Forms.ComboBox();
+ this.sql = new System.Windows.Forms.RichTextBox();
+ this.label5 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(9, 11);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(49, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Schema:";
+ //
+ // schema
+ //
+ this.schema.Enabled = false;
+ this.schema.Location = new System.Drawing.Point(64, 8);
+ this.schema.Name = "schema";
+ this.schema.Size = new System.Drawing.Size(160, 20);
+ this.schema.TabIndex = 1;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(20, 38);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(38, 13);
+ this.label2.TabIndex = 2;
+ this.label2.Text = "Name:";
+ //
+ // triggername
+ //
+ this.triggername.Location = new System.Drawing.Point(64, 35);
+ this.triggername.Name = "triggername";
+ this.triggername.Size = new System.Drawing.Size(160, 20);
+ this.triggername.TabIndex = 3;
+ this.triggername.TextChanged += new System.EventHandler(this.triggername_TextChanged);
+ //
+ // when
+ //
+ this.when.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.when.FormattingEnabled = true;
+ this.when.Items.AddRange(new object[] {
+ "BEFORE",
+ "AFTER"});
+ this.when.Location = new System.Drawing.Point(64, 62);
+ this.when.Name = "when";
+ this.when.Size = new System.Drawing.Size(121, 21);
+ this.when.TabIndex = 4;
+ this.when.SelectedIndexChanged += new System.EventHandler(this.when_SelectedIndexChanged);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(19, 65);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(39, 13);
+ this.label3.TabIndex = 5;
+ this.label3.Text = "When:";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(191, 65);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(40, 13);
+ this.label4.TabIndex = 6;
+ this.label4.Text = "Action:";
+ //
+ // action
+ //
+ this.action.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.action.FormattingEnabled = true;
+ this.action.Items.AddRange(new object[] {
+ "INSERT",
+ "UPDATE",
+ "DELETE"});
+ this.action.Location = new System.Drawing.Point(237, 62);
+ this.action.Name = "action";
+ this.action.Size = new System.Drawing.Size(121, 21);
+ this.action.TabIndex = 7;
+ this.action.SelectedIndexChanged += new System.EventHandler(this.action_SelectedIndexChanged);
+ //
+ // sql
+ //
+ this.sql.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.sql.Location = new System.Drawing.Point(12, 109);
+ this.sql.Name = "sql";
+ this.sql.Size = new System.Drawing.Size(556, 264);
+ this.sql.TabIndex = 8;
+ this.sql.Text = "";
+ this.sql.TextChanged += new System.EventHandler(this.sql_TextChanged);
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(9, 93);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(31, 13);
+ this.label5.TabIndex = 9;
+ this.label5.Text = "SQL:";
+ //
+ // TriggerEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.label5);
+ this.Controls.Add(this.sql);
+ this.Controls.Add(this.action);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.when);
+ this.Controls.Add(this.triggername);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.schema);
+ this.Controls.Add(this.label1);
+ this.Name = "TriggerEditor";
+ this.Padding = new System.Windows.Forms.Padding(5);
+ this.Size = new System.Drawing.Size(576, 381);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox schema;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox triggername;
+ private System.Windows.Forms.ComboBox when;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.ComboBox action;
+ private System.Windows.Forms.RichTextBox sql;
+ private System.Windows.Forms.Label label5;
+ }
+}
Added: trunk/VSTools/Editors/TriggerEditor.cs
===================================================================
--- trunk/VSTools/Editors/TriggerEditor.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Editors/TriggerEditor.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+
+namespace MySql.VSTools
+{
+ internal partial class TriggerEditor : BaseEditor
+ {
+ private TriggerNode triggerNode;
+
+ public TriggerEditor(TriggerNode 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;
+ IsDirty = false;
+ }
+
+ public string TriggerName
+ {
+ get { return schema.Text + "." + triggername.Text; }
+ }
+
+ public string ActionTiming
+ {
+ get { return when.SelectedItem.ToString(); }
+ }
+
+ public string Action
+ {
+ get { return action.SelectedItem.ToString(); }
+ }
+
+ public string Body
+ {
+ get { return sql.Text; }
+ }
+
+ private void triggername_TextChanged(object sender, EventArgs e)
+ {
+ IsDirty = true;
+ }
+
+ private void when_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ IsDirty = true;
+ }
+
+ private void action_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ IsDirty = true;
+ }
+
+ private void sql_TextChanged(object sender, EventArgs e)
+ {
+ IsDirty = true;
+ }
+ }
+}
Modified: trunk/VSTools/MyExplorerWindow.cs
===================================================================
--- trunk/VSTools/MyExplorerWindow.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/MyExplorerWindow.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -182,6 +182,7 @@
AddCommand(mcs, PkgCmdIDList.cmdidAddNewView);
AddCommand(mcs, PkgCmdIDList.cmdidOpenTableDef);
AddCommand(mcs, PkgCmdIDList.cmdidNewQuery);
+ AddCommand(mcs, PkgCmdIDList.cmdidAddNewTrigger);
}
}
Modified: trunk/VSTools/MyVSTools.csproj
===================================================================
--- trunk/VSTools/MyVSTools.csproj 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/MyVSTools.csproj 2006-04-24 18:21:51 UTC (rev 229)
@@ -7,8 +7,7 @@
<ApplicationIcon>
</ApplicationIcon>
<AssemblyName>MySql.VSTools</AssemblyName>
- <AssemblyOriginatorKeyFile>
- </AssemblyOriginatorKeyFile>
+ <AssemblyOriginatorKeyFile>cnet.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
@@ -90,6 +89,12 @@
<Compile Include="..\\mysqlclient\\common\\dbConnectionString.cs" />
<Compile Include="..\\mysqlclient\\common\\utility.cs" />
<Compile Include="DebugTrace.cs" />
+ <Compile Include="EditColumnDialog.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="EditColumnDialog.Designer.cs">
+ <DependentUpon>EditColumnDialog.cs</DependentUpon>
+ </Compile>
<Compile Include="Editor.cs">
<SubType>Component</SubType>
</Compile>
@@ -100,7 +105,7 @@
<Compile Include="Editors\BaseEditor.cs">
<SubType>UserControl</SubType>
</Compile>
- <Compile Include="Editors\StoredProcedureEditor.cs">
+ <Compile Include="Editors\SqlTextEditor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Editors\TableEditor.cs">
@@ -109,6 +114,12 @@
<Compile Include="Editors\TableEditor.Designer.cs">
<DependentUpon>TableEditor.cs</DependentUpon>
</Compile>
+ <Compile Include="Editors\TriggerEditor.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="Editors\TriggerEditor.Designer.cs">
+ <DependentUpon>TriggerEditor.cs</DependentUpon>
+ </Compile>
<Compile Include="Nodes\ColumnNode.cs" />
<Compile Include="Nodes\ExplorerNode.cs" />
<Compile Include="Nodes\MyHierarchyNode.cs" />
@@ -160,18 +171,26 @@
<SubType>Designer</SubType>
<DependentUpon>ConnectionDlg.cs</DependentUpon>
</EmbeddedResource>
+ <EmbeddedResource Include="EditColumnDialog.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>EditColumnDialog.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="Editors\BaseEditor.resx">
<SubType>Designer</SubType>
<DependentUpon>BaseEditor.cs</DependentUpon>
</EmbeddedResource>
- <EmbeddedResource Include="Editors\StoredProcedureEditor.resx">
- <DependentUpon>StoredProcedureEditor.cs</DependentUpon>
+ <EmbeddedResource Include="Editors\SqlTextEditor.resx">
+ <DependentUpon>SqlTextEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Editors\TableEditor.resx">
<DependentUpon>TableEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <EmbeddedResource Include="Editors\TriggerEditor.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>TriggerEditor.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="QueryControl.resx">
<SubType>Designer</SubType>
<DependentUpon>QueryControl.cs</DependentUpon>
@@ -227,7 +246,7 @@
<RegisterWithCodebase>true</RegisterWithCodebase>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="C:\Program Files (x86)\Visual Studio 2005 SDK\2006.04\VisualStudioIntegration\Tools\Build\Microsoft.VsSDK.targets" />
+ <Import Project="C:\Program Files\Visual Studio 2005 SDK\2006.04\VisualStudioIntegration\Tools\Build\Microsoft.VsSDK.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
Modified: trunk/VSTools/MyVSTools.csproj.user
===================================================================
--- trunk/VSTools/MyVSTools.csproj.user 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/MyVSTools.csproj.user 2006-04-24 18:21:51 UTC (rev 229)
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<StartAction>Program</StartAction>
- <StartProgram>C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\devenv.exe</StartProgram>
+ <StartProgram>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Modified: trunk/VSTools/Nodes/ExplorerNode.cs
===================================================================
--- trunk/VSTools/Nodes/ExplorerNode.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Nodes/ExplorerNode.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -23,6 +23,8 @@
private ExplorerNode nextSibling;
private ExplorerNode firstChild;
protected bool populated;
+ protected BaseEditor activeEditor;
+ protected bool isNew;
public ExplorerNode(ExplorerNode parent, string caption)
{
@@ -96,18 +98,23 @@
protected void LinkChild(ExplorerNode node)
{
+ ExplorerNode nodeIter = null;
if (firstChild == null)
firstChild = node;
else
{
- ExplorerNode nodeIter = firstChild;
+ nodeIter = firstChild;
while (nodeIter.NextSibling != null)
nodeIter = nodeIter.NextSibling;
nodeIter.NextSibling = node;
}
+ // notify our hierarchy node that we have linked in an item
+ GetHierNode().ItemAdded(ItemId,
+ nodeIter == null ? VSConstants.VSITEMID_NIL : nodeIter.ItemId,
+ node.ItemId);
}
- protected void AddChild(ExplorerNode node)
+ public void AddChild(ExplorerNode node)
{
IndexChild(node);
LinkChild(node);
@@ -132,7 +139,7 @@
else
prevNode.NextSibling = nodeIter.NextSibling;
- hierNode.RefreshItem(itemId);
+ hierNode.ItemDeleted(itemId);
}
protected DbConnection GetOpenConnection()
@@ -222,7 +229,7 @@
DebugTrace.Trace("starting editor on item = " + this.ItemId);
string filename = GetDatabaseNode().Caption + "." + Caption;
- editor = GuidList.guidProcedureEditor;
+ //editor = GuidList.guidProcedureEditor;
Guid logicalView = VSConstants.LOGVIEWID_Primary;
int result = openDoc.OpenSpecificEditor(0,
filename, ref ed, null, ref logicalView,
Modified: trunk/VSTools/Nodes/MyHierarchyNode.cs
===================================================================
--- trunk/VSTools/Nodes/MyHierarchyNode.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Nodes/MyHierarchyNode.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -95,6 +95,13 @@
(sinkEnum.Current as IVsHierarchyEvents).OnItemDeleted(itemId);
}
+ public void ItemAdded(uint parentId, uint prevId, uint itemId)
+ {
+ IEnumerator sinkEnum = (sinks as IEnumerable).GetEnumerator();
+ while (sinkEnum.MoveNext())
+ (sinkEnum.Current as IVsHierarchyEvents).OnItemAdded(parentId, prevId, itemId);
+ }
+
public ExplorerNode NodeFromId(uint itemId)
{
if (itemId == VSConstants.VSITEMID_ROOT)
Modified: trunk/VSTools/Nodes/TableNode.cs
===================================================================
--- trunk/VSTools/Nodes/TableNode.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Nodes/TableNode.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -6,6 +6,7 @@
using System.Data.Common;
using System.Collections;
using System.ComponentModel;
+using System.Globalization;
namespace MySql.VSTools
{
@@ -123,12 +124,32 @@
case PkgCmdIDList.cmdidShowTableData:
ShowTableData();
break;
+ case PkgCmdIDList.cmdidAddNewTrigger:
+ AddNewTrigger();
+ break;
default:
base.DoCommand(commandId);
break;
}
}
+ internal void AddNewTrigger()
+ {
+ // first determine a default name
+ int num = 1;
+ string name = String.Format("trigger{0}", num);
+ ExplorerNode node = FirstChild;
+ while (node != null)
+ {
+ if (node.Caption.ToLower(CultureInfo.InvariantCulture) == name)
+ name = String.Format("trigger{0}", ++num);
+ node = node.NextSibling;
+ }
+ TriggerNode newTrigger = new TriggerNode(this, name);
+ IndexChild(newTrigger);
+ newTrigger.Open();
+ }
+
internal override BaseEditor GetEditor()
{
TableEditor editor = new TableEditor(this);
Modified: trunk/VSTools/Nodes/TriggerNode.cs
===================================================================
--- trunk/VSTools/Nodes/TriggerNode.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/Nodes/TriggerNode.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -8,16 +8,52 @@
{
internal class TriggerNode : ExplorerNode
{
- private DataRow triggerDef;
private string body;
+ private string actionTiming;
+ private string action;
+ public TriggerNode(ExplorerNode parent, string name)
+ : base(parent, name)
+ {
+ actionTiming = "BEFORE";
+ action = "INSERT";
+ body = String.Empty;
+ isNew = true;
+ }
+
public TriggerNode(ExplorerNode parent, DataRow row)
: base(parent, row["TRIGGER_NAME"].ToString())
{
- triggerDef = row;
- body = triggerDef["ACTION_STATEMENT"].ToString();
+ body = row["ACTION_STATEMENT"].ToString();
+ actionTiming = row["ACTION_TIMING"].ToString();
+ action = row["EVENT_MANIPULATION"].ToString();
+ isNew = false;
}
+ #region Properties
+
+ public string Body
+ {
+ get { return body; }
+ }
+
+ public string Schema
+ {
+ get { return GetDatabaseNode().Caption; }
+ }
+
+ public string ActionTime
+ {
+ get { return actionTiming; }
+ }
+
+ public string Action
+ {
+ get { return action; }
+ }
+
+ #endregion
+
public override uint MenuId
{
get { return PkgCmdIDList.TriggerCtxtMenu; }
@@ -33,6 +69,34 @@
get { return false; }
}
+ public override bool Save()
+ {
+ TriggerEditor editor = (activeEditor as TriggerEditor);
+ StringBuilder sql = new StringBuilder();
+ TableNode parentTable = (Parent as TableNode);
+ if (!isNew)
+ sql.AppendFormat("DROP TRIGGER {0}.{1};", Schema, Caption);
+ sql.AppendFormat("CREATE TRIGGER {0} {1} {2} ON {3}.{4} FOR EACH ROW {5}",
+ editor.TriggerName, editor.ActionTiming, editor.Action,
+ parentTable.Schema, parentTable.Caption, editor.Body);
+ try
+ {
+ ExecuteNonQuery(sql.ToString());
+ if (isNew)
+ parentTable.AddChild(this);
+ activeEditor = null;
+ return true;
+ }
+ catch (Exception ex)
+ {
+ if (isNew)
+ MessageBox.Show("Error creating trigger: " + ex.Message);
+ else
+ MessageBox.Show("Error updating trigger: " + ex.Message);
+ return false;
+ }
+ }
+
public override void DoCommand(int commandId)
{
switch (commandId)
@@ -40,9 +104,9 @@
case PkgCmdIDList.cmdidDelete:
Delete();
break;
-// case PkgCmdIDList.cmdidOpen:
- // Open();
- // break;
+ case PkgCmdIDList.cmdidOpen:
+ Open();
+ break;
default:
base.DoCommand(commandId);
break;
@@ -51,14 +115,21 @@
private void Delete()
{
+ ExecuteNonQuery(String.Format("DROP TRIGGER {0}.{1}",
+ GetDatabaseNode().Caption, Caption));
+ Parent.RemoveChild(this);
}
-/* internal void Open()
+ internal override BaseEditor GetEditor()
{
- SqlTextEditor editor = new SqlTextEditor(
- Caption, GetDatabaseNode().Caption, body, GetOpenConnection());
- OpenEditor(editor);
+ activeEditor = new TriggerEditor(this);
+ return activeEditor;
}
- */
+
+ internal void Open()
+ {
+ if (activeEditor != null) return;
+ OpenEditor();
+ }
}
}
Modified: trunk/VSTools/VsPkg.cs
===================================================================
--- trunk/VSTools/VsPkg.cs 2006-04-23 02:41:06 UTC (rev 228)
+++ trunk/VSTools/VsPkg.cs 2006-04-24 18:21:51 UTC (rev 229)
@@ -49,6 +49,7 @@
[ProvideToolWindow(typeof(QueryToolWindow), Style = Microsoft.VisualStudio.Shell.VsDockStyle.MDI)]
[ProvideToolWindow(typeof(TableDataWindow), Style = Microsoft.VisualStudio.Shell.VsDockStyle.MDI)]
[ProvideEditorLogicalView(typeof(EditorFactory), "{7651a703-06e5-11d1-8ebd-00a0c90f26ea}")]
+ [RegisterEditorExtension(typeof(EditorFactory), ".xxx", 1)]
[Guid("5ceb61c4-7111-44f8-b7f2-ac049b81ad32")]
public sealed class MyVSTools : Package
{
@@ -132,7 +133,15 @@
//Create Editor Factory
editorFactory = new EditorFactory(this);
- base.RegisterEditorFactory(editorFactory);
+ try
+ {
+ base.RegisterEditorFactory(editorFactory);
+ }
+ catch (Exception ex)
+ {
+ string t = ex.GetType().ToString();
+ Console.WriteLine(ex.Message);
+ }
// Add our command handlers for menu (commands must exist in the .ctc file)
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
| Thread |
|---|
| • Connector/NET commit: r229 - in trunk/VSTools: . Editors Nodes | rburnett | 24 Apr |