com.intellij.notification.NotificationGroup Java Examples

The following examples show how to use com.intellij.notification.NotificationGroup. 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: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Notification showRunNotification(@NotNull FlutterApp app, @Nullable String title, @NotNull String content, boolean isError) {
  final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
  final NotificationGroup notificationGroup = getNotificationGroup(toolWindowId);
  final Notification notification;
  if (title == null) {
    notification = notificationGroup.createNotification(content, isError ? NotificationType.ERROR : NotificationType.INFORMATION);
  }
  else {
    notification =
      notificationGroup.createNotification(title, content, isError ? NotificationType.ERROR : NotificationType.INFORMATION, null);
  }
  notification.setIcon(FlutterIcons.Flutter);
  notification.notify(myProject);

  lastNotification = notification;

  return notification;
}
 
Example #2
Source File: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Notification showRunNotification(@NotNull FlutterApp app, @Nullable String title, @NotNull String content, boolean isError) {
  final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
  final NotificationGroup notificationGroup = getNotificationGroup(toolWindowId);
  final Notification notification;
  if (title == null) {
    notification = notificationGroup.createNotification(content, isError ? NotificationType.ERROR : NotificationType.INFORMATION);
  }
  else {
    notification =
      notificationGroup.createNotification(title, content, isError ? NotificationType.ERROR : NotificationType.INFORMATION, null);
  }
  notification.setIcon(FlutterIcons.Flutter);
  notification.notify(myProject);

  lastNotification = notification;

  return notification;
}
 
Example #3
Source File: NotificationParentGroup.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static NotificationParentGroupBean findParent(@Nonnull NotificationSettings setting) {
  prepareInfo();

  String groupId = setting.getGroupId();
  NotificationGroup group = NotificationGroup.findRegisteredGroup(groupId);
  NotificationParentGroupBean parent;

  if (group == null) {
    parent = myGroupToParent.get(groupId);
  }
  else {
    String parentId = group.getParentId();
    if (parentId == null) {
      parent = myGroupToParent.get(group.getDisplayId());
      if (parent != null) {
        group.setParentId(parent.id);
      }
    }
    else {
      parent = myParents.get(parentId);
    }
  }

  return parent;
}
 
Example #4
Source File: LombokPluginUpdateActivity.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void runActivity(@NotNull Project project) {
  final LombokSettings settings = LombokSettings.getInstance();
  boolean updated = !Version.PLUGIN_VERSION.equals(settings.getVersion());
  if (updated) {
    settings.setVersion(Version.PLUGIN_VERSION);

    NotificationGroup group = new NotificationGroup(Version.PLUGIN_NAME, NotificationDisplayType.STICKY_BALLOON, true);
    Notification notification = group.createNotification(
      LombokBundle.message("daemon.donate.title", Version.PLUGIN_VERSION),
      LombokBundle.message("daemon.donate.content"),
      NotificationType.INFORMATION,
      new NotificationListener.UrlOpeningListener(false)
    );

    Notifications.Bus.notify(notification, project);
  }
}
 
Example #5
Source File: AnalyzeDependenciesOnSpecifiedTargetHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean shouldShowDependenciesPanel(List<DependenciesBuilder> builders) {
  for (DependenciesBuilder builder : builders) {
    for (Set<PsiFile> files : builder.getDependencies().values()) {
      if (!files.isEmpty()) {
        return true;
      }
    }
  }
  final String source = StringUtil.decapitalize(builders.get(0).getScope().getDisplayName());
  final String target = StringUtil.decapitalize(myTargetScope.getDisplayName());
  final String message = AnalysisScopeBundle.message("no.dependencies.found.message", source, target);
  NotificationGroup.toolWindowGroup("Dependencies", ToolWindowId.DEPENDENCIES, true).createNotification(message, MessageType.INFO).notify(myProject);
  return false;
}
 
Example #6
Source File: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static NotificationGroup getNotificationGroup(String toolWindowId) {
  if (!toolWindowNotificationGroups.containsKey(toolWindowId)) {
    final NotificationGroup notificationGroup = NotificationGroup.toolWindowGroup("Flutter " + toolWindowId, toolWindowId, false);
    toolWindowNotificationGroups.put(toolWindowId, notificationGroup);
  }

  return toolWindowNotificationGroups.get(toolWindowId);
}
 
Example #7
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void register(@Nonnull String groupDisplayName, @Nonnull NotificationDisplayType displayType, boolean shouldLog, boolean shouldReadAloud) {
  if (!isRegistered(groupDisplayName)) {
    // register a new group and remember these settings as default
    new NotificationGroup(groupDisplayName, displayType, shouldLog);
    // and decide whether to save them explicitly (in case of non-default shouldReadAloud)
    changeSettings(groupDisplayName, displayType, shouldLog, shouldReadAloud);
  }
  else if (displayType == NotificationDisplayType.TOOL_WINDOW && !hasToolWindowCapability(groupDisplayName)) {
    // the first time with tool window capability
    changeSettings(getSettings(groupDisplayName).withDisplayType(NotificationDisplayType.TOOL_WINDOW));
    myToolWindowCapable.put(groupDisplayName, null);
  }
}
 
