@Inject
  public CreateCustomRunnerAction(
      RunnerLocalizationConstant locale,
      AppContext appContext,
      RunnerResources resources,
      RunnerManagerPresenter runnerManagerPresenter,
      NotificationManager notificationManager,
      GetProjectEnvironmentsAction getProjectEnvironmentsAction,
      AsyncCallbackBuilder<ItemReference> asyncCallbackBuilder,
      ProjectServiceClient projectService,
      TemplatesPresenter templatesPresenter,
      @LeftPanel TabContainer tabContainer) {
    super(
        appContext, locale.createCustomRunner(), locale.createCustomRunner(), resources.runWith());

    this.locale = locale;
    this.getProjectEnvironmentsAction = getProjectEnvironmentsAction;
    this.notificationManager = notificationManager;
    this.templatesPresenter = templatesPresenter;
    this.asyncCallbackBuilder = asyncCallbackBuilder;
    this.projectService = projectService;
    this.resources = resources;
    this.appContext = appContext;
    this.runnerManagerPresenter = runnerManagerPresenter;
    this.tabContainer = tabContainer;
  }
  private void initializeLeftPropertiesPanel(@NotNull Provider<TabBuilder> tabBuilderProvider) {
    final TabSelectHandler consoleHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            if (selectedRunner != null) {
              selectedRunner.setActiveTab(locale.runnerTabConsole());
            }
          }
        };

    consoleTab =
        tabBuilderProvider
            .get()
            .presenter(consoleContainer)
            .title(locale.runnerTabConsole())
            .visible(REMOVABLE)
            .selectHandler(consoleHandler)
            .scope(EnumSet.of(RUNNERS))
            .tabType(RIGHT)
            .build();

    leftPropertiesContainer.addTab(consoleTab);

    TabSelectHandler propertiesHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            if (RUNNERS.equals(panelState.getState())) {
              propertiesContainer.show(selectedRunner);

              if (selectedRunner != null) {
                selectedRunner.setActiveTab(locale.runnerTabProperties());
              }
            } else {
              propertiesContainer.show(selectedEnvironment);
            }
          }
        };

    propertiesTab =
        tabBuilderProvider
            .get()
            .presenter(propertiesContainer)
            .selectHandler(propertiesHandler)
            .title(locale.runnerTabProperties())
            .visible(REMOVABLE)
            .scope(EnumSet.allOf(State.class))
            .tabType(RIGHT)
            .build();

    leftPropertiesContainer.addTab(propertiesTab);
  }
  private void initializeLeftPanel(
      @NotNull final PanelState panelState,
      @NotNull Provider<TabBuilder> tabBuilderProvider,
      @NotNull HistoryPanel historyPanel,
      @NotNull final TemplatesContainer templatesContainer) {
    TabSelectHandler historyHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            selectHistoryTab();
          }
        };

    Tab historyTab =
        tabBuilderProvider
            .get()
            .presenter(historyPanel)
            .selectHandler(historyHandler)
            .title(locale.runnerTabHistory())
            .visible(REMOVABLE)
            .scope(EnumSet.allOf(State.class))
            .tabType(LEFT)
            .build();

    leftTabContainer.addTab(historyTab);

    TabSelectHandler templatesHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            state = TEMPLATE;
            panelState.setState(State.TEMPLATE);

            templatesContainer.selectEnvironment();
            templatesContainer.changeEnableStateRunButton();

            view.hideOtherButtons();
          }
        };

    Tab templateTab =
        tabBuilderProvider
            .get()
            .presenter(templatesContainer)
            .selectHandler(templatesHandler)
            .title(locale.runnerTabTemplates())
            .visible(REMOVABLE)
            .scope(EnumSet.allOf(State.class))
            .tabType(LEFT)
            .build();

    leftTabContainer.addTab(templateTab);
  }
  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());
      }
    }
  }
  private void initializeRightPropertiesPanel(@NotNull Provider<TabBuilder> tabBuilderProvider) {
    rightPropertiesContainer.addTab(consoleTab);

    TabSelectHandler terminalHandler =
        new TabSelectHandler() {
          @Override
          public void onTabSelected() {
            if (selectedRunner != null) {
              selectedRunner.setActiveTab(locale.runnerTabTerminal());

              terminalContainer.update(selectedRunner);
            }
          }
        };

    terminalTab =
        tabBuilderProvider
            .get()
            .presenter(terminalContainer)
            .title(locale.runnerTabTerminal())
            .visible(VISIBLE)
            .selectHandler(terminalHandler)
            .scope(EnumSet.of(RUNNERS))
            .tabType(RIGHT)
            .build();
    rightPropertiesContainer.addTab(terminalTab);

    rightPropertiesContainer.addTab(propertiesTab);

    rightPropertiesContainer.showTabTitle(consoleTab.getTitle(), false);
    rightPropertiesContainer.showTabTitle(propertiesTab.getTitle(), false);
  }
Example #7
0
  /**
   * This runner needs runner options (user configurations) and environment name (inputted by user).
   * It analyzes all given information and get necessary information.
   *
   * @param locale localization constants
   * @param runnerCounter utility that support the counter of runners
   * @param runOptions options which needs to be used
   * @param environmentName name of custom configuration
   */
  @AssistedInject
  public RunnerImpl(
      @NotNull RunnerLocalizationConstant locale,
      @NotNull RunnerCounter runnerCounter,
      @NotNull GetEnvironmentsUtil util,
      @NotNull @Assisted RunOptions runOptions,
      @NotNull @Assisted Scope environmentScope,
      @Nullable @Assisted String environmentName) {
    this.runOptions = runOptions;
    this.ram = runOptions.getMemorySize();
    this.title =
        RUNNER_NAME
            + runnerCounter.getRunnerNumber()
            + (environmentName == null ? "" : " - " + getCorrectName(environmentName));
    this.activeTab = locale.runnerTabConsole();
    this.status = IN_QUEUE;
    this.scope = environmentScope;

    creationTime = System.currentTimeMillis();

    String environmentId = runOptions.getEnvironmentId();

    if (environmentId == null || environmentId.startsWith("project:/")) {
      this.type = util.getType();
    } else {
      this.type = util.getCorrectCategoryName(runOptions.getEnvironmentId());
    }

    // the environment ID in runOptions should be an URL
    if (environmentId != null) {
      runOptions.setEnvironmentId(environmentId);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void actionPerformed(ActionEvent e) {
    runnerManagerPresenter.setActive();

    tabContainer.showTab(locale.runnerTabTemplates());

    createSimpleEnvironment();
  }
 private void changeURLDependingOnState(@NotNull Runner runner) {
   switch (runner.getStatus()) {
     case IN_PROGRESS:
       view.setApplicationURl(locale.uplAppWaitingForBoot());
       break;
     case IN_QUEUE:
       view.setApplicationURl(locale.uplAppWaitingForBoot());
       break;
     case STOPPED:
       view.setApplicationURl(locale.urlAppRunnerStopped());
       break;
     case FAILED:
       view.setApplicationURl(null);
       break;
     default:
       String url = runner.getApplicationURL();
       view.setApplicationURl(url == null ? locale.urlAppRunning() : url);
       setDebugPort(runner);
   }
 }
 /** {@inheritDoc} */
 @Nullable
 @Override
 public String getTitleToolTip() {
   return locale.tooltipRunnerPanel();
 }
 /** {@inheritDoc} */
 @NotNull
 @Override
 public String getTitle() {
   return locale.runnerTitle();
 }