Search in sources :

Example 41 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class SdkSetupNotificationTest method testModuleSdk.

public void testModuleSdk() throws Exception {
    final EditorNotificationPanel panel = configureBySdkAndText(IdeaTestUtil.getMockJdk18(), true, "Sample.java", "class Sample {}");
    assertNull(panel);
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel)

Example 42 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class SdkSetupNotificationTest method testNoProjectSdk.

public void testNoProjectSdk() throws Exception {
    final EditorNotificationPanel panel = configureBySdkAndText(null, false, "Sample.java", "class Sample {}");
    assertSdkSetupPanelShown(panel, "Project SDK is not defined");
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel)

Example 43 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class UseDistributionWithSourcesNotificationProvider method createNotificationPanel.

@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    try {
        if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) || GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) {
            final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
            if (module == null)
                return null;
            final String rootProjectPath = getRootProjectPath(module);
            if (rootProjectPath == null)
                return null;
            final GradleProjectSettings settings = GradleSettings.getInstance(module.getProject()).getLinkedProjectSettings(rootProjectPath);
            if (settings == null || settings.getDistributionType() != DistributionType.DEFAULT_WRAPPED)
                return null;
            if (settings.isDisableWrapperSourceDistributionNotification())
                return null;
            if (!showUseDistributionWithSourcesTip(rootProjectPath))
                return null;
            final EditorNotificationPanel panel = new EditorNotificationPanel();
            panel.setText(GradleBundle.message("gradle.notifications.use.distribution.with.sources"));
            panel.createActionLabel(GradleBundle.message("gradle.notifications.hide.tip"), () -> {
                settings.setDisableWrapperSourceDistributionNotification(true);
                EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
            });
            panel.createActionLabel(GradleBundle.message("gradle.notifications.apply.suggestion"), () -> {
                updateDefaultWrapperConfiguration(rootProjectPath);
                EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
                ExternalSystemUtil.refreshProject(module.getProject(), GradleConstants.SYSTEM_ID, settings.getExternalProjectPath(), false, ProgressExecutionMode.START_IN_FOREGROUND_ASYNC);
            });
            return panel;
        }
    } catch (ProcessCanceledException | IndexNotReadyException ignored) {
    }
    return null;
}
Also used : GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) Module(com.intellij.openapi.module.Module) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 44 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class MvcConfigureNotification method createConfigureNotificationPanel.

@Override
public EditorNotificationPanel createConfigureNotificationPanel(@NotNull final Module module) {
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText(framework.getFrameworkName() + " SDK is not configured for module '" + module.getName() + '\'');
    for (Entry<String, Runnable> action : framework.createConfigureActions(module).entrySet()) {
        panel.createActionLabel(action.getKey(), action.getValue());
    }
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel)

Example 45 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.

the class DetectedIndentOptionsNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) {
    Boolean notifiedFlag = fileEditor.getUserData(NOTIFIED_FLAG);
    if (fileEditor instanceof TextEditor && notifiedFlag != null) {
        final Editor editor = ((TextEditor) fileEditor).getEditor();
        final Project project = editor.getProject();
        if (project != null) {
            Document document = editor.getDocument();
            PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
            PsiFile psiFile = documentManager.getPsiFile(document);
            final Ref<FileIndentOptionsProvider> indentOptionsProviderRef = new Ref<>();
            if (psiFile != null) {
                CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
                CommonCodeStyleSettings.IndentOptions userOptions = settings.getIndentOptions(psiFile.getFileType());
                CommonCodeStyleSettings.IndentOptions detectedOptions = CodeStyleSettingsManager.getSettings(project).getIndentOptionsByFile(psiFile, null, false, provider -> {
                    indentOptionsProviderRef.set(provider);
                    return false;
                });
                final FileIndentOptionsProvider provider = indentOptionsProviderRef.get();
                EditorNotificationInfo info = provider != null && !provider.isAcceptedWithoutWarning(project, file) && !userOptions.equals(detectedOptions) ? provider.getNotificationInfo(project, file, fileEditor, userOptions, detectedOptions) : null;
                if (info != null) {
                    EditorNotificationPanel panel = new EditorNotificationPanel().text(info.getTitle());
                    if (info.getIcon() != null) {
                        panel.icon(info.getIcon());
                    }
                    for (final ActionLabelData actionLabelData : info.getLabelAndActions()) {
                        Runnable onClickAction = () -> {
                            actionLabelData.action.run();
                            EditorNotifications.getInstance(project).updateAllNotifications();
                        };
                        panel.createActionLabel(actionLabelData.label, onClickAction);
                    }
                    if (ApplicationManager.getApplication().isUnitTestMode()) {
                        file.putUserData(DETECT_INDENT_NOTIFICATION_SHOWN_KEY, Boolean.TRUE);
                    }
                    return panel;
                }
            }
        }
    }
    return null;
}
Also used : ActionLabelData(com.intellij.psi.codeStyle.EditorNotificationInfo.ActionLabelData) Document(com.intellij.openapi.editor.Document) Project(com.intellij.openapi.project.Project) Ref(com.intellij.openapi.util.Ref) TextEditor(com.intellij.openapi.fileEditor.TextEditor) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) PsiDocumentManager(com.intellij.psi.PsiDocumentManager) Nullable(org.jetbrains.annotations.Nullable)

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