Search in sources :

Example 1 with IconLabel

use of org.openremote.app.client.widget.IconLabel 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)

Example 2 with IconLabel

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

the class JsonEditorImpl method parseValue.

protected Value parseValue() {
    errorPanel.clear();
    Value value = null;
    String error = null;
    try {
        value = Values.parse(editor.getText()).orElse(null);
        if (value == null)
            error = managerMessages.emptyJsonData();
    } catch (ValueException ex) {
        error = ex.getMessage();
    }
    if (error != null) {
        errorPanel.add(new IconLabel("warning"));
        InlineLabel errorMessage = new InlineLabel(error);
        errorPanel.add(errorMessage);
        errorPanel.setVisible(true);
        return null;
    }
    errorPanel.setVisible(false);
    return value;
}
Also used : ValueException(org.openremote.model.value.ValueException) IconLabel(org.openremote.app.client.widget.IconLabel) Value(org.openremote.model.value.Value) InlineLabel(com.google.gwt.user.client.ui.InlineLabel)

Aggregations

IconLabel (org.openremote.app.client.widget.IconLabel)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)1 Widget (com.google.gwt.user.client.ui.Widget)1 FormLabel (org.openremote.app.client.widget.FormLabel)1 Value (org.openremote.model.value.Value)1 ValueException (org.openremote.model.value.ValueException)1