use of com.intellij.ide.projectView.impl.nodes.AbstractModuleNode in project intellij-community by JetBrains.
the class AbstractProjectViewPane method doSelectModuleOrGroup.
private void doSelectModuleOrGroup(final Object toSelect, final boolean requestFocus) {
ToolWindowManager windowManager = ToolWindowManager.getInstance(myProject);
final Runnable runnable = () -> {
ProjectView projectView = ProjectView.getInstance(myProject);
if (requestFocus) {
projectView.changeView(getId(), getSubId());
}
((BaseProjectTreeBuilder) getTreeBuilder()).selectInWidth(toSelect, requestFocus, node -> node instanceof AbstractModuleNode || node instanceof ModuleGroupNode || node instanceof AbstractProjectNode);
};
if (requestFocus) {
windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW).activate(runnable);
} else {
runnable.run();
}
}
use of com.intellij.ide.projectView.impl.nodes.AbstractModuleNode in project intellij-community by JetBrains.
the class AbstractProjectViewPane method getSelectedDirectoriesInAmbiguousCase.
@NotNull
protected PsiDirectory[] getSelectedDirectoriesInAmbiguousCase(@NotNull final DefaultMutableTreeNode node) {
final Object userObject = node.getUserObject();
if (userObject instanceof AbstractModuleNode) {
final Module module = ((AbstractModuleNode) userObject).getValue();
if (module != null) {
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
final VirtualFile[] sourceRoots = moduleRootManager.getSourceRoots();
List<PsiDirectory> dirs = new ArrayList<>(sourceRoots.length);
final PsiManager psiManager = PsiManager.getInstance(myProject);
for (final VirtualFile sourceRoot : sourceRoots) {
final PsiDirectory directory = psiManager.findDirectory(sourceRoot);
if (directory != null) {
dirs.add(directory);
}
}
return dirs.toArray(new PsiDirectory[dirs.size()]);
}
}
return PsiDirectory.EMPTY_ARRAY;
}
Aggregations