com.intellij.notification.Notifications Java Examples

The following examples show how to use com.intellij.notification.Notifications. 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 vote down vote up
/**
 * 上传时检查到配置错误时通知
 *
 * @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: IncrementalSyncProjectAction.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static void showPopupNotification(Project project) {
  String message =
      String.format(
          "Some relevant files (e.g. BUILD files, .blazeproject file) "
              + "have changed since the last sync. "
              + "Please press the 'Sync' button in the toolbar to re-sync your %s project.",
          ApplicationNamesInfo.getInstance().getFullProductName());
  Notification notification =
      new Notification(
          NOTIFICATION_GROUP.getDisplayId(),
          String.format("Changes since last %s sync", Blaze.buildSystemName(project)),
          message,
          NotificationType.INFORMATION);
  notification.setImportant(true);
  Notifications.Bus.notify(notification, project);
}
 
Example #3
Source File: TimeTrackerService.java    From DarkyenusTimeTracker with The Unlicense 6 votes vote down vote up
private void nagAboutGitIntegrationIfNeeded() {
	if ((naggedAbout & TimeTrackerPersistentState.NAGGED_ABOUT_GIT_INTEGRATION) == 0 && !gitIntegration) {
		ApplicationManager.getApplication().invokeLater(() -> {
			final VirtualFile projectBaseDir = getProjectBaseDir(project());
			if (!gitIntegration && projectBaseDir != null && projectBaseDir.findChild(".git") != null) {
				Notifications.Bus.notify(NOTIFICATION_GROUP.createNotification(
						"Git repository detected",
						"Enable time tracker git integration?<br><a href=\"yes\">Yes</a> <a href=\"no\">No</a><br>You can change your mind later. Git integration will append time spent on commit into commit messages.",
						NotificationType.INFORMATION,
						(n, event) -> {
							if ("yes".equals(event.getDescription())) {
								setGitIntegration(true);
							} else if (!"no".equals(event.getDescription())) {
								return;
							}
							n.expire();
							setNaggedAbout(getNaggedAbout() | TimeTrackerPersistentState.NAGGED_ABOUT_GIT_INTEGRATION);
						}), project());
			}
		}, ModalityState.NON_MODAL);
	}
}
 
Example #4
Source File: Settings.java    From weex-language-support with MIT License 6 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
    try {
        PropertiesComponent.getInstance().setValue(KEY_RULES_PATH, rulesPath.getText());
        if (!TextUtils.isEmpty(rulesPath.getText())) {
            load(rulesPath.getText());
            DirectiveLint.prepare();
        } else {
            DirectiveLint.reset();
        }
    } catch (Exception e) {
        ProjectUtil.guessCurrentProject(select).getMessageBus().syncPublisher(Notifications.TOPIC).notify(
                new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
                        "Weex language support - bad rules",
                        e.toString(),
                        NotificationType.ERROR));
    }
    savePaths();
}
 
Example #5
Source File: GotoTestDataAction.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project != null) {
        DataContext dataContext = e.getDataContext();
        List<String> fileNames = findRelatedFiles(project, dataContext);
        if (fileNames.isEmpty()) {
            Notifications.Bus.notify(new ORNotification("testdata", "Found no testdata files", "Cannot find related files", INFORMATION, null), project);
            return;
        }

        Editor editor = e.getData(CommonDataKeys.EDITOR);
        JBPopupFactory popupFactory = JBPopupFactory.getInstance();
        RelativePoint point = editor == null ? popupFactory.guessBestPopupLocation(dataContext) : popupFactory.guessBestPopupLocation(editor);

        TestDataNavigationHandler.navigate(point, fileNames, project);
    }
}
 
Example #6
Source File: DuneProcess.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
@Nullable
public ProcessHandler recreate(@NotNull CliType cliType, @Nullable Compiler.ProcessTerminated onProcessTerminated) {
    try {
        killIt();
        GeneralCommandLine cli = getGeneralCommandLine((CliType.Dune) cliType);
        if (cli != null) {
            m_processHandler = new KillableColoredProcessHandler(cli);
            m_processHandler.addProcessListener(m_outputListener);
            if (onProcessTerminated != null) {
                m_processHandler.addProcessListener(new ProcessAdapter() {
                    @Override
                    public void processTerminated(@NotNull ProcessEvent event) {
                        onProcessTerminated.run();
                    }
                });
            }
        }
        return m_processHandler;
    } catch (ExecutionException e) {
        Notifications.Bus.notify(new ORNotification("Dune", "Can't run sdk\n" + e.getMessage(), ERROR));
        return null;
    }
}
 
Example #7
Source File: SdkDownloader.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
public void run(@Nullable Project project, @NotNull ProgressIndicator indicator) {
    String sdkFilename = "ocaml-" + m_sdk + ".tar.gz";
    File targetSdkLocation = new File(m_sdkHome, sdkFilename);
    String sdkUrl = "http://caml.inria.fr/pub/distrib/ocaml-" + m_major + "/" + sdkFilename;

    indicator.setIndeterminate(true);
    indicator.setText("Download sdk from " + sdkUrl);

    boolean isDownloaded = WGet.apply(sdkUrl, targetSdkLocation, indicator, -1.0);
    if (isDownloaded) {
        try {
            indicator.setText("uncompress sdk");
            File tarPath = uncompress(targetSdkLocation);
            FileUtil.delete(targetSdkLocation);
            indicator.setText("Untar sdk");
            new Decompressor.Tar(tarPath).filter(KEEP_OCAML_SOURCES).extract(m_sdkHome);
            FileUtil.delete(tarPath);
        } catch (IOException e) {
            Notifications.Bus.notify(new ORNotification("Sdk", "Cannot download sdk, error: " + e.getMessage(), ERROR, null), project);
        }
    }
}
 
Example #8
Source File: UploadNotification.java    From markdown-image-kit with MIT License 6 votes vote down vote up
/**
 * 上传失败通知, 可打开设置面板
 * 文件链接, 帮助链接, 设置链接
 * todo-dong4j : (2019年03月23日 15:14) [{@link com.intellij.openapi.fileTypes.impl.ApproveRemovedMappingsActivity}]
 *
 * @param e       the e
 * @param project the project
 */
