Пример #1
0
        public TreeNode CloneShallow()
        {
            var treeNode = new TreeNodeWithConnectionInfo(this.Text, this.Provider);

            TreeNodeUtils.CopyContent(this, treeNode);
            return(treeNode);
        }
Пример #2
0
        private static TreeNodeWithConnectionInfo MakeEntityTreeNode(IMetadataProvider provider, ConnectionInfo connection, Entity table)
        {
            var node = new TreeNodeWithConnectionInfo(table.FullName, connection);

            node.ImageKey         = table.IsIndication ? "Indication" : (!table.IsAbstract ? "Table" : "TableAbstract");
            node.SelectedImageKey = node.ImageKey;
            node.Tag         = table;
            node.ToolTipText = string.Format(
                @"{0}
Base type: {1}
CanCreate: {2}
CanUpdate: {3}
CanDelete: {4}",
                table.FullName, table.BaseType, table.CanCreate, table.CanUpdate, table.CanDelete);

            // Add keys
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsKey));

            // Add the simple Properties
            AddPropertiesToNode(node, table.Properties.Where(c => !c.IsInherited && !c.IsNavigable && !c.IsKey));

            // Add the inherited Properties
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsInherited && !c.IsNavigable && !c.IsKey));

            // Add the Navigation Properties
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsNavigable));

            AddVerbsToNode(node, table, provider);
            return(node);
        }
Пример #3
0
        private static TreeNodeWithConnectionInfo CreateNode(IMetadataProvider provider, string name, string imageKey, object data)
        {
            var node = new TreeNodeWithConnectionInfo(name, provider);

            node.ImageKey         = imageKey;
            node.SelectedImageKey = imageKey;
            node.Tag = data;
            return(node);
        }
