Search in sources :

Example 1 with InlineLabel

use of com.google.gwt.user.client.ui.InlineLabel in project che by eclipse.

the class ActionPopupButton method renderImage.

/**
     * Redraw the icon.
     */
private void renderImage() {
    panel.clear();
    if (presentation.getImageResource() != null) {
        Image image = new Image(presentationFactory.getPresentation(action).getImageResource());
        image.setStyleName(toolbarResources.toolbar().popupButtonIcon());
        panel.add(image);
    } else if (presentation.getSVGResource() != null) {
        SVGImage image = new SVGImage(presentation.getSVGResource());
        image.getElement().setAttribute("class", toolbarResources.toolbar().popupButtonIcon());
        panel.add(image);
    } else if (presentation.getHTMLResource() != null) {
        FlowPanel icon = new FlowPanel();
        icon.setStyleName(toolbarResources.toolbar().iconButtonIcon());
        FlowPanel inner = new FlowPanel();
        inner.setStyleName(toolbarResources.toolbar().popupButtonIconInner());
        inner.getElement().setInnerHTML(presentation.getHTMLResource());
        icon.add(inner);
        panel.add(inner);
    }
    InlineLabel caret = new InlineLabel("");
    caret.setStyleName(toolbarResources.toolbar().caret());
    panel.add(caret);
}
Also used : FlowPanel(com.google.gwt.user.client.ui.FlowPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) Image(com.google.gwt.user.client.ui.Image) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 2 with InlineLabel

use of com.google.gwt.user.client.ui.InlineLabel in project gerrit by GerritCodeReview.

the class DownloadPanel method setupWidgets.

private void setupWidgets() {
    if (!urls.isEmpty()) {
        urls.select(Gerrit.getUserPreferences().downloadScheme());
        FlowPanel p = new FlowPanel();
        p.setStyleName(Gerrit.RESOURCES.css().downloadLinkHeader());
        p.add(commands);
        final InlineLabel glue = new InlineLabel();
        glue.setStyleName(Gerrit.RESOURCES.css().downloadLinkHeaderGap());
        p.add(glue);
        p.add(urls);
        add(p);
        add(copyLabel);
    }
}
Also used : FlowPanel(com.google.gwt.user.client.ui.FlowPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel)

Example 3 with InlineLabel

use of com.google.gwt.user.client.ui.InlineLabel in project gerrit by GerritCodeReview.

the class ChangeTable method populateChangeRow.