public static void notifyUploadFailure(UploadException e, Project project) {
    String details = e.getMessage();
    String content = "<p><a href=\"\">Configure oss...</a></p>";
    if (StringUtil.isNotEmpty(details)) {
        content = "<p>" + details + "</p>" + content;
    }
    Notifications.Bus.notify(new Notification(MIK_NOTIFICATION_GROUP, "Upload Failured",
                                              content, NotificationType.ERROR,
                                              (notification, event) -> {
                                                  ProjectSettingsPage configurable = new ProjectSettingsPage();
                                                  // 打开设置面板
                                                  ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
                                                  // 点击超链接后关闭通知
                                                  if (event.getEventType().equals(HyperlinkEvent.EventType.ENTERED)) {
                                                      notification.hideBalloon();
                                                  }
                                              }), project);
}
 
Example #9
Source File: FlutterMessages.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showWarning(String title, String message) {
  Notifications.Bus.notify(
    new Notification(FLUTTER_NOTIFICATION_GROUP_ID,
                     title,
                     message,
                     NotificationType.WARNING));
}
 
Example #10
Source File: BsCompilerImpl.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private boolean isDisabled() {
    if (m_disabled == null) {
        m_disabled = Boolean.getBoolean("reasonBsbDisabled");
        if (m_disabled) {
            // Possible but you should NEVER do that
            Notifications.Bus.notify(new ORNotification("Bsb", "Bucklescript is disabled", NotificationType.WARNING));
        }
    }

    return m_disabled;
}
 
Example #11
Source File: FlutterMessages.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showInfo(String title, String message) {
  final Notification notification = new Notification(
    FLUTTER_NOTIFICATION_GROUP_ID,
    title,
    message,
    NotificationType.INFORMATION);
  notification.setIcon(FlutterIcons.Flutter);
  Notifications.Bus.notify(notification);
}
 
Example #12
Source File: ProjectOpenActivity.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void runActivity(@NotNull Project project) {
  // TODO(messick): Remove 'FlutterUtils.isAndroidStudio()' after Android Q sources are published.
  if (FlutterUtils.isAndroidStudio() && AndroidUtils.isAndroidProject(project)) {
    AndroidUtils.addGradleListeners(project);
  }
  if (!FlutterModuleUtils.declaresFlutter(project)) {
    return;
  }

  final FlutterSdk sdk = FlutterSdk.getIncomplete(project);
  if (sdk == null) {
    // We can't do anything without a Flutter SDK.
    return;
  }

  ApplicationManager.getApplication().executeOnPooledThread(() -> {
    sdk.queryFlutterConfig("android-studio-dir", false);
  });
  if (FlutterUtils.isAndroidStudio() && !FLUTTER_PROJECT_TYPE.equals(ProjectTypeService.getProjectType(project))) {
    if (!AndroidUtils.isAndroidProject(project)) {
      ProjectTypeService.setProjectType(project, FLUTTER_PROJECT_TYPE);
    }
  }

  // If this project is intended as a bazel project, don't run the pub alerts.
  if (WorkspaceCache.getInstance(project).isBazel()) {
    return;
  }

  for (PubRoot pubRoot : PubRoots.forProject(project)) {
    if (!pubRoot.hasUpToDatePackages()) {
      Notifications.Bus.notify(new PackagesOutOfDateNotification(project, pubRoot));
    }
  }
}
 
Example #13
Source File: NotificationUtils.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * show a Notification
 *
 * @param message
 * @param type
 */
