Modified:
trunk/VSTools/Editors/StoredProcedureEditor.cs
trunk/VSTools/Nodes/FunctionNode.cs
trunk/VSTools/Nodes/FunctionsNode.cs
trunk/VSTools/Nodes/MyHierarchyNode.cs
trunk/VSTools/Nodes/ProcedureNode.cs
trunk/VSTools/Nodes/ProceduresNode.cs
trunk/VSTools/Nodes/TriggerNode.cs
trunk/VSTools/Nodes/ViewsNode.cs
trunk/mysqlclient/ISSchemaProvider.cs
Log:
ISSchemaProvider.cs
added initial where parameter to Query so that tables can filter out views without exposing that as a restriction
StoredProcedureEditor.cs
Renamed class to SqlTextEditor so it can be used for other node types
still need to rename the actual file
FunctionNode.cs
ProcedureNode.cs
now using SqlTextEditor instead of StoredProcedureEditor
FunctionsNode.cs
ProceduresNode.cs
viewsnode.cs
fixed populate to properly populate only items of the right type
MyHierachyNode.cs
Changed refreshitem to call refresh on the entire hiearchy. Works but flashes. stop gap
TriggerNode.cs
Implemented open
Modified: trunk/VSTools/Editors/StoredProcedureEditor.cs
===================================================================
--- trunk/VSTools/Editors/StoredProcedureEditor.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Editors/StoredProcedureEditor.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -14,9 +14,9 @@
/// <summary>
/// Summary description for StoredProcedureEditor.
/// </summary>
- public class StoredProcedureEditor : BaseEditor
+ public class SqlTextEditor : BaseEditor
{
- private System.Windows.Forms.RichTextBox procText;
+ private System.Windows.Forms.RichTextBox sqlText;
/// <summary>
/// Required designer variable.
/// </summary>
@@ -28,14 +28,14 @@
private bool changed;
private EnvDTE.DTE dte;
- public StoredProcedureEditor(string name, string database, string body,
+ public SqlTextEditor(string name, string database, string body,
DbConnection conn)
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
spName = name;
dbName = database;
- procText.Text = body;
+ sqlText.Text = body;
// set text editor font
if (dte == null)
@@ -43,7 +43,7 @@
EnvDTE.Properties props = dte.get_Properties("FontsAndColors", "TextEditor");
EnvDTE.Property family = props.Item("FontFamily");
EnvDTE.Property size = props.Item("FontSize");
- procText.Font = new Font(family.Value.ToString(),
+ sqlText.Font = new Font(family.Value.ToString(),
float.Parse(size.Value.ToString()));
}
@@ -60,22 +60,22 @@
protected override bool CanCopyAndCut
{
- get { return procText.SelectedText.Length > 0; }
+ get { return sqlText.SelectedText.Length > 0; }
}
protected override bool CanPaste
{
- get { return procText.CanPaste(DataFormats.GetFormat(DataFormats.Text)); }
+ get { return sqlText.CanPaste(DataFormats.GetFormat(DataFormats.Text)); }
}
protected override bool CanRedo
{
- get { return procText.CanRedo; }
+ get { return sqlText.CanRedo; }
}
protected override bool CanUndo
{
- get { return procText.CanUndo; }
+ get { return sqlText.CanUndo; }
}
/*public void Edit(string spName, string db, ServerConfig sc)
@@ -95,7 +95,7 @@
reader.Read();
string body = reader.GetString(2);
body = body.Replace("\n", "\r\n");
- procText.Text = body;
+ sqlText.Text = body;
}
}
catch (Exception ex)
@@ -131,23 +131,23 @@
/// </summary>
private void InitializeComponent()
{
- this.procText = new System.Windows.Forms.RichTextBox();
+ this.sqlText = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
- // procText
+ // sqlText
//
- this.procText.Dock = System.Windows.Forms.DockStyle.Fill;
- this.procText.Location = new System.Drawing.Point(2, 2);
- this.procText.Margin = new System.Windows.Forms.Padding(0);
- this.procText.Name = "procText";
- this.procText.Size = new System.Drawing.Size(436, 308);
- this.procText.TabIndex = 0;
- this.procText.Text = "";
- this.procText.TextChanged += new System.EventHandler(this.procText_TextChanged);
+ 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.procText);
+ this.Controls.Add(this.sqlText);
this.Name = "StoredProcedureEditor";
this.Padding = new System.Windows.Forms.Padding(2);
this.Size = new System.Drawing.Size(440, 312);
@@ -157,7 +157,7 @@
#endregion
- private void procText_TextChanged(object sender, EventArgs e)
+ private void sqlText_TextChanged(object sender, EventArgs e)
{
if (!IsDirty)
IsDirty = true;
@@ -168,7 +168,7 @@
base.PostCreateInit();
if (!CanEdit())
- procText.ReadOnly = true;
+ sqlText.ReadOnly = true;
}
*/
/* private void saveBtn_Click(object sender, System.EventArgs e)
@@ -179,7 +179,7 @@
{
conn.Open();
conn.ChangeDatabase(dbName);
- string sql = "DROP PROCEDURE IF EXISTS " + spName + "; " + procText.Text;
+ string sql = "DROP PROCEDURE IF EXISTS " + spName + "; " + sqlText.Text;
MySqlCommand cmd = new MySqlCommand(sql, conn);
cmd.ExecuteNonQuery();
}
Modified: trunk/VSTools/Nodes/FunctionNode.cs
===================================================================
--- trunk/VSTools/Nodes/FunctionNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/FunctionNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -38,7 +38,7 @@
private void Open()
{
- StoredProcedureEditor editor = new StoredProcedureEditor(
+ SqlTextEditor editor = new SqlTextEditor(
Caption, funcDef["ROUTINE_SCHEMA"].ToString(),
funcDef["ROUTINE_DEFINITION"].ToString(),
GetOpenConnection());
Modified: trunk/VSTools/Nodes/FunctionsNode.cs
===================================================================
--- trunk/VSTools/Nodes/FunctionsNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/FunctionsNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -38,8 +38,10 @@
try
{
- DataTable table = c.GetSchema("Functions",
- new string[] { null, Parent.Caption, null, null });
+ string[] restrictions = new string[4];
+ restrictions[1] = GetDatabaseNode().Caption;
+ restrictions[3] = "FUNCTION";
+ DataTable table = c.GetSchema("Procedures", restrictions);
foreach (DataRow row in table.Rows)
AddChild(new FunctionNode(this, row["ROUTINE_NAME"].ToString(), row));
Modified: trunk/VSTools/Nodes/MyHierarchyNode.cs
===================================================================
--- trunk/VSTools/Nodes/MyHierarchyNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/MyHierarchyNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -85,7 +85,7 @@
{
IEnumerator sinkEnum = (sinks as IEnumerable).GetEnumerator();
while (sinkEnum.MoveNext())
- (sinkEnum.Current as IVsHierarchyEvents).OnInvalidateItems(itemId);
+ (sinkEnum.Current as IVsHierarchyEvents).OnInvalidateItems(VSConstants.VSITEMID_ROOT);
}
public void ItemDeleted(uint itemId)
Modified: trunk/VSTools/Nodes/ProcedureNode.cs
===================================================================
--- trunk/VSTools/Nodes/ProcedureNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/ProcedureNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -91,7 +91,7 @@
internal void Open()
{
- StoredProcedureEditor editor = new StoredProcedureEditor(
+ SqlTextEditor editor = new SqlTextEditor(
Caption, GetDatabaseNode().Caption, body, GetOpenConnection());
OpenEditor(editor);
}
Modified: trunk/VSTools/Nodes/ProceduresNode.cs
===================================================================
--- trunk/VSTools/Nodes/ProceduresNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/ProceduresNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -77,8 +77,10 @@
try
{
- DataTable table = c.GetSchema("Procedures",
- new string[] { null, Parent.Caption, null, null });
+ string[] restrictions = new string[4];
+ restrictions[1] = GetDatabaseNode().Caption;
+ restrictions[3] = "PROCEDURE";
+ DataTable table = c.GetSchema("Procedures", restrictions);
foreach (DataRow row in table.Rows)
AddChild(new ProcedureNode(this, row["ROUTINE_NAME"].ToString(), row));
Modified: trunk/VSTools/Nodes/TriggerNode.cs
===================================================================
--- trunk/VSTools/Nodes/TriggerNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/TriggerNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -9,11 +9,13 @@
internal class TriggerNode : ExplorerNode
{
private DataRow triggerDef;
+ private string body;
public TriggerNode(ExplorerNode parent, DataRow row)
: base(parent, row["TRIGGER_NAME"].ToString())
{
triggerDef = row;
+ body = triggerDef["ACTION_STATEMENT"].ToString();
}
public override uint MenuId
@@ -38,6 +40,9 @@
case PkgCmdIDList.cmdidDelete:
Delete();
break;
+ case PkgCmdIDList.cmdidOpen:
+ Open();
+ break;
default:
base.DoCommand(commandId);
break;
@@ -48,5 +53,12 @@
{
}
+ internal void Open()
+ {
+ SqlTextEditor editor = new SqlTextEditor(
+ Caption, GetDatabaseNode().Caption, body, GetOpenConnection());
+ OpenEditor(editor);
+ }
+
}
}
Modified: trunk/VSTools/Nodes/ViewsNode.cs
===================================================================
--- trunk/VSTools/Nodes/ViewsNode.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/VSTools/Nodes/ViewsNode.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -44,6 +44,7 @@
foreach (DataRow row in table.Rows)
AddChild(new ViewNode(this, row["TABLE_NAME"].ToString(), row));
+ populated = true;
}
catch (Exception ex)
{
Modified: trunk/mysqlclient/ISSchemaProvider.cs
===================================================================
--- trunk/mysqlclient/ISSchemaProvider.cs 2006-04-19 15:47:20 UTC (rev 220)
+++ trunk/mysqlclient/ISSchemaProvider.cs 2006-04-19 18:16:59 UTC (rev 221)
@@ -13,9 +13,10 @@
}
- private DataTable Query(string table_name, string[] keys, string[] values)
+ private DataTable Query(string table_name, string initial_where,
+ string[] keys, string[] values)
{
- StringBuilder where = new StringBuilder();
+ StringBuilder where = new StringBuilder(initial_where);
StringBuilder query = new StringBuilder("SELECT * FROM INFORMATION_SCHEMA.");
query.Append(table_name);
@@ -76,7 +77,7 @@
keys[1] = "TABLE_sCHEMA";
keys[2] = "TABLE_NAME";
keys[3] = "TABLE_TYPE";
- return Query("TABLES", keys, restrictions);
+ return Query("TABLES", "TABLE_TYPE != 'VIEW'", keys, restrictions);
}
public override DataTable GetColumns(string[] restrictions)
@@ -86,12 +87,16 @@
keys[1] = "TABLE_sCHEMA";
keys[2] = "TABLE_NAME";
keys[3] = "COLUMN_NAME";
- return Query("COLUMNS", keys, restrictions);
+ return Query("COLUMNS", null, keys, restrictions);
}
public override DataTable GetViews(string[] restrictions)
{
- return Query("VIEWS", null, restrictions);
+ string[] keys = new string[3];
+ keys[0] = "TABLE_CATALOG";
+ keys[1] = "TABLE_sCHEMA";
+ keys[2] = "TABLE_NAME";
+ return Query("VIEWS", null, keys, restrictions);
}
public override DataTable GetTriggers(string[] restrictions)
@@ -101,7 +106,7 @@
keys[1] = "TRIGGER_sCHEMA";
keys[2] = "TRIGGER_NAME";
keys[3] = "EVENT_OBJECT_TABLE";
- return Query("TRIGGERS", keys, restrictions);
+ return Query("TRIGGERS", null, keys, restrictions);
}
/// <summary>
@@ -113,31 +118,12 @@
/// <returns></returns>
public override DataTable GetProcedures(string[] restrictions)
{
- StringBuilder where = new StringBuilder("");
- StringBuilder query = new StringBuilder("SELECT * FROM INFORMATION_SCHEMA.ROUTINES");
-
- if (restrictions[1] != null && restrictions[1].Length != 0)
- where.AppendFormat("ROUTINE_SCHEMA='{0}'", restrictions[1]);
- if (restrictions[2] != null && restrictions[2].Length != 0)
- {
- if (where.Length > 0)
- where.Append(" AND ");
- where.AppendFormat("ROUTINE_NAME='{0}'", restrictions[2]);
- }
- if (restrictions[3] != null && restrictions[3].Length != 0)
- {
- if (where.Length > 0)
- where.AppendLine(" AND ");
- where.AppendFormat("ROUTINE_TYPE='{0}'", restrictions[3]);
- }
- if (where.Length > 0)
- {
- query.Append(" WHERE ");
- query.Append(where);
- }
- DataTable table = GetTable(query.ToString());
- table.TableName = "Procedures";
- return table;
+ string[] keys = new string[4];
+ keys[0] = "ROUTINE_CATALOG";
+ keys[1] = "ROUTINE_sCHEMA";
+ keys[2] = "ROUTINE_NAME";
+ keys[3] = "ROUTINE_TYPE";
+ return Query("ROUTINES", null, keys, restrictions);
}
/// <summary>
| Thread |
|---|
| • Connector/NET commit: r221 - in trunk: VSTools/Editors VSTools/Nodes mysqlclient | rburnett | 19 Apr |