Beispiel #1
0
 public DBXTreeItem getItemsMeta() {
   List<DBXTreeNode> metaChildren = getMeta().getChildren(this);
   if (metaChildren != null
       && metaChildren.size() == 1
       && metaChildren.get(0) instanceof DBXTreeItem) {
     return (DBXTreeItem) metaChildren.get(0);
   } else {
     return null;
   }
 }
Beispiel #2
0
 protected void reloadChildren(DBRProgressMonitor monitor) throws DBException {
   DBNDatabaseNode[] oldChildren;
   synchronized (this) {
     if (childNodes == null) {
       // Nothing to reload
       return;
     }
     oldChildren = Arrays.copyOf(childNodes, childNodes.length);
   }
   List<DBNDatabaseNode> newChildren = new ArrayList<>();
   loadChildren(monitor, getMeta(), oldChildren, newChildren);
   synchronized (this) {
     childNodes = newChildren.toArray(new DBNDatabaseNode[newChildren.size()]);
   }
 }
Beispiel #3
0
 @Override
 public DBNDatabaseNode[] getChildren(DBRProgressMonitor monitor) throws DBException {
   if (childNodes == null && allowsChildren()) {
     if (this.initializeNode(monitor, null)) {
       final List<DBNDatabaseNode> tmpList = new ArrayList<>();
       loadChildren(monitor, getMeta(), null, tmpList);
       if (!monitor.isCanceled()) {
         if (tmpList.isEmpty()) {
           this.childNodes = EMPTY_NODES;
         } else {
           this.childNodes = tmpList.toArray(new DBNDatabaseNode[tmpList.size()]);
         }
         this.afterChildRead();
       }
     }
   }
   return childNodes;
 }
Beispiel #4
0
  private void loadChildren(
      DBRProgressMonitor monitor,
      final DBXTreeNode meta,
      final DBNDatabaseNode[] oldList,
      final List<DBNDatabaseNode> toList)
      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);
        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);
        }
      } 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);
              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);
              toList.add(oldObject);
              break;
            }
          }
        }
      } else {
        log.warn("Unsupported meta node type: " + child); // $NON-NLS-1$
      }
      monitor.worked(1);
    }
    monitor.done();

    if (filtered) {
      getModel().fireNodeUpdate(this, this, DBNEvent.NodeChange.REFRESH);
    }
  }