Java Code Examples for com.intellij.openapi.util.text.StringUtil#formatDuration()

The following examples show how to use com.intellij.openapi.util.text.StringUtil#formatDuration() . 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: CompileDriver.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static String createStatusMessage(final ExitStatus status, final int warningCount, final int errorCount, long duration) {
  String message;
  if (status == ExitStatus.CANCELLED) {
    message = CompilerBundle.message("status.compilation.aborted");
  }
  else if (status == ExitStatus.UP_TO_DATE) {
    message = CompilerBundle.message("status.all.up.to.date");
  }
  else {
    if (status == ExitStatus.SUCCESS) {
      message = warningCount > 0
                ? CompilerBundle.message("status.compilation.completed.successfully.with.warnings", warningCount)
                : CompilerBundle.message("status.compilation.completed.successfully");
    }
    else {
      message = CompilerBundle.message("status.compilation.completed.successfully.with.warnings.and.errors", errorCount, warningCount);
    }
    message = message + " in " + StringUtil.formatDuration(duration);
  }
  return message;
}
 
Example 2
Source File: TestsPresentationUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static String getDurationTimePresentation(final SMTestProxy proxy) {
  final Long duration = proxy.getDuration();

  if (duration == null) {
    // if suite without children
    return proxy.isSuite() && proxy.isLeaf()
           ? DURATION_NO_TESTS
           : DURATION_UNKNOWN;
  } else {
    return StringUtil.formatDuration(duration.longValue());
  }
}
 
Example 3
Source File: RunIdeConsoleAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void executeQuery(@Nonnull Project project, @Nonnull VirtualFile file, @Nonnull Editor editor, @Nonnull IdeScriptEngine engine) {
  String command = getCommandText(project, editor);
  if (StringUtil.isEmptyOrSpaces(command)) return;
  String profile = getProfileText(file);
  RunContentDescriptor descriptor = getConsoleView(project, file);
  ConsoleViewImpl consoleView = (ConsoleViewImpl)descriptor.getExecutionConsole();

  prepareEngine(project, engine, descriptor);
  try {
    long ts = System.currentTimeMillis();
    //myHistoryController.getModel().addToHistory(command);
    consoleView.print("> " + command, ConsoleViewContentType.USER_INPUT);
    consoleView.print("\n", ConsoleViewContentType.USER_INPUT);
    String script = profile == null ? command : profile + "\n" + command;
    Object o = engine.eval(script);
    String prefix = "[" + (StringUtil.formatDuration(System.currentTimeMillis() - ts)) + "]";
    consoleView.print(prefix + "=> " + o, ConsoleViewContentType.NORMAL_OUTPUT);
    consoleView.print("\n", ConsoleViewContentType.NORMAL_OUTPUT);
  }
  catch (Throwable e) {
    //noinspection ThrowableResultOfMethodCallIgnored
    Throwable ex = ExceptionUtil.getRootCause(e);
    consoleView.print(ex.getClass().getSimpleName() + ": " + ex.getMessage(), ConsoleViewContentType.ERROR_OUTPUT);
    consoleView.print("\n", ConsoleViewContentType.ERROR_OUTPUT);
  }
  selectContent(descriptor);
}
 
Example 4
Source File: SMTestProxy.java    From consulo with Apache License 2.0 4 votes vote down vote up
private String getDurationString() {
  final Long duration = getDuration();
  return duration != null ? StringUtil.formatDuration(duration.longValue(), "\u2009") : null;
}