void createChildren() { Collection<IModelTransferNode> dependencies = element.getDependencies(); Collection<IModelTransferNode> dependents = element.getDependents(); if (!dependencies.isEmpty() || !dependents.isEmpty()) { children = Lists.newArrayListWithCapacity(dependencies.size() + dependents.size()); // the recommendation for importing dependencies vs. dependents is // reversed for export as for import. We suggest to export dependencies // of an exported model (those that it references) and import dependents // of an imported model (those that reference it) for (IModelTransferNode next : isImport ? dependents : dependencies) { children.add(new TreeNode(this, next, isImport)); } for (IModelTransferNode next : isImport ? dependencies : dependents) { // don't show a model as both a dependent and a // dependency if it both references and is // referenced by the other if (isImport ? !dependents.contains(next) : !dependencies.contains(next)) { children.add(new TreeNode(this, next, false)); } } // initialize check state of new children from configuration Display.getCurrent() .asyncExec( new Runnable() { @Override public void run() { if (config != null) { Collection<IModelTransferNode> imported = config.getModelsToTransfer(); ICheckable checkable = (ICheckable) viewer; for (ITreeNode next : children) { if (imported.contains(next.getElement())) { checkable.setChecked(next, true); } } } } }); } }
@Override public boolean hasChildren(Object element) { IModelTransferNode importNode = ((TreeNode) element).getElement(); return !(importNode.getDependencies().isEmpty() && importNode.getDependents().isEmpty()); }