public bool IsValid(object caller, Condition condition)
        {
            IObjectExplorer objectExplorer = caller as IObjectExplorer;

            if (objectExplorer == null)
            {
                return(false);
            }

            TreeNode node = objectExplorer.GetSelectedNode();

            //Might be the one. Check it's root parent
            if (node.Level >= 1)
            {
                TreeNode root = node.Parent;
                while (root.Level > 0)
                {
                    root = root.Parent;
                }

                TreeNode rootCmp = objectExplorer.GetRootNode(FdoObjectExplorerExtender.RootNodeName);
                if (root == rootCmp)
                {
                    TreeNode connNode = node;
                    while (connNode.Level > 1)
                    {
                        connNode = connNode.Parent;
                    }
                    FdoConnectionManager connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
                    FdoConnection        conn    = connMgr.GetConnection(connNode.Name);
                    if (conn != null)
                    {
                        try
                        {
                            var applicable                     = (Array.IndexOf <string>(applicableProviders, conn.Provider.ToUpper()) >= 0);
                            var supportsSchemaMappings         = conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSchemaOverrides);
                            var supportsDescribeSchemaMappings = conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList).Cast <CommandType>().Contains(CommandType.CommandType_DescribeSchemaMapping);

                            return(supportsSchemaMappings && supportsDescribeSchemaMappings);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool IsValid(object caller, Condition condition)
        {
            IObjectExplorer objectExplorer = caller as IObjectExplorer;

            if (objectExplorer == null)
            {
                return(false);
            }

            TreeNode node = objectExplorer.GetSelectedNode();

            //Might be the one. Check it's root parent
            if (node.Level >= 1)
            {
                TreeNode root = node.Parent;
                while (root.Level > 0)
                {
                    root = root.Parent;
                }

                TreeNode rootCmp = objectExplorer.GetRootNode(FdoObjectExplorerExtender.RootNodeName);
                if (root == rootCmp)
                {
                    TreeNode connNode = node;
                    while (connNode.Level > 1)
                    {
                        connNode = connNode.Parent;
                    }
                    FdoConnection conn = connMgr.GetConnection(connNode.Name);
                    if (conn != null)
                    {
                        string cmd = "CommandType_" + condition.Properties["command"];
                        try
                        {
                            OSGeo.FDO.Commands.CommandType ctype = (OSGeo.FDO.Commands.CommandType)Enum.Parse(typeof(OSGeo.FDO.Commands.CommandType), cmd);
                            Array commands = conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList);
                            return(Array.IndexOf(commands, ctype) >= 0);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        void OnAfterNodeExpansion(object sender, TreeViewEventArgs e)
        {
            if (e.Action == TreeViewAction.Expand)
            {
                TreeNode node = e.Node;
                TreeNode root = _explorer.GetRootNode(RootNodeName);
                //Is a FDO data source node
                if (IsChild(root.Nodes, node, NODE_LEVEL_CLASS))
                {
                    //Find the connection node
                    TreeNode connNode = node;
                    while (connNode.Level > 1)
                    {
                        connNode = connNode.Parent;
                    }
                    string connName = connNode.Name;

                    using (new TempCursor(Cursors.WaitCursor))
                    {
                        switch (node.Level)
                        {
                        case NODE_LEVEL_CONNECTION:     //Connection node
                        {
                            if (!(bool)node.Tag)        //Not loaded, load it now
                            {
                                //Clear out dummy node
                                node.Nodes.Clear();
                                CreateSchemaNodes(node);
                                node.Tag = true;         //Schema is loaded
                            }
                        }
                        break;

                        case NODE_LEVEL_SCHEMA:     //Schema Node
                        {
                            bool isPartial = Convert.ToBoolean(node.Tag);
                            if (isPartial)
                            {
                                Debug.Assert(node.Nodes.Count == 1);         //Has a dummy node
                                string        schemaName = node.Name;
                                FdoConnection conn       = _connMgr.GetConnection(connName);

                                using (FdoFeatureService svc = conn.CreateFeatureService())
                                {
                                    Debug.Assert(svc.SupportsPartialSchemaDiscovery());
                                    List <string> classNames = svc.GetClassNames(schemaName);
                                    GetClassNodesPartial(classNames, node);
                                    node.Tag = false;         //This node is no longer partial
                                    node.Expand();
                                }
                            }
                        }
                        break;

                        case NODE_LEVEL_CLASS:     //Class Node
                        {
                            bool isPartial = Convert.ToBoolean(node.Tag);
                            if (isPartial)
                            {
                                Debug.Assert(node.Nodes.Count == 1);         //Has a dummy node
                                string        schemaName = node.Parent.Name;
                                FdoConnection conn       = _connMgr.GetConnection(connName);
                                using (FdoFeatureService svc = conn.CreateFeatureService())
                                {
                                    Debug.Assert(svc.SupportsPartialSchemaDiscovery());
                                    ClassDefinition cd = svc.GetClassByName(schemaName, node.Name);
                                    if (cd != null)
                                    {
                                        UpdateClassNode(node, cd);
                                    }
                                }
                            }
                        }
                        break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        void OnTaskRenamed(object sender, TaskRenameEventArgs e)
        {
            TreeNode node = _explorer.GetRootNode(RootNodeName).Nodes[e.OldName];

            node.Name = node.Text = e.NewName;
        }