Search in sources :

Example 16 with Image

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

the class ProjectInfoScreen method addWidget.

private void addWidget(LabeledWidgetsGrid g, Widget w, ConfigParameterInfo param) {
    if (param.description() != null || param.warning() != null) {
        HorizontalPanel p = new HorizontalPanel();
        p.add(new Label(getDisplayName(param)));
        if (param.description() != null) {
            Image infoImg = new Image(Gerrit.RESOURCES.info());
            infoImg.setTitle(param.description());
            p.add(infoImg);
        }
        if (param.warning() != null) {
            Image warningImg = new Image(Gerrit.RESOURCES.warning());
            warningImg.setTitle(param.warning());
            p.add(warningImg);
        }
        p.add(new Label(":"));
        g.add(p, w);
    } else {
        g.add(getDisplayName(param), w);
    }
}
Also used : HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Label(com.google.gwt.user.client.ui.Label) Image(com.google.gwt.user.client.ui.Image)

Example 17 with Image

use of com.google.gwt.user.client.ui.Image 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 18 with Image

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

the class ImageViewer method getImage.

/**
     * Image to display file with image type.
     *
     * @return {@link Image}
     */
private Image getImage() {
    String contentLink = urlModifier.modify(input.getFile().getContentUrl());
    Image image = (contentLink != null) ? new Image(contentLink) : new Image();
    image.setStyleName(resources.imageViewerCss().imageViewer());
    return image;
}
Also used : Image(com.google.gwt.user.client.ui.Image)

Example 19 with Image

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

the class PopupMenu method redraw.

/** Render Popup Menu component. */
private void redraw() {
    String idPrefix = itemIdPrefix;
    if (idPrefix == null) {
        idPrefix = "";
    } else {
        idPrefix += "/";
    }
    table = new PopupMenuTable();
    table.setStyleName(POPUP_RESOURCES.popup().popupMenuTable());
    table.setCellPadding(0);
    table.setCellSpacing(0);
    for (int i = 0; i < list.size(); i++) {
        Action menuItem = list.get(i);
        if (menuItem instanceof Separator) {
            final String separatorText = ((Separator) menuItem).getText();
            if (separatorText == null) {
                table.getCellFormatter().setStyleName(i, 0, POPUP_RESOURCES.popup().popupMenuDelimiter());
            } else {
                table.setWidget(i, 0, new Label(separatorText));
                table.getCellFormatter().setStyleName(i, 0, POPUP_RESOURCES.popup().popupMenuTextDelimiter());
            }
            table.getFlexCellFormatter().setColSpan(i, 0, hasCheckedItems ? 5 : 4);
        } else {
            Presentation presentation = presentationFactory.getPresentation(menuItem);
            if (presentation.getImageResource() != null) {
                Image image = new Image(presentation.getImageResource());
                table.setWidget(i, 0, image);
            } else if (presentation.getSVGResource() != null) {
                SVGImage image = new SVGImage(presentation.getSVGResource());
                table.setWidget(i, 0, image);
            } else if (presentation.getHTMLResource() != null) {
                table.setHTML(i, 0, presentation.getHTMLResource());
            }
            table.getCellFormatter().setStyleName(i, 0, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuIconField() : POPUP_RESOURCES.popup().popupMenuIconFieldDisabled());
            int work = 1;
            if (hasCheckedItems) {
                if (menuItem instanceof ToggleAction) {
                    ToggleAction toggleAction = (ToggleAction) menuItem;
                    ActionEvent e = new ActionEvent(presentationFactory.getPresentation(toggleAction), actionManager, managerProvider.get());
                    if (toggleAction.isSelected(e)) {
                        // Temporary solution
                        table.setHTML(i, work, "<i class=\"fa fa-check\"></i>");
                    }
                    table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuCheckField() : POPUP_RESOURCES.popup().popupMenuCheckFieldDisabled());
                } else {
                    table.setHTML(i, work, "");
                }
                work++;
            }
            table.setHTML(i, work, "<nobr id=\"" + idPrefix + presentation.getText() + "\">" + presentation.getText() + "</nobr>");
            table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuTitleField() : POPUP_RESOURCES.popup().popupMenuTitleFieldDisabled());
            if (showTooltips) {
                Tooltip.create((elemental.dom.Element) table.getCellFormatter().getElement(i, work), BOTTOM, MIDDLE, presentation.getText());
            }
            work++;
            String hotKey = KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(menuItem)));
            if (hotKey == null) {
                hotKey = "&nbsp;";
            } else {
                hotKey = "<nobr>&nbsp;" + hotKey + "&nbsp;</nobr>";
            }
            table.setHTML(i, work, hotKey);
            table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuHotKeyField() : POPUP_RESOURCES.popup().popupMenuHotKeyFieldDisabled());
            work++;
            if (menuItem instanceof ActionGroup && !(((ActionGroup) menuItem).canBePerformed() && !Utils.hasVisibleChildren((ActionGroup) menuItem, presentationFactory, actionManager, managerProvider.get()))) {
                table.setWidget(i, work, new SVGImage(POPUP_RESOURCES.subMenu()));
                table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuSubMenuField() : POPUP_RESOURCES.popup().popupMenuSubMenuFieldDisabled());
            } else {
                table.getCellFormatter().setStyleName(i, work, presentation.isEnabled() ? POPUP_RESOURCES.popup().popupMenuSubMenuField() : POPUP_RESOURCES.popup().popupMenuSubMenuFieldDisabled());
            }
            work++;
            table.getRowFormatter().getElement(i).setAttribute("item-index", Integer.toString(i));
            table.getRowFormatter().getElement(i).setAttribute("item-enabled", Boolean.toString(presentation.isEnabled()));
            String actionId = actionManager.getId(menuItem);
            String debugId;
            if (actionId == null) {
                debugId = idPrefix + menuItem.getTemplatePresentation().getText();
            } else {
                debugId = idPrefix + actionId;
            }
            UIObject.ensureDebugId(table.getRowFormatter().getElement(i), debugId);
        }
    }
    popupMenuPanel.add(table);
}
Also used : ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Label(com.google.gwt.user.client.ui.Label) Presentation(org.eclipse.che.ide.api.action.Presentation) Image(com.google.gwt.user.client.ui.Image) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Separator(org.eclipse.che.ide.api.action.Separator)