public static void showNotification(final String message,
                                    final NotificationType type) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            Notification notification =
                    NOTIFICATION_GROUP.createNotification(TITLE, message, type, null);
            Notifications.Bus.notify(notification);
        }
    });
}
 
Example #14
Source File: ExceptionRenderer.java    From GitLink with MIT License 5 votes vote down vote up
public void render(@NotNull final GitLinkException exception) {
    Notifications.Bus.notify(new Notification(
        plugin.displayName(),
        plugin.toString(),
        exception.getMessage(),
        NotificationType.ERROR
    ));
}
 
Example #15
Source File: Notify.java    From WIFIADB with Apache License 2.0 5 votes vote down vote up
private static void notify(final Notification notification){
    Executor.post(new Runnable() {
        @Override
        public void run() {
            Notifications.Bus.notify(notification);
        }
    });
}
 
Example #16
Source File: OpenAction.java    From AndroidGodEye with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    try {
        Project project = anActionEvent.getProject();
        String path = parseAndroidSDKPath(Objects.requireNonNull(project));
        if (TextUtils.isEmpty(path)) {
            Notifications.Bus.notify(new Notification("AndroidGodEye", "Open AndroidGodEye Failed", "Can not parse sdk.dir, Please add 'sdk.dir' to 'local.properties'.", NotificationType.ERROR));
            return;
        }
        mLogger.info("Current os name is " + SystemUtils.OS_NAME);
        String adbPath = String.format("%s/platform-tools/adb", path);
        mLogger.info("ADB path is " + adbPath);
        String parsedPort = parsePortByLogcatWithTimeout(project, adbPath);
        mLogger.info("Parse AndroidGodEye port is running at " + parsedPort);
        String inputPort = askForPort(project, parsedPort, getSavedPort(project));
        if (inputPort == null) {
            mLogger.warn("inputPort == null");
            return;
        }
        saveDefaultPort(project, inputPort);
        final String commandTcpProxy = String.format("%s forward tcp:%s tcp:%s", adbPath, inputPort, inputPort);
        mLogger.info("Exec [" + commandTcpProxy + "].");
        Runtime.getRuntime().exec(commandTcpProxy);
        String commandOpenUrl;
        if (SystemUtils.IS_OS_WINDOWS) {
            commandOpenUrl = String.format("cmd /c start http://localhost:%s/index.html", inputPort);
        } else {
            commandOpenUrl = String.format("open http://localhost:%s/index.html", inputPort);
        }
        mLogger.info("Exec [" + commandOpenUrl + "].");
        Runtime.getRuntime().exec(commandOpenUrl);
        Notifications.Bus.notify(new Notification("AndroidGodEye", "Open AndroidGodEye Success", String.format("http://localhost:%s/index.html", inputPort), NotificationType.INFORMATION));
    } catch (Throwable e) {
        mLogger.warn(e);
        Notifications.Bus.notify(new Notification("AndroidGodEye", "Open AndroidGodEye Failed", String.valueOf(e), NotificationType.ERROR));
    }
}
 
Example #17
Source File: Copy.java    From sourcegraph-jetbrains with Apache License 2.0 5 votes vote down vote up
@Override
void handleFileUri(String uri) {
    // Copy file uri to clipboard
    CopyPasteManager.getInstance().setContents(new StringSelection(uri));

    // Display bubble
    Notification notification = new Notification("Sourcegraph", "Sourcegraph",
            "File URL copied to clipboard.", NotificationType.INFORMATION);
    Notifications.Bus.notify(notification);
}
 
Example #18
Source File: SwaggerFileService.java    From intellij-swagger with MIT License 5 votes vote down vote up
private void notifyFailure(final Exception exception) {
  Notification notification =
      new Notification(
          "Swagger UI",
          "Could not generate Swagger UI",
          exception.getMessage(),
          NotificationType.WARNING);

  Notifications.Bus.notify(notification);
}
 
