<select wicket:id="fromRef" class="span3" />\r
<i class="icon-arrow-right"></i>\r
<select wicket:id="toRef" class="span3" />\r
+ <label style="padding:0px 5px;" class="checkbox"><input type="checkbox" wicket:id="ignoreWhitespaceCheckbox" /> <span wicket:id="ignoreWhitespaceLabel"></span></label>\r
<button class="btn" type="submit"><wicket:message key="gb.compare"></wicket:message></button>\r
</form>\r
</div>\r
<input wicket:id="fromId" type="text" class="span3" />\r
<i class="icon-arrow-right"></i>\r
<input wicket:id="toId" type="text" class="span3" />\r
+ <label style="padding:0px 5px;" class="checkbox"><input type="checkbox" wicket:id="ignoreWhitespaceCheckbox" /> <span wicket:id="ignoreWhitespaceLabel"></span></label>\r
<button class="btn" type="submit"><wicket:message key="gb.compare"></wicket:message></button>\r
</form>\r
</div>\r
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
IModel<String> fromRefId = new Model<String>("");
IModel<String> toRefId = new Model<String>("");
+ IModel<Boolean> ignoreWhitespace = Model.of(true);
+
public ComparePage(PageParameters params) {
super(params);
Repository r = getRepository();
comparison.add(new Label("diffText", diff.content).setEscapeModelStrings(false));
}
+ // set the default DiffComparator
+ DiffComparator diffComparator = WicketUtils.getDiffComparator(params);
+ ignoreWhitespace.setObject(DiffComparator.IGNORE_WHITESPACE == diffComparator);
+
//
// ref selection form
//
public void onSubmit() {
String from = ComparePage.this.fromRefId.getObject();
String to = ComparePage.this.toRefId.getObject();
+ boolean ignoreWS = ignoreWhitespace.getObject();
PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to);
+ if (ignoreWS) {
+ params.put("w", 1);
+ }
+
String relativeUrl = urlFor(ComparePage.class, params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
refsForm.add(new DropDownChoice<String>("fromRef", fromRefId, refs).setEnabled(refs.size() > 0));
refsForm.add(new DropDownChoice<String>("toRef", toRefId, refs).setEnabled(refs.size() > 0));
+ refsForm.add(new Label("ignoreWhitespaceLabel", getString(DiffComparator.IGNORE_WHITESPACE.getTranslationKey())));
+ refsForm.add(new CheckBox("ignoreWhitespaceCheckbox", ignoreWhitespace));
add(refsForm);
//
public void onSubmit() {
String from = ComparePage.this.fromCommitId.getObject();
String to = ComparePage.this.toCommitId.getObject();
+ boolean ignoreWS = ignoreWhitespace.getObject();
PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to);
+ if (ignoreWS) {
+ params.put("w", 1);
+ }
String relativeUrl = urlFor(ComparePage.class, params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
TextField<String> toIdField = new TextField<String>("toId", toCommitId);
WicketUtils.setInputPlaceholder(toIdField, getString("gb.to") + "...");
idsForm.add(toIdField);
+ idsForm.add(new Label("ignoreWhitespaceLabel", getString(DiffComparator.IGNORE_WHITESPACE.getTranslationKey())));
+ idsForm.add(new CheckBox("ignoreWhitespaceCheckbox", ignoreWhitespace));
add(idsForm);
r.close();