Java Code Examples for com.intellij.ui.EditorNotificationPanel#setText()
The following examples show how to use
com.intellij.ui.EditorNotificationPanel#setText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForcedSoftWrapsNotificationProvider.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction @Nullable @Override public EditorNotificationPanel createNotificationPanel(@Nonnull final VirtualFile file, @Nonnull final FileEditor fileEditor) { if (!(fileEditor instanceof TextEditor)) return null; final Editor editor = ((TextEditor)fileEditor).getEditor(); if (!Boolean.TRUE.equals(editor.getUserData(DesktopEditorImpl.FORCED_SOFT_WRAPS)) || !Boolean.TRUE.equals(editor.getUserData(DesktopEditorImpl.SOFT_WRAPS_EXIST)) || PropertiesComponent.getInstance().isTrueValue(DISABLED_NOTIFICATION_KEY)) { return null; } final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(EditorBundle.message("forced.soft.wrap.message")); panel.createActionLabel(EditorBundle.message("forced.soft.wrap.hide.message"), () -> { editor.putUserData(DesktopEditorImpl.FORCED_SOFT_WRAPS, null); EditorNotifications.getInstance(myProject).updateNotifications(file); }); panel.createActionLabel(EditorBundle.message("forced.soft.wrap.dont.show.again.message"), () -> { PropertiesComponent.getInstance().setValue(DISABLED_NOTIFICATION_KEY, "true"); EditorNotifications.getInstance(myProject).updateAllNotifications(); }); return panel; }
Example 2
Source File: IgnoredEditingNotificationProvider.java From idea-gitignore with MIT License | 6 votes |
/** * Creates notification panel for given file and checks if is allowed to show the notification. * * @param file current file * @param fileEditor current file editor * @return created notification panel */ @Nullable @Override public EditorNotificationPanel createNotificationPanel(@NotNull final VirtualFile file, @NotNull FileEditor fileEditor, @NotNull Project project) { if (!settings.isNotifyIgnoredEditing() || Properties.isDismissedIgnoredEditingNotification(project, file) || !changeListManager.isIgnoredFile(file) && !manager.isFileIgnored(file)) { return null; } final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(IgnoreBundle.message("daemon.ignoredEditing")); panel.createActionLabel(IgnoreBundle.message("daemon.ok"), () -> { Properties.setDismissedIgnoredEditingNotification(project, file); notifications.updateAllNotifications(); }); try { // ignore if older SDK does not support panel icon panel.icon(Icons.IGNORE); } catch (NoSuchMethodError ignored) { } return panel; }
Example 3
Source File: AddTsConfigNotificationProvider.java From intellij with Apache License 2.0 | 5 votes |
private EditorNotificationPanel createNotificationPanel( Project project, VirtualFile file, Label tsConfig) { EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText("Do you want to add the tsconfig.json for this file to the project view?"); panel.createActionLabel( "Add tsconfig.json to project view", () -> { ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView( project, builder -> { ListSection<Label> rules = builder.getLast(TsConfigRulesSection.KEY); builder.replace( rules, ListSection.update(TsConfigRulesSection.KEY, rules).add(tsConfig)); return true; }); if (edit != null) { edit.apply(); } EditorNotifications.getInstance(project).updateNotifications(file); }); panel.createActionLabel( "Hide notification", () -> { // suppressed for this file until the editor is restarted suppressedFiles.add(VfsUtil.virtualToIoFile(file)); EditorNotifications.getInstance(project).updateNotifications(file); }); return panel; }
Example 4
Source File: GeneratedFileEditingNotificationProvider.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nullable @Override public EditorNotificationPanel createNotificationPanel(@Nonnull VirtualFile file, @Nonnull FileEditor fileEditor) { if (!GeneratedSourcesFilter.isGenerated(myProject, 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; }
Example 5
Source File: PluginAdvertiserEditorNotificationProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private EditorNotificationPanel createPanel(VirtualFile virtualFile, Set<PluginDescriptor> plugins) { String extension = virtualFile.getExtension(); final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(IdeBundle.message("plugin.advestiser.notification.text", plugins.size())); final PluginDescriptor disabledPlugin = getDisabledPlugin(plugins.stream().map(x -> x.getPluginId().getIdString()).collect(Collectors.toSet())); if (disabledPlugin != null) { panel.createActionLabel("Enable " + disabledPlugin.getName() + " plugin", () -> { myEnabledExtensions.add(extension); consulo.container.plugin.PluginManager.enablePlugin(disabledPlugin.getPluginId().getIdString()); myNotifications.updateAllNotifications(); PluginManagerMain.notifyPluginsWereUpdated("Plugin was successfully enabled", null); }); } else { panel.createActionLabel(IdeBundle.message("plugin.advestiser.notification.install.link", plugins.size()), () -> { final PluginsAdvertiserDialog advertiserDialog = new PluginsAdvertiserDialog(null, new ArrayList<>(plugins)); advertiserDialog.show(); if (advertiserDialog.isUserInstalledPlugins()) { myEnabledExtensions.add(extension); myNotifications.updateAllNotifications(); } }); } panel.createActionLabel("Ignore by file name", () -> { myUnknownFeaturesCollector.ignoreFeature(new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, virtualFile.getName())); myNotifications.updateAllNotifications(); }); panel.createActionLabel("Ignore by extension", () -> { myUnknownFeaturesCollector.ignoreFeature(new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, "*." + virtualFile.getExtension())); myNotifications.updateAllNotifications(); }); return panel; }
Example 6
Source File: FileChangedNotificationProvider.java From consulo with Apache License 2.0 | 5 votes |
private EditorNotificationPanel createPanel(@Nonnull 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; }
Example 7
Source File: MissingGitignoreNotificationProvider.java From idea-gitignore with MIT License | 5 votes |
/** * Creates notification panel. * * @param project current project * @param moduleRoot module root * @return notification panel */ private EditorNotificationPanel createPanel(@NotNull final Project project, @NotNull VirtualFile moduleRoot) { final EditorNotificationPanel panel = new EditorNotificationPanel(); final IgnoreFileType fileType = GitFileType.INSTANCE; panel.setText(IgnoreBundle.message("daemon.missingGitignore")); panel.createActionLabel(IgnoreBundle.message("daemon.missingGitignore.create"), () -> { PsiDirectory directory = PsiManager.getInstance(project).findDirectory(moduleRoot); if (directory != null) { try { PsiFile file = new CreateFileCommandAction(project, directory, fileType).execute(); FileEditorManager.getInstance(project).openFile(file.getVirtualFile(), true); new GeneratorDialog(project, file).show(); } catch (Throwable throwable) { throwable.printStackTrace(); } } }); panel.createActionLabel(IgnoreBundle.message("daemon.cancel"), () -> { Properties.setIgnoreMissingGitignore(project); notifications.updateAllNotifications(); }); try { // ignore if older SDK does not support panel icon Icon icon = fileType.getIcon(); if (icon != null) { panel.icon(icon); } } catch (NoSuchMethodError ignored) { } return panel; }
Example 8
Source File: AddUnversionedFilesNotificationProvider.java From idea-gitignore with MIT License | 5 votes |
/** * Creates notification panel. * * @param project current project * @return notification panel */ private EditorNotificationPanel createPanel(@NotNull final Project project) { final EditorNotificationPanel panel = new EditorNotificationPanel(); final IgnoreFileType fileType = GitFileType.INSTANCE; panel.setText(IgnoreBundle.message("daemon.addUnversionedFiles")); panel.createActionLabel(IgnoreBundle.message("daemon.addUnversionedFiles.create"), () -> { final VirtualFile projectDir = Utils.guessProjectDir(project); if (projectDir == null) { return; } final VirtualFile virtualFile = projectDir.findChild(GitLanguage.INSTANCE.getFilename()); final PsiFile file = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null; if (file != null) { final String content = StringUtil.join(unignoredFiles, Constants.NEWLINE); try { new AppendFileCommandAction(project, file, content, true, false) .execute(); } catch (Throwable throwable) { throwable.printStackTrace(); } handledMap.put(virtualFile, true); notifications.updateAllNotifications(); } }); panel.createActionLabel(IgnoreBundle.message("daemon.cancel"), () -> { Properties.setAddUnversionedFiles(project); notifications.updateAllNotifications(); }); try { // ignore if older SDK does not support panel icon Icon icon = fileType.getIcon(); if (icon != null) { panel.icon(icon); } } catch (NoSuchMethodError ignored) { } return panel; }
Example 9
Source File: SetupUnitySDKProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Nonnull private static EditorNotificationPanel createPanel(@Nullable String name, @Nonnull final Module rootModule) { EditorNotificationPanel panel = new EditorNotificationPanel(); if(StringUtil.isEmpty(name)) { panel.setText(Unity3dBundle.message("unity.sdk.is.not.defiled")); } else { panel.setText(Unity3dBundle.message("unity.0.sdk.is.not.defined", name)); } panel.createActionLabel("Open Settings", () -> ProjectSettingsService.getInstance(rootModule.getProject()).openModuleSettings(rootModule)); return panel; }
Example 10
Source File: IncompatibleDartPluginNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private static EditorNotificationPanel createUpdateDartPanel(@NotNull Project project, @Nullable Module module, @NotNull String currentVersion, @NotNull String minimumVersion) { if (module == null) return null; final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(FlutterBundle.message("flutter.incompatible.dart.plugin.warning", minimumVersion, currentVersion)); panel.createActionLabel(FlutterBundle.message("dart.plugin.update.action.label"), () -> ShowSettingsUtil.getInstance().showSettingsDialog(project, PluginManagerConfigurable.class)); return panel; }
Example 11
Source File: SdkConfigurationNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private EditorNotificationPanel createOutOfDateFlutterSdkPanel(@NotNull FlutterSdk sdk) { final FlutterUIConfig settings = FlutterUIConfig.getInstance(); if (settings.shouldIgnoreOutOfDateFlutterSdks()) return null; final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.icon(FlutterIcons.Flutter); panel.setText(FlutterBundle.message("flutter.old.sdk.warning")); panel.createActionLabel("Dismiss", () -> { settings.setIgnoreOutOfDateFlutterSdks(); panel.setVisible(false); }); return panel; }
Example 12
Source File: SdkConfigurationNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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; }
Example 13
Source File: IncompatibleDartPluginNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable private static EditorNotificationPanel createUpdateDartPanel(@NotNull Project project, @Nullable Module module, @NotNull String currentVersion, @NotNull String minimumVersion) { if (module == null) return null; final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(FlutterBundle.message("flutter.incompatible.dart.plugin.warning", minimumVersion, currentVersion)); panel.createActionLabel(FlutterBundle.message("dart.plugin.update.action.label"), () -> ShowSettingsUtil.getInstance().showSettingsDialog(project, PluginManagerConfigurable.class)); return panel; }
Example 14
Source File: SdkConfigurationNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private EditorNotificationPanel createOutOfDateFlutterSdkPanel(@NotNull FlutterSdk sdk) { final FlutterUIConfig settings = FlutterUIConfig.getInstance(); if (settings.shouldIgnoreOutOfDateFlutterSdks()) return null; final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.icon(FlutterIcons.Flutter); panel.setText(FlutterBundle.message("flutter.old.sdk.warning")); panel.createActionLabel("Dismiss", () -> { settings.setIgnoreOutOfDateFlutterSdks(); panel.setVisible(false); }); return panel; }
Example 15
Source File: SdkConfigurationNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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; }
Example 16
Source File: ExternalFileProjectManagementHelper.java From intellij with Apache License 2.0 | 4 votes |
@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, vf); if (context == null) { return null; } boolean inProjectDirectories = AddSourceToProjectHelper.sourceInProjectDirectories(context); boolean alreadyBuilt = AddSourceToProjectHelper.sourceCoveredByProjectViewTargets(context); if (alreadyBuilt && inProjectDirectories) { return null; } boolean addTargets = !alreadyBuilt && !AddSourceToProjectHelper.autoDeriveTargets(project); ListenableFuture<List<TargetInfo>> targetsFuture = addTargets ? AddSourceToProjectHelper.getTargetsBuildingSource(context) : Futures.immediateFuture(ImmutableList.of()); if (targetsFuture == null) { return null; } EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setVisible(false); // starts off not visible until we get the query results 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, BlazeUserSettingsCompositeConfigurable.ID, BlazeUserSettingsConfigurable.SHOW_ADD_FILE_TO_PROJECT.label()); }); targetsFuture.addListener( () -> { try { List<TargetInfo> targets = targetsFuture.get(); if (!targets.isEmpty() || !inProjectDirectories) { panel.setVisible(true); } } catch (InterruptedException | ExecutionException e) { // ignore } }, MoreExecutors.directExecutor()); return panel; }
Example 17
Source File: AdditionalLanguagesHelper.java From intellij with Apache License 2.0 | 4 votes |
@Nullable @Override public EditorNotificationPanel createNotificationPanel(VirtualFile file, FileEditor fileEditor) { String ext = file.getExtension(); if (ext == null) { return null; } LanguageClass language = LanguageClass.fromExtension(ext); if (language == null || notifiedLanguages.contains(language)) { return null; } BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (projectData == null) { return null; } WorkspaceLanguageSettings settings = projectData.getWorkspaceLanguageSettings(); if (settings.isLanguageActive(language)) { return null; } if (!LanguageSupport.supportedLanguagesForWorkspaceType(settings.getWorkspaceType()) .contains(language)) { return null; } String langName = language.getName(); String message = String.format( "Do you want to enable %s plugin %s support?", Blaze.buildSystemName(project), langName); EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(message); panel.createActionLabel( String.format("Enable %s support", langName), () -> { enableLanguageSupport(project, ImmutableList.of(language)); suppressNotifications(language); }); panel.createActionLabel("Don't show again", () -> suppressNotifications(language)); return panel; }