Search in sources :

Example 11 with EditorNotificationPanel

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

the class JsonSchemaConflictNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    final List<Pair<Boolean, String>> descriptors = myJsonSchemaService.getMatchingSchemaDescriptors(file);
    if (descriptors == null || descriptors.size() <= 1)
        return null;
    final Worker worker = new Worker();
    final String message = worker.createMessage(descriptors);
    if (message == null)
        return null;
    final EditorNotificationPanel panel = new EditorNotificationPanel(LightColors.RED);
    panel.setText(message);
    panel.createActionLabel("Edit JSON Schema Mappings", () -> {
        ShowSettingsUtil.getInstance().editConfigurable(myProject, new JsonSchemaMappingsConfigurable(myProject));
        EditorNotifications.getInstance(myProject).updateNotifications(file);
    });
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) Pair(com.intellij.openapi.util.Pair) JsonSchemaMappingsConfigurable(com.jetbrains.jsonSchema.JsonSchemaMappingsConfigurable) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with EditorNotificationPanel

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

the class SrcFileAnnotator method showEditorWarningMessage.

private void showEditorWarningMessage(final String message) {
    Editor textEditor = myEditor;
    PsiFile file = myFile;
    ApplicationManager.getApplication().invokeLater(() -> {
        if (textEditor == null || textEditor.isDisposed() || file == null)
            return;
        final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
        final VirtualFile vFile = file.getVirtualFile();
        assert vFile != null;
        Map<FileEditor, EditorNotificationPanel> map = file.getCopyableUserData(NOTIFICATION_PANELS);
        if (map == null) {
            map = new HashMap<>();
            file.putCopyableUserData(NOTIFICATION_PANELS, map);
        }
        final FileEditor[] editors = fileEditorManager.getAllEditors(vFile);
        for (final FileEditor editor : editors) {
            if (isCurrentEditor(editor)) {
                final EditorNotificationPanel panel = new EditorNotificationPanel() {

                    {
                        myLabel.setIcon(AllIcons.General.ExclMark);
                        myLabel.setText(message);
                    }
                };
                panel.createActionLabel("Close", () -> fileEditorManager.removeTopComponent(editor, panel));
                map.put(editor, panel);
                fileEditorManager.addTopComponent(editor, panel);
                break;
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) PsiFile(com.intellij.psi.PsiFile) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor)

Example 13 with EditorNotificationPanel

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

the class DiffNotifications method createNotification.

@NotNull
public static JPanel createNotification(@NotNull String text, @Nullable final Color background, boolean showHideAction) {
    final EditorNotificationPanel panel = new EditorNotificationPanel(background);
    panel.text(text);
    if (showHideAction) {
        HyperlinkLabel link = panel.createActionLabel("Hide", () -> panel.setVisible(false));
        link.setToolTipText("Hide this notification");
    }
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with EditorNotificationPanel

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

the class IdeFrameFixture method requireEditorNotification.

@NotNull
public EditorNotificationPanelFixture requireEditorNotification(@NotNull final String message) {
    final Ref<EditorNotificationPanel> notificationPanelRef = new Ref<EditorNotificationPanel>();
    pause(new Condition("Notification with message '" + message + "' shows up") {

        @Override
        public boolean test() {
            EditorNotificationPanel notificationPanel = findNotificationPanel(message);
            notificationPanelRef.set(notificationPanel);
            return notificationPanel != null;
        }
    });
    EditorNotificationPanel notificationPanel = notificationPanelRef.get();
    assertNotNull(notificationPanel);
    return new EditorNotificationPanelFixture(robot(), notificationPanel);
}
Also used : Condition(org.fest.swing.timing.Condition) Ref(com.intellij.openapi.util.Ref) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with EditorNotificationPanel

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

the class FileChangedNotificationProvider method createPanel.

private EditorNotificationPanel createPanel(@NotNull final VirtualFile file) {
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText(IdeBundle.message("file.changed.externally.message"));
    panel.createActionLabel(IdeBundle.message("file.changed.externally.reload"), () -> {
        if (!myProject.isDisposed()) {
            file.refresh(false, false);
            EditorNotifications.getInstance(myProject).updateNotifications(file);
        }
    });
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel)

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