com.intellij.notification.NotificationDisplayType Java Examples

The following examples show how to use com.intellij.notification.NotificationDisplayType. 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: NotificationSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public Element save() {
  final Element result = new Element("notification");

  result.setAttribute("groupId", getGroupId());
  final NotificationDisplayType displayType = getDisplayType();
  if (displayType != NotificationDisplayType.BALLOON) {
    result.setAttribute("displayType", displayType.toString());
  }
  if (!myShouldLog) {
    result.setAttribute("shouldLog", "false");
  }
  if (myShouldReadAloud) {
    result.setAttribute("shouldReadAloud", "true");
  }

  return result;
}
 
Example #2
Source File: Notifications.java    From KodeBeagle with Apache License 2.0 6 votes vote down vote up
public final void save() {
    NotificationDisplayType notificationDisplayType = NotificationDisplayType.NONE;

    boolean shouldLog = false;
    propertiesComponent.setValue(RefreshActionBase.NOTIFICATION_CHECKBOX_VALUE,
            String.valueOf(this.getNotificationsCheckBoxValue()));
    propertiesComponent.setValue(RefreshActionBase.LOGGING_CHECKBOX_VALUE,
            String.valueOf(this.getLoggingCheckBoxValue()));

    if (this.getNotificationsCheckBoxValue()) {
        notificationDisplayType = NotificationDisplayType.BALLOON;
    }

    if (this.getLoggingCheckBoxValue()) {
        shouldLog = true;
    }

    NotificationsConfigurationImpl.getNotificationsConfiguration().changeSettings(
            MainWindowBase.KODEBEAGLE, notificationDisplayType, shouldLog, false);
}
 
Example #3
Source File: NotificationSettings.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public static NotificationSettings load(@Nonnull final Element element) {
  final String displayTypeString = element.getAttributeValue("displayType");
  NotificationDisplayType displayType = NotificationDisplayType.BALLOON;
  boolean shouldLog = !"false".equals(element.getAttributeValue("shouldLog"));
  boolean shouldReadAloud = "true".equals(element.getAttributeValue("shouldReadAloud"));
  if ("BALLOON_ONLY".equals(displayTypeString)) {
    shouldLog = false;
    displayType = NotificationDisplayType.BALLOON;
  }
  else if (displayTypeString != null) {
    try {
      displayType = NotificationDisplayType.valueOf(displayTypeString.toUpperCase());
    }
    catch (IllegalArgumentException ignored) {
    }
  }

  final String groupId = element.getAttributeValue("groupId");
  return groupId != null ? new NotificationSettings(groupId, displayType, shouldLog, shouldReadAloud) : null;
}
 
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: MigrationsCondition.java    From yiistorm with MIT License 6 votes vote down vote up
@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 #6
Source File: NotificationsConfigurablePanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setValueAt(Object value, Object node, int column) {
  SettingsWrapper wrapper = (SettingsWrapper)((DefaultMutableTreeNode)node).getUserObject();

  switch (column) {
    case NotificationsTreeTable.DISPLAY_TYPE_COLUMN:
      wrapper.myVersion = wrapper.myVersion.withDisplayType((NotificationDisplayType)value);
      break;
    case NotificationsTreeTable.LOG_COLUMN:
      wrapper.myVersion = wrapper.myVersion.withShouldLog((Boolean)value);
      break;
    case NotificationsTreeTable.READ_ALOUD_COLUMN:
      wrapper.myVersion = wrapper.myVersion.withShouldReadAloud((Boolean)value);
      break;
  }
}
 
Example #7
Source File: Notifications.java    From SmartIM4IntelliJ with Apache License 2.0 5 votes vote down vote up
public static void notify(final IMPanel contactView, final IContact target, final String title,
    final CharSequence text) {
    com.intellij.notification.Notifications.Bus.register("SmartIM", NotificationDisplayType.BALLOON);
    Notification n = new Notification("SmartIM", title, StringUtils.isEmpty(text) ? "" : text.toString(),
        NotificationType.INFORMATION);
    com.intellij.notification.Notifications.Bus.notify(n);
}
 
Example #8
Source File: NotificationsConfigurablePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Class getColumnClass(int column) {
  if (NotificationsTreeTable.DISPLAY_TYPE_COLUMN == column) {
    return NotificationDisplayType.class;
  }
  if (NotificationsTreeTable.LOG_COLUMN == column) {
    return Boolean.class;
  }
  if (NotificationsTreeTable.READ_ALOUD_COLUMN == column) {
    return Boolean.class;
  }

  return TreeTableModel.class;
}
 
Example #9
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 #10
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 #11
Source File: Notifications.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
private void retrieve() {
    boolean isNotificationEnabled = false;
    if (NotificationsConfigurationImpl.getSettings(MainWindowBase.KODEBEAGLE).getDisplayType()
            != NotificationDisplayType.NONE) {
        isNotificationEnabled = true;
    }

    this.setNotificationsCheckBoxValue(isNotificationEnabled);
    this.setLoggingCheckBoxValue(NotificationsConfigurationImpl.getSettings(
            MainWindowBase.KODEBEAGLE).isShouldLog());
}
 
