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

The following examples show how to use com.vaadin.client.UIDL#hasAttribute() . 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: CubaUIConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateBrowserHistory(UIDL uidl) {
    String lastHistoryOp = uidl.getStringAttribute(CubaUIConstants.LAST_HISTORY_OP);

    History history = Browser.getWindow().getHistory();
    String pageTitle = getState().pageState.title;

    String replace = uidl.getStringAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE);
    String push = uidl.getStringAttribute(UIConstants.ATTRIBUTE_PUSH_STATE);

    if (CubaUIConstants.HISTORY_PUSH_OP.equals(lastHistoryOp)) {
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE)) {
            history.replaceState(null, pageTitle, replace);
        }
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_PUSH_STATE)) {
            history.pushState(null, pageTitle, push);
        }
    } else {
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_PUSH_STATE)) {
            history.pushState(null, pageTitle, push);
        }
        if (uidl.hasAttribute(UIConstants.ATTRIBUTE_REPLACE_STATE)) {
            history.replaceState(null, pageTitle, replace);
        }
    }
}
 
Example 2
Source File: TableAggregationRow.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void addCellsFromUIDL(UIDL uidl) {
    int colIndex = 0;
    final Iterator cells = uidl.getChildIterator();
    while (cells.hasNext() && colIndex < tableWidget.getVisibleColOrder().length) {
        String columnId = tableWidget.getVisibleColOrder()[colIndex];

        if (addSpecificCell(columnId, colIndex)) {
            colIndex++;
            continue;
        }

        final Object cell = cells.next();

        String style = "";
        if (uidl.hasAttribute("style-" + columnId)) {
            style = uidl.getStringAttribute("style-" + columnId);
        }

        boolean sorted = tableWidget.getHead().getHeaderCell(colIndex).isSorted();

        if (isAggregationEditable(uidl, colIndex)) {
            addCellWithField((String) cell, aligns[colIndex], colIndex);
        } else if (cell instanceof String) {
            addCell((String) cell, aligns[colIndex], style, sorted);
        }

        final String colKey = tableWidget.getColKeyByIndex(colIndex);
        int colWidth;
        if ((colWidth = tableWidget.getColWidth(colKey)) > -1) {
            tableWidget.setColWidth(colIndex, colWidth, false);
        }

        colIndex++;
    }
}
 
Example 3
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected VScrollTableRow createRow(UIDL uidl, char[] aligns2) {
    if (uidl.hasAttribute("gen_html")) {
        // This is a generated row.
        return new VTreeTableGeneratedRow(uidl, aligns2);
    }
    return new CubaTreeTableRow(uidl, aligns2);
}
 
Example 4
Source File: CubaMenuBarConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
protected void assignAdditionalAttributes(VMenuBar.CustomMenuItem currentItem, UIDL item) {
    if (item.hasAttribute("cid")) {
        currentItem.getElement().setAttribute("cuba-id", item.getStringAttribute("cid"));
    }
}
 
Example 5
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();
}