Example usage for com.vaadin.client UIDL getChildIterator

List of usage examples for com.vaadin.client UIDL getChildIterator

Introduction

In this page you can find the example usage for com.vaadin.client UIDL getChildIterator.

Prototype

@Deprecated
public Iterator<Object> getChildIterator() 

Source Link

Document

Gets an iterator that can be used to iterate trough the children of this UIDL.

Usage

From source file:annis.gui.widgets.gwt.client.ui.VSimpleCanvas.java

License:Apache License

/**
 * Called whenever an update is received from the server 
 *///ww w.  ja va  2  s.  c om
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    // This call should be made first. 
    // It handles sizes, captions, tooltips, etc. automatically.
    if (client.updateComponent(this, uidl, true)) {
        // If client.updateComponent returns true there has been no changes and we
        // 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();

    if (context != null) {
        Iterator<Object> it = uidl.getChildIterator();
        while (it.hasNext()) {
            UIDL child = (UIDL) it.next();

            if ("clear".equals(child.getTag())) {
                context.clearRect(0, 0, context.getCanvas().getWidth(), context.getCanvas().getHeight());
            } else if ("line".equals(child.getTag())) {
                context.setGlobalAlpha(1.0);
                context.setLineWidth(1.0);
                context.setStrokeStyle("black");
                context.beginPath();
                context.moveTo(child.getIntAttribute("from_x"), child.getIntAttribute("from_y"));
                context.lineTo(child.getIntAttribute("to_x"), child.getIntAttribute("to_y"));
                context.closePath();
                context.stroke();
            }
            // todo: more commands :)
        }

    }
}

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

License:Apache License

@Override
public void buildOptions(final UIDL uidl) {
    panel.clear();/*from ww  w.j  a v  a  2 s  . co m*/
    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.haulmont.cuba.web.toolkit.ui.client.aggregation.TableAggregationRow.java

License:Apache License

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++;//from www. j av a2 s .  co  m
            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 (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++;
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.twincolselect.CubaTwinColSelectWidget.java

License:Apache License

@Override
public void buildOptions(UIDL uidl) {
    options.setMultipleSelect(isMultiselect());
    selections.setMultipleSelect(isMultiselect());

    int optionsSelectedIndex = options.getSelectedIndex();
    int selectionsSelectedIndex = selections.getSelectedIndex();
    options.clear();/*  ww  w . j  a  v  a 2s . c o  m*/
    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);
}

From source file:org.vaadin.tepi.listbuilder.widgetset.client.ui.VListBuilder.java

License:Apache License

void buildOptions(UIDL uidl) {
    final boolean enabled = !isDisabled() && !isReadonly();
    options.setEnabled(enabled);/*from   w  w  w .j  a  v a2 s . co  m*/
    selections.setEnabled(enabled);
    add.setEnabled(enabled);
    remove.setEnabled(enabled);
    options.clear();
    selections.clear();
    originalOrder.clear();

    HashMap<String, String> capts = new HashMap<String, String>();
    for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
        final UIDL optionUidl = (UIDL) i.next();
        if (optionUidl.hasAttribute("selected")) {
            capts.put(optionUidl.getStringAttribute("key"), optionUidl.getStringAttribute("caption"));
        } else {
            options.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));
        }
        originalOrder.add(optionUidl.getStringAttribute("key"));
    }
    for (String key : selectedKeys) {
        selections.addItem(capts.get(key), key);
    }

    if (getRows() > 0) {
        options.setVisibleItemCount(getRows());
        selections.setVisibleItemCount(getRows());
    }
}