/// <summary>The navigate to.</summary> /// <param name="modelObject">The model object.</param> public void NavigateTo(IDbModelNamedObject modelObject) { if (modelObject == null) { return; } switch (modelObject.ObjectType) { case ObjectTypes.Table: foreach (TreeNode treeNode in _tablesNode.Nodes) { IDbModelNamedObject obj = treeNode.Tag as IDbModelNamedObject; if (obj != null && modelObject == obj) { SelectNode(treeNode); } } break; case ObjectTypes.View: foreach (TreeNode treeNode in _viewsNode.Nodes) { IDbModelNamedObject obj = treeNode.Tag as IDbModelNamedObject; if (obj != null && modelObject == obj) { SelectNode(treeNode); } } break; case ObjectTypes.Column: DbModelColumn modelColumn = modelObject as DbModelColumn; if (modelColumn != null) { foreach (TreeNode treeNode in _tablesNode.Nodes) { // only look in the tables nodw for FK refs DbModelTable modelTable = treeNode.Tag as DbModelTable; if (modelTable != null && modelTable == modelColumn.ParentTable) { // now find the column in the child nodes foreach (TreeNode columnNode in treeNode.Nodes) { DbModelColumn modelReferingColumn = columnNode.Tag as DbModelColumn; if (modelReferingColumn != null && modelReferingColumn == modelColumn) { SelectNode(columnNode); } } } } } break; } }
/// <summary>The database tree view_ node mouse double click.</summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void DatabaseTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode node = e.Node; if (e.Button == MouseButtons.Left) { IDbModelNamedObject namedObject = node.Tag as IDbModelNamedObject; if (namedObject != null) { SetText(namedObject.FullName); } } }
/// <summary>Execute the command.</summary> public override void Execute() { using (var frm = Services.Resolve <FindObjectForm>()) { frm.ShowDialog(HostWindow.Instance); if (frm.DialogResult == DialogResult.OK) { IDbModelNamedObject obj = HostWindow.DatabaseInspector.DbSchema.FindTableOrView(frm.SelectedTableName); HostWindow.DatabaseInspector.NavigateTo(obj); } } }
/// <summary>Execute the command.</summary> public override void Execute() { using (var frm = Services.Resolve <FindObjectForm>()) { frm.ShowDialog(HostWindow.Instance); var selectedTableName = frm.SelectedObjectName; if (frm.DialogResult == DialogResult.OK && !String.IsNullOrEmpty(selectedTableName)) { // Special case for handling schemas - We want the search without the [dbo].[foo] part // but the FindTableOrView expects it.... var parts = selectedTableName.Split('.').Select(s => "[" + s + "]").ToArray(); var name = String.Join(".", parts); IDbModelNamedObject obj = HostWindow.DatabaseInspector.DbSchema.FindTableOrView(name); HostWindow.DatabaseInspector.NavigateTo(obj); } } }
/// <summary>The database tree view_ node mouse click.</summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void DatabaseTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode node = e.Node; if (e.Button == MouseButtons.Right) { IDbModelNamedObject namedObject = node.Tag as IDbModelNamedObject; _rightClickedModelObject = namedObject; if (namedObject != null && (namedObject.ObjectType == ObjectTypes.Table || namedObject.ObjectType == ObjectTypes.View)) { _rightClickedNode = node; } else { _rightClickedNode = null; } } }
/// <summary>The database tree view_ node mouse click.</summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void DatabaseTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode node = e.Node; if (e.Button == MouseButtons.Right) { IDbModelNamedObject namedObject = node.Tag as IDbModelNamedObject; _rightClickedModelObject = namedObject; if (namedObject != null && (namedObject.ObjectType == ObjectTypes.Table || namedObject.ObjectType == ObjectTypes.View)) { _rightClickedNode = node; } else { _rightClickedNode = null; } } }
/// <summary>The navigate to.</summary> /// <param name="modelObject">The model object.</param> public void NavigateTo(IDbModelNamedObject modelObject) { if (modelObject == null) { return; } switch (modelObject.ObjectType) { case ObjectTypes.Table: foreach (TreeNode treeNode in _tablesNode.Nodes) { IDbModelNamedObject obj = treeNode.Tag as IDbModelNamedObject; if (obj != null && modelObject == obj) { SelectNode(treeNode); } } break; case ObjectTypes.View: foreach (TreeNode treeNode in _viewsNode.Nodes) { IDbModelNamedObject obj = treeNode.Tag as IDbModelNamedObject; if (obj != null && modelObject == obj) { SelectNode(treeNode); } } break; case ObjectTypes.Column: DbModelColumn modelColumn = modelObject as DbModelColumn; if (modelColumn != null) { foreach (TreeNode treeNode in _tablesNode.Nodes) { // only look in the tables nodw for FK refs DbModelTable modelTable = treeNode.Tag as DbModelTable; if (modelTable != null && modelTable == modelColumn.ParentTable) { // now find the column in the child nodes foreach (TreeNode columnNode in treeNode.Nodes) { DbModelColumn modelReferingColumn = columnNode.Tag as DbModelColumn; if (modelReferingColumn != null && modelReferingColumn == modelColumn) { SelectNode(columnNode); } } } } } break; } }