Search in sources :

Example 6 with DBXTreeNode

use of org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode in project dbeaver by serge-rider.

the class DBNDatabaseNode method loadChildren.

private void loadChildren(DBRProgressMonitor monitor, final DBXTreeNode meta, final DBNDatabaseNode[] oldList, final List<DBNDatabaseNode> toList, boolean reflect) throws DBException {
    if (monitor.isCanceled()) {
        return;
    }
    this.filtered = false;
    List<DBXTreeNode> childMetas = meta.getChildren(this);
    if (CommonUtils.isEmpty(childMetas)) {
        return;
    }
    monitor.beginTask(ModelMessages.model_navigator_load_items_, childMetas.size());
    for (DBXTreeNode child : childMetas) {
        if (monitor.isCanceled()) {
            break;
        }
        monitor.subTask(ModelMessages.model_navigator_load_ + " " + child.getChildrenType(getObject().getDataSource()));
        if (child instanceof DBXTreeItem) {
            final DBXTreeItem item = (DBXTreeItem) child;
            boolean isLoaded = loadTreeItems(monitor, item, oldList, toList, reflect);
            if (!isLoaded && item.isOptional() && item.getRecursiveLink() == null) {
                // This may occur only if no child nodes was read
                // Then we try to go on next DBX level
                loadChildren(monitor, item, oldList, toList, reflect);
            }
        } else if (child instanceof DBXTreeFolder) {
            if (oldList == null) {
                // Load new folders only if there are no old ones
                toList.add(new DBNDatabaseFolder(this, (DBXTreeFolder) child));
            } else {
                for (DBNDatabaseNode oldFolder : oldList) {
                    if (oldFolder.getMeta() == child) {
                        oldFolder.reloadChildren(monitor, reflect);
                        toList.add(oldFolder);
                        break;
                    }
                }
            }
        } else if (child instanceof DBXTreeObject) {
            if (oldList == null) {
                // Load new objects only if there are no old ones
                toList.add(new DBNDatabaseObject(this, (DBXTreeObject) child));
            } else {
                for (DBNDatabaseNode oldObject : oldList) {
                    if (oldObject.getMeta() == child) {
                        oldObject.reloadChildren(monitor, reflect);
                        toList.add(oldObject);
                        break;
                    }
                }
            }
        } else {
            //$NON-NLS-1$
            log.warn("Unsupported meta node type: " + child);
        }
        monitor.worked(1);
    }
    monitor.done();
    if (reflect && filtered) {
        getModel().fireNodeUpdate(this, this, DBNEvent.NodeChange.REFRESH);
    }
}
Also used : DBXTreeNode(org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode) DBXTreeItem(org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem) DBXTreeObject(org.jkiss.dbeaver.model.navigator.meta.DBXTreeObject) DBXTreeFolder(org.jkiss.dbeaver.model.navigator.meta.DBXTreeFolder)

Aggregations

DBXTreeNode (org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode)6 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)4 DBException (org.jkiss.dbeaver.DBException)3 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 DBSObjectContainer (org.jkiss.dbeaver.model.struct.DBSObjectContainer)2 ArrayList (java.util.ArrayList)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 GridData (org.eclipse.swt.layout.GridData)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 DBPObject (org.jkiss.dbeaver.model.DBPObject)1 DBPSystemObject (org.jkiss.dbeaver.model.DBPSystemObject)1 DBNDatabaseFolder (org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder)1 DBXTreeFolder (org.jkiss.dbeaver.model.navigator.meta.DBXTreeFolder)1 DBXTreeItem (org.jkiss.dbeaver.model.navigator.meta.DBXTreeItem)1 DBXTreeObject (org.jkiss.dbeaver.model.navigator.meta.DBXTreeObject)1 CSmartCombo (org.jkiss.dbeaver.ui.controls.CSmartCombo)1 ListContentProvider (org.jkiss.dbeaver.ui.controls.ListContentProvider)1 TreeContentProvider (org.jkiss.dbeaver.ui.controls.TreeContentProvider)1