String to = ComparePage.this.toRefId.getObject();
PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to);
String relativeUrl = urlFor(ComparePage.class, params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
List<String> refs = new ArrayList<String>();
for (RefModel ref : JGitUtils.getLocalBranches(r, true, -1)) {
refs.add(ref.getName());
}
if (repository.showRemoteBranches) {
for (RefModel ref : JGitUtils.getRemoteBranches(r, true, -1)) {
refs.add(ref.getName());
}
}
for (RefModel ref : JGitUtils.getTags(r, true, -1)) {
refs.add(ref.getName());
}
refsForm.add(new DropDownChoice<String>("fromRef", fromRefId, refs).setEnabled(refs.size() > 0));
refsForm.add(new DropDownChoice<String>("toRef", toRefId, refs).setEnabled(refs.size() > 0));
add(refsForm);
//
// manual ids form
//
SessionlessForm<Void> idsForm = new SessionlessForm<Void>("compareIdsForm", getClass(), getPageParameters()) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit() {
String from = ComparePage.this.fromCommitId.getObject();
String to = ComparePage.this.toCommitId.getObject();
PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to);
String relativeUrl = urlFor(ComparePage.class, params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
TextField<String> fromIdField = new TextField<String>("fromId", fromCommitId);
WicketUtils.setInputPlaceholder(fromIdField, getString("gb.from") + "...");