Search in sources :

Example 1 with PerlModuleExtension

use of com.intellij.openapi.projectRoots.impl.PerlModuleExtension in project Perl5-IDEA by Camelcade.

the class PerlMarkSourceRootAction method modifyRoots.

@Override
protected void modifyRoots(@NotNull AnActionEvent e, @NotNull Module module, @NotNull VirtualFile[] files) {
    PerlModuleExtension modifiableModel = (PerlModuleExtension) PerlModuleExtension.getInstance(module).getModifiableModel(true);
    for (VirtualFile virtualFile : files) {
        modifiableModel.setRoot(virtualFile, myType);
    }
    modifiableModel.commit();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlModuleExtension(com.intellij.openapi.projectRoots.impl.PerlModuleExtension)

Example 2 with PerlModuleExtension

use of com.intellij.openapi.projectRoots.impl.PerlModuleExtension in project Perl5-IDEA by Camelcade.

the class PerlUnmarkSourceRootAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    RootsSelection selection = getSelection(e);
    if (selection.myModule == null) {
        presentation.setEnabledAndVisible(false);
        return;
    }
    boolean enabled = isEnabled(selection, selection.myModule);
    presentation.setEnabledAndVisible(enabled);
    if (!enabled) {
        return;
    }
    List<VirtualFile> virtualFiles = getFilesFromSelection(selection);
    PerlModuleExtension perlModuleExtension = PerlModuleExtension.getInstance(selection.myModule);
    if (perlModuleExtension == null || virtualFiles.isEmpty()) {
        return;
    }
    if (virtualFiles.size() == 1) {
        PerlSourceRootType type = perlModuleExtension.getRootType(virtualFiles.get(0));
        if (type == null) {
            return;
        }
        ModuleSourceRootEditHandler<?> handler = type.getEditHandler();
        presentation.setText(handler.getUnmarkRootButtonText());
        presentation.setIcon(new LayeredIcon(handler.getRootIcon(), AllIcons.RunConfigurations.InvalidConfigurationLayer));
    } else {
        presentation.setText(PerlBundle.message("perl.action.unmark.multi"));
        presentation.setIcon(new LayeredIcon(PerlIcons.PERL_LANGUAGE_ICON, AllIcons.RunConfigurations.InvalidConfigurationLayer));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayeredIcon(com.intellij.ui.LayeredIcon) PerlSourceRootType(com.perl5.lang.perl.idea.modules.PerlSourceRootType) Presentation(com.intellij.openapi.actionSystem.Presentation) PerlModuleExtension(com.intellij.openapi.projectRoots.impl.PerlModuleExtension)

Example 3 with PerlModuleExtension

use of com.intellij.openapi.projectRoots.impl.PerlModuleExtension in project Perl5-IDEA by Camelcade.

the class PerlUnmarkSourceRootAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    RootsSelection selection = getSelection(e);
    PerlModuleExtension perlModuleExtension = (PerlModuleExtension) PerlModuleExtension.getInstance(selection.myModule).getModifiableModel(true);
    for (VirtualFile virtualFile : getFilesFromSelection(selection)) {
        perlModuleExtension.removeRoot(virtualFile);
    }
    perlModuleExtension.commit();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlModuleExtension(com.intellij.openapi.projectRoots.impl.PerlModuleExtension)

Example 4 with PerlModuleExtension

use of com.intellij.openapi.projectRoots.impl.PerlModuleExtension in project Perl5-IDEA by Camelcade.

the class PerlToggleSourceRootAction method setSelected.

@Override
public void setSelected(AnActionEvent e, boolean state) {
    PerlModuleExtension modifiableModel = myEditor.getModifiableModel();
    for (VirtualFile virtualFile : myEditor.getSelectedFiles()) {
        if (state) {
            modifiableModel.setRoot(virtualFile, myHandler.getRootType());
        } else {
            modifiableModel.removeRoot(virtualFile);
        }
    }
    myEditor.repaint();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlModuleExtension(com.intellij.openapi.projectRoots.impl.PerlModuleExtension)

Aggregations

PerlModuleExtension (com.intellij.openapi.projectRoots.impl.PerlModuleExtension)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Presentation (com.intellij.openapi.actionSystem.Presentation)1 LayeredIcon (com.intellij.ui.LayeredIcon)1 PerlSourceRootType (com.perl5.lang.perl.idea.modules.PerlSourceRootType)1