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: 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 #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: 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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
Source File: ShowLockInfoTask.java From SVNToolBox with Apache License 2.0 | 5 votes |
private Notification createNoLockNotification() { return SvnToolBoxApp.NOTIFICATION.createNotification( getString("configurable.app.svnlock.noinfo.title"), getString("configurable.app.svnlock.noinfo.content"), NotificationType.INFORMATION, null ); }
Example #16
Source File: PantsMakeBeforeRun.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private void notify(final String title, final String subtitle, NotificationType type) { /* Show pop up notification about pants compile result. */ ApplicationManager.getApplication().invokeLater(() -> { Notification start = new Notification(PantsConstants.PANTS, PantsIcons.Icon, title, subtitle, null, type, null); Notifications.Bus.notify(start); }); }
Example #17
Source File: UploadNotification.java From markdown-image-kit with MIT License | 5 votes |
/** * Notify upload failure. * * @param fileNotFoundListMap the file not found list map * @param uploadFailuredListMap the upload failured list map * @param project the project */ public static void notifyUploadFailure(Map<VirtualFile, List<String>> fileNotFoundListMap, Map<VirtualFile, List<String>> uploadFailuredListMap, Project project) { StringBuilder content = new StringBuilder(); StringBuilder fileNotFoundContent = new StringBuilder(); StringBuilder uploadFailuredContent = new StringBuilder(); if (fileNotFoundListMap.size() > 0) { buildContent(fileNotFoundListMap, fileNotFoundContent, "Image Not Found:"); } if (uploadFailuredListMap.size() > 0) { buildContent(uploadFailuredListMap, uploadFailuredContent, "Image Upload Failured:"); } content.append(fileNotFoundContent).append(uploadFailuredContent); Notifications.Bus.notify(new Notification(MIK_NOTIFICATION_GROUP, "Upload Warning", content.toString(), NotificationType.WARNING, new NotificationListener.Adapter() { @Override protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) { URL url = e.getURL(); if (url != null) { try { ShowFilePathAction.openFile(new File(url.toURI())); } catch (URISyntaxException ex) { log.warn("invalid URL: " + url, ex); } } hideBalloon(notification.getBalloon()); } }), project); }
Example #18
Source File: UploadNotification.java From markdown-image-kit with MIT License | 5 votes |
/** * 上传完成后通知 * * @param content the content */ public static void notifyUploadFinshed(String content) { Notification notification = new Notification(MIK_NOTIFICATION_GROUP, null, NotificationType.INFORMATION); notification.setTitle(UPLOAD_FINSHED); // 可使用 HTML 标签 notification.setContent(content); Notifications.Bus.notify(notification); }
Example #19
Source File: ReadonlyStatusIsVisibleActivationCheck.java From consulo with Apache License 2.0 | 5 votes |
public static void check(final Project project, final String vcsName) { if (SystemInfo.isUnix && "root".equals(System.getenv("USER"))) { Notifications.Bus.notify(new Notification(vcsName, vcsName + ": can not see read-only status", "You are logged as <b>root</b>, that's why:<br><br>- " + ApplicationNamesInfo.getInstance().getFullProductName() + " can not see read-only status of files.<br>" + "- All files are treated as writeable.<br>- Automatic file checkout on modification is impossible.", NotificationType.WARNING), project); } }
Example #20
Source File: OSSRefreshPromptIntegrationTest.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
public void testNoRefreshPromptPantsd() throws Throwable { doImport("examples/tests/java/org/pantsbuild/example/useproto"); String workdir = Paths.get(this.getProjectPath()).relativize(Paths.get(myProjectRoot.getPath())).toString() + "/.pants.d/"; createProjectSubDir(workdir); VirtualFile buildHtml = createProjectSubFile(workdir + "build.html"); ApplicationManager.getApplication().runWriteAction(() -> { withSelectedEditor(buildHtml, editor -> { editor.getDocument().setText(editor.getDocument().getText() + "\n"); FileDocumentManager.getInstance().saveAllDocuments(); }); ArrayList<Notification> notifications = EventLog.getLogModel(myProject).getNotifications(); notifications.forEach(notification -> assertNotSame(notification.getTitle(), NOTIFICATION_TITLE)); }); }
Example #21
Source File: AnnotateDiffViewerAction.java From consulo with Apache License 2.0 | 5 votes |
private static void doAnnotate(@Nonnull final ViewerAnnotator annotator) { final DiffViewerBase viewer = annotator.getViewer(); final Project project = viewer.getProject(); if (project == null) return; final FileAnnotationLoader loader = annotator.createAnnotationsLoader(); if (loader == null) return; final DiffContextEx diffContext = ObjectUtils.tryCast(viewer.getContext(), DiffContextEx.class); annotator.getBackgroundableLock().lock(); if (diffContext != null) diffContext.showProgressBar(true); BackgroundTaskUtil.executeOnPooledThread(viewer, () -> { try { loader.run(); } finally { ApplicationManager.getApplication().invokeLater(() -> { if (diffContext != null) diffContext.showProgressBar(false); annotator.getBackgroundableLock().unlock(); VcsException exception = loader.getException(); if (exception != null) { Notification notification = VcsNotifier.IMPORTANT_ERROR_NOTIFICATION.createNotification("Can't Load Annotations", exception.getMessage(), NotificationType.ERROR, null); showNotification(viewer, notification); LOG.warn(exception); return; } if (loader.getResult() == null) return; if (viewer.isDisposed()) return; annotator.showAnnotation(loader.getResult()); }, ProgressManager.getGlobalProgressIndicator().getModalityState()); } }); }
Example #22
Source File: AnnotateDiffViewerAction.java From consulo with Apache License 2.0 | 5 votes |
private static void showNotification(@Nonnull DiffViewerBase viewer, @Nonnull Notification notification) { JComponent component = viewer.getComponent(); Window awtWindow = UIUtil.getWindow(component); if (awtWindow != null) { consulo.ui.Window uiWindow = TargetAWT.from(awtWindow); IdeFrame ideFrame = uiWindow.getUserData(IdeFrame.KEY); if (ideFrame != null && NotificationsManagerImpl.findWindowForBalloon(viewer.getProject()) == awtWindow) { notification.notify(viewer.getProject()); return; } } Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true, null, viewer); Dimension componentSize = component.getSize(); Dimension balloonSize = balloon.getPreferredSize(); int width = Math.min(balloonSize.width, componentSize.width); int height = Math.min(balloonSize.height, componentSize.height); // top-right corner, 20px to the edges RelativePoint point = new RelativePoint(component, new Point(componentSize.width - 20 - width / 2, 20 + height / 2)); balloon.show(point, Balloon.Position.above); }
Example #23
Source File: IdeNotificationArea.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess private void updateStatus() { final Project project = getProject(); ArrayList<Notification> notifications = EventLog.getLogModel(project).getNotifications(); applyIconToStatusAndToolWindow(project, createIconWithNotificationCount(notifications)); int count = notifications.size(); myLabel.setToolTipText(count > 0 ? String.format("%s notification%s pending", count, count == 1 ? "" : "s") : "No new notifications"); myStatusBar.updateWidget(ID()); }
Example #24
Source File: ConsoleLogModel.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
void logShown() { for (Notification notification : getNotifications()) { if (!notification.isImportant()) { removeNotification(notification); } } setStatusToImportant(); }
Example #25
Source File: LatteIdeHelper.java From intellij-latte with MIT License | 5 votes |
public static void doNotify(Notification notification, @Nullable Project project) { if (project != null && !project.isDisposed() && !project.isDefault()) { project.getMessageBus().syncPublisher(Notifications.TOPIC).notify(notification); } else { Application app = ApplicationManager.getApplication(); if (!app.isDisposed()) { app.getMessageBus().syncPublisher(Notifications.TOPIC).notify(notification); } } }
Example #26
Source File: IdeHelper.java From yiistorm with MIT License | 5 votes |
public static void showNotification(String message, NotificationType type, @Nullable Project project) { final MessageBus messageBus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus(); final Notification notification = new Notification("Notification", "Notification", message, type, null); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { messageBus.syncPublisher(Notifications.TOPIC).notify(notification); } }); }
Example #27
Source File: IdeHelper.java From idea-php-typo3-plugin with MIT License | 5 votes |
/** * @author Daniel Espendiller <[email protected]> */ public static void notifyEnableMessage(final Project project) { Notification notification = new Notification( "TYPO3 CMS Plugin", "TYPO3 CMS Plugin", "Enable the TYPO3 CMS Plugin <a href=\"enable\">with auto configuration now</a>, open <a href=\"config\">Project Settings</a> or <a href=\"dismiss\">dismiss</a> further messages", NotificationType.INFORMATION, (notification1, event) -> { // handle html click events if ("config".equals(event.getDescription())) { // open settings dialog and show panel TYPO3CMSProjectSettings.showSettings(project); } else if ("enable".equals(event.getDescription())) { enablePluginAndConfigure(project); Notifications.Bus.notify(new Notification("TYPO3 CMS Plugin", "TYPO3 CMS Plugin", "Plugin enabled", NotificationType.INFORMATION), project); } else if ("dismiss".equals(event.getDescription())) { // user doesn't want to show notification again TYPO3CMSProjectSettings.getInstance(project).dismissEnableNotification = true; } notification1.expire(); } ); Notifications.Bus.notify(notification, project); }
Example #28
Source File: ConsoleLogModel.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
void addNotification(Notification notification) { long stamp = System.currentTimeMillis(); if(myProject != null) { SlingServerTreeSelectionHandler selectionHandler = ComponentProvider.getComponent(myProject, SlingServerTreeSelectionHandler.class); if(selectionHandler != null) { ServerConfiguration serverConfiguration = selectionHandler.getCurrentConfiguration(); ServerConfiguration.LogFilter logFilter = serverConfiguration != null ? serverConfiguration.getLogFilter() : ServerConfiguration.LogFilter.info; switch(logFilter) { case debug: add(notification); break; case info: if(!(notification instanceof DebugNotification)) { add(notification); } break; case warning: if(notification.getType() != NotificationType.INFORMATION) { add(notification); } break; case error: default: if(notification.getType() == NotificationType.ERROR) { add(notification); } break; } } myStamps.put(notification, stamp); myStatuses.put(notification, ConsoleLog.formatForLog(notification, "").status); setStatusMessage(notification, stamp); fireModelChanged(); } }
Example #29
Source File: LatteIndexUtil.java From intellij-latte with MIT License | 5 votes |
public static Notification notifyReparseFiles(Project project) { return LatteIdeHelper.doNotify( "Latte configuration reloaded", "Latte plugin detected latte-intellij.xml file. Latte files need reparse.", NotificationType.WARNING, project, true, new NotificationAction("Reparse Latte Files") { @Override public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification current) { tryPerform(new Project[]{project}, current); } } ); }
Example #30
Source File: AzureDevOpsNotifications.java From azure-devops-intellij with MIT License | 5 votes |
public static void showManageRemoteUrlsNotification(@NotNull Project project, @NotNull String hostName) { Notification notification = AZURE_DEVOPS_NOTIFICATIONS.createNotification( TfPluginBundle.message(TfPluginBundle.KEY_GIT_NOTIFICATION_REMOTE, hostName), MessageType.ERROR); GitConfigureRemotesAction gitConfigureRemotesAction = new GitConfigureRemotesAction(); gitConfigureRemotesAction.getTemplatePresentation().setText( TfPluginBundle.message(TfPluginBundle.KEY_GIT_CONFIGURE_REMOTES)); notification.addAction(gitConfigureRemotesAction); Notifications.Bus.notify(notification, project); }