void () { // Found selected components final RadContainer rootContainer = myEditor.getRootContainer(); final ArrayList<RadComponent> selection = new ArrayList<>(); FormEditingUtil.iterate( rootContainer, new FormEditingUtil.ComponentVisitor<RadComponent>() { @Override public boolean visit(final RadComponent component) { if(component.isSelected()){ selection.add(component); } return true; } } ); if(selection.size() == 0){ // If there is no selected component in the hierarchy, then // we have to select RadRootContainer selection.add(rootContainer); } List<Promise<TreeVisitor>> treeVisitors = new ArrayList<>(selection.size()); for (RadComponent s : selection) { ComponentPtr componentPtr = new ComponentPtr(myEditor, s); treeVisitors.add(myStructureTreeModel.promiseVisitor(componentPtr)); } // Set selection in the tree Promises.collectResults(treeVisitors).onProcessed(visitors -> { TreeUtil.promiseSelect(myTree, visitors.stream()).onProcessed(__ -> { // Notify the ComponentTree that selected component changed myEditor.fireSelectedComponentChanged(); }); }); }