コード例 #1
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
  /** {@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);
          }
        });
  }
コード例 #2
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
  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
          }
        });
  }
コード例 #3
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
  /** {@inheritDoc} */
  @Override
  public void onBranchSelected(@NotNull Branch branch) {
    selectedBranch = branch;
    boolean isActive = selectedBranch.isActive();

    view.setEnableCheckoutButton(!isActive);
    view.setEnableDeleteButton(!isActive);
    view.setEnableRenameButton(true);
  }
コード例 #4
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
 /** {@inheritDoc} */
 @Override
 public void onRenameClicked() {
   if (selectedBranch.isRemote()) {
     dialogFactory
         .createConfirmDialog(
             constant.branchConfirmRenameTitle(),
             constant.branchConfirmRenameMessage(),
             getConfirmRenameBranchCallback(),
             null)
         .show();
   } else {
     renameBranch();
   }
 }
コード例 #5
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
  /** {@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);
          }
        });
  }
コード例 #6
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
 /** @return name of branch, e.g. 'origin/master' -> 'master' */
 private String getSelectedBranchName() {
   String selectedBranchName = selectedBranch.getDisplayName();
   String[] tokens = selectedBranchName.split("/");
   return tokens.length > 0 ? tokens[tokens.length - 1] : selectedBranchName;
 }