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());
}
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());
}
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;
}
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;
}
Aggregations