Search in sources :

Example 1 with BranchInfo

use of com.google.gerrit.client.projects.BranchInfo in project gerrit by GerritCodeReview.

the class ProjectBranchesScreen method doAddNewBranch.

private void doAddNewBranch() {
    final String branchName = nameTxtBox.getText().trim();
    if ("".equals(branchName)) {
        nameTxtBox.setFocus(true);
        return;
    }
    final String rev = irevTxtBox.getText().trim();
    if ("".equals(rev)) {
        irevTxtBox.setText("HEAD");
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                irevTxtBox.selectAll();
                irevTxtBox.setFocus(true);
            }
        });
        return;
    }
    addBranch.setEnabled(false);
    ProjectApi.createBranch(getProjectKey(), branchName, rev, new GerritCallback<BranchInfo>() {

        @Override
        public void onSuccess(BranchInfo branch) {
            showAddedBranch(branch);
            nameTxtBox.setText("");
            irevTxtBox.setText("");
            query = new Query(match).start(start).run();
        }

        @Override
        public void onFailure(Throwable caught) {
            addBranch.setEnabled(true);
            selectAllAndFocus(nameTxtBox);
            new ErrorDialog(caught.getMessage()).center();
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) BranchInfo(com.google.gerrit.client.projects.BranchInfo) ErrorDialog(com.google.gerrit.client.ErrorDialog) NativeString(com.google.gerrit.client.rpc.NativeString)

Aggregations

ErrorDialog (com.google.gerrit.client.ErrorDialog)1 BranchInfo (com.google.gerrit.client.projects.BranchInfo)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1