use of com.intellij.ide.projectView.ViewSettings 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.ViewSettings 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;
}
use of com.intellij.ide.projectView.ViewSettings in project android by JetBrains.
the class AndroidViewProjectNode method getChildren.
@NotNull
@Override
public Collection<? extends AbstractTreeNode> getChildren() {
Project project = getProject();
assert project != null;
ViewSettings settings = getSettings();
// add a node for every module
// TODO: make this conditional on getSettings().isShowModules(), otherwise collapse them all at the root
List<Module> modules = Arrays.asList(ModuleManager.getInstance(project).getModules());
List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(modules.size());
for (Module module : modules) {
if (isRootModuleWithNoSources(module)) {
// If we detect such a module, then we don't show it..
continue;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
NdkFacet ndkFacet = NdkFacet.getInstance(module);
if (androidFacet != null && androidFacet.getAndroidModel() != null) {
children.add(new AndroidModuleNode(project, module, settings, myProjectViewPane));
} else if (ndkFacet != null && ndkFacet.getNdkModuleModel() != null) {
children.add(new NdkModuleNode(project, module, settings));
} else {
children.add(new NonAndroidModuleNode(project, module, settings));
}
}
// are still visible. See https://code.google.com/p/android/issues/detail?id=76564
if (children.isEmpty() && isBuildWithGradle(project) && GradleSyncState.getInstance(project).lastSyncFailed()) {
PsiDirectory dir = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
if (dir != null) {
children.add(new PsiDirectoryNode(project, dir, settings));
}
}
if (isBuildWithGradle(project)) {
children.add(new AndroidBuildScriptsGroupNode(project, settings));
}
ExternalBuildFilesGroupNode externalBuildFilesNode = new ExternalBuildFilesGroupNode(project, settings);
if (!externalBuildFilesNode.getChildren().isEmpty()) {
children.add(externalBuildFilesNode);
}
return children;
}
use of com.intellij.ide.projectView.ViewSettings in project intellij-community by JetBrains.
the class MvcProjectViewPane method createStructure.
@Override
protected ProjectAbstractTreeStructureBase createStructure() {
final Project project = myProject;
final String id = getId();
return new ProjectTreeStructure(project, id) {
@Override
public boolean isHideEmptyMiddlePackages() {
return myViewState.hideEmptyMiddlePackages;
}
@Override
protected AbstractTreeNode createRoot(final Project project, ViewSettings settings) {
return new MvcProjectNode(project, this, myDescriptor);
}
};
}
use of com.intellij.ide.projectView.ViewSettings in project intellij-community by JetBrains.
the class MvcModuleNode method getChildren.
@Override
@NotNull
public Collection<? extends AbstractTreeNode> getChildren() {
final List<AbstractTreeNode> nodesList = new ArrayList<>();
final Module module = getValue();
final ViewSettings viewSettings = getSettings();
final VirtualFile root = myDescriptor.getFramework().findAppRoot(module);
if (root == null) {
return Collections.emptyList();
}
myDescriptor.fillModuleChildren(nodesList, module, viewSettings, root);
return nodesList;
}
Aggregations