예제 #1
0
  @Override
  public void onCloseCommandOutputClick(@NotNull ProcessTreeNode node) {
    String commandId = node.getId();
    OutputConsole console = consoles.get(commandId);

    if (console == null) {
      return;
    }

    if (console.isFinished()) {
      console.close();
      onStopProcess(node);
      consoles.remove(commandId);
      consoleCommands.remove(console);
      return;
    }

    dialogFactory
        .createConfirmDialog(
            "",
            localizationConstant.outputsConsoleViewStopProcessConfirmation(console.getTitle()),
            getConfirmCloseConsoleCallback(console, node),
            null)
        .show();
  }
예제 #2
0
  @Override
  public void onPreviewSsh(@NotNull final String machineId) {
    ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
    if (machineTreeNode == null) {
      return;
    }

    MachineDto machine = (MachineDto) machineTreeNode.getData();

    OutputConsole defaultConsole = commandConsoleFactory.create("SSH");
    addCommandOutput(machineId, defaultConsole);

    String machineName = machine.getConfig().getName();
    String sshServiceAddress = getSshServerAddress(machine);
    String machineHost = "";
    String sshPort = SSH_PORT;
    if (sshServiceAddress != null) {
      String[] parts = sshServiceAddress.split(":");
      machineHost = parts[0];
      sshPort = (parts.length == 2) ? parts[1] : sshPort;
    }

    if (defaultConsole instanceof DefaultOutputConsole) {
      ((DefaultOutputConsole) defaultConsole)
          .printText(localizationConstant.sshConnectInfo(machineName, machineHost, sshPort));
    }
  }
예제 #3
0
  @Inject
  public ConsolesPanelPresenter(
      ConsolesPanelView view,
      EventBus eventBus,
      DtoFactory dtoFactory,
      DialogFactory dialogFactory,
      EntityFactory entityFactory,
      TerminalFactory terminalFactory,
      CommandConsoleFactory commandConsoleFactory,
      CommandTypeRegistry commandTypeRegistry,
      WorkspaceAgent workspaceAgent,
      NotificationManager notificationManager,
      MachineLocalizationConstant localizationConstant,
      MachineServiceClient machineService,
      MachineResources resources,
      AppContext appContext) {
    this.view = view;
    this.terminalFactory = terminalFactory;
    this.workspaceAgent = workspaceAgent;
    this.commandConsoleFactory = commandConsoleFactory;
    this.commandTypeRegistry = commandTypeRegistry;
    this.dtoFactory = dtoFactory;
    this.dialogFactory = dialogFactory;
    this.notificationManager = notificationManager;
    this.localizationConstant = localizationConstant;
    this.resources = resources;
    this.entityFactory = entityFactory;
    this.appContext = appContext;
    this.machineService = machineService;

    this.rootChildren = new ArrayList<>();
    this.terminals = new HashMap<>();
    this.consoles = new HashMap<>();
    this.consoleCommands = new HashMap<>();
    this.machineNodes = new HashMap<>();

    fetchMachines();

    this.view.setDelegate(this);
    this.view.setTitle(localizationConstant.viewConsolesTitle());

    eventBus.addHandler(
        DevMachineStateEvent.TYPE,
        new DevMachineStateEvent.Handler() {
          @Override
          public void onDevMachineStarted(DevMachineStateEvent event) {
            fetchMachines();
          }

          @Override
          public void onDevMachineDestroyed(DevMachineStateEvent event) {}
        });

    eventBus.addHandler(ProcessFinishedEvent.TYPE, this);
    eventBus.addHandler(WorkspaceStoppedEvent.TYPE, this);
    eventBus.addHandler(MachineStateEvent.TYPE, this);
  }
예제 #4
0
  private String getUniqueTerminalName(ProcessTreeNode machineNode) {
    String terminalName = DEFAULT_TERMINAL_NAME;
    if (!isTerminalNameExist(machineNode, terminalName)) {
      return DEFAULT_TERMINAL_NAME;
    }

    int counter = 2;
    do {
      terminalName = localizationConstant.viewProcessesTerminalNodeTitle(String.valueOf(counter));
      counter++;
    } while (isTerminalNameExist(machineNode, terminalName));
    return terminalName;
  }
예제 #5
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);
  }
예제 #6
0
 @Override
 public String getTitleToolTip() {
   return localizationConstant.viewProcessesTooltip();
 }
예제 #7
0
 @NotNull
 @Override
 public String getTitle() {
   return localizationConstant.viewConsolesTitle();
 }