Example #8
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static NotificationSettings getDefaultSettings(String groupId) {
  NotificationGroup group = NotificationGroup.findRegisteredGroup(groupId);
  if (group != null) {
    return new NotificationSettings(groupId, group.getDisplayType(), group.isLogByDefault(), false);
  }
  return new NotificationSettings(groupId, NotificationDisplayType.BALLOON, true, false);
}
 
Example #9
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public synchronized NotificationSettings[] getAllSettings() {
  Collection<NotificationSettings> settings = new THashSet<NotificationSettings>(myIdToSettingsMap.values());
  for (NotificationGroup group : NotificationGroup.getAllRegisteredGroups()) {
    settings.add(getSettings(group.getDisplayId()));
  }
  NotificationSettings[] result = settings.toArray(new NotificationSettings[settings.size()]);
  Arrays.sort(result, NOTIFICATION_SETTINGS_COMPARATOR);
  return result;
}
 
Example #10
Source File: GtNotifierImpl.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
@NotNull
private Notification notify(@NotNull NotificationGroup notificationGroup,
                            @NotNull String title,
                            @NotNull String message,
                            @NotNull NotificationType type,
                            @Nullable NotificationListener listener) {
  Notification notification = createNotification(notificationGroup, title, message, type, listener);
  return notify(notification);
}
 
Example #11
Source File: GtNotifierImpl.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
@NotNull
private Notification createNotification(@NotNull NotificationGroup notificationGroup,
                                        @NotNull String title,
                                        @NotNull String message,
                                        @NotNull NotificationType type,
                                        @Nullable NotificationListener listener) {
  // title can be empty; message can't be neither null, nor empty
  if (StringUtil.isEmptyOrSpaces(message)) {
    message = title;
    title = "";
  }
  // if both title and message were empty, then it is a problem in the calling code =>
  // Notifications engine assertion will notify.
  return notificationGroup.createNotification(title, message, type, listener);
}
 
Example #12
Source File: ProtostuffPluginController.java    From protobuf-jetbrains-plugin with Apache License 2.0 5 votes vote down vote up
private void askUserToDisablePlugins(Collection<IdeaPluginDescriptor> conflictingPlugins) {
    final String text = formatMessage(conflictingPlugins);
    NotificationGroup ng = NotificationGroup.balloonGroup("Conflicting Plugins");
    ng.createNotification(PLUGIN_NAME, text, NotificationType.WARNING,
            (notification, event) -> {
                if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    for (IdeaPluginDescriptor foreignPlugin : conflictingPlugins) {
                        PluginManager.disablePlugin(foreignPlugin.getPluginId().toString());
                    }
                    Application application = ApplicationManager.getApplication();
                    application.restart();
                }
            }).notify(project);
}
 
Example #13
Source File: FlutterReloadManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static NotificationGroup getNotificationGroup(String toolWindowId) {
  if (!toolWindowNotificationGroups.containsKey(toolWindowId)) {
    final NotificationGroup notificationGroup = NotificationGroup.toolWindowGroup("Flutter " + toolWindowId, toolWindowId, false);
    toolWindowNotificationGroups.put(toolWindowId, notificationGroup);
  }

  return toolWindowNotificationGroups.get(toolWindowId);
}
 
Example #14
Source File: AbstractExternalSystemToolWindowFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected AbstractExternalSystemToolWindowFactory(@Nonnull ProjectSystemId id) {
  myExternalSystemId = id;
  myNotificationGroup = NotificationGroup.toolWindowGroup("notification.group.id." + id.toString().toLowerCase(),
                                                          myExternalSystemId.getReadableName(),
                                                          true);
}
 
