Example usage for com.vaadin.client ApplicationConnection DISABLED_CLASSNAME

List of usage examples for com.vaadin.client ApplicationConnection DISABLED_CLASSNAME

Introduction

In this page you can find the example usage for com.vaadin.client ApplicationConnection DISABLED_CLASSNAME.

Prototype

String DISABLED_CLASSNAME

To view the source code for com.vaadin.client ApplicationConnection DISABLED_CLASSNAME.

Click Source Link

Usage

From source file:com.eternach.client.RichOptionGroupWidget.java

License:Apache License

@Override
public void buildOptions(final UIDL uidl) {
    panel.clear();/* w w  w.j a va 2s .  c om*/
    optionsEnabled.clear();
    for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
        boolean iconDisplayed = false;
        final UIDL opUidl = (UIDL) it.next();
        CheckBox op;

        String itemHtml = opUidl.getStringAttribute("caption");
        if (!htmlContentAllowed) {
            itemHtml = Util.escapeHTML(itemHtml);
        }

        final String icon = opUidl.getStringAttribute("icon");
        if (icon != null && icon.length() != 0) {
            final String iconUrl = client.translateVaadinUri(icon);
            itemHtml = "<span style=\"white-space: normal;\">" + itemHtml + "</span><br/><img src=\"" + iconUrl
                    + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />";
            iconDisplayed = true;
        }

        if (isMultiselect()) {
            op = new VCheckBox();
        } else {
            op = new RadioButton(paintableId, null, true);
            op.setStyleName("v-radiobutton");
        }

        op.addStyleName(CLASSNAME_OPTION);
        op.setValue(opUidl.getBooleanAttribute("selected"));
        final boolean optionEnabled = !opUidl
                .getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED);
        final boolean enabled = optionEnabled && !isReadonly() && isEnabled();
        op.setEnabled(enabled);
        optionsEnabled.add(optionEnabled);
        setStyleName(op.getElement(), ApplicationConnection.DISABLED_CLASSNAME,
                !(optionEnabled && isEnabled()));
        op.addClickHandler(this);
        optionsToKeys.put(op, opUidl.getStringAttribute("key"));
        String description = opUidl.getStringAttribute("description-text");
        if (description == null) {
            description = "";
        }
        if (opUidl.getStringAttribute("description-icon") != null) {
            description += "<br/><img src=\""
                    + client.translateVaadinUri(opUidl.getStringAttribute("description-icon")) + "\"\\>";
        }

        final FocusableFlexTable table = new FocusableFlexTable();
        table.setWidget(0, 0, op);
        table.setHTML(0, 1, itemHtml);
        table.setCellPadding(0);
        table.setCellSpacing(0);
        panel.add(table);

        if (description != null && description.length() != 0) {
            elementsToDescription.put(table.getElement(), description);
        }
        if (iconDisplayed) {
            Util.sinkOnloadForImages(table.getElement());
            table.addHandler(iconLoadHandler, LoadEvent.getType());
        }
    }

}

From source file:com.eternach.client.RichOptionGroupWidget.java

License:Apache License

@Override
protected void updateEnabledState() {
    int i = 0;//  w  w w.ja  v  a 2 s . c o m
    final boolean optionGroupEnabled = isEnabled() && !isReadonly();
    // sets options enabled according to the widget's enabled,
    // readonly and each options own enabled
    for (final Widget w : panel) {
        if (w instanceof HasEnabled) {
            ((HasEnabled) w).setEnabled(optionsEnabled.get(i) && optionGroupEnabled);
            setStyleName(w.getElement(), ApplicationConnection.DISABLED_CLASSNAME,
                    !(optionsEnabled.get(i) && isEnabled()));
        }
        i++;
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.actionbar.widget.ActionbarItemWidget.java

License:Open Source License

public void update() {
    text.setInnerText(data.getLabel());//  w ww  .j  a v a2  s . c  o m
    if (data.getIconFontId() != null) {
        icon.setClassName("v-icon");
        if (data.getIconFontId() != null && !data.getIconFontId().isEmpty()) {
            icon.addClassName(data.getIconFontId());
        }
    } else if (iconImage != null) {
        iconImage.setUri(data.getResourceUrl());
    }

    if (isEnabled() && root.getClassName().contains(ApplicationConnection.DISABLED_CLASSNAME)) {
        root.removeClassName(ApplicationConnection.DISABLED_CLASSNAME);
    } else if (!isEnabled() && !root.getClassName().contains(ApplicationConnection.DISABLED_CLASSNAME)) {
        root.addClassName(ApplicationConnection.DISABLED_CLASSNAME);
    }
}