use of com.intellij.ide.projectView.SettingsProvider in project intellij-community by JetBrains.
the class AbstractTreeStructureBase method getChildElements.
@Override
public Object[] getChildElements(Object element) {
LOG.assertTrue(element instanceof AbstractTreeNode, element != null ? element.getClass().getName() : null);
AbstractTreeNode<?> treeNode = (AbstractTreeNode) element;
Collection<? extends AbstractTreeNode> elements = treeNode.getChildren();
List<TreeStructureProvider> providers = getProvidersDumbAware();
if (!providers.isEmpty()) {
ViewSettings settings = treeNode instanceof SettingsProvider ? ((SettingsProvider) treeNode).getSettings() : ViewSettings.DEFAULT;
for (TreeStructureProvider provider : providers) {
try {
elements = provider.modify(treeNode, (Collection<AbstractTreeNode>) elements, settings);
} catch (ProcessCanceledException e) {
throw e;
} catch (Exception e) {
LOG.error(e);
}
}
}
for (AbstractTreeNode node : elements) {
node.setParent(treeNode);
}
return ArrayUtil.toObjectArray(elements);
}
use of com.intellij.ide.projectView.SettingsProvider in project intellij-community by JetBrains.
the class FavoritesTreeStructure method getChildElements.
@Override
public Object[] getChildElements(Object element) {
if (!(element instanceof AbstractTreeNode)) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
final AbstractTreeNode favTreeElement = (AbstractTreeNode) element;
try {
if (!(element instanceof FavoritesListNode)) {
Object[] elements = super.getChildElements(favTreeElement);
if (elements.length > 0)
return elements;
ViewSettings settings = favTreeElement instanceof SettingsProvider ? ((SettingsProvider) favTreeElement).getSettings() : ViewSettings.DEFAULT;
return ArrayUtil.toObjectArray(myNonProjectProvider.modify(favTreeElement, new ArrayList<>(), settings));
}
final List<AbstractTreeNode> result = new ArrayList<>();
final FavoritesListNode listNode = (FavoritesListNode) element;
if (listNode.getProvider() != null) {
return ArrayUtil.toObjectArray(listNode.getChildren());
}
final Collection<AbstractTreeNode> roots = FavoritesListNode.getFavoritesRoots(myProject, listNode.getName(), listNode);
for (AbstractTreeNode<?> abstractTreeNode : roots) {
final Object value = abstractTreeNode.getValue();
if (value == null)
continue;
if (value instanceof PsiElement && !((PsiElement) value).isValid())
continue;
if (value instanceof SmartPsiElementPointer && ((SmartPsiElementPointer) value).getElement() == null)
continue;
boolean invalid = false;
for (FavoriteNodeProvider nodeProvider : Extensions.getExtensions(FavoriteNodeProvider.EP_NAME, myProject)) {
if (nodeProvider.isInvalidElement(value)) {
invalid = true;
break;
}
}
if (invalid)
continue;
result.add(abstractTreeNode);
}
//}
return ArrayUtil.toObjectArray(result);
} catch (Exception e) {
LOGGER.error(e);
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
Aggregations