Example #15
Source File: ExternalSystemTasksPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ExternalSystemTasksPanel(@Nonnull Project project,
                                @Nonnull ProjectSystemId externalSystemId,
                                @Nonnull NotificationGroup notificationGroup)
{
  super(true);
  myExternalSystemId = externalSystemId;
  myNotificationGroup = notificationGroup;
  myProject = project;

  ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
  assert manager != null;
  AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);

  ExternalSystemRecentTaskListModel recentTasksModel = new ExternalSystemRecentTaskListModel(externalSystemId, project);
  recentTasksModel.setTasks(settings.getRecentTasks());
  myRecentTasksList = new ExternalSystemRecentTasksList(recentTasksModel, externalSystemId, project) {
    @Override
    protected void processMouseEvent(MouseEvent e) {
      if (e.getClickCount() > 0) {
        mySelectedTaskProvider = myRecentTasksList;
        myAllTasksTree.getSelectionModel().clearSelection();
      }
      super.processMouseEvent(e);
    }
  };

  myAllTasksModel = new ExternalSystemTasksTreeModel(externalSystemId);
  myAllTasksTree = new ExternalSystemTasksTree(myAllTasksModel, settings.getExpandStates(), project, externalSystemId) {
    @Override
    protected void processMouseEvent(MouseEvent e) {
      if (e.getClickCount() > 0) {
        mySelectedTaskProvider = myAllTasksTree;
        myRecentTasksList.getSelectionModel().clearSelection();
      }
      super.processMouseEvent(e);
    }
  };
  final String actionIdToUseForDoubleClick = DefaultRunExecutor.getRunExecutorInstance().getContextActionId();
  myAllTasksTree.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() >= 2 && !e.isPopupTrigger()) {
        ExternalSystemUiUtil.executeAction(actionIdToUseForDoubleClick, e);
      }
    }
  });
  ExternalSystemUiUtil.apply(settings, myAllTasksModel);
  CustomizationUtil.installPopupHandler(myAllTasksTree, TREE_ACTIONS_GROUP_ID, TREE_CONTEXT_MENU_PLACE);

  ActionManager actionManager = ActionManager.getInstance();
  ActionGroup group = (ActionGroup)actionManager.getAction(TOOL_WINDOW_TOOLBAR_ACTIONS_GROUP_ID);
  ActionToolbar toolbar = actionManager.createActionToolbar(TOOL_WINDOW_PLACE, group, true);
  toolbar.setTargetComponent(this);
  setToolbar(toolbar.getComponent());

  JPanel content = new JPanel(new GridBagLayout());
  content.setOpaque(true);
  content.setBackground(UIUtil.getListBackground());
  JComponent recentTasksWithTitle = wrap(myRecentTasksList, ExternalSystemBundle.message("tasks.recent.title"));
  content.add(recentTasksWithTitle, ExternalSystemUiUtil.getFillLineConstraints(0));
  JBScrollPane scrollPane = new JBScrollPane(myAllTasksTree);
  scrollPane.setBorder(null);
  JComponent allTasksWithTitle = wrap(scrollPane, ExternalSystemBundle.message("tasks.all.title"));
  content.add(allTasksWithTitle, ExternalSystemUiUtil.getFillLineConstraints(0).weighty(1).fillCell());
  setContent(content);
}
 
Example #16
Source File: ExternalSystemNotificationManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void showNotification(@Nonnull final ProjectSystemId externalSystemId, @Nonnull final NotificationData notificationData) {
  myUpdater.execute(new Runnable() {
    @Override
    public void run() {
      if (myProject.isDisposed()) return;

      if (!initializedExternalSystem.contains(externalSystemId)) {
        final Application app = ApplicationManager.getApplication();
        Runnable action = new Runnable() {
          @Override
          public void run() {
            app.runWriteAction(new Runnable() {
              @Override
              public void run() {
                if (myProject.isDisposed()) return;
                ExternalSystemUtil.ensureToolWindowContentInitialized(myProject, externalSystemId);
                initializedExternalSystem.add(externalSystemId);
              }
            });
          }
        };
        if (app.isDispatchThread()) {
          action.run();
        }
        else {
          app.invokeAndWait(action, ModalityState.defaultModalityState());
        }
      }

      final NotificationGroup group = ExternalSystemUtil.getToolWindowElement(
              NotificationGroup.class, myProject, ExternalSystemDataKeys.NOTIFICATION_GROUP, externalSystemId);
      if (group == null) return;

      final Notification notification = group.createNotification(
              notificationData.getTitle(), notificationData.getMessage(),
              notificationData.getNotificationCategory().getNotificationType(), notificationData.getListener());

      myNotifications.add(notification);

      if (notificationData.isBalloonNotification()) {
        applyNotification(notification);
      }
      else {
        addMessage(notification, externalSystemId, notificationData);
      }
    }
  });
}
 
Example #17
Source File: JarHandler.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected NotificationGroup compute() {
  return NotificationGroup.balloonGroup(VfsBundle.message("jar.copy.error.title"));
}
 
Example #18
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public String getToolWindowId(@Nonnull String groupId) {
  NotificationGroup group = NotificationGroup.findRegisteredGroup(groupId);
  return group == null ? null : group.getToolWindowId();
}
 
Example #19
Source File: BuiltInServerManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected NotificationGroup compute() {
  return new NotificationGroup("Built-in Server", NotificationDisplayType.STICKY_BALLOON, true);
}
 
Example #20
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public synchronized boolean isRegistered(@Nonnull final String id) {
  return myIdToSettingsMap.containsKey(id) || NotificationGroup.findRegisteredGroup(id) != null;
}