void _tree_BeforeExpand(object sender, TreeViewCancelEventArgs e) { var verbNode = e.Node; if (verbNode.Tag is Verb) { var provider = FindProvider(verbNode); TreeNodesBuilder.RebuildVerbArguments(verbNode, provider); } }
public void AddServer(IMetadataProvider provider, ConnectionInfo connection) { //Check if the current connection can create subscription DataTable dt = null; try { dt = connection.Query("SELECT CanCreate FROM Metadata.Entity WHERE FullName='System.Subscription'"); } catch (ApplicationException e) { log.Info("Exception checking if we can create subscriptions.", e); } if (dt != null && (dt.Rows.Count == 1 && dt.Columns.Count == 1)) { connection.CanCreateSubscription = Convert.ToBoolean(dt.Rows[0][0]); } var tableContextMenuWithoutCrud = new ContextMenu(); var tableContextMenuWithCrud = new ContextMenu(); var commonTableContextMenus = new[] { tableContextMenuWithCrud, tableContextMenuWithoutCrud }; foreach (var tableContextMenu in commonTableContextMenus) { tableContextMenu.MenuItems.Add("Generate Select Statement", (s, e) => GenerateSelectStatement(_contextMenuNode.Tag as Entity, false)); tableContextMenu.MenuItems.Add("Generate Select Statement (with Inherited Properties)", (s, e) => GenerateSelectStatement(_contextMenuNode.Tag as Entity, true)); if (connection.CanCreateSubscription) { tableContextMenu.MenuItems.Add("Subscribe", StartSubscription); } } tableContextMenuWithCrud.MenuItems.Add("-"); // note: the names are crucial for disabling/enabling the menu based on operations allowed tableContextMenuWithCrud.MenuItems.Add("Create", (s, e) => Crud(_contextMenuNode.Tag as Entity, CrudOperation.Create)).Name = "create"; tableContextMenuWithCrud.MenuItems.Add("Update", (s, e) => Crud(_contextMenuNode.Tag as Entity, CrudOperation.Update)).Name = "update"; tableContextMenuWithCrud.MenuItems.Add("Delete", (s, e) => Crud(_contextMenuNode.Tag as Entity, CrudOperation.Delete)).Name = "delete"; _tableContextMenuItems.Add(connection.Title, tableContextMenuWithoutCrud); _tableCrudContextMenuItems.Add(connection.Title, tableContextMenuWithCrud); var serverContextMenu = new ContextMenuStrip(); serverContextMenu.Items.Add("Refresh", Properties.Resources.Refresh_16x, (s, e) => RefreshServer(_contextMenuNode)); if (connection.CanCreateSubscription) { serverContextMenu.Items.Add("Activity Monitor", null, (s, e) => OpenActivityMonitor(_contextMenuNode)); } serverContextMenu.Items.Add("Generate C# Code...", null, (s, e) => GenerateCSharpCode(_contextMenuNode)); var closeMenuItem = new ToolStripMenuItem("Disconnect", Properties.Resources.Disconnect_16x, (s, e) => CloseServer(_contextMenuNode)); serverContextMenu.Items.Add(closeMenuItem); _serverContextMenuItems.Add(connection.Title, serverContextMenu); TreeNode[] existingNodes = _treeData.Nodes.Find(provider.Name, false); if (existingNodes.Length == 0) { TreeNode databaseNode = TreeNodesBuilder.CreateDatabaseNode(_treeData, provider, connection); RefreshServer(databaseNode); } else { // Node exists. Just focus on it. _treeData.SelectedNode = existingNodes[0]; UpdateDrawnNodesSelection(); } }