private void populateChangeRow(final int row, final ChangeInfo c, boolean highlightUnreviewed) {
    CellFormatter fmt = table.getCellFormatter();
    if (Gerrit.isSignedIn()) {
        table.setWidget(row, C_STAR, StarredChanges.createIcon(c.legacyId(), c.starred()));
    }
    table.setWidget(row, C_ID, new TableChangeLink(String.valueOf(c.legacyId()), c));
    String subject = Util.cropSubject(c.subject());
    table.setWidget(row, C_SUBJECT, new TableChangeLink(subject, c));
    Change.Status status = c.status();
    if (status != Change.Status.NEW) {
        table.setText(row, C_STATUS, Util.toLongString(status) + (c.isPrivate() ? (" " + Util.C.isPrivate()) : ""));
    } else if (!c.mergeable()) {
        table.setText(row, C_STATUS, Util.C.changeTableNotMergeable() + (c.isPrivate() ? (" " + Util.C.isPrivate()) : ""));
    } else if (c.isPrivate()) {
        table.setText(row, C_STATUS, Util.C.isPrivate());
    }
    if (c.owner() != null) {
        table.setWidget(row, C_OWNER, AccountLinkPanel.withStatus(c.owner(), status));
    } else {
        table.setText(row, C_OWNER, "");
    }
    if (showAssignee) {
        if (c.assignee() != null) {
            table.setWidget(row, C_ASSIGNEE, AccountLinkPanel.forAssignee(c.assignee()));
            if (Gerrit.getUserPreferences().highlightAssigneeInChangeTable() && Objects.equals(c.assignee().getId(), Gerrit.getUserAccount().getId())) {
                table.getRowFormatter().addStyleName(row, Gerrit.RESOURCES.css().cASSIGNEDTOME());
            }
        } else {
            table.setText(row, C_ASSIGNEE, "");
        }
    }
    table.setWidget(row, C_PROJECT, new ProjectLink(c.projectNameKey()));
    table.setWidget(row, C_BRANCH, new BranchLink(c.projectNameKey(), c.status(), c.branch(), c.topic()));
    if (Gerrit.getUserPreferences().relativeDateInChangeTable()) {
        table.setText(row, C_LAST_UPDATE, relativeFormat(c.updated()));
    } else {
        table.setText(row, C_LAST_UPDATE, shortFormat(c.updated()));
    }
    int col = C_SIZE;
    if (!Gerrit.getUserPreferences().sizeBarInChangeTable()) {
        table.setText(row, col, Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
    } else {
        table.setWidget(row, col, getSizeWidget(c));
        fmt.getElement(row, col).setTitle(Util.M.insertionsAndDeletions(c.insertions(), c.deletions()));
    }
    col++;
    for (int idx = 0; idx < labelNames.size(); idx++, col++) {
        String name = labelNames.get(idx);
        LabelInfo label = c.label(name);
        if (label == null) {
            fmt.getElement(row, col).setTitle(Gerrit.C.labelNotApplicable());
            fmt.addStyleName(row, col, Gerrit.RESOURCES.css().labelNotApplicable());
            continue;
        }
        String user;
        String info;
        ReviewCategoryStrategy reviewCategoryStrategy = Gerrit.getUserPreferences().reviewCategoryStrategy();
        if (label.rejected() != null) {
            user = label.rejected().name();
            info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.rejected());
            if (info != null) {
                FlowPanel panel = new FlowPanel();
                panel.add(new Image(Gerrit.RESOURCES.redNot()));
                panel.add(new InlineLabel(info));
                table.setWidget(row, col, panel);
            } else {
                table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot()));
            }
        } else if (label.approved() != null) {
            user = label.approved().name();
            info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.approved());
            if (info != null) {
                FlowPanel panel = new FlowPanel();
                panel.add(new Image(Gerrit.RESOURCES.greenCheck()));
                panel.add(new InlineLabel(info));
                table.setWidget(row, col, panel);
            } else {
                table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
            }
        } else if (label.disliked() != null) {
            user = label.disliked().name();
            info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.disliked());
            String vstr = String.valueOf(label._value());
            if (info != null) {
                vstr = vstr + " " + info;
            }
            fmt.addStyleName(row, col, Gerrit.RESOURCES.css().negscore());
            table.setText(row, col, vstr);
        } else if (label.recommended() != null) {
            user = label.recommended().name();
            info = getReviewCategoryDisplayInfo(reviewCategoryStrategy, label.recommended());
            String vstr = "+" + label._value();
            if (info != null) {
                vstr = vstr + " " + info;
            }
            fmt.addStyleName(row, col, Gerrit.RESOURCES.css().posscore());
            table.setText(row, col, vstr);
        } else {
            table.clearCell(row, col);
            continue;
        }
        fmt.addStyleName(row, col, Gerrit.RESOURCES.css().singleLine());
        if (user != null) {
            // Some web browsers ignore the embedded newline; some like it;
            // so we include a space before the newline to accommodate both.
            fmt.getElement(row, col).setTitle(name + " \nby " + user);
        }
    }
    boolean needHighlight = false;
    if (highlightUnreviewed && !c.reviewed()) {
        needHighlight = true;
    }
    final Element tr = fmt.getElement(row, 0).getParentElement();
    UIObject.setStyleName(tr, Gerrit.RESOURCES.css().needsReview(), needHighlight);
    setRowItem(row, c);
}
Also used : ReviewCategoryStrategy(com.google.gerrit.extensions.client.GeneralPreferencesInfo.ReviewCategoryStrategy) Element(com.google.gwt.dom.client.Element) BranchLink(com.google.gerrit.client.ui.BranchLink) Change(com.google.gerrit.reviewdb.client.Change) CellFormatter(com.google.gwt.user.client.ui.HTMLTable.CellFormatter) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) Image(com.google.gwt.user.client.ui.Image) LabelInfo(com.google.gerrit.client.info.ChangeInfo.LabelInfo) ProjectLink(com.google.gerrit.client.ui.ProjectLink) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel)

