Search in sources :

Example 6 with ContentFolder

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

the class ManagingContentRootFoldersTest method testCreationOfSourceFolderWithFile.

public void testCreationOfSourceFolderWithFile() throws IOException {
    VirtualFile dir = createSrc();
    String url = dir.getUrl();
    ContentFolder f = entry.addSourceFolder(dir, false);
    assertEquals(dir, f.getFile());
    assertEquals(url, f.getUrl());
    delete(dir);
    assertNull(f.getFile());
    assertEquals(url, f.getUrl());
    dir = createSrc();
    assertEquals(dir, f.getFile());
    assertEquals(url, f.getUrl());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentFolder(com.intellij.openapi.roots.ContentFolder)

Example 7 with ContentFolder

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

the class ManagingContentRootFoldersTest method testCreationOfExcludedFolderWithFile.

public void testCreationOfExcludedFolderWithFile() throws IOException {
    VirtualFile dir = createSrc();
    String url = dir.getUrl();
    ContentFolder f = entry.addExcludeFolder(dir);
    assertEquals(dir, f.getFile());
    assertEquals(url, f.getUrl());
    delete(dir);
    assertNull(f.getFile());
    assertEquals(url, f.getUrl());
    dir = createSrc();
    assertEquals(dir, f.getFile());
    assertEquals(url, f.getUrl());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentFolder(com.intellij.openapi.roots.ContentFolder)

Example 8 with ContentFolder

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

the class ContentRootPanel method createFolderGroupComponent.

protected JComponent createFolderGroupComponent(String title, ContentFolder[] folders, Color foregroundColor, @Nullable ModuleSourceRootEditHandler<?> editor) {
    final JPanel panel = new JPanel(new GridLayoutManager(folders.length, 3, JBUI.insets(1, 17, 0, 5), 0, 1));
    panel.setOpaque(false);
    for (int idx = 0; idx < folders.length; idx++) {
        final ContentFolder folder = folders[idx];
        final int verticalPolicy = idx == folders.length - 1 ? GridConstraints.SIZEPOLICY_CAN_GROW : GridConstraints.SIZEPOLICY_FIXED;
        panel.add(createFolderComponent(folder, foregroundColor, editor), new GridConstraints(idx, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, verticalPolicy, null, null, null));
        int column = 1;
        int colspan = 2;
        if (editor != null) {
            JComponent additionalComponent = createRootPropertiesEditor(editor, (SourceFolder) folder);
            if (additionalComponent != null) {
                panel.add(additionalComponent, new GridConstraints(idx, column++, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, verticalPolicy, null, null, null));
                colspan = 1;
            }
        }
        panel.add(createFolderDeleteComponent(folder, editor), new GridConstraints(idx, column, 1, colspan, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, verticalPolicy, null, null, null));
    }
    final JLabel titleLabel = new JLabel(title);
    final Font labelFont = UIUtil.getLabelFont();
    titleLabel.setFont(labelFont.deriveFont(Font.BOLD));
    titleLabel.setOpaque(false);
    titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
    registerTextComponent(titleLabel, foregroundColor);
    final JPanel groupPanel = new JPanel(new BorderLayout());
    groupPanel.setOpaque(false);
    groupPanel.add(titleLabel, BorderLayout.NORTH);
    groupPanel.add(panel, BorderLayout.CENTER);
    return groupPanel;
}
Also used : GridLayoutManager(com.intellij.uiDesigner.core.GridLayoutManager) ContentFolder(com.intellij.openapi.roots.ContentFolder) GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 9 with ContentFolder

use of com.intellij.openapi.roots.ContentFolder 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)

Aggregations

ContentFolder (com.intellij.openapi.roots.ContentFolder)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 ExcludeFolder (com.intellij.openapi.roots.ExcludeFolder)2 SourceFolder (com.intellij.openapi.roots.SourceFolder)2 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)1 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)1 MultiMap (com.intellij.util.containers.MultiMap)1 NotNull (org.jetbrains.annotations.NotNull)1 JpsModuleSourceRootType (org.jetbrains.jps.model.module.JpsModuleSourceRootType)1