⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectionstreepanel.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            return;        }        Object object = tree.getLastPathComponent();        if (!(object instanceof BrowserTreeNode)) {            return;        }        // ensure node is expandable        BrowserTreeNode node = (BrowserTreeNode)object;        if (node.isLeaf() &&                 node.getNodeType() == BrowserConstants.HOST_NODE) {            ConnectionObject metaObject =                     (ConnectionObject)node.getDatabaseUserObject();            TreeExpansionEvent _e =                     new TreeExpansionEvent(tree, tree.getSelectionPath());//selectedPath);            treeExpanded(_e);            tree.nodeStructureChanged(node);        }    }    // --------------------------------------------------    // ------- TreeSelectionListener implementation    // --------------------------------------------------        /**     * Called whenever the value of the selection changes.     * This will store the current path selection.     *     * @param the event that characterizes the change     */    public void valueChanged(TreeSelectionEvent e) {        // store the last position        oldSelectionPath = e.getOldLeadSelectionPath();        // check that we don't have any alter tables        if (!reselecting && controller.hasAlterTable()) {            controller.applyTableChange(true);            return;        }        Object object = e.getPath().getLastPathComponent();        if (object == null) {            return;        }        controller.selectionChanging();        if (object == tree.getRootNode()) { // root node            controller.displayRootPanel();            enableButtons(false);            return;        }        final BrowserTreeNode node = (BrowserTreeNode)object;        // check if it is an unexpanded host node        if (node.getNodeType() == BrowserConstants.HOST_NODE) {            // enable buttons            enableButtons(true);            // check expanded state            if (node.isLeaf()) {                ConnectionObject metaObject =                         (ConnectionObject)node.getDatabaseUserObject();                if (metaObject.isConnected()) {                    GUIUtils.invokeAndWait(new Runnable() {                        public void run() {                            doHostExpansion(node);                        }                    });                    //doHostExpansion(node);                }            }        }         else {            enableButtons(false);        }        try {            controller.valueChanged(                    getSelectedMetaObject(), (BrowserTreeNode)object, reloadView);        }         finally {            // make sure we reset these flags            reloadView = false;            reselecting = false;        }    }        private boolean connectionValid(boolean showDialog) {        boolean isConnected = !(SystemUtilities.isConnected());        if (!isConnected && showDialog) {            GUIUtilities.displayWarningMessage("No connection available");        }        return isConnected;    }        /**     * Reloads the currently selected node.     */    public void reloadSelection() {        reloadPath(tree.getSelectionPath());    }    /** whether to reload the panel view */    private boolean reloadView;        /**     * Reloads the specified tree path.     */    public void reloadPath(TreePath path) {        if (treeExpanding) {            return;        }                Object object = path.getLastPathComponent();        if (!(object instanceof BrowserTreeNode)) {            return;        }                BrowserTreeNode node = (BrowserTreeNode)object;        doHostExpansion(node, true);    }        // --------------------------------------------------    // ------- TreeExpansionListener implementation    // --------------------------------------------------    public void treeExpanded(TreeExpansionEvent e) {        TreePath path = e.getPath();        Object object = path.getLastPathComponent();        if (!(object instanceof BrowserTreeNode)) {            return;        }        doHostExpansion((BrowserTreeNode)object);    }        /** provides an indicator that an expansion is in progress */    private boolean treeExpanding = false;        /**     * Performs the expansion on a host node.     *     * @param node - the host node to be expanded     */    private void doHostExpansion(BrowserTreeNode node) {        doHostExpansion(node, false);    }        private synchronized void doHostExpansion(final BrowserTreeNode node,                                               final boolean reload) {        // if its already expanded - return        if (node.isExpanded() && !reload) {            return;        }                worker = new SwingWorker() {            public Object construct() {                try {                    treeExpanding = true;                    //Log.debug("BEFORE expanding "+treeExpanding);                    GUIUtilities.showWaitCursor();                    if (reload) {                        node.removeAllChildren();                    }                    return doTreeExpandedWork(node);                }                finally {                    GUIUtilities.showNormalCursor();                    treeExpanding = false;                }            }            public void finished() {                try {                    GUIUtilities.showWaitCursor();                    BrowserTreeNode _node = (BrowserTreeNode)get();                    tree.nodeStructureChanged(_node);                    _node.setExpanded(true);                                        if (reload) {                        reloadView = true;                        TreePath path = tree.getSelectionPath();                        valueChanged(new TreeSelectionEvent(                                tree, path, true, oldSelectionPath, path));                    }                                    } finally {                    GUIUtilities.showNormalCursor();                    treeExpanding = false;                    //Log.debug("AFTER expanding "+treeExpanding);                }            }        };        worker.start();            }        /**     * Performs the tree expansion work for the expanded node.     *     * @param the node expanded     */    private BrowserTreeNode doTreeExpandedWork(BrowserTreeNode node) {        DatabaseObject metaObject = node.getDatabaseUserObject();        int type = metaObject.getType();                switch (type) {            case BrowserConstants.HOST_NODE:                populateHostBranches(node);                                break;            case BrowserConstants.CATALOG_NODE:                populateSchemaBranches(node);                break;            case BrowserConstants.SCHEMA_NODE:                populateSchemaObjectBranches(node);                break;            case BrowserConstants.FUNCTIONS_NODE:            case BrowserConstants.INDEX_NODE:            case BrowserConstants.PROCEDURE_NODE:            case BrowserConstants.SEQUENCE_NODE:            case BrowserConstants.SYNONYM_NODE:            case BrowserConstants.SYSTEM_TABLE_NODE:            case BrowserConstants.TABLE_NODE:            case BrowserConstants.TRIGGER_NODE:            case BrowserConstants.VIEW_NODE:            case BrowserConstants.SYSTEM_FUNCTION_NODE:            case BrowserConstants.SYSTEM_STRING_FUNCTIONS_NODE:            case BrowserConstants.SYSTEM_NUMERIC_FUNCTIONS_NODE:            case BrowserConstants.SYSTEM_DATE_TIME_FUNCTIONS_NODE:            case BrowserConstants.OTHER_NODE:                populateObjectBranches(node);                break;        }        return node;    }        public void treeCollapsed(TreeExpansionEvent e) {} // do nothing    // --------------------------------------------------        /**     * Populates the branches of a host (connection) node.     *     * @param the host node     */    private void populateHostBranches(BrowserTreeNode parent) {        ConnectionObject object = (ConnectionObject)                                            parent.getDatabaseUserObject();        if (!object.isConnected()) {            return;        }        BrowserTreeNode node = null;        DatabaseConnection dc = object.getDatabaseConnection();        String defaultCatalog = controller.getCatalogName(dc);        Vector<String> values = controller.getHostedCatalogs(dc);        if (values == null || values.isEmpty()) {            object.setCatalogsInUse(false);            DatabaseObject catalog =                 new DatabaseObject(BrowserConstants.CATALOG_NODE,                                        controller.getDataSourceName(dc));            catalog.setUseInQuery(false);            node = new BrowserTreeNode(catalog, true);            parent.add(node);        }        else {            object.setCatalogsInUse(true);            for (int i = 0, k = values.size(); i < k; i++) {                String value = values.get(i);                DatabaseObject catalog =                     new DatabaseObject(BrowserConstants.CATALOG_NODE, value);                catalog.setCatalogName(value);                catalog.setDefaultCatalog(defaultCatalog.equalsIgnoreCase(value));                node = new BrowserTreeNode(catalog, true);                parent.add(node);               }                    }    }        protected BrowserTreeNode getParentNode(BrowserTreeNode child) {        if (child.getDatabaseUserObject().getType() ==                 BrowserConstants.HOST_NODE) {            return child;        }        BrowserTreeNode _parent = null;        TreeNode parent = child.getParent();        while (parent != null) {            if (parent instanceof BrowserTreeNode) {                _parent = (BrowserTreeNode)parent;                if (_parent.getDatabaseUserObject().getType() ==                         BrowserConstants.HOST_NODE) {                    return _parent;                }                parent = _parent.getParent();            }        }        return null;    }    /**     * Selects the node that matches the specified prefix forward      * from the currently selected node.     *     * @param prefix - the prefix of the node to select     */    protected void selectBrowserNode(final String prefix) {        // make sure it has its children        DefaultMutableTreeNode node =                (DefaultMutableTreeNode)tree.getSelectionPath().getLastPathComponent();        if (node.getChildCount() == 0) {            doHostExpansion((BrowserTreeNode)node);        }//        SwingUtilities.invokeLater(new Runnable() {//            public void run() {                tree.expandSelectedRow();                tree.selectNextNode(prefix);//            }//        });    }    /**     * Returns the available meta key names associated with the     * specified child node.     */    protected String[] getMetaKeyNames(BrowserTreeNode child) {        // get the host node for this path        BrowserTreeNode parent = getParentNode(child);        // get the meta data object from the host node        ConnectionObject object = (ConnectionObject)                                            parent.getDatabaseUserObject();        return object.getMetaKeyNames();    }    /**     * Returns the connection properties object associated with     * the specified child node.     */    protected DatabaseConnection getDatabaseConnection(BrowserTreeNode child) {        return getConnectionObject(child).getDatabaseConnection();    }    /**     * Returns the ConnectionObject (host node) associated with     * the specified child node.     */    protected ConnectionObject getConnectionObject(BrowserTreeNode child) {        // get the host node for this path        BrowserTreeNode parent = getParentNode(child);        // get the meta data object from the host node        return (ConnectionObject)parent.getDatabaseUserObject();    }        private void populateObjectBranches(BrowserTreeNode parent) {        BrowserTreeNode node = null;        DatabaseObject object = parent.getDatabaseUserObject();        DatabaseConnection dc = getDatabaseConnection(parent);        String defaultSchema = controller.getCatalogName(dc);        boolean isDefault =                 defaultSchema.equalsIgnoreCase(object.getSchemaName())                     ||

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -