Java Code Examples for com.intellij.notification.Notification#expire()

The following examples show how to use com.intellij.notification.Notification#expire() . 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 Project: intellij-latte   File: LatteIndexUtil.java    License: MIT License 6 votes vote down vote up
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 2
Source Project: consulo   File: DvcsBranchPopup.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: consulo   File: VcsRootProblemNotifier.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void hyperlinkActivated(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
  if (event.getDescription().equals("configure") && !myProject.isDisposed()) {
    ShowSettingsUtil.getInstance().showSettingsDialog(myProject, ActionsBundle.message("group.VcsGroup.text"));
    Collection<VcsRootError> errorsAfterPossibleFix = getInstance(myProject).scan();
    if (errorsAfterPossibleFix.isEmpty() && !notification.isExpired()) {
      notification.expire();
    }
  }
  else if (event.getDescription().equals("ignore")) {
    mySettings.addIgnoredUnregisteredRoots(ContainerUtil.map(myImportantUnregisteredRoots, PATH_FROM_ROOT_ERROR));
    notification.expire();
  }
  else if (event.getDescription().equals("add")) {
    List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings();
    for (VcsRootError root : myImportantUnregisteredRoots) {
      mappings = VcsUtil.addMapping(mappings, root.getMapping(), root.getVcsKey().getName());
    }
    myVcsManager.setDirectoryMappings(mappings);
  }
}
 
Example 4
@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 5
public void actionPerformed(final AnActionEvent e) {
    ConsoleLogModel model = myConsole.myProjectModel;
    for (Notification notification : model.getNotifications()) {
        notification.expire();
        model.removeNotification(notification);
    }
    model.setStatusMessage(null, 0);
    final Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (editor != null) {
        editor.getDocument().deleteString(0, editor.getDocument().getTextLength());
    }
}
 
Example 6
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
  if (HREF_REFRESH.equals(event.getDescription())) {
    PantsUtil.refreshAllProjects(project);
  }

  notification.expire();
}
 
Example 7
/**
 * Shows the settings dialog when the user presses "configure" on a balloon.
 */
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        if (event.getDescription().equals("configureHaskellTools") && !myProject.isDisposed()) {
            ShowSettingsUtil.getInstance().showSettingsDialog(myProject, HaskellToolsConfigurable.HASKELL_TOOLS_ID);
            notification.expire();
        }
    }
}
 
Example 8
Source Project: consulo   File: JBViewport.java    License: Apache License 2.0 5 votes vote down vote up
private static Notification notify(String message) {
  Notification notification = NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION);
  notification.notify(null);

  Timer timer = new Timer(NOTIFICATION_TIMEOUT, event -> notification.expire());
  timer.setRepeats(false);
  timer.start();

  return notification;
}
 
Example 9
Source Project: consulo   File: ShowFilePathAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void hyperlinkActivated(@Nonnull Notification notification, @Nonnull HyperlinkEvent e) {
  URL url = e.getURL();
  if (url != null) {
    try {
      openFile(new File(url.toURI()));
    }
    catch (URISyntaxException ex) {
      LOG.warn("invalid URL: " + url, ex);
    }
  }
  notification.expire();
}