/*
 * Copyright 2000-2016 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.updater;

import java.util.Map;
import java.util.List;
import java.util.Collections;

@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"})
public class ConsoleUpdaterUI implements UpdaterUI {
  private String myStatus;

  public void startProcess(String title) {
    System.out.println(title);
    Runner.logger().info("title: " + title);
  }

  public void setProgress(int percentage) {
  }

  public void setProgressIndeterminate() {
  }

  public void setStatus(String status) {
    System.out.println(myStatus = status);
    Runner.logger().info("status: " + status);
  }

  public void showError(Throwable e) {
    e.printStackTrace();
  }

  public void checkCancelled() throws OperationCancelledException {
  }

  @Override
  public void setDescription(String oldBuildDesc, String newBuildDesc) {
    System.out.println("From " + oldBuildDesc + " to " + newBuildDesc);
  }

  @Override
  public boolean showWarning(String message) {
    System.out.println("Warning: " + message);
    return false;
  }

  public Map<String, ValidationResult.Option> askUser(List<ValidationResult> validationResults) {
    return Collections.emptyMap();
  }

  @Override
  public String toString() {
    return "Status: '" + myStatus + '\'';
  }
}
@@ -642,19 +642,27 @@
 va.util.
-Map
+Collections
 ;%0Aimport
@@ -695,27 +695,19 @@
 va.util.
-Collections
+Map
 ;%0A%0A@Supp
@@ -1742,17 +1742,756 @@
 esults) 
-%7B
+throws OperationCancelledException %7B%0A    if (!validationResults.isEmpty()) %7B%0A      System.out.println(%22Validation info:%22);%0A%0A      for (ValidationResult item : validationResults) %7B%0A        System.out.println(String.format(%22  %25s  %25s: %25s%22, item.kind, item.path, item.message));%0A      %7D%0A%0A      if (validationResults.stream().anyMatch(it -%3E it.kind == ValidationResult.Kind.ERROR)) %7B%0A        System.out.println(%22Invalid files were detected. Failing.%22);%0A        throw new OperationCancelledException();%0A      %7D%0A%0A      if (validationResults.stream().anyMatch(it -%3E it.kind == ValidationResult.Kind.CONFLICT)) %7B%0A        System.out.println(%22Conflicting files were detected. Failing.%22);%0A        throw new OperationCancelledException();%0A      %7D%0A    %7D%0A
 %0A    ret
@@ -2575,16 +2575,30 @@
  return 
+String.format(
 %22Status:
@@ -2599,19 +2599,21 @@
 tatus: '
-%22 +
+%25s'%22,
  myStatu
@@ -2617,15 +2617,9 @@
 atus
- + '%5C''
+)
 ;%0A  

Clean up + better logging and error handling from Eugene Petrenko