Exemplo n.º 1
0
  @Override
  public IStatus execute(
      final String id,
      final IConsoleService service,
      final Map<String, Object> data,
      final IProgressMonitor monitor) {
    final IStatus status =
        ToolCommandHandlerUtil.getCheckedData(data, REPORT_STATUS_DATA_KEY, IStatus.class, false);
    if (status != null) {
      final String br = service.getWorkspaceData().getLineSeparator();
      final StringBuilder msg = new StringBuilder(br);
      switch (status.getSeverity()) {
        case IStatus.ERROR:
          msg.append("[ERROR] ");
          break;
        case IStatus.WARNING:
          msg.append("[WARNING] ");
          break;
        case IStatus.INFO:
          msg.append("[INFO] ");
          break;
      }
      msg.append(status.getMessage());
      msg.append(br);
      boolean details = (status.getException() != null);
      final IStatus[] children = status.getChildren();
      for (final IStatus subStatus : children) {
        msg.append("    "); // $NON-NLS-1$
        msg.append(subStatus.getMessage());
        msg.append(br);
        details |= (subStatus.getChildren().length > 0 || subStatus.getException() != null);
      }
      if (details) {
        msg.append("    (details available in Eclipse error log)");
        msg.append(br);
      }

      try {
        final ToolStreamMonitor infoStream =
            service.getController().getStreams().getInfoStreamMonitor();
        infoStream.append(msg.toString(), service.getController().getCurrentSubmitType(), 0);
      } catch (final Exception e) {
      }

      switch (status.getSeverity()) {
        case IStatus.ERROR:
          StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.SHOW);
          break;
        case IStatus.WARNING:
          StatusManager.getManager().handle(status, StatusManager.LOG);
          break;
        default:
          break;
      }
    }

    return Status.OK_STATUS;
  }