Search in sources :

Example 1 with UIDL

use of com.vaadin.client.UIDL in project cuba by cuba-platform.

the class CubaTwinColSelectWidget method buildOptions.

@Override
public void buildOptions(UIDL uidl) {
    options.setMultipleSelect(isMultiselect());
    selections.setMultipleSelect(isMultiselect());
    int optionsSelectedIndex = options.getSelectedIndex();
    int selectionsSelectedIndex = selections.getSelectedIndex();
    options.clear();
    selections.clear();
    int selectedOptions = 0;
    int availableOptions = 0;
    for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext(); ) {
        final UIDL optionUidl = (UIDL) i.next();
        if (optionUidl.hasAttribute("selected")) {
            selections.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));
            if (optionUidl.hasAttribute("style")) {
                CubaDoubleClickListBox cubaSelections = (CubaDoubleClickListBox) selections;
                cubaSelections.setOptionClassName(selectedOptions, optionUidl.getStringAttribute("style"));
            }
            selectedOptions++;
        } else {
            options.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));
            if (optionUidl.hasAttribute("style")) {
                CubaDoubleClickListBox cubaOptions = (CubaDoubleClickListBox) options;
                cubaOptions.setOptionClassName(availableOptions, optionUidl.getStringAttribute("style"));
            }
            availableOptions++;
        }
    }
    if (getRows() > 0) {
        options.setVisibleItemCount(getRows());
        selections.setVisibleItemCount(getRows());
    }
    setSelectedIndex(options, optionsSelectedIndex);
    setSelectedIndex(selections, selectionsSelectedIndex);
}
Also used : UIDL(com.vaadin.client.UIDL)

Example 2 with UIDL

use of com.vaadin.client.UIDL in project ANNIS by korpling.

the class VAnnotationGrid method addRow.

private void addRow(UIDL row, int rowNumber) {
    String caption = row.getStringAttribute("caption");
    boolean showNamespace = row.getBooleanAttribute("show-namespace");
    String style = row.hasAttribute("style") ? row.getStringAttribute("style") : null;
    String name;
    if (showNamespace) {
        name = caption;
    } else {
        String[] captionSplit = caption.split("::");
        name = captionSplit[captionSplit.length - 1];
    }
    boolean showCaption = row.getBooleanAttribute("show-caption");
    int startColumn = 0;
    if (showCaption) {
        table.setHTML(rowNumber, 0, WidgetUtil.escapeHTML(name));
        formatter.addStyleName(rowNumber, 0, "header");
        startColumn = 1;
    }
    if (style != null && !style.isEmpty()) {
        table.getRowFormatter().addStyleName(rowNumber, style);
    }
    int colspanOffset = 0;
    UIDL events = row.getChildByTagName("events");
    for (int j = 0; j < events.getChildCount(); j++) {
        UIDL event = events.getChildUIDL(j);
        String id = event.getStringAttribute("id");
        int left = event.getIntAttribute("left");
        int right = event.getIntAttribute("right");
        String value = event.getStringAttribute("value");
        if (escapeHTML) {
            value = WidgetUtil.escapeHTML(value);
        }
        // +1 because we also have a caption column, subtract columns we
        // jumped over by using colspan
        int col = left + startColumn - colspanOffset;
        table.setHTML(rowNumber, col, value);
        if (event.hasAttribute("tooltip")) {
            Element tdElement = table.getCellFormatter().getElement(rowNumber, col);
            tdElement.setTitle(event.getStringAttribute("tooltip"));
        }
        position2id.put(new Position(rowNumber, col), id);
        int colspan = right - left + 1;
        formatter.setColSpan(rowNumber, col, colspan);
        if (colspan > 1) {
            colspanOffset += (colspan - 1);
        }
        addStyleForEvent(event, rowNumber, col);
    }
}
Also used : TableCellElement(com.google.gwt.dom.client.TableCellElement) TableRowElement(com.google.gwt.dom.client.TableRowElement) Element(com.google.gwt.dom.client.Element) UIDL(com.vaadin.client.UIDL)

Example 3 with UIDL

use of com.vaadin.client.UIDL in project cuba by cuba-platform.

the class TableAggregationRow method isAggregationEditable.

protected boolean isAggregationEditable(UIDL uidl, int colIndex) {
    UIDL colUidl = uidl.getChildByTagName("editableAggregationColumns");
    if (colUidl == null) {
        return false;
    }
    String colKey = tableWidget.getColKeyByIndex(colIndex);
    Iterator iterator = colUidl.getChildIterator();
    while (iterator.hasNext()) {
        Object uidlKey = iterator.next();
        if (uidlKey.equals(colKey)) {
            return true;
        }
    }
    return false;
}
Also used : Iterator(java.util.Iterator) UIDL(com.vaadin.client.UIDL)

Example 4 with UIDL

use of com.vaadin.client.UIDL in project cuba by cuba-platform.

the class CubaDateFieldConnector method updateFromUIDL.

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    super.updateFromUIDL(uidl, client);
    getWidget().updateTextState();
    // 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);
            }
        }
    }
}
Also used : ShortcutActionHandler(com.vaadin.client.ui.ShortcutActionHandler) UIDL(com.vaadin.client.UIDL)

Example 5 with UIDL

use of com.vaadin.client.UIDL in project ANNIS by korpling.

the class VAnnotationGrid method updateFromUIDL.

/**
 * Called whenever an update is received from the server
 */
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // It handles sizes, captions, tooltips, etc. automatically.
    if (client.updateComponent(this, uidl, true)) {
        // do not need to update anything.
        return;
    }
    // Save reference to server connection object to be able to send
    // user interaction later
    this.gClient = client;
    // Save the client side identifier (paintable id) for the widget
    paintableId = uidl.getId();
    try {
        if (uidl.hasAttribute("escapeHTML")) {
            this.escapeHTML = uidl.getBooleanAttribute("escapeHTML");
        }
        UIDL rows = uidl.getChildByTagName("rows");
        if (rows != null) {
            // clear all old table cells
            table.removeAllRows();
            highlighted.clear();
            position2id.clear();
            for (int i = 0; i < rows.getChildCount(); i++) {
                UIDL row = rows.getChildUIDL(i);
                if ("row".equals(row.getTag())) {
                    addRow(row, i);
                }
            }
        }
        // end if rows not null
        // add end events if necessary to have a nicely aligned regular grid
        int maxCellCount = 0;
        for (int row = 0; row < table.getRowCount(); row++) {
            maxCellCount = Math.max(maxCellCount, getRealColumnCount(row));
        }
        for (int row = 0; row < table.getRowCount(); row++) {
            int isValue = getRealColumnCount(row);
            if (isValue < maxCellCount) {
                int diff = maxCellCount - isValue;
                table.setHTML(row, table.getCellCount(row) + diff - 1, "");
            }
        }
    } catch (Exception ex) {
        Logger.getLogger(VAnnotationGrid.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
}
Also used : UIDL(com.vaadin.client.UIDL)

Aggregations

UIDL (com.vaadin.client.UIDL)6 Element (com.google.gwt.dom.client.Element)1 TableCellElement (com.google.gwt.dom.client.TableCellElement)1 TableRowElement (com.google.gwt.dom.client.TableRowElement)1 ShortcutActionHandler (com.vaadin.client.ui.ShortcutActionHandler)1 Iterator (java.util.Iterator)1