Search in sources :

Example 16 with CellFormatter

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;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter) SafeHtmlBuilder(com.google.gwtexpui.safehtml.client.SafeHtmlBuilder)

Example 17 with CellFormatter

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"));
}
Also used : ApprovalInfo(com.google.gerrit.client.info.ChangeInfo.ApprovalInfo) CheckBox(com.google.gwt.user.client.ui.CheckBox) JsArrayString(com.google.gwt.core.client.JsArrayString) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter)

Example 18 with CellFormatter

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);
        }
    }
}
Also used : ApprovalInfo(com.google.gerrit.client.info.ChangeInfo.ApprovalInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter)

Aggregations

CellFormatter (com.google.gwt.user.client.ui.HTMLTable.CellFormatter)18 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)6 Grid (com.google.gwt.user.client.ui.Grid)6 Element (com.google.gwt.dom.client.Element)4 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)3 ApprovalInfo (com.google.gerrit.client.info.ChangeInfo.ApprovalInfo)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2 Anchor (com.google.gwt.user.client.ui.Anchor)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 CopyableLabel (com.google.gwtexpui.clippy.client.CopyableLabel)2 AvatarImage (com.google.gerrit.client.AvatarImage)1 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)1 ProjectScreen (com.google.gerrit.client.admin.ProjectScreen)1 ChangeListScreen (com.google.gerrit.client.changes.ChangeListScreen)1 AccountInfo (com.google.gerrit.client.info.AccountInfo)1 LabelInfo (com.google.gerrit.client.info.ChangeInfo.LabelInfo)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 BranchLink (com.google.gerrit.client.ui.BranchLink)1 InlineHyperlink (com.google.gerrit.client.ui.InlineHyperlink)1 LinkMenuBar (com.google.gerrit.client.ui.LinkMenuBar)1