Browse Source

minor bugfix to load 'empty' metadata files - event handler in place for table description form

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1744 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Dickon Field 19 years ago
parent
commit
26104f5fc2
  1. 18
      src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfo.cs
  2. 25
      src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

18
src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfo.cs

@ -63,7 +63,13 @@ namespace SharpDbTools.Model @@ -63,7 +63,13 @@ namespace SharpDbTools.Model
public string InvariantName {
get {
DataTable table = this.Tables[TableNames.ConnectionInfo];
string invariantName = table.Rows[0][ColumnNames.InvariantName] as string;
string invariantName = null;
try {
invariantName = table.Rows[0][ColumnNames.InvariantName] as string;
}
catch(ArgumentException e) {
// see comment below - it is correct to bury this exception
}
return invariantName;
}
set {
@ -90,7 +96,15 @@ namespace SharpDbTools.Model @@ -90,7 +96,15 @@ namespace SharpDbTools.Model
public string ConnectionString {
get {
DataTable table = this.Tables[TableNames.ConnectionInfo];
string connectionString = table.Rows[0][ColumnNames.ConnectionString] as string;
string connectionString = null;
try {
connectionString = table.Rows[0][ColumnNames.ConnectionString] as string;
}
catch(ArgumentException e) {
// this simply indicates that this attribute was not defined when the
// DbModelInfo was saved, returning null makes sense here - so it is
// correct to bury this exception
}
return connectionString;
}
set {

25
src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

@ -149,7 +149,7 @@ namespace SharpDbTools @@ -149,7 +149,7 @@ namespace SharpDbTools
TreeNode treeNode = new TreeNode(name);
// create and add the menustrip for this node
DbModelInfoContextMenuStrip cMenu = new DbModelInfoContextMenuStrip(treeNode);
NodeAwareContextMenuStrip cMenu = new NodeAwareContextMenuStrip(treeNode);
// create menu items
ToolStripMenuItem setConnectionStringMenuItem =
@ -224,10 +224,22 @@ namespace SharpDbTools @@ -224,10 +224,22 @@ namespace SharpDbTools
if (dbObjectRow.ItemArray.Length > 1) {
objectNode = new TreeNode((string)dbObjectRow[1]);
objectNode.Name = name + ":Object:" + (string)dbObjectRow[1];
// TODO: >>>>>>> NEXT: building Describe invocation will need to be somewhere around here
} else {
objectNode = new TreeNode((string)dbObjectRow[0]);
objectNode.Name = name + ":Object:" + (string)dbObjectRow[0];
}
// HACK All this building stuff needs to be externalise I think
if (metadataCollectionName.Equals("Tables")) {
// add the handler to invoke describer
NodeAwareContextMenuStrip cMenu = new NodeAwareContextMenuStrip(objectNode);
ToolStripMenuItem invokeDescriberMenuItem = new ToolStripMenuItem("Describe");
invokeDescriberMenuItem.Click += new EventHandler(DescribeTableClickHandler);
cMenu.Items.Add(invokeDescriberMenuItem);
objectNode.ContextMenuStrip = cMenu;
}
// TreeNode ownerNode = new TreeNode("Owner: " + (string)dbObjectRow["OWNER"]);
// TreeNode typeNode = new TreeNode("Type: " + (string)dbObjectRow["TYPE"]);
@ -303,7 +315,7 @@ namespace SharpDbTools @@ -303,7 +315,7 @@ namespace SharpDbTools
private static string getConnectionName(object sender)
{
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
DbModelInfoContextMenuStrip toolStrip = menuItem.Owner as DbModelInfoContextMenuStrip;
NodeAwareContextMenuStrip toolStrip = menuItem.Owner as NodeAwareContextMenuStrip;
TreeNode node = toolStrip.TreeNode;
string connectionLogicalName = node.Text;
return connectionLogicalName;
@ -355,13 +367,18 @@ namespace SharpDbTools @@ -355,13 +367,18 @@ namespace SharpDbTools
"An Exception was thrown while trying to connect to: " + connectionLogicalName);
}
}
public void DescribeTableClickHandler(object sender, EventArgs args)
{
LoggingService.Debug("describe table clicked for: ");
}
}
class DbModelInfoContextMenuStrip : ContextMenuStrip
class NodeAwareContextMenuStrip : ContextMenuStrip
{
TreeNode treeNodeAttached;
public DbModelInfoContextMenuStrip(TreeNode treeNodeAttached) : base()
public NodeAwareContextMenuStrip(TreeNode treeNodeAttached) : base()
{
this.treeNodeAttached = treeNodeAttached;
}

Loading…
Cancel
Save