use of org.jkiss.dbeaver.ui.navigator.database.load.TreeNodeLazyExpander in project dbeaver by dbeaver.
the class DatabaseNavigatorContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parent) {
if (parent instanceof TreeNodeSpecial) {
return EMPTY_CHILDREN;
}
if (!(parent instanceof DBNNode)) {
return EMPTY_CHILDREN;
}
// view.getNavigatorModel().findNode(parent);
final DBNNode parentNode = (DBNNode) parent;
/*
if (parentNode == null) {
log.error("Can't find parent node '" + ((DBSObject) parent).getName() + "' in model");
return EMPTY_CHILDREN;
}
*/
if (!parentNode.hasChildren(true)) {
return EMPTY_CHILDREN;
}
if (parentNode instanceof DBNDatabaseNode && ((DBNDatabaseNode) parentNode).needsInitialization()) {
return TreeLoadVisualizer.expandChildren(navigatorTree.getViewer(), new TreeLoadService("Loading", ((DBNDatabaseNode) parentNode)));
} else {
try {
// Read children with null monitor cos' it's not a lazy node
// and no blocking process will occur
DBNNode[] children = DBNUtils.getNodeChildrenFiltered(new VoidProgressMonitor(), parentNode, true);
if (ArrayUtils.isEmpty(children)) {
return EMPTY_CHILDREN;
} else {
int longListFetchSize = Math.max(NavigatorPreferences.MIN_LONG_LIST_FETCH_SIZE, DBWorkbench.getPlatform().getPreferenceStore().getInt(NavigatorPreferences.NAVIGATOR_LONG_LIST_FETCH_SIZE));
if (children.length > longListFetchSize) {
Object[] curChildren = new Object[longListFetchSize + 1];
System.arraycopy(children, 0, curChildren, 0, longListFetchSize);
curChildren[longListFetchSize] = new TreeNodeLazyExpander(parentNode, children, longListFetchSize);
return curChildren;
}
return children;
}
} catch (Throwable ex) {
DBWorkbench.getPlatformUI().showError("Navigator error", ex.getMessage(), ex);
// Collapse this item
UIUtils.asyncExec(() -> {
navigatorTree.getViewer().collapseToLevel(parent, 1);
navigatorTree.getViewer().refresh(parent);
});
return EMPTY_CHILDREN;
}
}
}
use of org.jkiss.dbeaver.ui.navigator.database.load.TreeNodeLazyExpander in project dbeaver by serge-rider.
the class DatabaseNavigatorContentProvider method getChildren.
@Override
public Object[] getChildren(final Object parent) {
if (parent instanceof TreeNodeSpecial) {
return EMPTY_CHILDREN;
}
if (!(parent instanceof DBNNode)) {
return EMPTY_CHILDREN;
}
// view.getNavigatorModel().findNode(parent);
final DBNNode parentNode = (DBNNode) parent;
/*
if (parentNode == null) {
log.error("Can't find parent node '" + ((DBSObject) parent).getName() + "' in model");
return EMPTY_CHILDREN;
}
*/
if (!parentNode.hasChildren(true)) {
return EMPTY_CHILDREN;
}
if (parentNode instanceof DBNDatabaseNode && ((DBNDatabaseNode) parentNode).needsInitialization()) {
return TreeLoadVisualizer.expandChildren(navigatorTree.getViewer(), new TreeLoadService("Loading", ((DBNDatabaseNode) parentNode)));
} else {
try {
// Read children with null monitor cos' it's not a lazy node
// and no blocking process will occur
DBNNode[] children = DBNUtils.getNodeChildrenFiltered(new VoidProgressMonitor(), parentNode, true);
if (ArrayUtils.isEmpty(children)) {
return EMPTY_CHILDREN;
} else {
int longListFetchSize = Math.max(NavigatorPreferences.MIN_LONG_LIST_FETCH_SIZE, DBWorkbench.getPlatform().getPreferenceStore().getInt(NavigatorPreferences.NAVIGATOR_LONG_LIST_FETCH_SIZE));
if (children.length > longListFetchSize) {
Object[] curChildren = new Object[longListFetchSize + 1];
System.arraycopy(children, 0, curChildren, 0, longListFetchSize);
curChildren[longListFetchSize] = new TreeNodeLazyExpander(parentNode, children, longListFetchSize);
return curChildren;
}
return children;
}
} catch (Throwable ex) {
DBWorkbench.getPlatformUI().showError("Navigator error", ex.getMessage(), ex);
// Collapse this item
UIUtils.asyncExec(() -> {
navigatorTree.getViewer().collapseToLevel(parent, 1);
navigatorTree.getViewer().refresh(parent);
});
return EMPTY_CHILDREN;
}
}
}
Aggregations