Search in sources :

Example 1 with ErrorDialog

use of com.google.gerrit.client.ErrorDialog 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)

Example 2 with ErrorDialog

use of com.google.gerrit.client.ErrorDialog in project gerrit by GerritCodeReview.

the class PermissionEditor method addGroup.

private void addGroup(final GroupReference ref) {
    if (ref.getUUID() != null) {
        if (value.getRule(ref) == null) {
            PermissionRule newRule = value.getRule(ref, true);
            if (validRange != null) {
                int min = validRange.getDefaultMin();
                int max = validRange.getDefaultMax();
                newRule.setRange(min, max);
            } else if (GlobalCapability.PRIORITY.equals(value.getName())) {
                newRule.setAction(PermissionRule.Action.BATCH);
            }
            rules.getList().add(newRule);
        }
        groupToAdd.setValue(null);
        groupToAdd.setFocus(true);
    } else {
        // If the oracle didn't get to complete a UUID, resolve it now.
        //
        addRule.setEnabled(false);
        GroupMap.suggestAccountGroupForProject(projectName.get(), ref.getName(), 1, new GerritCallback<GroupMap>() {

            @Override
            public void onSuccess(GroupMap result) {
                addRule.setEnabled(true);
                if (result.values().length() == 1) {
                    addGroup(new GroupReference(result.values().get(0).getGroupUUID(), result.values().get(0).name()));
                } else {
                    groupToAdd.setFocus(true);
                    new ErrorDialog(Gerrit.M.noSuchGroupMessage(ref.getName())).center();
                }
            }

            @Override
            public void onFailure(Throwable caught) {
                addRule.setEnabled(true);
                super.onFailure(caught);
            }
        });
    }
}
Also used : PermissionRule(com.google.gerrit.common.data.PermissionRule) GroupMap(com.google.gerrit.client.groups.GroupMap) ErrorDialog(com.google.gerrit.client.ErrorDialog) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 3 with ErrorDialog

use of com.google.gerrit.client.ErrorDialog in project gerrit by GerritCodeReview.

the class ProjectTagsScreen method doAddNewTag.

private void doAddNewTag() {
    String tagName = nameTxtBox.getText().trim();
    if (tagName.isEmpty()) {
        nameTxtBox.setFocus(true);
        return;
    }
    String rev = irevTxtBox.getText().trim();
    if (rev.isEmpty()) {
        irevTxtBox.setText("HEAD");
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                irevTxtBox.selectAll();
                irevTxtBox.setFocus(true);
            }
        });
        return;
    }
    addTag.setEnabled(false);
    ProjectApi.createTag(getProjectKey(), tagName, rev, new GerritCallback<TagInfo>() {

        @Override
        public void onSuccess(TagInfo tag) {
            showAddedTag(tag);
            nameTxtBox.setText("");
            irevTxtBox.setText("");
            query = new Query(match).start(start).run();
        }

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

Example 4 with ErrorDialog

use of com.google.gerrit.client.ErrorDialog in project gerrit by GerritCodeReview.

the class ChangeScreen method resolveRevisionToDisplay.

private RevisionInfo resolveRevisionToDisplay(ChangeInfo info) {
    RevisionInfo rev = resolveRevisionOrPatchSetId(info, revision, info.currentRevision());
    if (rev != null) {
        revision = rev.name();
        return rev;
    }
    // the revision is not visible to the calling user (maybe it is a draft?)
    // or the change is corrupt, take the last revision that was returned,
    // if no revision was returned display an error
    JsArray<RevisionInfo> revisions = info.revisions().values();
    if (revisions.length() > 0) {
        RevisionInfo.sortRevisionInfoByNumber(revisions);
        rev = revisions.get(revisions.length() - 1);
        revision = rev.name();
        return rev;
    }
    new ErrorDialog(Resources.M.changeWithNoRevisions(info.legacyId().get())).center();
    throw new IllegalStateException("no revision, cannot proceed");
}
Also used : RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ErrorDialog(com.google.gerrit.client.ErrorDialog)

Example 5 with ErrorDialog

use of com.google.gerrit.client.ErrorDialog in project gerrit by GerritCodeReview.

the class ConfigInfo method commentlinks.

final List<FindReplace> commentlinks() {
    JsArray<CommentLinkInfo> cls = commentlinks0().values();
    List<FindReplace> commentLinks = new ArrayList<>(cls.length());
    for (int i = 0; i < cls.length(); i++) {
        CommentLinkInfo cl = cls.get(i);
        if (!cl.enabled()) {
            continue;
        }
        if (cl.link() != null) {
            commentLinks.add(new LinkFindReplace(cl.match(), cl.link()));
        } else {
            try {
                FindReplace fr = new RawFindReplace(cl.match(), cl.html());
                commentLinks.add(fr);
            } catch (RuntimeException e) {
                int index = e.getMessage().indexOf("at Object");
                new ErrorDialog("Invalid commentlink configuration: " + (index == -1 ? e.getMessage() : e.getMessage().substring(0, index))).center();
            }
        }
    }
    return commentLinks;
}
Also used : FindReplace(com.google.gwtexpui.safehtml.client.FindReplace) LinkFindReplace(com.google.gwtexpui.safehtml.client.LinkFindReplace) RawFindReplace(com.google.gwtexpui.safehtml.client.RawFindReplace) LinkFindReplace(com.google.gwtexpui.safehtml.client.LinkFindReplace) ArrayList(java.util.ArrayList) ErrorDialog(com.google.gerrit.client.ErrorDialog) RawFindReplace(com.google.gwtexpui.safehtml.client.RawFindReplace)

Aggregations

ErrorDialog (com.google.gerrit.client.ErrorDialog)11 NativeString (com.google.gerrit.client.rpc.NativeString)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 NotSignedInDialog (com.google.gerrit.client.NotSignedInDialog)1 GroupMap (com.google.gerrit.client.groups.GroupMap)1 AccountInfo (com.google.gerrit.client.info.AccountInfo)1 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)1 BranchInfo (com.google.gerrit.client.projects.BranchInfo)1 TagInfo (com.google.gerrit.client.projects.TagInfo)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 AccessSection (com.google.gerrit.common.data.AccessSection)1 GroupReference (com.google.gerrit.common.data.GroupReference)1 PermissionRule (com.google.gerrit.common.data.PermissionRule)1 ProjectAccess (com.google.gerrit.common.data.ProjectAccess)1 CodeDownloadException (com.google.gwt.core.client.CodeDownloadException)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1