Пример #4
0
        private void AddTablesToNode(TreeNode parent, IMetadataProvider provider, ConnectionInfo connection)
        {
            switch (EntityGroupingMode)
            {
            case EntityGroupingMode.Flat:
                parent.Nodes.AddRange(MakeEntityTreeNodes(provider, connection, provider.Tables.OrderBy(e => e.FullName)));
                break;

            case EntityGroupingMode.ByNamespace:
                foreach (var group in provider.Tables.GroupBy(e => e.Namespace).OrderBy(g => g.Key))
                {
                    TreeNode[] childNodes = MakeEntityTreeNodes(provider, connection, group.OrderBy(e => e.FullName));

                    int countChilds   = childNodes.Length;
                    var namespaceNode = new TreeNode(string.Format("{0} ({1} item{2})", group.Key, countChilds, countChilds > 1 ? "s" : string.Empty))
                    {
                        Tag      = group.Key,
                        ImageKey = "Namespace"
                    };
                    namespaceNode.SelectedImageKey = namespaceNode.ImageKey;

                    namespaceNode.Nodes.AddRange(childNodes);
                    parent.Nodes.Add(namespaceNode);
                }
                break;

            case SwqlStudio.EntityGroupingMode.ByBaseType:
                foreach (var group in provider.Tables.Where(e => e.BaseEntity != null).GroupBy(
                             e => e.BaseEntity,
                             (key, group) => new { Key = key, Entities = group }).OrderBy(item => item.Key.FullName))
                {
                    TreeNode[] childNodes = MakeEntityTreeNodes(provider, connection, group.Entities.OrderBy(e => e.FullName));

                    int countChilds  = childNodes.Length;
                    var baseTypeNode = new TreeNodeWithConnectionInfo(
                        string.Format("{0} ({1} item{2})", group.Key.FullName, countChilds, countChilds > 1 ? "s" : string.Empty),
                        connection)
                    {
                        Tag = group.Key
                    };
                    baseTypeNode.ImageKey         = !group.Key.IsAbstract ? "BaseType" : "BaseTypeAbstract";
                    baseTypeNode.SelectedImageKey = baseTypeNode.ImageKey;

                    baseTypeNode.Nodes.AddRange(childNodes);
                    parent.Nodes.Add(baseTypeNode);
                }
                break;

            case SwqlStudio.EntityGroupingMode.ByHierarchy:
                GroupByHierarchy(provider, connection, parent);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #5
0
        private void CloseServer(TreeNode contextMenuNode)
        {
            TreeNodeWithConnectionInfo node = contextMenuNode as TreeNodeWithConnectionInfo;

            if (node != null)
            {
                node.Connection.Close();
                _treeData.Nodes.Remove(_treeBindings.FindDataNode(node));
            }
        }
Пример #6
0
        public static TreeNodeWithConnectionInfo CreateDatabaseNode(TreeView treeView, IMetadataProvider provider,
                                                                    ConnectionInfo connection)
        {
            TreeNodeWithConnectionInfo node = CreateNode(provider, provider.Name, ImageKeys.Database, provider);

            node.Name = node.Text;
            treeView.Nodes.Add(node);
            treeView.SelectedNode = node;
            return(node);
        }
Пример #7
0
        private void CloseServer(TreeNode contextMenuNode)
        {
            TreeNodeWithConnectionInfo node = contextMenuNode as TreeNodeWithConnectionInfo;

            if (node != null)
            {
                node.Connection.Close();
                _tree.Nodes.Remove(node);
            }
        }
Пример #8
0
        private static TreeNode CreateDatabaseNode(IMetadataProvider provider, ConnectionInfo connection)
        {
            TreeNode node = new TreeNodeWithConnectionInfo(provider.Name, connection);

            node.SelectedImageKey = "Database";
            node.ImageKey         = "Database";
            node.Tag  = provider;
            node.Name = node.Text;

            return(node);
        }
Пример #9
0
        internal void CloseServer(ConnectionInfo connection)
        {
            TreeNodeWithConnectionInfo serverNode = FindServerNodeByConnection(connection);

            if (serverNode != null)
            {
                RemoveFromMenus(serverNode.Connection);
                _treeData.Nodes.Remove(_treeBindings.FindDataNode(serverNode));
                _tree.Nodes.Remove(serverNode);
            }
        }
        public TreeNode CloneShallow()
        {
            var treeNode = new TreeNodeWithConnectionInfo(Text, Connection);

            treeNode.Text               = Text;
            treeNode.Name               = Name;
            treeNode.ImageIndex         = ImageIndex;
            treeNode.SelectedImageIndex = SelectedImageIndex;
            treeNode.StateImageIndex    = StateImageIndex;

            treeNode.SelectedImageKey = SelectedImageKey;
            treeNode.ImageKey         = ImageKey;
            treeNode.Tag = Tag;

            treeNode.ToolTipText      = ToolTipText;
            treeNode.ContextMenu      = ContextMenu;
            treeNode.ContextMenuStrip = ContextMenuStrip;
            treeNode.Checked          = Checked;
            return(treeNode);
        }
Пример #11
0
        private static TreeNodeWithConnectionInfo MakeEntityTreeNode(IMetadataProvider provider, ConnectionInfo connection, Entity table)
        {
            var node = new TreeNodeWithConnectionInfo(table.FullName, connection);

            node.ImageKey         = GetImageKey(table);
            node.SelectedImageKey = node.ImageKey;
            node.Tag = table;
            if (table.IsIndication)
            {
                node.ToolTipText += $@"{table.FullName}
{(string.IsNullOrEmpty(table.Summary) ? string.Empty : table.Summary + Environment.NewLine)}Base type: {table.BaseType}
CanSubscribe: {connection.CanCreateSubscription}";
            }
            else
            {
                node.ToolTipText = $@"{table.FullName}
{(string.IsNullOrEmpty(table.Summary) ? string.Empty : table.Summary + Environment.NewLine)}Base type: {table.BaseType}
CanCreate: {table.CanCreate}
CanUpdate: {table.CanUpdate}
CanDelete: {table.CanDelete}";
            }

            // Add keys
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsKey));

            // Add the simple Properties
            AddPropertiesToNode(node, table.Properties.Where(c => !c.IsInherited && !c.IsNavigable && !c.IsKey));

            // Add the inherited Properties
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsInherited && !c.IsNavigable && !c.IsKey));

            // Add the Navigation Properties
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsNavigable));

            AddVerbsToNode(node, table, provider);
            return(node);
        }
