Java Code Examples for com.intellij.util.ui.UIUtil#getInformationIcon()

The following examples show how to use com.intellij.util.ui.UIUtil#getInformationIcon() . 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: DefaultLanguageClient.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams showMessageRequestParams) {
    List<MessageActionItem> actions = showMessageRequestParams.getActions();
    String title = "Language Server message";
    String message = showMessageRequestParams.getMessage();
    MessageType msgType = showMessageRequestParams.getType();
    Icon icon;
    if (msgType == MessageType.Error) {
        icon = UIUtil.getErrorIcon();
    } else if (msgType == MessageType.Warning) {
        icon = UIUtil.getWarningIcon();
    } else if (msgType == MessageType.Info) {
        icon = UIUtil.getInformationIcon();
    } else if (msgType == MessageType.Log) {
        icon = UIUtil.getInformationIcon();
    } else {
        icon = null;
        LOG.warn("No message type for " + message);
    }

    List<String> titles = new ArrayList<>();
    for (MessageActionItem item : actions) {
        titles.add(item.getTitle());
    }
    FutureTask<Integer> task = new FutureTask<>(
            () -> Messages.showDialog(message, title, (String[]) titles.toArray(), 0, icon));
    ApplicationManager.getApplication().invokeAndWait(task);

    int exitCode = 0;
    try {
        exitCode = task.get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn(e.getMessage());
    }

    return CompletableFuture.completedFuture(new MessageActionItem(actions.get(exitCode).getTitle()));
}
 
Example 2
Source File: JBMacMessages.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int showMessageDialog(@Nonnull String title,
                             String message,
                             @Nonnull String[] buttons,
                             boolean errorStyle,
                             @Nullable consulo.ui.Window window,
                             int defaultOptionIndex,
                             int focusedOptionIndex,
                             @Nullable DialogWrapper.DoNotAskOption doNotAskDialogOption) {
  if (window == null) {
    window = getForemostWindow(null);
  }

  Icon icon = errorStyle ? UIUtil.getErrorIcon() : UIUtil.getInformationIcon();

  focusedOptionIndex = (defaultOptionIndex == focusedOptionIndex) ? buttons.length - 1 : focusedOptionIndex;

  SheetMessage sheetMessage = new SheetMessage(window, title, message, icon, buttons, doNotAskDialogOption, buttons[defaultOptionIndex],
                                               buttons[focusedOptionIndex]);
  String result = sheetMessage.getResult();
  for (int i = 0; i < buttons.length; i++) {
    if (result.equals(buttons[i])) {
      if (doNotAskDialogOption != null) {
        doNotAskDialogOption.setToBeShown(sheetMessage.toBeShown(), i);
      }
      return i;
    }
  }
  return -1;
}
 
Example 3
Source File: JBMacMessages.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void showOkMessageDialog(@Nonnull String title, String message, @Nonnull String okText, @Nullable consulo.ui.Window window) {
  if (window == null) {
    window = getForemostWindow(null);
  }
  new SheetMessage(window, title, message, UIUtil.getInformationIcon(), new String [] {okText}, null, null, okText);
}
 
Example 4
Source File: DesktopAlertImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private Icon getIcon() {
  switch (myType) {
    case INFO:
      return UIUtil.getInformationIcon();
    case WARNING:
      return UIUtil.getWarningIcon();
    case ERROR:
      return UIUtil.getErrorIcon();
    case QUESTION:
      return UIUtil.getQuestionIcon();
    default:
      throw new UnsupportedOperationException(myType.name());
  }
}
 
Example 5
Source File: Messages.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static Icon getInformationIcon() {
  return UIUtil.getInformationIcon();
}
 
Example 6
Source File: JBMacMessages.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void showOkMessageDialog(@Nonnull String title, String message, @Nonnull String okText) {
  final consulo.ui.Window foremostWindow = getForemostWindow(null);
  new SheetMessage(foremostWindow, title, message, UIUtil.getInformationIcon(), new String [] {okText},null, null, okText);
}