use of com.intellij.openapi.roots.libraries.ui.OrderRootTypePresentation in project intellij-community by JetBrains.
the class LibraryTreeStructure method getChildElements.
@Override
public Object[] getChildElements(Object element) {
final LibraryEditor libraryEditor = myParentEditor.getLibraryEditor();
if (element == myRootElementDescriptor) {
ArrayList<LibraryTableTreeContentElement> elements = new ArrayList<>(3);
for (OrderRootType type : myComponentDescriptor.getRootTypes()) {
final String[] urls = libraryEditor.getUrls(type);
if (urls.length > 0) {
OrderRootTypePresentation presentation = myComponentDescriptor.getRootTypePresentation(type);
if (presentation == null) {
presentation = DefaultLibraryRootsComponentDescriptor.getDefaultPresentation(type);
}
elements.add(new OrderRootTypeElement(myRootElementDescriptor, type, presentation.getNodeText(), presentation.getIcon()));
}
}
return elements.toArray();
}
if (element instanceof OrderRootTypeElement) {
OrderRootTypeElement rootTypeElement = (OrderRootTypeElement) element;
OrderRootType orderRootType = rootTypeElement.getOrderRootType();
ArrayList<ItemElement> items = new ArrayList<>();
final String[] urls = libraryEditor.getUrls(orderRootType).clone();
Arrays.sort(urls, LibraryRootsComponent.ourUrlComparator);
for (String url : urls) {
items.add(new ItemElement(rootTypeElement, url, orderRootType, libraryEditor.isJarDirectory(url, orderRootType), libraryEditor.isValid(url, orderRootType)));
}
return items.toArray();
}
if (element instanceof ItemElement) {
ItemElement itemElement = (ItemElement) element;
List<String> excludedUrls = new ArrayList<>();
for (String excludedUrl : libraryEditor.getExcludedRootUrls()) {
if (VfsUtilCore.isEqualOrAncestor(itemElement.getUrl(), excludedUrl)) {
excludedUrls.add(excludedUrl);
}
}
ExcludedRootElement[] items = new ExcludedRootElement[excludedUrls.size()];
Collections.sort(excludedUrls, LibraryRootsComponent.ourUrlComparator);
for (int i = 0; i < excludedUrls.size(); i++) {
items[i] = new ExcludedRootElement(itemElement, itemElement.getUrl(), excludedUrls.get(i));
}
return items;
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
Aggregations