Search in sources :

Example 1 with ExcludeFolder

use of com.intellij.openapi.roots.ExcludeFolder 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);
    }
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) MultiMap(com.intellij.util.containers.MultiMap) JpsModuleSourceRootType(org.jetbrains.jps.model.module.JpsModuleSourceRootType) ContentFolder(com.intellij.openapi.roots.ContentFolder) ExcludeFolder(com.intellij.openapi.roots.ExcludeFolder)

Example 2 with ExcludeFolder

use of com.intellij.openapi.roots.ExcludeFolder in project intellij-community by JetBrains.

the class ContentEntryImpl method clearExcludeFolders.

@Override
public void clearExcludeFolders() {
    assert !isDisposed();
    getRootModel().assertWritable();
    for (ExcludeFolder excludeFolder : myExcludeFolders) {
        Disposer.dispose((Disposable) excludeFolder);
    }
    myExcludeFolders.clear();
}
Also used : ExcludeFolder(com.intellij.openapi.roots.ExcludeFolder)

Example 3 with ExcludeFolder

use of com.intellij.openapi.roots.ExcludeFolder in project intellij-community by JetBrains.

the class ContentEntryImpl method writeExternal.

public void writeExternal(@NotNull Element element) throws WriteExternalException {
    assert !isDisposed();
    LOG.assertTrue(ELEMENT_NAME.equals(element.getName()));
    element.setAttribute(URL_ATTRIBUTE, myRoot.getUrl());
    for (final SourceFolder sourceFolder : mySourceFolders) {
        if (sourceFolder instanceof SourceFolderImpl) {
            JpsModuleRootModelSerializer.saveSourceRoot(element, sourceFolder.getUrl(), sourceFolder.getJpsElement().asTyped());
        }
    }
    for (final ExcludeFolder excludeFolder : myExcludeFolders) {
        if (excludeFolder instanceof ExcludeFolderImpl) {
            final Element subElement = new Element(ExcludeFolderImpl.ELEMENT_NAME);
            ((ExcludeFolderImpl) excludeFolder).writeExternal(subElement);
            element.addContent(subElement);
        }
    }
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) JpsElement(org.jetbrains.jps.model.JpsElement) Element(org.jdom.Element) ExcludeFolder(com.intellij.openapi.roots.ExcludeFolder)

Example 4 with ExcludeFolder

use of com.intellij.openapi.roots.ExcludeFolder in project intellij-community by JetBrains.

the class ContentEntryImpl method cloneEntry.

@Override
@NotNull
public ContentEntry cloneEntry(@NotNull RootModelImpl rootModel) {
    assert !isDisposed();
    ContentEntryImpl cloned = new ContentEntryImpl(myRoot.getUrl(), rootModel);
    for (final SourceFolder sourceFolder : mySourceFolders) {
        if (sourceFolder instanceof ClonableContentFolder) {
            ContentFolder folder = ((ClonableContentFolder) sourceFolder).cloneFolder(cloned);
            cloned.addSourceFolder((SourceFolderImpl) folder);
        }
    }
    for (final ExcludeFolder excludeFolder : myExcludeFolders) {
        if (excludeFolder instanceof ClonableContentFolder) {
            ContentFolder folder = ((ClonableContentFolder) excludeFolder).cloneFolder(cloned);
            cloned.addExcludeFolder((ExcludeFolder) folder);
        }
    }
    return cloned;
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentFolder(com.intellij.openapi.roots.ContentFolder) ExcludeFolder(com.intellij.openapi.roots.ExcludeFolder) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ExcludeFolder

use of com.intellij.openapi.roots.ExcludeFolder in project intellij-community by JetBrains.

the class ContentEntryImpl method removeExcludeFolder.

@Override
public boolean removeExcludeFolder(@NotNull String url) {
    for (ExcludeFolder folder : myExcludeFolders) {
        if (folder.getUrl().equals(url)) {
            myExcludeFolders.remove(folder);
            Disposer.dispose((Disposable) folder);
            return true;
        }
    }
    return false;
}
Also used : ExcludeFolder(com.intellij.openapi.roots.ExcludeFolder)

Aggregations

ExcludeFolder (com.intellij.openapi.roots.ExcludeFolder)5 SourceFolder (com.intellij.openapi.roots.SourceFolder)3 ContentFolder (com.intellij.openapi.roots.ContentFolder)2 MultiMap (com.intellij.util.containers.MultiMap)1 Element (org.jdom.Element)1 NotNull (org.jetbrains.annotations.NotNull)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JpsModuleSourceRootType (org.jetbrains.jps.model.module.JpsModuleSourceRootType)1