Java Code Examples for com.vaadin.client.UIDL#getChildCount()

The following examples show how to use com.vaadin.client.UIDL#getChildCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaTextFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // We may have actions attached to this text field
    if (uidl.getChildCount() > 0) {
        final int cnt = uidl.getChildCount();
        for (int i = 0; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}
 
Example 2
Source File: CubaMaskedFieldConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // We may have actions attached to this text field
    if (uidl.getChildCount() > 0) {
        final int cnt = uidl.getChildCount();
        for (int i = 0; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}
 
Example 3
Source File: CubaComboBoxConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // We may have actions attached to this text field
    if (uidl.getChildCount() > 0) {
        final int cnt = uidl.getChildCount();
        for (int i = 0; i < cnt; i++) {
            UIDL childUidl = uidl.getChildUIDL(i);
            if (childUidl.getTag().equals("actions")) {
                if (getWidget().getShortcutActionHandler() == null) {
                    getWidget().setShortcutActionHandler(new ShortcutActionHandler(uidl.getId(), client));
                }
                getWidget().getShortcutActionHandler().updateActionMap(childUidl);
            }
        }
    }
}
 
Example 4
Source File: CubaOrderedActionsLayoutConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    final int cnt = uidl.getChildCount();
    for (int i = 0; i < cnt; i++) {
        UIDL childUidl = uidl.getChildUIDL(i);
        if (childUidl.getTag().equals("actions")) {
            if (getWidget().getShortcutHandler() == null) {
                getWidget().setShortcutHandler(new ShortcutActionHandler(uidl.getId(), client));
            }
            getWidget().getShortcutHandler().updateActionMap(childUidl);
        }
    }
}
 
Example 5
Source File: TableAggregationRow.java    From cuba with Apache License 2.0 4 votes vote down vote up
public void updateFromUIDL(UIDL uidl) {
    if (container.hasChildNodes()) {
        container.removeAllChildren();
    }

    aligns = tableWidget.getHead().getColumnAlignments();

    if (uidl.getChildCount() > 0) {
        final Element table = DOM.createTable();
        table.setAttribute("cellpadding", "0");
        table.setAttribute("cellspacing", "0");

        final Element tBody = DOM.createTBody();
        tr = DOM.createTR();

        tr.setClassName(tableWidget.getStylePrimaryName() + "-arow-row");

        if (inputsList != null && !inputsList.isEmpty()) {
            inputsList.clear();
        }

        addCellsFromUIDL(uidl);

        tBody.appendChild(tr);
        table.appendChild(tBody);

        DivElement tableWrapper = Document.get().createDivElement();
        tableWrapper.appendChild(table);
        container.appendChild(tableWrapper);

        // set focus to input if we pressed `ENTER`
        String focusColumnKey = uidl.getStringAttribute("focusInput");
        if (focusColumnKey != null && inputsList != null) {
            for (AggregationInputFieldInfo info : inputsList) {
                if (info.getColumnKey().equals(focusColumnKey)) {
                    info.getInputElement().focus();
                    break;
                }
            }
        }
    }

    initialized = container.hasChildNodes();
}
 
Example 6
Source File: CubaMenuBarWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public String buildItemHTML(UIDL item) {
    // Construct html from the text and the optional icon
    // Haulmont API : Added support for shortcuts
    StringBuilder itemHTML = new StringBuilder();
    if (item.hasAttribute("separator")) {
        itemHTML.append("<span>---</span><span>---</span>");
    } else {
        itemHTML.append("<span class=\"")
                .append(getStylePrimaryName())
                .append("-menuitem-caption\">");

        Icon icon = client.getIcon(item.getStringAttribute("icon"));
        if (icon != null) {
            itemHTML.append(icon.getElement().getString());
        }

        String itemText = item.getStringAttribute("text");
        if (!htmlContentAllowed) {
            itemText = WidgetUtil.escapeHTML(itemText);
        }
        itemHTML.append(itemText);
        itemHTML.append("</span>");

        // Add submenu indicator
        if (item.getChildCount() > 0) {
            String bgStyle = "";
            itemHTML.append("<span class=\"")
                    .append(getStylePrimaryName())
                    .append("-submenu-indicator\"")
                    .append(bgStyle)
                    .append("><span class=\"")
                    .append(getStylePrimaryName())
                    .append("-submenu-indicator-icon\"")
                    .append("><span class=\"text\">&#x25BA;</span></span></span>");
        } else {
            itemHTML.append("<span class=\"");
            String shortcut = "";
            if (item.hasAttribute("shortcut")) {
                shortcut = item.getStringAttribute("shortcut");
            } else {
                itemHTML.append(getStylePrimaryName())
                        .append("-menuitem-empty-shortcut ");
            }

            itemHTML.append(getStylePrimaryName())
                    .append("-menuitem-shortcut\">")
                    .append(shortcut)
                    .append("</span");
        }
    }
    return itemHTML.toString();
}
 
Example 7
Source File: ViewClientCriterion.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
// Exception squid:S1604 - GWT 2.7 does not support Java 8
@SuppressWarnings("squid:S1604")
public void accept(final VDragEvent drag, final UIDL configuration, final VAcceptCallback callback) {

    if (isDragStarting(drag)) {
        final NativePreviewHandler nativeEventHandler = new NativePreviewHandler() {
            @Override
            public void onPreviewNativeEvent(final NativePreviewEvent event) {
                if (isEscKey(event) || isMouseUp(event)) {
                    try {
                        hideDropTargetHints(configuration);
                    } finally {
                        nativeEventHandlerRegistration.removeHandler();
                    }
                }
            }
        };

        nativeEventHandlerRegistration = Event.addNativePreviewHandler(nativeEventHandler);
        setMultiRowDragDecoration(drag);
    }

    final int childCount = configuration.getChildCount();
    accepted = false;
    for (int childIndex = 0; childIndex < childCount; childIndex++) {
        final VAcceptCriterion crit = getCriteria(configuration, childIndex);
        crit.accept(drag, configuration.getChildUIDL(childIndex), this);
        if (Boolean.TRUE.equals(accepted)) {
            callback.accepted(drag);
            return;
        }
    }

    // if no VAcceptCriterion accepts and the mouse is release, an error
    // message is shown
    if (Event.ONMOUSEUP == Event.getTypeInt(drag.getCurrentGwtEvent().getType())) {
        showErrorNotification(drag);
    }

    errorMessage = configuration.getStringAttribute(ERROR_MESSAGE);
}