Example 4 with InlineLabel

use of com.google.gwt.user.client.ui.InlineLabel in project gerrit by GerritCodeReview.

the class DownloadBox method insertPatch.

private void insertPatch() {
    String id = revision.substring(0, 7);
    Anchor patchBase64 = new Anchor(id + ".diff.base64");
    patchBase64.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision).view("patch").addParameterTrue("download").url());
    Anchor patchZip = new Anchor(id + ".diff.zip");
    patchZip.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision).view("patch").addParameterTrue("zip").url());
    HorizontalPanel p = new HorizontalPanel();
    p.add(patchBase64);
    InlineLabel spacer = new InlineLabel("|");
    spacer.setStyleName(Gerrit.RESOURCES.css().downloadBoxSpacer());
    p.add(spacer);
    p.add(patchZip);
    insertCommand("Patch-File", p);
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) RestApi(com.google.gerrit.client.rpc.RestApi) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel)

Example 5 with InlineLabel

use of com.google.gwt.user.client.ui.InlineLabel in project gerrit by GerritCodeReview.

the class DownloadBox method insertArchive.

private void insertArchive() {
    List<String> activated = Gerrit.info().download().archives();
    if (activated.isEmpty()) {
        return;
    }
    List<Anchor> anchors = new ArrayList<>(activated.size());
    for (String f : activated) {
        Anchor archive = new Anchor(f);
        archive.setHref(new RestApi("/changes/").id(psId.getParentKey().get()).view("revisions").id(revision).view("archive").addParameter("format", f).url());
        anchors.add(archive);
    }
    HorizontalPanel p = new HorizontalPanel();
    Iterator<Anchor> it = anchors.iterator();
    while (it.hasNext()) {
        Anchor a = it.next();
        p.add(a);
        if (it.hasNext()) {
            InlineLabel spacer = new InlineLabel("|");
            spacer.setStyleName(Gerrit.RESOURCES.css().downloadBoxSpacer());
            p.add(spacer);
        }
    }
    insertCommand("Archive", p);
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) RestApi(com.google.gerrit.client.rpc.RestApi) ArrayList(java.util.ArrayList) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel)

Aggregations

InlineLabel (com.google.gwt.user.client.ui.InlineLabel)17 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)6 Anchor (com.google.gwt.user.client.ui.Anchor)4 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)4 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 RestApi (com.google.gerrit.client.rpc.RestApi)2 EntryPoint (com.google.gwt.core.client.EntryPoint)2 JSONValue (com.google.gwt.json.client.JSONValue)2 Grid (com.google.gwt.user.client.ui.Grid)2 Image (com.google.gwt.user.client.ui.Image)2 AccountInfo (com.google.gerrit.client.info.AccountInfo)1 LabelInfo (com.google.gerrit.client.info.ChangeInfo.LabelInfo)1 BranchLink (com.google.gerrit.client.ui.BranchLink)1 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)1 ProjectLink (com.google.gerrit.client.ui.ProjectLink)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 ReviewCategoryStrategy (com.google.gerrit.extensions.client.GeneralPreferencesInfo.ReviewCategoryStrategy)1 Change (com.google.gerrit.reviewdb.client.Change)1