예제 #1
0
  /**
   * Adds command node to process tree and displays command output
   *
   * @param machineId id of machine in which the command will be executed
   * @param outputConsole the console for command output
   */
  public void addCommandOutput(@NotNull String machineId, @NotNull OutputConsole outputConsole) {
    ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
    if (machineTreeNode == null) {
      notificationManager.notify(
          localizationConstant.failedToExecuteCommand(),
          localizationConstant.machineNotFound(machineId),
          FAIL,
          FLOAT_MODE);
      Log.error(getClass(), localizationConstant.machineNotFound(machineId));
      return;
    }

    String commandId;
    String outputConsoleTitle = outputConsole.getTitle();
    ProcessTreeNode processTreeNode = getProcessTreeNodeByName(outputConsoleTitle, machineTreeNode);
    if (processTreeNode != null && isCommandStopped(processTreeNode.getId())) {
      commandId = processTreeNode.getId();
      view.hideProcessOutput(commandId);
    } else {
      ProcessTreeNode commandNode =
          new ProcessTreeNode(
              COMMAND_NODE,
              machineTreeNode,
              outputConsoleTitle,
              outputConsole.getTitleIcon(),
              null);
      commandId = commandNode.getId();
      view.addProcessNode(commandNode);
      addChildToMachineNode(commandNode, machineTreeNode);
    }

    updateCommandOutput(commandId, outputConsole);

    resfreshStopButtonState(commandId);
    workspaceAgent.setActivePart(this);
  }