Search in sources :

Example 51 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project ballerina by ballerina-lang.

the class WrongModuleTypeNotificationProvider method createPanel.

@NotNull
private static EditorNotificationPanel createPanel(@NotNull Project project, @NotNull Module module) {
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("'" + module.getName() + "' is not a Ballerina Module, some code insight might not work here");
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) NotNull(org.jetbrains.annotations.NotNull)

Example 52 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel 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)

Example 53 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij by bazelbuild.

the class ExternalFileProjectManagementHelper method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(VirtualFile vf, FileEditor fileEditor) {
    if (!enabled.getValue()) {
        return null;
    }
    if (!BlazeUserSettings.getInstance().getShowAddFileToProjectNotification() || suppressedFiles.contains(new File(vf.getPath()))) {
        return null;
    }
    File file = new File(vf.getPath());
    if (!supportedFileType(file)) {
        return null;
    }
    LocationContext context = AddSourceToProjectHelper.getContext(project, file);
    if (context == null) {
        return null;
    }
    ListenableFuture<List<TargetInfo>> targetsFuture = AddSourceToProjectHelper.getTargetsBuildingSource(context);
    if (targetsFuture == null) {
        return null;
    }
    boolean inProjectDirectories = AddSourceToProjectHelper.sourceInProjectDirectories(context);
    EditorNotificationPanel panel = new EditorNotificationPanel();
    // starts off not visible until we get the query results
    panel.setVisible(false);
    panel.setText("Do you want to add this file to your project sources?");
    panel.createActionLabel("Add file to project", () -> {
        AddSourceToProjectHelper.addSourceToProject(project, context.workspacePath, inProjectDirectories, targetsFuture);
        EditorNotifications.getInstance(project).updateNotifications(vf);
    });
    panel.createActionLabel("Hide notification", () -> {
        // suppressed for this file until the editor is restarted
        suppressedFiles.add(file);
        EditorNotifications.getInstance(project).updateNotifications(vf);
    });
    panel.createActionLabel("Don't show again", () -> {
        // disables the notification permanently, and focuses the relevant setting, so users know
        // how to turn it back on
        BlazeUserSettings.getInstance().setShowAddFileToProjectNotification(false);
        ShowSettingsUtilImpl.showSettingsDialog(project, BlazeUserSettingsConfigurable.ID, BlazeUserSettingsConfigurable.SHOW_ADD_FILE_TO_PROJECT_LABEL_TEXT);
    });
    targetsFuture.addListener(() -> {
        try {
            List<TargetInfo> targets = targetsFuture.get();
            if (!targets.isEmpty() || !inProjectDirectories) {
                panel.setVisible(true);
            }
        } catch (InterruptedException | ExecutionException e) {
        // ignore
        }
    }, MoreExecutors.directExecutor());
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) LocationContext(com.google.idea.blaze.base.dependencies.AddSourceToProjectHelper.LocationContext) ExecutionException(java.util.concurrent.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(javax.annotation.Nullable)

Example 54 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project go-lang-idea-plugin by go-lang-plugin-org.

the class WrongSdkConfigurationNotificationProvider method createMissingSdkPanel.

@NotNull
private static EditorNotificationPanel createMissingSdkPanel(@NotNull Project project, @Nullable Module module) {
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText(ProjectBundle.message("project.sdk.not.defined"));
    panel.createActionLabel(ProjectBundle.message("project.sdk.setup"), () -> GoSdkService.getInstance(project).chooseAndSetSdk(module));
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) NotNull(org.jetbrains.annotations.NotNull)

Example 55 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project go-lang-idea-plugin by go-lang-plugin-org.

the class WrongModuleTypeNotificationProvider method createPanel.

@NotNull
private static EditorNotificationPanel createPanel(@NotNull Project project, @NotNull Module module) {
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("'" + module.getName() + "' is not Go Module, some code insight might not work here");
    panel.createActionLabel("Change module type to Go and reload project", () -> {
        int message = Messages.showOkCancelDialog(project, "Updating module type requires project reload. Proceed?", "Update Module Type", "Reload project", "Cancel", null);
        if (message == Messages.YES) {
            module.setOption(Module.ELEMENT_TYPE, GoModuleType.getInstance().getId());
            project.save();
            EditorNotifications.getInstance(project).updateAllNotifications();
            ProjectManager.getInstance().reloadProject(project);
        }
    });
    panel.createActionLabel("Don't show again for this module", () -> {
        Set<String> ignoredModules = getIgnoredModules(project);
        ignoredModules.add(module.getName());
        PropertiesComponent.getInstance(project).setValue(DONT_ASK_TO_CHANGE_MODULE_TYPE_KEY, StringUtil.join(ignoredModules, ","));
        EditorNotifications.getInstance(project).updateAllNotifications();
    });
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)56 Nullable (org.jetbrains.annotations.Nullable)20 NotNull (org.jetbrains.annotations.NotNull)13 FileEditor (com.intellij.openapi.fileEditor.FileEditor)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 PsiFile (com.intellij.psi.PsiFile)7 Editor (com.intellij.openapi.editor.Editor)6 TextEditor (com.intellij.openapi.fileEditor.TextEditor)5 Project (com.intellij.openapi.project.Project)4 Module (com.intellij.openapi.module.Module)3 PluginManagerConfigurable (com.intellij.ide.plugins.PluginManagerConfigurable)2 Document (com.intellij.openapi.editor.Document)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 Ref (com.intellij.openapi.util.Ref)2 PerlLocalSettings (com.perl5.lang.perl.idea.configuration.settings.PerlLocalSettings)2 File (java.io.File)2 List (java.util.List)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)1