use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class KeyHelpPopup method formatKeys.
private int formatKeys(final Grid lists, int row, final int col, final KeyCommandSet set, final SafeHtml prefix) {
final CellFormatter fmt = lists.getCellFormatter();
final List<KeyCommand> keys = sort(set);
if (lists.getRowCount() < row + keys.size()) {
lists.resizeRows(row + keys.size());
}
Map<KeyCommand, Integer> rows = new HashMap<>();
FORMAT_KEYS: for (int i = 0; i < keys.size(); i++) {
final KeyCommand k = keys.get(i);
if (rows.containsKey(k)) {
continue;
}
if (k instanceof CompoundKeyCommand) {
final SafeHtmlBuilder b = new SafeHtmlBuilder();
b.append(k.describeKeyStroke());
row = formatKeys(lists, row, col, ((CompoundKeyCommand) k).getSet(), b);
continue;
}
for (int prior = 0; prior < i; prior++) {
if (KeyCommand.same(keys.get(prior), k)) {
final int r = rows.get(keys.get(prior));
final SafeHtmlBuilder b = new SafeHtmlBuilder();
b.append(SafeHtml.get(lists, r, col + 0));
b.append(" ");
b.append(KeyConstants.I.orOtherKey());
b.append(" ");
if (prefix != null) {
b.append(prefix);
b.append(" ");
b.append(KeyConstants.I.thenOtherKey());
b.append(" ");
}
b.append(k.describeKeyStroke());
SafeHtml.set(lists, r, col + 0, b);
rows.put(k, r);
continue FORMAT_KEYS;
}
}
SafeHtmlBuilder b = new SafeHtmlBuilder();
String t = k.getHelpText();
if (prefix != null) {
b.append(prefix);
b.append(" ");
b.append(KeyConstants.I.thenOtherKey());
b.append(" ");
}
b.append(k.describeKeyStroke());
if (k.sibling != null) {
b.append(" / ").append(k.sibling.describeKeyStroke());
t += " / " + k.sibling.getHelpText();
rows.put(k.sibling, row);
}
SafeHtml.set(lists, row, col + 0, b);
lists.setText(row, col + 1, ":");
lists.setText(row, col + 2, t);
rows.put(k, row);
fmt.addStyleName(row, col + 0, KeyResources.I.css().helpKeyStroke());
fmt.addStyleName(row, col + 1, KeyResources.I.css().helpSeparator());
row++;
}
return row;
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class ReplyBox method renderCheckBox.
private void renderCheckBox(int row, LabelAndValues lv) {
ApprovalInfo self = Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount().getId().get()) : null;
final String id = lv.info.name();
final CheckBox b = new CheckBox();
b.setText(id);
b.setEnabled(lv.permitted.contains((short) 1));
if (self != null && self.value() == 1) {
b.setValue(true);
}
b.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
in.label(id, event.getValue() ? (short) 1 : (short) 0);
}
});
b.setStyleName(style.label_name());
labelsTable.setWidget(row, 0, b);
CellFormatter fmt = labelsTable.getCellFormatter();
fmt.setStyleName(row, labelHelpColumn, style.label_help());
labelsTable.setText(row, labelHelpColumn, lv.info.valueText("+1"));
}
use of com.google.gwt.user.client.ui.HTMLTable.CellFormatter in project gerrit by GerritCodeReview.
the class ReplyBox method renderRadio.
private void renderRadio(int row, List<Short> columns, LabelAndValues lv) {
String id = lv.info.name();
Short dv = normalizeDefaultValue(lv.info.defaultValue(), lv.permitted);
labelHelpColumn = 1 + columns.size();
labelsTable.setText(row, 0, id);
CellFormatter fmt = labelsTable.getCellFormatter();
fmt.setStyleName(row, 0, style.label_name());
fmt.setStyleName(row, labelHelpColumn, style.label_help());
ApprovalInfo self = Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount().getId().get()) : null;
final LabelRadioGroup group = new LabelRadioGroup(row, id, lv.permitted.size());
for (int i = 0; i < columns.size(); i++) {
Short v = columns.get(i);
if (lv.permitted.contains(v)) {
String text = lv.info.valueText(LabelValue.formatValue(v));
LabelRadioButton b = new LabelRadioButton(group, text, v);
if ((self != null && v == self.value()) || (self == null && v.equals(dv))) {
b.setValue(true);
group.select(b);
in.label(group.label, v);
labelsTable.setText(row, labelHelpColumn, b.text);
}
group.buttons.add(b);
labelsTable.setWidget(row, 1 + i, b);
}
}
}
Aggregations