Example 20 with Image

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

the class ActionButton method renderImage.

/** Redraw icon. */
private void renderImage() {
    panel.clear();
    if (presentation.getImageResource() != null) {
        Image img = new Image(presentation.getImageResource());
        img.setStyleName(toolbarResources.toolbar().iconButtonIcon());
        panel.add(img);
    } else if (presentation.getSVGResource() != null) {
        SVGImage image = new SVGImage(presentation.getSVGResource());
        image.getElement().setAttribute("class", toolbarResources.toolbar().iconButtonIcon());
        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().iconButtonIconInner());
        inner.getElement().setInnerHTML(presentation.getHTMLResource());
        icon.add(inner);
        panel.add(inner);
    }
}
Also used : FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Image(com.google.gwt.user.client.ui.Image) SVGImage(org.vectomatic.dom.svg.ui.SVGImage) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Aggregations

Image (com.google.gwt.user.client.ui.Image)52 Test (org.junit.Test)13 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)9 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)9 Element (com.google.gwt.dom.client.Element)8 Label (com.google.gwt.user.client.ui.Label)8 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)7 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)7 ImageResource (com.google.gwt.resources.client.ImageResource)6 FlexTable (com.google.gwt.user.client.ui.FlexTable)5 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)5 HTML (com.google.gwt.user.client.ui.HTML)5 Style (com.google.gwt.dom.client.Style)4 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)4 Anchor (com.google.gwt.user.client.ui.Anchor)4 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)4 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)3 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)3 HighlightingInlineHyperlink (com.google.gerrit.client.ui.HighlightingInlineHyperlink)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2