use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.
the class SideBySideChunkManager method render.
private void render(Region region, String diffColor) {
int startA = lineMapper.getLineA();
int startB = lineMapper.getLineB();
JsArrayString a = region.a();
JsArrayString b = region.b();
int aLen = a != null ? a.length() : 0;
int bLen = b != null ? b.length() : 0;
String color = a == null || b == null ? diffColor : SideBySideTable.style.intralineBg();
colorLines(cmA, color, startA, aLen);
colorLines(cmB, color, startB, bLen);
markEdit(cmA, startA, a, region.editA());
markEdit(cmB, startB, b, region.editB());
addPadding(cmA, startA + aLen - 1, bLen - aLen);
addPadding(cmB, startB + bLen - 1, aLen - bLen);
addGutterTag(region, startA, startB);
lineMapper.appendReplace(aLen, bLen);
int endA = lineMapper.getLineA() - 1;
int endB = lineMapper.getLineB() - 1;
if (aLen > 0) {
addDiffChunk(cmB, endA, aLen, bLen > 0);
}
if (bLen > 0) {
addDiffChunk(cmA, endB, bLen, aLen > 0);
}
}
use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.
the class DiffTable method set.
void set(DiffPreferences prefs, JsArray<RevisionInfo> list, int parents, DiffInfo info, boolean editExists, boolean current, boolean open, boolean binary) {
this.changeType = info.changeType();
patchSetSelectBoxA.setUpPatchSetNav(list, parents, info.metaA(), editExists, current, open, binary);
patchSetSelectBoxB.setUpPatchSetNav(list, parents, info.metaB(), editExists, current, open, binary);
JsArrayString hdr = info.diffHeader();
if (hdr != null) {
StringBuilder b = new StringBuilder();
for (int i = 1; i < hdr.length(); i++) {
String s = hdr.get(i);
if (!info.binary() && (s.startsWith("diff --git ") || s.startsWith("index ") || s.startsWith("+++ ") || s.startsWith("--- "))) {
continue;
}
b.append(s).append('\n');
}
String hdrTxt = b.toString().trim();
header = !hdrTxt.isEmpty();
diffHeaderText.setInnerText(hdrTxt);
UIObject.setVisible(diffHeaderRow, header);
} else {
header = false;
UIObject.setVisible(diffHeaderRow, false);
}
setHideEmptyPane(prefs.hideEmptyPane());
}
use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.
the class PathSuggestOracle method onRequestSuggestions.
@Override
protected void onRequestSuggestions(final Request req, final Callback cb) {
RestApi api = ChangeApi.revision(changeId.get(), revision.name()).view("files");
if (req.getQuery() != null) {
api.addParameter("q", req.getQuery() == null ? "" : req.getQuery());
}
api.background().get(new AsyncCallback<JsArrayString>() {
@Override
public void onSuccess(JsArrayString result) {
List<Suggestion> r = new ArrayList<>();
for (String path : Natives.asList(result)) {
r.add(new PathSuggestion(path));
}
cb.onSuggestionsReady(req, new Response(r));
}
@Override
public void onFailure(Throwable caught) {
List<Suggestion> none = Collections.emptyList();
cb.onSuggestionsReady(req, new Response(none));
}
});
}
use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.
the class QuickApprove method set.
void set(ChangeInfo info, String commit, ReplyAction action) {
if (!info.hasPermittedLabels() || !info.status().isOpen()) {
// Quick approve needs at least one label on an open change.
setVisible(false);
return;
}
if (info.revision(commit).isEdit() || info.revision(commit).draft()) {
setVisible(false);
return;
}
String qName = null;
String qValueStr = null;
short qValue = 0;
int index = info.getMissingLabelIndex();
if (index != -1) {
LabelInfo label = Natives.asList(info.allLabels().values()).get(index);
JsArrayString values = info.permittedValues(label.name());
String s = values.get(values.length() - 1);
short v = LabelInfo.parseValue(s);
if (v > 0 && s.equals(label.maxValue())) {
qName = label.name();
qValueStr = s;
qValue = v;
}
}
if (qName != null) {
changeId = info.legacyId();
revision = commit;
input = ReviewInput.create();
input.drafts(DraftHandling.PUBLISH_ALL_REVISIONS);
input.label(qName, qValue);
replyAction = action;
setText(qName + qValueStr);
setVisible(true);
} else {
setVisible(false);
}
}
use of com.google.gwt.core.client.JsArrayString in project gerrit by GerritCodeReview.
the class Hashtags method formatHashtags.
private SafeHtmlBuilder formatHashtags(JsArrayString hashtags) {
SafeHtmlBuilder html = new SafeHtmlBuilder();
Iterator<String> itr = Natives.asList(hashtags).iterator();
while (itr.hasNext()) {
String hashtagName = itr.next();
html.openSpan().setAttribute(DATA_ID, hashtagName).setStyleName(style.hashtagName()).openAnchor().setAttribute("href", "#" + PageLinks.toChangeQuery("hashtag:\"" + hashtagName + "\"")).setAttribute("role", "listitem").openSpan().setStyleName(style.hashtagIcon()).append(new ImageResourceRenderer().render(Gerrit.RESOURCES.hashtag())).closeSpan().append(" ").append(hashtagName).closeAnchor();
if (canEdit) {
html.openElement("button").setAttribute("title", "Remove hashtag").setAttribute("onclick", REMOVE + "(event)").append("×").closeElement("button");
}
html.closeSpan();
if (itr.hasNext()) {
html.append(' ');
}
}
return html;
}
Aggregations