@Override public void calcData(final DataKey key, final DataSink sink) { if (key.equals(LangDataKeys.PSI_ELEMENT)) { if (mySelectedElements != null && !mySelectedElements.isEmpty()) { T selectedElement = mySelectedElements.iterator().next(); if (selectedElement instanceof ClassMemberWithElement) { sink.put( LangDataKeys.PSI_ELEMENT, ((ClassMemberWithElement) selectedElement).getElement()); } } } }
@SuppressWarnings("unchecked") public void resetElements( T[] elements, final @Nullable Comparator<T> sortComparator, final boolean restoreSelectedElements) { final List<T> selectedElements = restoreSelectedElements && mySelectedElements != null ? new ArrayList<T>(mySelectedElements) : null; myElements = elements; if (sortComparator != null) { myComparator = new ElementNodeComparatorWrapper(sortComparator); } mySelectedNodes.clear(); myNodeToParentMap.clear(); myElementToNodeMap.clear(); myContainerNodes.clear(); ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { myTreeModel = buildModel(); } }); myTree.setModel(myTreeModel); myTree.setRootVisible(false); 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(myElements != null && myElements.length > 0); if (selectedElements != null) { selectElements(selectedElements.toArray(new ClassMember[selectedElements.size()])); } if (mySelectedElements == null || mySelectedElements.isEmpty()) { expandFirst(); } }
protected final boolean areElementsSelected() { return mySelectedElements != null && !mySelectedElements.isEmpty(); }
@Nullable public T[] getSelectedElements(T[] a) { LinkedHashSet<T> list = getSelectedElementsList(); if (list == null) return null; return list.toArray(a); }