提交 06c6dad6 编写于 作者: S serge-rider

Navigator model refactoring. Folder child nodes existence check


Former-commit-id: 3faf3b4f
上级 b8925cbf
......@@ -157,7 +157,7 @@ public abstract class NodeListControl extends ObjectListControl<DBNNode> impleme
public boolean hasChildren(Object parentElement)
{
return parentElement instanceof DBNDatabaseNode &&
((DBNDatabaseNode) parentElement).allowsChildren();
((DBNDatabaseNode) parentElement).hasChildren(false);
}
@Override
......
......@@ -103,7 +103,7 @@ class DatabaseNavigatorContentProvider implements IStructuredContentProvider, IT
return EMPTY_CHILDREN;
}
*/
if (!parentNode.allowsNavigableChildren()) {
if (!parentNode.hasChildren(true)) {
return EMPTY_CHILDREN;
}
if (parentNode instanceof DBNDatabaseNode && ((DBNDatabaseNode)parentNode).needsInitialization()) {
......@@ -147,7 +147,7 @@ class DatabaseNavigatorContentProvider implements IStructuredContentProvider, IT
@Override
public boolean hasChildren(Object parent)
{
return parent instanceof DBNNode && ((DBNNode) parent).allowsNavigableChildren();
return parent instanceof DBNNode && ((DBNNode) parent).hasChildren(true);
}
/*
......
......@@ -184,7 +184,7 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
public synchronized DBNDatabaseNode[] getChildren(DBRProgressMonitor monitor)
throws DBException
{
if (childNodes == null && allowsChildren()) {
if (childNodes == null && hasChildren(false)) {
if (this.initializeNode(monitor, null)) {
final List<DBNDatabaseNode> tmpList = new ArrayList<>();
loadChildren(monitor, getMeta(), null, tmpList);
......@@ -264,7 +264,7 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
public boolean needsInitialization()
{
return childNodes == null && allowsChildren();
return childNodes == null && hasChildren(false);
}
@Override
......@@ -514,7 +514,7 @@ public abstract class DBNDatabaseNode extends DBNNode implements DBSWrapper, DBP
if (oldChild.getMeta() == meta && equalObjects(oldChild.getObject(), object)) {
oldChild.reloadObject(monitor, object);
if (oldChild.allowsChildren() && !oldChild.needsInitialization()) {
if (oldChild.hasChildren(false) && !oldChild.needsInitialization()) {
// Refresh children recursive
oldChild.reloadChildren(monitor);
}
......
......@@ -60,12 +60,6 @@ public class DBNEmptyNode extends DBNNode
return false;
}
@Override
public boolean allowsNavigableChildren()
{
return false;
}
@Override
public DBNNode[] getChildren(DBRProgressMonitor monitor)
{
......
......@@ -143,9 +143,16 @@ public class DBNLocalFolder extends DBNNode implements DBNContainer
}
@Override
public boolean allowsNavigableChildren()
{
return true;
public boolean hasChildren(boolean navigableOnly) {
if (!ArrayUtils.isEmpty(folder.getChildren())) {
return true;
}
for (DBNDataSource dataSource : getParentNode().getDataSources()) {
if (folder == dataSource.getDataSourceContainer().getFolder()) {
return true;
}
}
return false;
}
public DBNNode getLogicalParent() {
......
......@@ -118,7 +118,7 @@ public abstract class DBNNode implements DBPNamedObject, DBPPersistedObject, IAd
{
DBPImage image = getNodeIcon();
if (image == null) {
if (this.allowsChildren()) {
if (this.hasChildren(false)) {
return DBIcon.TREE_FOLDER;
} else {
return DBIcon.TREE_PAGE;
......@@ -146,10 +146,16 @@ public abstract class DBNNode implements DBPNamedObject, DBPPersistedObject, IAd
return pathName.toString();
}
public abstract boolean allowsChildren();
public boolean hasChildren(boolean navigableOnly) {
return navigableOnly ? allowsNavigableChildren() : allowsChildren();
}
protected abstract boolean allowsChildren();
protected boolean allowsNavigableChildren() {
return allowsChildren();
}
public abstract boolean allowsNavigableChildren();
public abstract DBNNode[] getChildren(DBRProgressMonitor monitor) throws DBException;
void clearNode(boolean reflect)
......
......@@ -131,12 +131,6 @@ public class DBNProjectDatabases extends DBNNode implements DBNContainer, DBPEve
return !dataSources.isEmpty();
}
@Override
public boolean allowsNavigableChildren()
{
return allowsChildren();
}
@Override
public DBNNode[] getChildren(DBRProgressMonitor monitor)
{
......@@ -256,7 +250,7 @@ public class DBNProjectDatabases extends DBNNode implements DBNContainer, DBPEve
parentFound = false;
}
if (parentNode != null) {
if (parentNode.getChildNodes() == null && parentNode.allowsChildren()) {
if (parentNode.getChildNodes() == null && parentNode.hasChildren(false)) {
final DBNDatabaseNode nodeToLoad = parentNode;
// We have to load children here
final AbstractJob loaderJob = new AbstractJob("Load sibling nodes of new database object") {
......
......@@ -136,12 +136,6 @@ public class DBNResource extends DBNNode// implements IContributorResourceAdapte
return resource instanceof IContainer;
}
@Override
public boolean allowsNavigableChildren()
{
return allowsChildren();
}
@Override
public DBNNode[] getChildren(DBRProgressMonitor monitor) throws DBException
{
......
......@@ -104,12 +104,6 @@ public class DBNRoot extends DBNNode implements DBNContainer, DBPProjectListener
return projects.length > 0;
}
@Override
public boolean allowsNavigableChildren()
{
return allowsChildren();
}
@Override
public DBNProject[] getChildren(DBRProgressMonitor monitor)
{
......
......@@ -80,7 +80,7 @@ public class HandlerObjectValidate extends AbstractHandler {
private void processNode(DBRProgressMonitor monitor, DBNNode node)
throws DBException
{
if (!node.allowsChildren()) {
if (!node.hasChildren(false)) {
return;
}
final DBNNode[] children = node.getChildren(monitor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册