use of com.perl5.lang.perl.idea.modules.PerlSourceRootType in project Perl5-IDEA by Camelcade.
the class PerlUnmarkSourceRootAction method update.
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
RootsSelection selection = getSelection(e);
if (selection.myModule == null) {
presentation.setEnabledAndVisible(false);
return;
}
boolean enabled = isEnabled(selection, selection.myModule);
presentation.setEnabledAndVisible(enabled);
if (!enabled) {
return;
}
List<VirtualFile> virtualFiles = getFilesFromSelection(selection);
PerlModuleExtension perlModuleExtension = PerlModuleExtension.getInstance(selection.myModule);
if (perlModuleExtension == null || virtualFiles.isEmpty()) {
return;
}
if (virtualFiles.size() == 1) {
PerlSourceRootType type = perlModuleExtension.getRootType(virtualFiles.get(0));
if (type == null) {
return;
}
ModuleSourceRootEditHandler<?> handler = type.getEditHandler();
presentation.setText(handler.getUnmarkRootButtonText());
presentation.setIcon(new LayeredIcon(handler.getRootIcon(), AllIcons.RunConfigurations.InvalidConfigurationLayer));
} else {
presentation.setText(PerlBundle.message("perl.action.unmark.multi"));
presentation.setIcon(new LayeredIcon(PerlIcons.PERL_LANGUAGE_ICON, AllIcons.RunConfigurations.InvalidConfigurationLayer));
}
}
use of com.perl5.lang.perl.idea.modules.PerlSourceRootType 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