Search in sources :

Example 1 with ContentEntryEditor

use of com.intellij.openapi.roots.ui.configuration.ContentEntryEditor in project intellij-community by JetBrains.

the class ToggleExcludedStateAction method setSelected.

@Override
public void setSelected(final AnActionEvent e, final boolean isSelected) {
    final VirtualFile[] selectedFiles = getSelectedFiles();
    assert selectedFiles.length != 0;
    ContentEntryEditor contentEntryEditor = myEntryTreeEditor.getContentEntryEditor();
    for (VirtualFile selectedFile : selectedFiles) {
        if (isSelected) {
            if (!contentEntryEditor.isExcludedOrUnderExcludedDirectory(selectedFile)) {
                // not excluded yet
                contentEntryEditor.addExcludeFolder(selectedFile);
            }
        } else {
            contentEntryEditor.removeExcludeFolder(selectedFile.getUrl());
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentEntryEditor(com.intellij.openapi.roots.ui.configuration.ContentEntryEditor)

Example 2 with ContentEntryEditor

use of com.intellij.openapi.roots.ui.configuration.ContentEntryEditor in project intellij-community by JetBrains.

the class ToggleSourcesStateAction method isSelected.

@Override
public boolean isSelected(final AnActionEvent e) {
    final VirtualFile[] selectedFiles = getSelectedFiles();
    if (selectedFiles.length == 0)
        return false;
    final ContentEntryEditor editor = myEntryTreeEditor.getContentEntryEditor();
    return myEditHandler.getRootType().equals(editor.getRootType(selectedFiles[0]));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentEntryEditor(com.intellij.openapi.roots.ui.configuration.ContentEntryEditor)

Example 3 with ContentEntryEditor

use of com.intellij.openapi.roots.ui.configuration.ContentEntryEditor in project intellij-community by JetBrains.

the class ToggleSourcesStateAction method setSelected.

@Override
public void setSelected(final AnActionEvent e, final boolean isSelected) {
    final VirtualFile[] selectedFiles = getSelectedFiles();
    assert selectedFiles.length != 0;
    final ContentEntryEditor contentEntryEditor = myEntryTreeEditor.getContentEntryEditor();
    for (VirtualFile selectedFile : selectedFiles) {
        final SourceFolder sourceFolder = contentEntryEditor.getSourceFolder(selectedFile);
        if (isSelected) {
            if (sourceFolder == null) {
                // not marked yet
                P properties = myEditHandler.getRootType().createDefaultProperties();
                contentEntryEditor.addSourceFolder(selectedFile, myEditHandler.getRootType(), properties);
            } else if (!myEditHandler.getRootType().equals(sourceFolder.getRootType())) {
                P properties;
                if (myEditHandler.getRootType().getClass().equals(sourceFolder.getRootType().getClass())) {
                    properties = (P) sourceFolder.getJpsElement().getProperties().getBulkModificationSupport().createCopy();
                } else {
                    properties = myEditHandler.getRootType().createDefaultProperties();
                }
                contentEntryEditor.removeSourceFolder(sourceFolder);
                contentEntryEditor.addSourceFolder(selectedFile, myEditHandler.getRootType(), properties);
            }
        } else if (sourceFolder != null) {
            // already marked
            contentEntryEditor.removeSourceFolder(sourceFolder);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentEntryEditor(com.intellij.openapi.roots.ui.configuration.ContentEntryEditor)

Aggregations

ContentEntryEditor (com.intellij.openapi.roots.ui.configuration.ContentEntryEditor)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 SourceFolder (com.intellij.openapi.roots.SourceFolder)1