com.intellij.notification.Notification Java Examples
The following examples show how to use
com.intellij.notification.Notification.
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: UploadNotification.java From markdown-image-kit with MIT License | 7 votes |
/** * 上传时检查到配置错误时通知 * * @param project the project * @param actionName the action name */ public static void notifyConfigurableError(Project project, String actionName) { String content = "<p><a href=''>Configure " + actionName + " OSS</a></p><br />"; content = "<p>You may need to set or reset your account. Please be sure to <b>test</b> it after the setup is complete.</p>" + content + "<br />"; content = content + "<p>Or you may need <a href='" + HELP_URL + "'>Help</a></p>"; Notifications.Bus.notify(new Notification(MIK_NOTIFICATION_GROUP, "Configurable Error", content, NotificationType.ERROR, new NotificationListener.Adapter() { @Override protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { String url = e.getDescription(); log.trace("{}", e.getDescription()); if (StringUtils.isBlank(url)) { ProjectSettingsPage configurable = new ProjectSettingsPage(); // 打开设置面板 ShowSettingsUtil.getInstance().editConfigurable(project, configurable); } else { BrowserUtil.browse(url); } hideBalloon(notification.getBalloon()); } }), project); }
Example #2
Source File: GaugeWebBrowserPreview.java From Intellij-Plugin with Apache License 2.0 | 6 votes |
@Nullable private Url previewUrl(OpenInBrowserRequest request, VirtualFile virtualFile, GaugeSettingsModel settings) throws IOException, InterruptedException { ProcessBuilder builder = new ProcessBuilder(settings.getGaugePath(), Constants.DOCS, Spectacle.NAME, virtualFile.getPath()); String projectName = request.getProject().getName(); builder.environment().put("spectacle_out_dir", FileUtil.join(createOrGetTempDirectory(projectName).getPath(), "docs")); File gaugeModuleDir = GaugeUtil.moduleDir(GaugeUtil.moduleForPsiElement(request.getFile())); builder.directory(gaugeModuleDir); GaugeUtil.setGaugeEnvironmentsTo(builder, settings); Process docsProcess = builder.start(); int exitCode = docsProcess.waitFor(); if (exitCode != 0) { String docsOutput = String.format("<pre>%s</pre>", GaugeUtil.getOutput(docsProcess.getInputStream(), " ").replace("<", "<").replace(">", ">")); Notifications.Bus.notify(new Notification("Specification Preview", "Error: Specification Preview", docsOutput, NotificationType.ERROR)); return null; } String relativePath = FileUtil.getRelativePath(gaugeModuleDir, new File(virtualFile.getParent().getPath())); return new UrlImpl(FileUtil.join(createOrGetTempDirectory(projectName).getPath(), "docs", "html", relativePath, virtualFile.getNameWithoutExtension() + ".html")); }
Example #3
Source File: ProjectRefreshListener.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
/** * Template came from maven plugin: * https://github.com/JetBrains/intellij-community/blob/b5d046018b9a82fccd86bc9c1f1da2e28068440a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenImportNotifier.java#L92-L108 */ static void notify(Project project) { if(hasExistingRefreshNotification(project)){ return; } Notification notification = new Notification( PantsConstants.PANTS, NOTIFICATION_TITLE, "<a href='refresh'>" + NOTIFICATION_BUTTON_TITLE + "</a> ", NotificationType.INFORMATION, new ProjectRefreshListener(project) ); notification.notify(project); }
Example #4
Source File: DvcsBranchPopup.java From consulo with Apache License 2.0 | 6 votes |
private void notifyAboutSyncedBranches() { String description = "You have several " + myVcs.getDisplayName() + " roots in the project and they all are checked out at the same branch. " + "We've enabled synchronous branch control for the project. <br/>" + "If you wish to control branches in different roots separately, " + "you may <a href='settings'>disable</a> the setting."; NotificationListener listener = new NotificationListener() { @Override public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName()); if (myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) { notification.expire(); } } } }; VcsNotifier.getInstance(myProject).notifyImportantInfo("Synchronous branch control enabled", description, listener); }
Example #5
Source File: JumpToSourceAction.java From MavenHelper with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { final Navigatable navigatable = getNavigatable(myArtifact, myProject, myMavenProject); if (navigatable != null && navigatable.canNavigate()) { navigatable.navigate(true); } else { final Notification notification = new Notification(MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "", "Parent dependency not found, strange...", NotificationType.WARNING); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Notifications.Bus.notify(notification, myProject); } }); } }
Example #6
Source File: LatteIndexUtil.java From intellij-latte with MIT License | 6 votes |
private static void showWaring(Project[] projects) { if (projects.length == 0) { return; } LatteIdeHelper.doNotify( "Latte plugin warning", "Latte files can not be reparsed during indexing. Wait after all processes around indexing will be done.", NotificationType.ERROR, projects[0], new NotificationAction("Refresh Configuration") { @Override public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) { tryPerform(projects, notification); } } ); }
Example #7
Source File: GraphQLIntrospectEndpointUrlLineMarkerProvider.java From js-graphql-intellij-plugin with MIT License | 6 votes |
private String getSchemaPath(JsonProperty urlElement, boolean showNotificationOnMissingPath) { JsonObject jsonObject = PsiTreeUtil.getParentOfType(urlElement, JsonObject.class); while (jsonObject != null) { JsonProperty schemaPathElement = jsonObject.findProperty("schemaPath"); if (schemaPathElement != null) { if (schemaPathElement.getValue() instanceof JsonStringLiteral) { String schemaPath = ((JsonStringLiteral) schemaPathElement.getValue()).getValue(); if (schemaPath.trim().isEmpty()) { Notifications.Bus.notify(new Notification("GraphQL", "Unable to perform introspection", "Please set a non-empty 'schemaPath' field", NotificationType.WARNING), urlElement.getProject()); } return schemaPath; } else { break; } } jsonObject = PsiTreeUtil.getParentOfType(jsonObject, JsonObject.class); } if (showNotificationOnMissingPath) { Notifications.Bus.notify(new Notification("GraphQL", "Unable to perform introspection", "Please set a non-empty 'schemaPath' field. The introspection result will be written to that file.", NotificationType.WARNING), urlElement.getProject()); } return null; }
Example #8
Source File: LatteIdeHelper.java From intellij-latte with MIT License | 6 votes |
public static Notification doNotify( @NotNull String title, @NotNull @Nls(capitalization = Nls.Capitalization.Sentence) String content, @NotNull NotificationType type, @Nullable Project project, boolean important, @Nullable NotificationAction notificationAction ) { Notification notification = new Notification(NOTIFICATION_GROUP, title, content, type); notification.setImportant(important); if (notificationAction != null) { notification.addAction(notificationAction); } doNotify(notification, project); return notification; }
Example #9
Source File: WindowsDefenderFixAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@Nonnull AnActionEvent e, @Nonnull Notification notification) { int rc = Messages.showDialog(e.getProject(), DiagnosticBundle .message("virus.scanning.fix.explanation", ApplicationNamesInfo.getInstance().getFullProductName(), WindowsDefenderChecker.getInstance().getConfigurationInstructionsUrl()), DiagnosticBundle.message("virus.scanning.fix.title"), new String[]{DiagnosticBundle.message("virus.scanning.fix.automatically"), DiagnosticBundle.message("virus.scanning.fix.manually"), CommonBundle.getCancelButtonText()}, 0, null); switch (rc) { case Messages.OK: notification.expire(); ApplicationManager.getApplication().executeOnPooledThread(() -> { if (WindowsDefenderChecker.getInstance().runExcludePathsCommand(e.getProject(), myPaths)) { UIUtil.invokeLaterIfNeeded(() -> { Notifications.Bus.notifyAndHide(new Notification("System Health", "", DiagnosticBundle.message("virus.scanning.fix.success.notification"), NotificationType.INFORMATION), e.getProject()); }); } }); break; case Messages.CANCEL: BrowserUtil.browse(WindowsDefenderChecker.getInstance().getConfigurationInstructionsUrl()); break; } }
Example #10
Source File: NotificationsUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static HyperlinkListener wrapListener(@Nonnull final Notification notification) { final NotificationListener listener = notification.getListener(); if (listener == null) return null; return new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { final NotificationListener listener1 = notification.getListener(); if (listener1 != null) { listener1.hyperlinkUpdate(notification, e); } } } }; }
Example #11
Source File: BuckPluginNotifications.java From buck with Apache License 2.0 | 6 votes |
public static void notifyActionToolbar(final Project project) { if (!PropertiesComponent.getInstance().isValueSet(GROUP_DISPLAY_ID)) { Notifications.Bus.notify( new Notification( GROUP_DISPLAY_ID, "Buck Plugin", "<html><a href=''>Enable</a> the toolbar to easily access the buck plugin actions." + "<br>You can enable/disable it at any time by pressing on View > Toolbar " + "in the menu.</html>", NotificationType.INFORMATION, new NotificationListener() { @Override public void hyperlinkUpdate( @NotNull Notification notification, @NotNull HyperlinkEvent hyperlinkEvent) { BuckUIManager.getInstance(project).getBuckToolWindow().showMainToolbar(); } }), project); PropertiesComponent.getInstance().setValue(GROUP_DISPLAY_ID, "true"); } }
Example #12
Source File: MigrationsCondition.java From yiistorm with MIT License | 6 votes |
@Override public boolean value(Object o) { YiiStormProjectComponent component = YiiStormProjectComponent.getInstance((Project) o); Notifications.Bus.register("yiicnotfound", NotificationDisplayType.BALLOON); if (component.getBooleanProp("useYiiMigrations")) { boolean phpOk = CommonHelper.phpVersionCheck(); if (component.getProp("yiicFile").length() < 1) { Notifications.Bus.notify(new Notification("yiistormMigration", "YiiStorm migrations", "Yiic not selected ", NotificationType.WARNING)); return false; } if (component.getProp("yiicFile") != null && phpOk && Yiic.yiicIsRunnable(component.getProp("yiicFile"))) { return true; } else { Notifications.Bus.notify(new Notification("yiistormMigration", "YiiStorm migrations", phpOk ? "Yiic file not configured." : "Can't run php. Check your system configuration. ", NotificationType.WARNING)); } } return false; }
Example #13
Source File: LatteIndexUtil.java From intellij-latte with MIT License | 6 votes |
private static void tryPerformReadLock(Project[] projects, @NotNull Notification notification) { if (LatteIdeHelper.holdsReadLock()) { notification.expire(); showWaring(projects); return; } for (Project project : projects) { if (!reinitializeDefaultConfig(project)) { return; } } notification.expire(); LatteIdeHelper.doNotify("Latte plugin settings", "Configuration was reloaded", NotificationType.INFORMATION, null); }
Example #14
Source File: ConsoleLog.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public static void expireNotification(@NotNull Notification notification) { ConsoleLog consoleLog = getApplicationComponent(); if(consoleLog != null) { if(consoleLog.myModel != null) { consoleLog.myModel.removeNotification(notification); for(Project p : ProjectManager.getInstance().getOpenProjects()) { getProjectComponent(p).getMyProjectModel().removeNotification(notification); } } } }
Example #15
Source File: AddSourceToProjectHelper.java From intellij with Apache License 2.0 | 5 votes |
private static void notifyFailed(Project project, String message) { Notification notification = NOTIFICATION_GROUP.createNotification( "Failed to add source file to project", message, NotificationType.WARNING, /* listener= */ null); notification.notify(project); }
Example #16
Source File: RailwaysUtils.java From railways with MIT License | 5 votes |
/** * Internally used method that runs rake task and gets its output. This * method should be called from backgroundable task. * * @param module Rails module for which rake task should be run. * @return Output of 'rake routes'. */ @Nullable public static ProcessOutput queryRakeRoutes(Module module, String routesTaskName, String railsEnv) { // Get root path of Rails application from module. RailsApp app = RailsApp.fromModule(module); if ((app == null) || (app.getRailsApplicationRoot() == null)) return null; String moduleContentRoot = app.getRailsApplicationRoot().getPresentableUrl(); ModuleRootManager mManager = ModuleRootManager.getInstance(module); Sdk sdk = mManager.getSdk(); if (sdk == null) { Notifications.Bus.notify(new Notification("Railways", "Railways Error", "Cannot update route list for '" + module.getName() + "' module, because its SDK is not set", NotificationType.ERROR) , module.getProject()); return null; } try { railsEnv = (railsEnv == null) ? "" : "RAILS_ENV=" + railsEnv; // Will work on IntelliJ platform since 2017.3 return RubyGemExecutionContext.create(sdk, "rake") .withModule(module) .withWorkingDirPath(moduleContentRoot) .withExecutionMode(new ExecutionModes.SameThreadMode()) .withArguments(routesTaskName, "--trace", railsEnv) .executeScript(); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #17
Source File: GraphQLConfigManager.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private void createParseErrorNotification(VirtualFile file, Exception e) { Notifications.Bus.notify(new Notification("GraphQL", "Unable to parse " + file.getName(), "<a href=\"" + file.getUrl() + "\">" + file.getPresentableUrl() + "</a>: " + e.getMessage(), NotificationType.WARNING, (notification, event) -> { VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(event.getURL().toString()); if (virtualFile != null) { FileEditorManager.getInstance(myProject).openFile(virtualFile, true, true); } else { notification.expire(); } })); }
Example #18
Source File: UserMessage.java From p4ic4idea with Apache License 2.0 | 5 votes |
/** * Shows a notification. Can be invoked from any thread. * * @param project source project * @param message message to display to the user * @param title * @param icon */ public static void showNotification(@Nullable Project project, int level, @NotNull @Nls(capitalization = Nls.Capitalization.Sentence) String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull NotificationType icon) { if (UserProjectPreferences.isUserMessageLevel(project, level)) { Notification notification = createNotification(P4Vcs.VCS_NAME, title, message, icon, null, null); Notifications.Bus.notify(notification, project); } }
Example #19
Source File: AbstractLayoutCodeProcessor.java From consulo with Apache License 2.0 | 5 votes |
void handleFileTooBigException(Logger logger, FilesTooBigForDiffException e, @Nonnull PsiFile file) { logger.info("Error while calculating changed ranges for: " + file.getVirtualFile(), e); if (!ApplicationManager.getApplication().isUnitTestMode()) { Notification notification = new Notification(ApplicationBundle.message("reformat.changed.text.file.too.big.notification.groupId"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.title"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.text", file.getName()), NotificationType.INFORMATION); notification.notify(file.getProject()); } }
Example #20
Source File: Notifier.java From EclipseCodeFormatter with Apache License 2.0 | 5 votes |
public void notifyFailedFormatting(PsiFile psiFile, boolean formattedByIntelliJ, final String reason) { String content; if (!formattedByIntelliJ) { content = psiFile.getName() + " failed to format with Eclipse Code Formatter. " + reason + "\n"; } else { content = psiFile.getName() + " failed to format with IntelliJ code formatter.\n" + reason; } Notification notification = ProjectComponent.GROUP_DISPLAY_ID_ERROR.createNotification(content, NotificationType.ERROR); showNotification(notification, psiFile.getProject()); }
Example #21
Source File: KBNotification.java From KodeBeagle with Apache License 2.0 | 5 votes |
public Notification notifyInvasive(final String content, final NotificationType type) { expire(); prevNotification = notificationsInvasive.createNotification(RefreshActionBase.KODEBEAGLE, content, type, null); prevNotification.notify(windowObjects.getProject()); return prevNotification; }
Example #22
Source File: CreatePullRequestModel.java From azure-devops-intellij with MIT License | 5 votes |
private void notifySuccess(final Project project, final String title, final String message) { VcsNotifier.getInstance(project).notifyImportantInfo(title, message, new NotificationListener() { @Override public void hyperlinkUpdate(@NotNull final Notification n, @NotNull final HyperlinkEvent e) { BrowserUtil.browse(e.getURL()); } }); // Update the PR tab and any other UI that is listening for PR Changed events EventContextHelper.triggerPullRequestChanged(EventContextHelper.SENDER_CREATE_PULL_REQUEST, project); }
Example #23
Source File: RemoveDependencyAction.java From MavenHelper with Apache License 2.0 | 5 votes |
private void exclude() { DomFileElement domFileElement = getDomFileElement(myArtifact); if (domFileElement != null) { final MavenDomProjectModel rootElement = (MavenDomProjectModel) domFileElement.getRootElement(); final MavenDomDependencies dependencies = rootElement.getDependencies(); boolean found = false; for (MavenDomDependency mavenDomDependency : dependencies.getDependencies()) { if (isSameDependency(myArtifact.getArtifact(), mavenDomDependency)) { found = true; mavenDomDependency.undefine(); dependencyDeleted(); } } if (!found) { final Notification notification = new Notification(MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "", "Parent dependency not found, it is probably in the parent pom", NotificationType.WARNING); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Notifications.Bus.notify(notification, myProject); } }); } } }
Example #24
Source File: CommonUtil.java From svgtoandroid with MIT License | 5 votes |
public static void showTopic(Project project, String title, String content, NotificationType type) { project.getMessageBus().syncPublisher(Notifications.TOPIC).notify( new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, title, content, type)); }
Example #25
Source File: FlutterMessages.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void showWarning(String title, String message) { Notifications.Bus.notify( new Notification(FLUTTER_NOTIFICATION_GROUP_ID, title, message, NotificationType.WARNING)); }
Example #26
Source File: KBNotification.java From KodeBeagle with Apache License 2.0 | 5 votes |
public Notification notifyBalloon(final String content, final NotificationType type) { expire(); prevNotification = notifications.createNotification(RefreshActionBase.KODEBEAGLE, content, type, null); prevNotification.notify(windowObjects.getProject()); schedule(); return prevNotification; }
Example #27
Source File: JumpToAttachPointAction.java From needsmoredojo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { Editor editor = e.getData(PlatformDataKeys.EDITOR); PsiFile file = e.getData(LangDataKeys.PSI_FILE); if(editor == null || file == null) { return; } PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); if(element == null) { return; } PsiFile templateFile = new TemplatedWidgetUtil(file).findTemplatePath(); if(templateFile == null) { Notifications.Bus.notify(new Notification("needsmoredojo", "Jump To Attach Point", "No attach point found for " + element.getText(), NotificationType.INFORMATION)); return; } jumpToElementInTemplate(templateFile, element); }
Example #28
Source File: NotificationCenter.java From GsonFormat with Apache License 2.0 | 5 votes |
public static void sendNotification(String message, NotificationType notificationType) { if(message == null || message.trim().length()==0){ return; } Notification notification = new Notification("com.dim.plugin.Gsonformat", "Gsonformat ", espaceString(message), notificationType); Notifications.Bus.notify(notification); }
Example #29
Source File: WindowsDefenderCheckerActivity.java From consulo with Apache License 2.0 | 5 votes |
@Override public void runActivity(@Nonnull UIAccess uiAccess, @Nonnull Project project) { if(!Boolean.getBoolean("consulo.windows.defender.activity")) { return; } if (myApplication.isUnitTestMode()) { return; } WindowsDefenderChecker windowsDefenderChecker = myWindowsDefenderChecker.get(); if (windowsDefenderChecker.isVirusCheckIgnored(project)) { return; } WindowsDefenderChecker.CheckResult checkResult = windowsDefenderChecker.checkWindowsDefender(project); if (checkResult.status == WindowsDefenderChecker.RealtimeScanningStatus.SCANNING_ENABLED && ContainerUtil.any(checkResult.pathStatus, (it) -> !it.getValue())) { List<Path> nonExcludedPaths = checkResult.pathStatus.entrySet().stream().filter(it -> !it.getValue()).map(Map.Entry::getKey).collect(Collectors.toList()); WindowsDefenderNotification notification = new WindowsDefenderNotification( DiagnosticBundle.message("virus.scanning.warn.message", ApplicationNamesInfo.getInstance().getFullProductName(), StringUtil.join(nonExcludedPaths, "<br/>")), nonExcludedPaths); notification.setImportant(true); notification.setCollapseActionsDirection(Notification.CollapseActionsDirection.KEEP_LEFTMOST); windowsDefenderChecker.configureActions(project, notification); myApplication.invokeLater(() -> notification.notify(project)); } }
Example #30
Source File: NotificationsUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String buildHtml(@Nonnull final Notification notification, @Nullable String style) { String title = notification.getTitle(); String content = notification.getContent(); if (title.length() > TITLE_LIMIT || content.length() > CONTENT_LIMIT) { LOG.info("Too large notification " + notification + " of " + notification.getClass() + "\nListener=" + notification.getListener() + "\nTitle=" + title + "\nContent=" + content); title = StringUtil.trimLog(title, TITLE_LIMIT); content = StringUtil.trimLog(content, CONTENT_LIMIT); } return buildHtml(title, null, content, style, "#" + ColorUtil.toHex(getMessageType(notification).getTitleForeground()), null, null); }