use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class ContentEntryTreeCellRenderer method updateIcon.
protected Icon updateIcon(final ContentEntry entry, final VirtualFile file, Icon originalIcon) {
if (ContentEntryEditor.isExcludedOrUnderExcludedDirectory(myTreeEditor.getProject(), entry, file)) {
return AllIcons.Modules.ExcludeRoot;
}
final SourceFolder[] sourceFolders = entry.getSourceFolders();
for (SourceFolder sourceFolder : sourceFolders) {
if (file.equals(sourceFolder.getFile())) {
return SourceRootPresentation.getSourceRootIcon(sourceFolder);
}
}
Icon icon = originalIcon;
VirtualFile currentRoot = null;
for (SourceFolder sourceFolder : sourceFolders) {
final VirtualFile sourcePath = sourceFolder.getFile();
if (sourcePath != null && VfsUtilCore.isAncestor(sourcePath, file, true)) {
if (currentRoot != null && VfsUtilCore.isAncestor(sourcePath, currentRoot, false)) {
continue;
}
Icon folderIcon = getSourceFolderIcon(sourceFolder.getRootType());
if (folderIcon != null) {
icon = folderIcon;
}
currentRoot = sourcePath;
}
}
return icon;
}
use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class ContentRootPanel method createFolderComponent.
private <P extends JpsElement> JComponent createFolderComponent(final ContentFolder folder, Color foreground, ModuleSourceRootEditHandler<P> editor) {
final VirtualFile folderFile = folder.getFile();
final VirtualFile contentEntryFile = getContentEntry().getFile();
final String properties = folder instanceof SourceFolder ? StringUtil.notNullize(editor.getPropertiesString((P) ((SourceFolder) folder).getJpsElement().getProperties())) : "";
if (folderFile != null && contentEntryFile != null) {
String path = folderFile.equals(contentEntryFile) ? "." : VfsUtilCore.getRelativePath(folderFile, contentEntryFile, File.separatorChar);
HoverHyperlinkLabel hyperlinkLabel = new HoverHyperlinkLabel(path + properties, foreground);
hyperlinkLabel.setMinimumSize(new Dimension(0, 0));
hyperlinkLabel.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
myCallback.navigateFolder(getContentEntry(), folder);
}
});
registerTextComponent(hyperlinkLabel, foreground);
return new UnderlinedPathLabel(hyperlinkLabel);
} else {
String path = toRelativeDisplayPath(folder.getUrl(), getContentEntry().getUrl());
final JLabel pathLabel = new JLabel(path + properties);
pathLabel.setOpaque(false);
pathLabel.setForeground(JBColor.RED);
return new UnderlinedPathLabel(pathLabel);
}
}
use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class ContentRootPanel method addFolderGroupComponents.
protected void addFolderGroupComponents() {
final SourceFolder[] sourceFolders = getContentEntry().getSourceFolders();
MultiMap<JpsModuleSourceRootType<?>, SourceFolder> folderByType = new MultiMap<>();
for (SourceFolder folder : sourceFolders) {
if (!folder.isSynthetic()) {
folderByType.putValue(folder.getRootType(), folder);
}
}
Insets insets = JBUI.insetsBottom(10);
GridBagConstraints constraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, insets, 0, 0);
for (ModuleSourceRootEditHandler<?> editor : myModuleSourceRootEditHandlers) {
Collection<SourceFolder> folders = folderByType.get(editor.getRootType());
if (folders.isEmpty())
continue;
ContentFolder[] foldersArray = folders.toArray(new ContentFolder[folders.size()]);
final JComponent sourcesComponent = createFolderGroupComponent(editor.getRootsGroupTitle(), foldersArray, editor.getRootsGroupColor(), editor);
add(sourcesComponent, constraints);
}
ExcludeFolder[] excluded = getContentEntry().getExcludeFolders();
if (excluded.length > 0) {
final JComponent excludedComponent = createFolderGroupComponent(ProjectBundle.message("module.paths.excluded.group"), excluded, EXCLUDED_COLOR, null);
this.add(excludedComponent, constraints);
}
}
use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class ContentEntryImpl method clearSourceFolders.
@Override
public void clearSourceFolders() {
assert !isDisposed();
getRootModel().assertWritable();
for (SourceFolder folder : mySourceFolders) {
Disposer.dispose((Disposable) folder);
}
mySourceFolders.clear();
}
use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class ContentEntryImpl method getSourceFolderFiles.
@Override
@NotNull
public VirtualFile[] getSourceFolderFiles() {
assert !isDisposed();
final SourceFolder[] sourceFolders = getSourceFolders();
ArrayList<VirtualFile> result = new ArrayList<>(sourceFolders.length);
for (SourceFolder sourceFolder : sourceFolders) {
final VirtualFile file = sourceFolder.getFile();
if (file != null) {
result.add(file);
}
}
return VfsUtilCore.toVirtualFileArray(result);
}
Aggregations