use of com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler in project intellij-community by JetBrains.
the class ProjectViewDirectoryHelper method getLocationString.
@Nullable
public String getLocationString(@NotNull PsiDirectory psiDirectory, boolean includeUrl, boolean includeRootType) {
StringBuilder result = new StringBuilder();
final VirtualFile directory = psiDirectory.getVirtualFile();
if (ProjectRootsUtil.isLibraryRoot(directory, psiDirectory.getProject())) {
result.append(ProjectBundle.message("module.paths.root.node", "library").toLowerCase(Locale.getDefault()));
} else if (includeRootType) {
SourceFolder sourceRoot = ProjectRootsUtil.getModuleSourceRoot(psiDirectory.getVirtualFile(), psiDirectory.getProject());
if (sourceRoot != null) {
ModuleSourceRootEditHandler<?> handler = ModuleSourceRootEditHandler.getEditHandler(sourceRoot.getRootType());
if (handler != null) {
JavaSourceRootProperties properties = sourceRoot.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
if (properties != null && properties.isForGeneratedSources()) {
result.append("generated ");
}
result.append(handler.getFullRootTypeName().toLowerCase(Locale.getDefault()));
}
}
}
if (includeUrl) {
if (result.length() > 0)
result.append(",").append(FontUtil.spaceAndThinSpace());
result.append(FileUtil.getLocationRelativeToUserHome(directory.getPresentableUrl()));
}
return result.length() == 0 ? null : result.toString();
}
use of com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler in project Perl5-IDEA by Camelcade.
the class PerlTreeStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
Map<VirtualFile, PerlSourceRootType> roots = myProjectManager.getAllModulesRoots();
return ContainerUtil.map2List(children, node -> {
if (!(node instanceof PsiDirectoryNode)) {
return node;
}
Project nodeProject = node.getProject();
if (nodeProject == null) {
return node;
}
// fixme support different roots here
VirtualFile virtualFile = ((PsiDirectoryNode) node).getVirtualFile();
if (virtualFile != null && roots.containsKey(virtualFile)) {
PerlSourceRootType rootType = roots.get(virtualFile);
ModuleSourceRootEditHandler handler = rootType.getEditHandler();
node = new PsiDirectoryNode(node.getProject(), ((PsiDirectoryNode) node).getValue(), ((PsiDirectoryNode) node).getSettings()) {
@Override
protected void updateImpl(PresentationData data) {
super.updateImpl(data);
data.setIcon(handler.getRootIcon());
data.addText(virtualFile.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
data.addText(" " + handler.getRootTypeName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
}
};
}
return node;
});
}
Aggregations