private void getGitRemoteRepositories(final ProjectConfigDto projectConfig) {
   gitService
       .remoteList(appContext.getWorkspaceId(), projectConfig, null, true)
       .then(
           new Operation<List<Remote>>() {
             @Override
             public void apply(List<Remote> result) throws OperationException {
               if (!result.isEmpty()) {
                 projectRemotes = unmodifiableList(result);
                 loadOpenShiftData();
               } else {
                 dialogFactory
                     .createMessageDialog(
                         locale.noGitRemoteRepositoryWarningTitle(),
                         locale.noGitRemoteRepositoryWarning(projectConfig.getName()),
                         null)
                     .show();
               }
             }
           })
       .catchError(
           new Operation<PromiseError>() {
             @Override
             public void apply(PromiseError arg) throws OperationException {
               notificationManager.notify(
                   locale.getGitRemoteRepositoryError(projectConfig.getName()), FAIL, true);
             }
           });
 }
Пример #2
0
  /** Get the list of branches. */
  private void getBranches() {
    service.branchList(
        workspaceId,
        project.getRootProject(),
        LIST_ALL,
        new AsyncRequestCallback<List<Branch>>(
            dtoUnmarshallerFactory.newListUnmarshaller(Branch.class)) {
          @Override
          protected void onSuccess(List<Branch> result) {
            view.setBranches(result);
            view.showDialogIfClosed();
          }

          @Override
          protected void onFailure(Throwable exception) {
            final String errorMessage =
                (exception.getMessage() != null)
                    ? exception.getMessage()
                    : constant.branchesListFailed();
            final GitOutputConsole console =
                gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
            console.printError(errorMessage);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
            notificationManager.notify(
                constant.branchesListFailed(), FAIL, true, project.getRootProject());
          }
        });
  }
Пример #3
0
  private void renameBranch(String newName) {
    service.branchRename(
        workspaceId,
        project.getRootProject(),
        selectedBranch.getDisplayName(),
        newName,
        new AsyncRequestCallback<String>() {
          @Override
          protected void onSuccess(String result) {
            getBranches();
          }

          @Override
          protected void onFailure(Throwable exception) {
            String errorMessage =
                (exception.getMessage() != null)
                    ? exception.getMessage()
                    : constant.branchRenameFailed();
            final GitOutputConsole console =
                gitOutputConsoleFactory.create(BRANCH_RENAME_COMMAND_NAME);
            console.printError(errorMessage);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
            notificationManager.notify(
                constant.branchRenameFailed(), FAIL, true, project.getRootProject());
            getBranches(); // rename of remote branch occurs in three stages, so needs update list
            // of branches on view
          }
        });
  }
Пример #4
0
  /** {@inheritDoc} */
  @Override
  public void onCheckoutClicked() {
    String name = selectedBranch.getDisplayName();

    if (name == null) {
      return;
    }

    final CheckoutRequest checkoutRequest = dtoFactory.createDto(CheckoutRequest.class);
    if (selectedBranch.isRemote()) {
      checkoutRequest.setTrackBranch(selectedBranch.getDisplayName());
    } else {
      checkoutRequest.setName(selectedBranch.getDisplayName());
    }

    final ProjectConfigDto root = project.getRootProject();
    final String path = root.getPath();
    final String projectType = root.getType();

    service.checkout(
        workspaceId,
        root,
        checkoutRequest,
        new AsyncRequestCallback<String>() {
          @Override
          protected void onSuccess(String result) {
            getBranches();
            // In this case we can have unconfigured state of the project,
            // so we must repeat the logic which is performed when we open a project
            projectService.getProject(
                workspaceId,
                path,
                new AsyncRequestCallback<ProjectConfigDto>(
                    dtoUnmarshallerFactory.newUnmarshaller(ProjectConfigDto.class)) {
                  @Override
                  protected void onSuccess(ProjectConfigDto result) {
                    result.setType(projectType);
                    updateProject(result);
                  }

                  @Override
                  protected void onFailure(Throwable exception) {
                    notificationManager.notify(
                        exception.getLocalizedMessage(), FAIL, true, project.getProjectConfig());
                  }
                });
          }

          @Override
          protected void onFailure(Throwable exception) {
            final GitOutputConsole console =
                gitOutputConsoleFactory.create(BRANCH_CHECKOUT_COMMAND_NAME);
            printGitMessage(exception.getMessage(), console);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
          }
        });
  }
Пример #5
0
  /** {@inheritDoc} */
  @Override
  public void onDeleteClicked() {
    final String name = selectedBranch.getName();

    service.branchDelete(
        workspaceId,
        project.getRootProject(),
        name,
        true,
        new AsyncRequestCallback<String>() {
          @Override
          protected void onSuccess(String result) {
            getBranches();
          }

          @Override
          protected void onFailure(Throwable exception) {
            GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_DELETE_COMMAND_NAME);
            handleError(exception, console);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
          }
        });
  }