void (T[] elements, final @Nullable Comparator<? super T> sortComparator, final boolean restoreSelectedElements) { final List<T> selectedElements = restoreSelectedElements && mySelectedElements != null ? new ArrayList<>(mySelectedElements) : null; myElements = elements; if (sortComparator != null) { myComparator = new ElementNodeComparatorWrapper<>(sortComparator); } mySelectedNodes.clear(); myNodeToParentMap.clear(); myElementToNodeMap.clear(); myContainerNodes.clear(); ApplicationManager.getApplication().runReadAction(() -> { myTreeModel = buildModel(); }); myTree.setModel(myTreeModel); myTree.setRootVisible(false); doSort(); defaultExpandTree(); //TODO: dmitry batkovich: appcode tests fail //restoreTree(); if (myOptionControls == null) { myCopyJavadocCheckbox = new NonFocusableCheckBox(IdeBundle.message("checkbox.copy.javadoc")); if (myIsInsertOverrideVisible) { myInsertOverrideAnnotationCheckbox = new NonFocusableCheckBox(IdeBundle.message("checkbox.insert.at.override")); myOptionControls = new JCheckBox[] {myCopyJavadocCheckbox, myInsertOverrideAnnotationCheckbox}; } else { myOptionControls = new JCheckBox[] {myCopyJavadocCheckbox}; } } myTree.doLayout(); setOKActionEnabled(myAllowEmptySelection || myElements != null && myElements.length > 0); if (selectedElements != null) { selectElements(selectedElements.toArray(ClassMember.EMPTY_ARRAY)); } if (mySelectedElements == null || mySelectedElements.isEmpty()) { expandFirst(); } }