Search in sources :

Example 16 with EditorNotificationPanel

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

the class MergePanel2 method tryInitView.

private void tryInitView() {
    if (!hasAllEditors())
        return;
    if (myMergeList != null)
        return;
    myMergeList = MergeList.create(myData);
    myMergeList.addListener(myDividersRepainter);
    myStatusUpdater = StatusUpdater.install(myMergeList, myPanel);
    Editor left = getEditor(0);
    Editor base = getEditor(1);
    Editor right = getEditor(2);
    setupHighlighterSettings(left, base, right);
    myMergeList.setMarkups(left, base, right);
    EditingSides[] sides = { getFirstEditingSide(), getSecondEditingSide() };
    myScrollSupport.install(sides);
    for (int i = 0; i < myDividers.length; i++) {
        myDividers[i].listenEditors(sides[i]);
    }
    if (myScrollToFirstDiff) {
        myPanel.requestScrollEditors();
    }
    if (myMergeList.getErrorMessage() != null) {
        myPanel.insertTopComponent(new EditorNotificationPanel() {

            {
                myLabel.setText(myMergeList.getErrorMessage());
            }
        });
    }
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) Editor(com.intellij.openapi.editor.Editor) DiffDividerPaint(com.intellij.openapi.diff.impl.splitter.DiffDividerPaint)

Example 17 with EditorNotificationPanel

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

the class LargeFileNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    if (!(fileEditor instanceof LargeFileEditorProvider.LargeTextFileEditor))
        return null;
    Editor editor = ((TextEditor) fileEditor).getEditor();
    Project project = editor.getProject();
    if (project == null || editor.getUserData(HIDDEN_KEY) != null || PropertiesComponent.getInstance().isTrueValue(DISABLE_KEY)) {
        return null;
    }
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.createActionLabel("Hide notification", () -> {
        editor.putUserData(HIDDEN_KEY, "true");
        update(file, project);
    });
    panel.createActionLabel("Don't show again", () -> {
        PropertiesComponent.getInstance().setValue(DISABLE_KEY, "true");
        update(file, project);
    });
    return panel.text(String.format("This file is too large for editing (%s). Read only preview mode is activated.", StringUtil.formatFileSize(file.getLength())));
}
Also used : Project(com.intellij.openapi.project.Project) TextEditor(com.intellij.openapi.fileEditor.TextEditor) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with EditorNotificationPanel

use of com.intellij.ui.EditorNotificationPanel in project android by JetBrains.

the class GeneratedFileNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    AndroidModuleModel androidModel = GradleProjectInfo.getInstance(myProject).findAndroidModelInModule(file);
    if (androidModel == null) {
        return null;
    }
    VirtualFile buildFolder = VfsUtil.findFileByIoFile(androidModel.getAndroidProject().getBuildFolder(), false);
    if (buildFolder == null || !buildFolder.isDirectory()) {
        return null;
    }
    if (VfsUtilCore.isAncestor(buildFolder, file, false)) {
        if (myGeneratedSourceFileChangeTracker.isEditedGeneratedFile(file)) {
            // A warning is already being displayed by GeneratedFileEditingNotificationProvider
            return null;
        }
        VirtualFile explodedBundled = buildFolder.findChild(EXPLODED_AAR);
        boolean inAar = explodedBundled != null && VfsUtilCore.isAncestor(explodedBundled, file, true);
        String text;
        if (inAar) {
            text = "Resource files inside Android library archive files (.aar) should not be edited";
        } else {
            text = "Files under the build folder are generated and should not be edited.";
        }
        EditorNotificationPanel panel = new EditorNotificationPanel();
        panel.setText(text);
        return panel;
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with EditorNotificationPanel

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

the class GeneratedFileEditingNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    if (!myChangeTracker.isEditedGeneratedFile(file))
        return null;
    EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("Generated source files should not be edited. The changes will be lost when sources are regenerated.");
    return panel;
}
Also used : EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with EditorNotificationPanel

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

the class SdkSetupNotificationTest method testProjectSdk.

public void testProjectSdk() throws Exception {
    final EditorNotificationPanel panel = configureBySdkAndText(IdeaTestUtil.getMockJdk18(), false, "Sample.java", "class Sample {}");
    assertNull(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