private void runnerSelected() {
    selectedRunner = selectionManager.getRunner();
    if (selectedRunner == null) {
      showNoRunnerMessage(true);

      propertiesContainer.reset();
      return;
    }

    showNoRunnerMessage(false);

    if (SPLITTER_OFF.equals(panelState.getSplitterState())) {
      rightPropertiesContainer.showTab(selectedRunner.getActiveTab());
    }

    history.selectRunner(selectedRunner);

    if (locale.runnerTabTerminal().equals(selectedRunner.getActiveTab())
        || SPLITTER_ON.equals(panelState.getSplitterState())) {
      terminalContainer.update(selectedRunner);
    }

    update(selectedRunner);

    updateRunnerTimer();
  }
  /** {@inheritDoc} */
  @Override
  public void onToggleSplitterClicked(boolean isShowSplitter) {
    terminalTab.setScopes(isShowSplitter ? EnumSet.allOf(State.class) : EnumSet.of(RUNNERS));

    if (isShowSplitter) {
      panelState.setSplitterState(SPLITTER_ON);

      view.setLeftPropertiesPanel(leftPropertiesContainer);
      view.setRightPropertiesPanel(rightPropertiesContainer);
    } else {
      panelState.setSplitterState(SPLITTER_OFF);

      view.setGeneralPropertiesPanel(rightPropertiesContainer);
    }

    if (TEMPLATE.equals(state)) {
      panelState.setState(TEMPLATE);

      leftTabContainer.showTab(locale.runnerTabTemplates());

      if (SPLITTER_OFF.equals(panelState.getSplitterState())) {
        rightPropertiesContainer.showTab(propertiesTab.getTitle());
      }
    }
  }
  @NotNull
  private Runner launchRunner(@NotNull Runner runner) {
    if (runActionPermit.isAllowed()) {

      CurrentProject currentProject = appContext.getCurrentProject();

      if (currentProject == null) {
        throw new IllegalStateException(
            "Can't launch runner for current project. Current project is absent...");
      }

      selectedEnvironment = null;

      panelState.setState(RUNNERS);
      view.showOtherButtons();

      history.addRunner(runner);

      runnerInQueueTimer.schedule(ONE_SEC.getValue());

      CheckRamAndRunAction checkRamAndRunAction = actionFactory.createCheckRamAndRun();
      checkRamAndRunAction.perform(runner);

      runnerActions.put(runner, checkRamAndRunAction);

      runner.resetCreationTime();
      runnerTimer.schedule(ONE_SEC.getValue());
    } else {
      runActionDenyAccessDialog.show();
    }
    return runner;
  }
  private void selectHistoryTab() {
    state = RUNNERS;
    panelState.setState(RUNNERS);

    view.setEnableRunButton(runnerUtil.hasRunPermission());

    view.showOtherButtons();
  }
  /** {@inheritDoc} */
  @Override
  public void onRunButtonClicked() {
    if (State.TEMPLATE.equals(panelState.getState())) {
      RunOptions runOptions =
          dtoFactory
              .createDto(RunOptions.class)
              .withOptions(selectedEnvironment.getOptions())
              .withEnvironmentId(selectedEnvironment.getId())
              .withMemorySize(selectedEnvironment.getRam());

      Runner runner =
          modelsFactory.createRunner(
              runOptions, selectedEnvironment.getScope(), selectedEnvironment.getName());

      if (PROJECT.equals(selectedEnvironment.getScope())) {
        runner.setScope(PROJECT);
      }

      launchRunner(runner);
    } else {
      launchRunner();
    }
  }
  @Inject
  public RunnerManagerPresenter(
      final RunnerManagerView view,
      RunnerActionFactory actionFactory,
      ModelsFactory modelsFactory,
      AppContext appContext,
      DtoFactory dtoFactory,
      ChooseRunnerAction chooseRunnerAction,
      EventBus eventBus,
      final RunnerLocalizationConstant locale,
      @LeftPanel TabContainer leftTabContainer,
      @LeftPropertiesPanel TabContainer leftPropertiesContainer,
      @RightPropertiesPanel TabContainer rightPropertiesContainer,
      PanelState panelState,
      Provider<TabBuilder> tabBuilderProvider,
      final ConsoleContainer consoleContainer,
      TerminalContainer terminalContainer,
      PropertiesContainer propertiesContainer,
      HistoryPanel history,
      TemplatesContainer templateContainer,
      RunnerCounter runnerCounter,
      SelectionManager selectionManager,
      TimerFactory timerFactory,
      GetSystemEnvironmentsAction getSystemEnvironmentsAction,
      RunnerUtil runnerUtil,
      @Run ResourcesLockedActionPermit runActionPermit,
      @Run ActionDenyAccessDialog runActionDenyAccessDialog) {
    this.view = view;
    this.view.setDelegate(this);
    this.locale = locale;
    this.dtoFactory = dtoFactory;
    this.chooseRunnerAction = chooseRunnerAction;
    this.actionFactory = actionFactory;
    this.modelsFactory = modelsFactory;
    this.appContext = appContext;
    this.runnerCounter = runnerCounter;
    this.getSystemEnvironmentsAction = getSystemEnvironmentsAction;
    this.runnerUtil = runnerUtil;
    this.runActionPermit = runActionPermit;
    this.runActionDenyAccessDialog = runActionDenyAccessDialog;

    this.leftTabContainer = leftTabContainer;
    this.leftTabContainer.setLocation(PanelLocation.LEFT);
    this.leftPropertiesContainer = leftPropertiesContainer;
    this.leftPropertiesContainer.setLocation(PanelLocation.LEFT_PROPERTIES);
    this.rightPropertiesContainer = rightPropertiesContainer;
    this.rightPropertiesContainer.setLocation(RIGHT_PROPERTIES);

    this.selectionManager = selectionManager;
    this.selectionManager.addListener(this);

    this.history = history;

    this.panelState = panelState;

    this.consoleContainer = consoleContainer;
    this.templateContainer = templateContainer;
    this.terminalContainer = terminalContainer;
    this.propertiesContainer = propertiesContainer;

    this.runnerActions = new HashMap<>();

    this.runnerTimer =
        timerFactory.newInstance(
            new TimerFactory.TimerCallBack() {
              @Override
              public void onRun() {
                updateRunnerTimer();

                runnerTimer.schedule(ONE_SEC.getValue());
              }
            });

    this.runnerInQueueTimer =
        timerFactory.newInstance(
            new TimerFactory.TimerCallBack() {
              @Override
              public void onRun() {
                if (IN_QUEUE.equals(selectedRunner.getStatus())) {
                  consoleContainer.printInfo(selectedRunner, locale.messageRunnerInQueue());
                }
              }
            });

    eventBus.addHandler(ProjectActionEvent.TYPE, this);
    runnersId = new HashSet<>();

    initializeLeftPanel(panelState, tabBuilderProvider, history, templateContainer);

    initializeLeftPropertiesPanel(tabBuilderProvider);
    initializeRightPropertiesPanel(tabBuilderProvider);

    view.setLeftPanel(leftTabContainer);

    panelState.setSplitterState(SPLITTER_OFF);
    view.setGeneralPropertiesPanel(rightPropertiesContainer);
  }