コード例 #1
0
  public static void printToConsole(
      @NotNull final LanguageConsoleImpl console,
      @NotNull final String string,
      @NotNull final ConsoleViewContentType mainType,
      @Nullable ConsoleViewContentType additionalType) {
    final TextAttributes mainAttributes = mainType.getAttributes();
    final TextAttributes attributes;
    if (additionalType == null) {
      attributes = mainAttributes;
    } else {
      attributes = additionalType.getAttributes().clone();
      attributes.setBackgroundColor(mainAttributes.getBackgroundColor());
    }

    Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
      console.printToHistory(string, attributes);
    } else {
      application.invokeLater(
          new Runnable() {
            public void run() {
              console.printToHistory(string, attributes);
            }
          },
          ModalityState.stateForComponent(console.getComponent()));
    }
  }
コード例 #2
0
  public static void printToConsole(
      @NotNull final LanguageConsoleImpl console,
      @NotNull final ConsoleViewContentType mainType,
      @NotNull final List<Pair<String, ConsoleViewContentType>> textToPrint) {
    final List<Pair<String, TextAttributes>> attributedText =
        ContainerUtil.map(
            textToPrint,
            new Function<Pair<String, ConsoleViewContentType>, Pair<String, TextAttributes>>() {
              @Override
              public Pair<String, TextAttributes> fun(Pair<String, ConsoleViewContentType> input) {
                final TextAttributes mainAttributes = mainType.getAttributes();
                final TextAttributes attributes;
                if (input.getSecond() == null) {
                  attributes = mainAttributes;
                } else {
                  attributes = input.getSecond().getAttributes().clone();
                  attributes.setBackgroundColor(mainAttributes.getBackgroundColor());
                }
                return Pair.create(input.getFirst(), attributes);
              }
            });

    Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
      console.printToHistory(attributedText);
    } else {
      application.invokeLater(
          new Runnable() {
            public void run() {
              console.printToHistory(attributedText);
            }
          },
          ModalityState.stateForComponent(console.getComponent()));
    }
  }