Example #19
Source File: IdeHelper.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
/**
 * @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 #20
Source File: FlutterMessages.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showError(String title, String message) {
  Notifications.Bus.notify(
    new Notification(FLUTTER_NOTIFICATION_GROUP_ID,
                     title,
                     message,
                     NotificationType.ERROR));
}
 
Example #21
Source File: ProjectOpenActivity.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void runActivity(@NotNull Project project) {
  // TODO(messick): Remove 'FlutterUtils.isAndroidStudio()' after Android Q sources are published.
  if (FlutterUtils.isAndroidStudio() && AndroidUtils.isAndroidProject(project)) {
    AndroidUtils.addGradleListeners(project);
  }
  if (!FlutterModuleUtils.declaresFlutter(project)) {
    return;
  }

  final FlutterSdk sdk = FlutterSdk.getIncomplete(project);
  if (sdk == null) {
    // We can't do anything without a Flutter SDK.
    return;
  }

  ApplicationManager.getApplication().executeOnPooledThread(() -> {
    sdk.queryFlutterConfig("android-studio-dir", false);
  });
  if (FlutterUtils.isAndroidStudio() && !FLUTTER_PROJECT_TYPE.equals(ProjectTypeService.getProjectType(project))) {
    if (!AndroidUtils.isAndroidProject(project)) {
      ProjectTypeService.setProjectType(project, FLUTTER_PROJECT_TYPE);
    }
  }

  // If this project is intended as a bazel project, don't run the pub alerts.
  if (WorkspaceCache.getInstance(project).isBazel()) {
    return;
  }

  for (PubRoot pubRoot : PubRoots.forProject(project)) {
    if (!pubRoot.hasUpToDatePackages()) {
      Notifications.Bus.notify(new PackagesOutOfDateNotification(project, pubRoot));
    }
  }
}
 
Example #22
Source File: FlutterMessages.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showInfo(String title, String message) {
  final Notification notification = new Notification(
    FLUTTER_NOTIFICATION_GROUP_ID,
    title,
    message,
    NotificationType.INFORMATION);
  notification.setIcon(FlutterIcons.Flutter);
  Notifications.Bus.notify(notification);
}
 
Example #23
Source File: FlutterMessages.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showWarning(String title, String message) {
  Notifications.Bus.notify(
    new Notification(FLUTTER_NOTIFICATION_GROUP_ID,
                     title,
                     message,
                     NotificationType.WARNING));
}
 
Example #24
Source File: FlutterMessages.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void showError(String title, String message) {
  Notifications.Bus.notify(
    new Notification(FLUTTER_NOTIFICATION_GROUP_ID,
                     title,
                     message,
                     NotificationType.ERROR));
}
 
Example #25
Source File: NotificationHelper.java    From ADB-Duang with MIT License 5 votes vote down vote up
public static void sendNotification(String message, NotificationType notificationType, NotificationListener notificationListener) {
	Notification notification = new Notification("com.dim.plugin.adbduang",
			"ADB Duang ",
			espaceString(message),
			notificationType,notificationListener);
	Notifications.Bus.notify(notification);
}
 
Example #26
Source File: NotificationHelper.java    From ADB-Duang with MIT License 5 votes vote down vote up
public static void sendNotification(String message, NotificationType notificationType) {
	Notification notification = new Notification("com.dim.plugin.adbduang",
	                                             "ADB Duang ",
	                                             espaceString(message),
	                                             notificationType);
	Notifications.Bus.notify(notification);
}
 
Example #27
Source File: MuleSchemaProvider.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getLocations(@NotNull @NonNls final String namespace, @NotNull final XmlFile context) throws ProcessCanceledException {
    Set<String> locations = new HashSet<>();
    final Module module = ModuleUtil.findModuleForPsiElement(context);
    if (module == null) {
        return null;
    }
    try {
        final Map<String, XmlFile> schemas = getSchemas(module);
        for (Map.Entry<String, XmlFile> entry : schemas.entrySet()) {
            final String s = getNamespace(entry.getValue(), context.getProject());
            if (s != null && s.equals(namespace)) {
                if (!entry.getKey().contains("mule-httpn.xsd")) {
                    locations.add(entry.getKey()); //Observe the formatting rules
                    XmlFile schemaFile = entry.getValue();
                    try {
                        String url = schemaFile.getVirtualFile().getUrl();
                        if (url != null) {
                            if (url.startsWith("jar://"))
                                url = url.substring(6);
                            ExternalResourceManager.getInstance().addResource(namespace, url);
                        }
                    } catch (Throwable ex) {
                        Notifications.Bus.notify(new Notification("Schema Provider", "Schema Provider", ex.toString(),
                                NotificationType.ERROR));
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return locations;
}
 
Example #28
Source File: MessageUtil.java    From weex-language-support with MIT License 5 votes vote down vote up
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 #29
Source File: UploadNotification.java    From markdown-image-kit with MIT License 5 votes vote down vote up
/**
 * 上传完成后通知
 *
 * @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 #30
Source File: MikNotification.java    From markdown-image-kit with MIT License 5 votes vote down vote up
/**
 * Notify compress info.
 *
 * @param project the project
 */
public static void notifyCompressInfo(Project project, Map<String, String> compressInfo) {
    StringBuilder content = new StringBuilder();
    for(Map.Entry<String, String> entry : compressInfo.entrySet()){
        content.append("<p>").append(entry.getKey()).append("\t\t\t").append(entry.getValue()).append("</p>");
    }
    Notifications.Bus.notify(new Notification(MIK_NOTIFICATION_NONE_GROUP,
                                              "<p>Compress Finished: </p>",
                                              content.toString(),
                                              NotificationType.INFORMATION), project);

}