Search in sources :

Example 1 with PerlLocalSettings

use of com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings in project Perl5-IDEA by Camelcade.

the class PerlAssociationEditorNotification method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    PerlLocalSettings perlLocalSettings = PerlLocalSettings.getInstance(myProject);
    if (perlLocalSettings.DISABLE_ASSOCIATIONS_CHECKING) {
        return null;
    }
    Optional<Map.Entry<FileNameMatcher, FileType>> matchedEntry = PERL_FILE_TYPES.entrySet().stream().filter(entry -> entry.getKey().accept(file.getName())).findFirst();
    if (matchedEntry == null || !matchedEntry.isPresent()) {
        return null;
    }
    FileType expectedType = matchedEntry.get().getValue();
    if (file.getFileType() == expectedType) {
        return null;
    }
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText(PerlBundle.message("perl.notification.wrong.association", matchedEntry.get().getKey(), expectedType.getName(), file.getFileType().getName()));
    panel.createActionLabel(PerlBundle.message("perl.configure.plugins"), () -> ShowSettingsUtil.getInstance().showSettingsDialog(null, PluginManagerConfigurable.class));
    panel.createActionLabel(PerlBundle.message("perl.configure.associations"), () -> ShowSettingsUtil.getInstance().showSettingsDialog(null, FileTypeConfigurable.class));
    panel.createActionLabel(PerlBundle.message("perl.notification.disable.notification"), () -> {
        perlLocalSettings.DISABLE_ASSOCIATIONS_CHECKING = true;
        EditorNotifications.getInstance(myProject).updateAllNotifications();
    });
    return panel;
}
Also used : ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) EditorNotifications(com.intellij.ui.EditorNotifications) PerlBundle(com.perl5.PerlBundle) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Key(com.intellij.openapi.util.Key) FileType(com.intellij.openapi.fileTypes.FileType) PluginManagerConfigurable(com.intellij.ide.plugins.PluginManagerConfigurable) ContainerUtil(com.intellij.util.containers.ContainerUtil) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Nullable(org.jetbrains.annotations.Nullable) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) List(java.util.List) FileNameMatcher(com.intellij.openapi.fileTypes.FileNameMatcher) FileTypeConfigurable(com.intellij.openapi.fileTypes.impl.FileTypeConfigurable) Map(java.util.Map) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) Project(com.intellij.openapi.project.Project) Optional(java.util.Optional) DumbAware(com.intellij.openapi.project.DumbAware) NotNull(org.jetbrains.annotations.NotNull) FileType(com.intellij.openapi.fileTypes.FileType) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) FileTypeConfigurable(com.intellij.openapi.fileTypes.impl.FileTypeConfigurable) PluginManagerConfigurable(com.intellij.ide.plugins.PluginManagerConfigurable) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PerlLocalSettings

use of com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings in project Perl5-IDEA by Camelcade.

the class PerlCriticAnnotator method getPerlCriticExecutable.

protected GeneralCommandLine getPerlCriticExecutable(Project project) throws ExecutionException {
    PerlSharedSettings sharedSettings = PerlSharedSettings.getInstance(project);
    PerlLocalSettings localSettings = PerlLocalSettings.getInstance(project);
    String executable = localSettings.PERL_CRITIC_PATH;
    if (StringUtil.isEmpty(executable)) {
        throw new ExecutionException("Path to Perl::Critic executable must be configured in perl settings");
    }
    GeneralCommandLine commandLine = new GeneralCommandLine(executable).withWorkDirectory(project.getBasePath());
    if (StringUtil.isNotEmpty(sharedSettings.PERL_CRITIC_ARGS)) {
        commandLine.addParameters(StringUtil.split(sharedSettings.PERL_CRITIC_ARGS, " "));
    }
    return commandLine;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) PerlSharedSettings(com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) ExecutionException(com.intellij.execution.ExecutionException)

Example 3 with PerlLocalSettings

use of com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings in project Perl5-IDEA by Camelcade.

the class PerlFormatWithPerlTidyAction method getPerlTidyCommandLine.

protected GeneralCommandLine getPerlTidyCommandLine(Project project) throws ExecutionException {
    PerlSharedSettings sharedSettings = PerlSharedSettings.getInstance(project);
    PerlLocalSettings localSettings = PerlLocalSettings.getInstance(project);
    String executable = localSettings.PERL_TIDY_PATH;
    if (StringUtil.isEmpty(executable)) {
        throw new ExecutionException(PerlBundle.message("perl.action.perl.tidy.execution.exception"));
    }
    GeneralCommandLine commandLine = new GeneralCommandLine(executable, "-st", "-se").withWorkDirectory(project.getBasePath());
    if (StringUtil.isNotEmpty(sharedSettings.PERL_TIDY_ARGS)) {
        commandLine.addParameters(StringUtil.split(sharedSettings.PERL_TIDY_ARGS, " "));
    }
    return commandLine;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) PerlSharedSettings(com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) ExecutionException(com.intellij.execution.ExecutionException)

Example 4 with PerlLocalSettings

use of com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings in project Perl5-IDEA by Camelcade.

the class PerlInterpreterEditorNotification method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile virtualFile, @NotNull FileEditor fileEditor) {
    if (virtualFile.getFileType() instanceof PerlFileType && !(virtualFile instanceof LightVirtualFile)) {
        final PerlLocalSettings perlLocalSettings = PerlLocalSettings.getInstance(myProject);
        if (perlLocalSettings.DISABLE_NO_INTERPRETER_WARNING) {
            return null;
        }
        EditorNotificationPanel panel;
        String sdkPath = PerlProjectManager.getSdkPath(myProject, virtualFile);
        if (sdkPath != null && VfsUtil.findFileByIoFile(new File(sdkPath), true) != null) {
            return null;
        }
        panel = new EditorNotificationPanel();
        panel.setText(PerlBundle.message("perl.notification.sdk.not.configured"));
        panel.createActionLabel(PerlBundle.message("perl.notification.configure"), () -> Perl5SettingsConfigurable.open(myProject));
        panel.createActionLabel(PerlBundle.message("perl.notification.disable.notification"), () -> {
            perlLocalSettings.DISABLE_NO_INTERPRETER_WARNING = true;
            EditorNotifications.getInstance(myProject).updateAllNotifications();
        });
        return panel;
    }
    return null;
}
Also used : PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PerlLocalSettings(com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PerlLocalSettings (com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings)4 ExecutionException (com.intellij.execution.ExecutionException)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)2 PerlSharedSettings (com.perl5.lang.perl.idea.configuration.settings.PerlSharedSettings)2 Nullable (org.jetbrains.annotations.Nullable)2 PluginManagerConfigurable (com.intellij.ide.plugins.PluginManagerConfigurable)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileNameMatcher (com.intellij.openapi.fileTypes.FileNameMatcher)1 FileType (com.intellij.openapi.fileTypes.FileType)1 FileTypeConfigurable (com.intellij.openapi.fileTypes.impl.FileTypeConfigurable)1 ShowSettingsUtil (com.intellij.openapi.options.ShowSettingsUtil)1 DumbAware (com.intellij.openapi.project.DumbAware)1 Project (com.intellij.openapi.project.Project)1 Key (com.intellij.openapi.util.Key)1 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)1 EditorNotifications (com.intellij.ui.EditorNotifications)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 PerlBundle (com.perl5.PerlBundle)1