Search in sources :

Example 1 with FormLabel

use of org.openremote.app.client.widget.FormLabel in project openremote by openremote.

the class MapInfoPanel method setItems.

public void setItems(List<MapInfoItem> infoItems) {
    contentPanel.clear();
    int itemLineHeightPixels = 20;
    int itemMarginPixels = 8;
    int itemHeightPixels = itemLineHeightPixels + (itemMarginPixels * 2);
    int totalMaxHeight = itemHeightPixels * MAX_ITEMS_BEFORE_SCROLLING;
    for (MapInfoItem infoItem : infoItems) {
        IconLabel itemIcon = new IconLabel(infoItem.getIcon());
        itemIcon.addStyleName(style.infoItemIcon());
        FormLabel itemLabel = new FormLabel(TextUtil.ellipsize(infoItem.getLabel(), 35));
        itemLabel.addStyleName("flex");
        itemLabel.addStyleName(style.infoItemLabel());
        Widget itemValue = createItemValue(infoItem);
        itemValue.addStyleName(style.infoItemValue());
        FlowPanel itemPanel = new FlowPanel();
        itemPanel.addStyleName("flex-none layout horizontal center");
        itemPanel.addStyleName(style.infoItem());
        itemPanel.add(itemIcon);
        itemPanel.add(itemLabel);
        itemPanel.add(itemValue);
        contentPanel.add(itemPanel);
    }
    // Show up to 6 items, then start scrolling
    panel.setHeight(Math.min((infoItems.size() * itemHeightPixels), totalMaxHeight) + "px");
    // If the panel is already shown, "blink" it so users know there is an update
    if (isOpen()) {
        contentPanel.addStyleName(widgetStyle.HighlightBackground());
        Browser.getWindow().setTimeout(() -> {
            contentPanel.removeStyleName(widgetStyle.HighlightBackground());
        }, 250);
    }
}
Also used : IconLabel(org.openremote.app.client.widget.IconLabel) Widget(com.google.gwt.user.client.ui.Widget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) FormLabel(org.openremote.app.client.widget.FormLabel)

Aggregations

FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Widget (com.google.gwt.user.client.ui.Widget)1 FormLabel (org.openremote.app.client.widget.FormLabel)1 IconLabel (org.openremote.app.client.widget.IconLabel)1