use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class SrcFileAnnotator method hideCoverageData.
public void hideCoverageData() {
Editor editor = myEditor;
PsiFile file = myFile;
Document document = myDocument;
if (editor == null || editor.isDisposed() || file == null || document == null)
return;
final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
final List<RangeHighlighter> highlighters = editor.getUserData(COVERAGE_HIGHLIGHTERS);
if (highlighters != null) {
for (final RangeHighlighter highlighter : highlighters) {
ApplicationManager.getApplication().invokeLater(() -> highlighter.dispose());
}
editor.putUserData(COVERAGE_HIGHLIGHTERS, null);
}
final Map<FileEditor, EditorNotificationPanel> map = file.getCopyableUserData(NOTIFICATION_PANELS);
if (map != null) {
final VirtualFile vFile = getVirtualFile(file);
boolean freeAll = !fileEditorManager.isFileOpen(vFile);
file.putCopyableUserData(NOTIFICATION_PANELS, null);
for (FileEditor fileEditor : map.keySet()) {
if (!freeAll && !isCurrentEditor(fileEditor)) {
continue;
}
fileEditorManager.removeTopComponent(fileEditor, map.get(fileEditor));
}
}
final DocumentListener documentListener = editor.getUserData(COVERAGE_DOCUMENT_LISTENER);
if (documentListener != null) {
document.removeDocumentListener(documentListener);
editor.putUserData(COVERAGE_DOCUMENT_LISTENER, null);
}
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class SdkSetupNotificationProvider method createPanel.
@NotNull
private static EditorNotificationPanel createPanel(@NotNull String message, @NotNull Runnable fix) {
EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(message);
panel.createActionLabel(ProjectBundle.message("project.sdk.setup"), fix);
return panel;
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-community by JetBrains.
the class AttachSourcesNotificationProvider method createNotificationPanel.
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor) {
if (file.getFileType() != JavaClassFileType.INSTANCE)
return null;
final EditorNotificationPanel panel = new EditorNotificationPanel();
String text = ProjectBundle.message("class.file.decompiled.text");
String classInfo = getClassFileInfo(file);
if (classInfo != null)
text += ", " + classInfo;
panel.setText(text);
final VirtualFile sourceFile = JavaEditorFileSwapper.findSourceFile(myProject, file);
if (sourceFile == null) {
final List<LibraryOrderEntry> libraries = findLibraryEntriesForFile(file);
if (libraries != null) {
List<AttachSourcesProvider.AttachSourcesAction> actions = new ArrayList<>();
PsiFile clsFile = PsiManager.getInstance(myProject).findFile(file);
boolean hasNonLightAction = false;
for (AttachSourcesProvider each : Extensions.getExtensions(EXTENSION_POINT_NAME)) {
for (AttachSourcesProvider.AttachSourcesAction action : each.getActions(libraries, clsFile)) {
if (hasNonLightAction) {
if (action instanceof AttachSourcesProvider.LightAttachSourcesAction) {
// Don't add LightAttachSourcesAction if non light action exists.
continue;
}
} else {
if (!(action instanceof AttachSourcesProvider.LightAttachSourcesAction)) {
// All previous actions is LightAttachSourcesAction and should be removed.
actions.clear();
hasNonLightAction = true;
}
}
actions.add(action);
}
}
Collections.sort(actions, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
AttachSourcesProvider.AttachSourcesAction defaultAction;
if (findSourceFileInSameJar(file) != null) {
defaultAction = new AttachJarAsSourcesAction(file);
} else {
defaultAction = new ChooseAndAttachSourcesAction(myProject, panel);
}
actions.add(defaultAction);
for (final AttachSourcesProvider.AttachSourcesAction action : actions) {
panel.createActionLabel(GuiUtils.getTextWithoutMnemonicEscaping(action.getName()), () -> {
List<LibraryOrderEntry> entries = findLibraryEntriesForFile(file);
if (!Comparing.equal(libraries, entries)) {
Messages.showErrorDialog(myProject, "Can't find library for " + file.getName(), "Error");
return;
}
panel.setText(action.getBusyText());
action.perform(entries);
});
}
}
} else {
panel.createActionLabel(ProjectBundle.message("class.file.open.source.action"), () -> {
OpenFileDescriptor descriptor = new OpenFileDescriptor(myProject, sourceFile);
FileEditorManager.getInstance(myProject).openTextEditor(descriptor, true);
});
}
return panel;
}
use of com.intellij.ui.EditorNotificationPanel in project intellij-elixir by KronicDeth.
the class SetupSDKNotificationProvider method createPanel.
@NotNull
private static EditorNotificationPanel createPanel(@NotNull final Project project, @NotNull final PsiFile file) {
EditorNotificationPanel panel = new EditorNotificationPanel();
// project.sdk.not.defined -> "Project SDK is not defined"
// project.sdk.setup -> "Setup SDK"
panel.setText(ProjectBundle.message("project.sdk.not.defined"));
panel.createActionLabel(ProjectBundle.message("project.sdk.setup"), new Runnable() {
@Override
public void run() {
if (ElixirSystemUtil.isSmallIde()) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, ElixirExternalToolsConfigurable.ELIXIR_RELATED_TOOLS);
return;
}
Sdk projectSdk = ProjectSettingsService.getInstance(project).chooseAndSetSdk();
if (projectSdk == null)
return;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
ModuleRootModificationUtil.setSdkInherited(module);
}
}
});
}
});
return panel;
}
use of com.intellij.ui.EditorNotificationPanel in project flutter-intellij by flutter.
the class SdkConfigurationNotificationProvider method createNoFlutterSdkPanel.
@SuppressWarnings("SameReturnValue")
private static EditorNotificationPanel createNoFlutterSdkPanel(Project project) {
final EditorNotificationPanel panel = new EditorNotificationPanel();
panel.icon(FlutterIcons.Flutter);
panel.setText(FlutterBundle.message("flutter.no.sdk.warning"));
panel.createActionLabel("Dismiss", () -> panel.setVisible(false));
panel.createActionLabel("Open Flutter settings", () -> FlutterUtils.openFlutterSettings(project));
return panel;
}
Aggregations