Example #12
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull final String groupDisplayName, @Nonnull final NotificationDisplayType displayType) {
  register(groupDisplayName, displayType, true);
}
 
Example #13
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull String groupDisplayName, @Nonnull NotificationDisplayType displayType, boolean shouldLog) {
  register(groupDisplayName, displayType, shouldLog, false);
}
 
Example #14
Source File: NotificationsConfigurationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void changeSettings(String groupDisplayName, NotificationDisplayType displayType, boolean shouldLog, boolean shouldReadAloud) {
  changeSettings(new NotificationSettings(groupDisplayName, displayType, shouldLog, shouldReadAloud));
}
 
Example #15
Source File: SystemShortcuts.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void doNotify(@Nonnull Keymap keymap, @Nonnull String actionId, @Nonnull KeyStroke sysKS, @Nullable String macOsShortcutAction, @Nonnull KeyboardShortcut conflicted) {
  if (!ourIsNotificationRegistered) {
    ourIsNotificationRegistered = true;
    NotificationsConfiguration.getNotificationsConfiguration().register(ourNotificationGroupId, NotificationDisplayType.STICKY_BALLOON, true);
  }

  final AnAction act = ActionManager.getInstance().getAction(actionId);
  final String actText = act == null ? actionId : act.getTemplateText();
  final String message = "The " +
                         actText +
                         " shortcut conflicts with macOS shortcut" +
                         (macOsShortcutAction == null ? "" : " '" + macOsShortcutAction + "'") +
                         ". Modify this shortcut or change macOS system settings.";
  final Notification notification = new Notification(ourNotificationGroupId, "Shortcuts conflicts", message, NotificationType.WARNING, null);

  final AnAction configureShortcut = DumbAwareAction.create("Modify shortcut", e -> {
    Component component = e.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT);
    if (component == null) {
      Window[] frames = Window.getWindows();
      component = frames == null || frames.length == 0 ? null : frames[0];
      if (component == null) {
        LOG.error("can't show KeyboardShortcutDialog (parent component wasn't found)");
        return;
      }
    }

    KeymapPanel.addKeyboardShortcut(actionId, ActionShortcutRestrictions.getInstance().getForActionId(actionId), keymap, component, conflicted, SystemShortcuts.this);
    notification.expire();
  });
  notification.addAction(configureShortcut);

  final AnAction muteAction = DumbAwareAction.create("Don't show again", e -> {
    myMutedConflicts.addMutedAction(actionId);
    notification.expire();
  });
  notification.addAction(muteAction);

  if (SystemInfo.isMac) {
    final AnAction changeSystemSettings = DumbAwareAction.create("Change system settings", e -> {
      ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final GeneralCommandLine cmdLine =
                new GeneralCommandLine("osascript", "-e", "tell application \"System Preferences\"", "-e", "set the current pane to pane id \"com.apple.preference.keyboard\"", "-e",
                                       "reveal anchor \"shortcutsTab\" of pane id \"com.apple.preference.keyboard\"", "-e", "activate", "-e", "end tell");
        try {
          ExecUtil.execAndGetOutput(cmdLine);
          // NOTE: we can't detect OS-settings changes
          // but we can try to schedule check conflicts (and expire notification if necessary)
        }
        catch (ExecutionException ex) {
          LOG.error(ex);
        }
      });
    });
    notification.addAction(changeSystemSettings);
  }

  myNotifiedActions.add(actionId);
  notification.notify(null);
}
 
Example #16
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 #17
Source File: NotificationSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NotificationSettings(String groupId, NotificationDisplayType displayType, boolean shouldLog, boolean shouldReadAloud) {
  myGroupId = groupId;
  myDisplayType = displayType;
  myShouldLog = shouldLog;
  myShouldReadAloud = shouldReadAloud;
}
 
Example #18
Source File: NotificationSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public NotificationDisplayType getDisplayType() {
  return myDisplayType;
}
 
Example #19
Source File: NotificationSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public NotificationSettings withDisplayType(NotificationDisplayType displayType) {
  return new NotificationSettings(myGroupId, displayType, myShouldLog, myShouldReadAloud);
}
 
Example #20
Source File: Notifications.java    From SmartIM4IntelliJ with Apache License 2.0 4 votes vote down vote up
public static void notify(final String title, final CharSequence text) {
    com.intellij.notification.Notifications.Bus.register("SmartIM", NotificationDisplayType.BALLOON);
    Notification n = new Notification("SmartIM", title, StringUtils.isEmpty(text) ? "" : text.toString(),
        NotificationType.INFORMATION);
    com.intellij.notification.Notifications.Bus.notify(n);
}