Пример #12
0
        internal void RefreshServer(ConnectionInfo connection)
        {
            TreeNodeWithConnectionInfo serverNode = FindServerNodeByConnection(connection);

            RefreshServer(serverNode);
        }
Пример #13
0
        private static TreeNodeWithConnectionInfo MakeEntityTreeNode(IMetadataProvider provider, ConnectionInfo connection, Entity table)
        {
            var node = new TreeNodeWithConnectionInfo(table.FullName, connection);
            node.ImageKey = table.IsIndication ? "Indication" : (!table.IsAbstract ? "Table" : "TableAbstract");
            node.SelectedImageKey = node.ImageKey;
            node.Tag = table;
            node.ToolTipText = string.Format(
                @"{0}
Base type: {1}
CanCreate: {2}
CanUpdate: {3}
CanDelete: {4}",
                table.FullName, table.BaseType, table.CanCreate, table.CanUpdate, table.CanDelete);

            // Add keys
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsKey));

            // Add the simple Properties
            AddPropertiesToNode(node, table.Properties.Where(c => !c.IsInherited && !c.IsNavigable && !c.IsKey));

            // Add the inherited Properties
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsInherited && !c.IsNavigable && !c.IsKey));

            // Add the Navigation Properties
            AddPropertiesToNode(node, table.Properties.Where(c => c.IsNavigable));

            AddVerbsToNode(node, table, provider);
            return node;
        }
Пример #14
0
        private void AddTablesToNode(TreeNode parent, IMetadataProvider provider, ConnectionInfo connection)
        {
            switch (EntityGroupingMode)
            {
                case EntityGroupingMode.Flat:
                    parent.Nodes.AddRange(MakeEntityTreeNodes(provider, connection, provider.Tables.OrderBy(e => e.FullName)));
                    break;
                case EntityGroupingMode.ByNamespace:
                    foreach (var group in provider.Tables.GroupBy(e => e.Namespace).OrderBy(g => g.Key))
                    {
                        TreeNode[] childNodes = MakeEntityTreeNodes(provider, connection, group.OrderBy(e => e.FullName));

                        int countChilds = childNodes.Length;
                        var namespaceNode = new TreeNode(string.Format("{0} ({1} item{2})", group.Key, countChilds, countChilds > 1 ? "s" : string.Empty))
                        {
                            Tag = group.Key,
                            ImageKey = "Namespace"
                        };
                        namespaceNode.SelectedImageKey = namespaceNode.ImageKey;

                        namespaceNode.Nodes.AddRange(childNodes);
                        parent.Nodes.Add(namespaceNode);
                    }
                    break;
                case SwqlStudio.EntityGroupingMode.ByBaseType:
                    foreach (var group in provider.Tables.Where(e => e.BaseEntity != null).GroupBy(
                        e => e.BaseEntity,
                        (key, group) => new { Key = key, Entities = group }).OrderBy(item => item.Key.FullName))
                    {
                        TreeNode[] childNodes = MakeEntityTreeNodes(provider, connection, group.Entities.OrderBy(e => e.FullName));

                        int countChilds = childNodes.Length;
                        var baseTypeNode = new TreeNodeWithConnectionInfo(
                            string.Format("{0} ({1} item{2})", group.Key.FullName, countChilds, countChilds > 1 ? "s" : string.Empty),
                            connection)
                        {
                            Tag = group.Key
                        };
                        baseTypeNode.ImageKey = !group.Key.IsAbstract ? "BaseType" : "BaseTypeAbstract";
                        baseTypeNode.SelectedImageKey = baseTypeNode.ImageKey;

                        baseTypeNode.Nodes.AddRange(childNodes);
                        parent.Nodes.Add(baseTypeNode);
                    }
                    break;
                case SwqlStudio.EntityGroupingMode.ByHierarchy:
                    GroupByHierarchy(provider, connection, parent);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Пример #15
0
        private static TreeNode CreateDatabaseNode(IMetadataProvider provider, ConnectionInfo connection)
        {
            TreeNode node = new TreeNodeWithConnectionInfo(provider.Name, connection);
            node.SelectedImageKey = "Database";
            node.ImageKey = "Database";
            node.Tag = provider;
            node.Name = node.Text;

            return node;
        }