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();
}
});
}
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);
}
});
}
}
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();
}
});
}
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");
}
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;
}
Aggregations