Example usage for com.vaadin.client UIDL hasAttribute

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

Introduction

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

Prototype

public boolean hasAttribute(final String name) 

Source Link

Document

Indicates whether or not the named attribute is available.

Usage

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();//w w  w  . ja  va  2 s  . 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:com.haulmont.cuba.web.toolkit.ui.client.widgetstree.CubaWidgetsTreeConnector.java

License:Apache License

@Override
protected VTree.TreeNode createNode(UIDL childUidl) {
    if (childUidl.hasAttribute("widgetIndex")) {
        int widgetIndex = childUidl.getIntAttribute("widgetIndex");
        if (widgetIndex < nodeWidgets.size()) {
            ComponentConnector componentConnector = getChildComponents().get(widgetIndex);

            CubaWidgetsTreeWidget.WidgetTreeNode treeNode = getWidget().new WidgetTreeNode();
            treeNode.setNodeWidget(componentConnector.getWidget());
            return treeNode;
        }//from w ww . j a  v  a  2  s  . c o  m
    }
    // all branches should return instance of same TreeNode class
    return getWidget().new WidgetTreeNode();
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VDragDropUtil.java

License:Apache License

public static void updateDropHandlerFromUIDL(UIDL uidl, ComponentConnector connector,
        VDDAbstractDropHandler dropHandler) {
    VDDHasDropHandler widget = (VDDHasDropHandler) connector.getWidget();
    if (AbstractComponentConnector.isRealUpdate(uidl) && !uidl.hasAttribute("hidden")) {
        UIDL acceptCrit = uidl.getChildByTagName("-ac");
        if (acceptCrit == null) {
            widget.setDropHandler(null);
        } else {/*from   w  w  w.j a va  2  s.  c  o  m*/
            if (widget.getDropHandler() == null) {
                widget.setDropHandler(dropHandler);
            }
            widget.getDropHandler().updateAcceptRules(acceptCrit);
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.client.table.CubaScrollTableWidget.java

License:Apache License

@Override
public void updateColumnProperties(UIDL uidl) {
    super.updateColumnProperties(uidl);

    if (uidl.hasAttribute("colcubaids") && uidl.hasAttribute("vcolorder")) {
        try {//from www . ja va  2  s  . com
            String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
            String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");

            Map<String, HeaderCell> headerCellMap = new HashMap<>();
            for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
                HeaderCell headerCell = getHead().getHeaderCell(i);
                if (headerCell.getColKey() != null) {
                    headerCellMap.put(headerCell.getColKey(), headerCell);
                }
            }

            for (int i = 0; i < vcolorder.length; i++) {
                String key = vcolorder[i];
                HeaderCell headerCell = headerCellMap.get(key);

                if (headerCell != null) {
                    headerCell.getElement().setAttribute("cuba-id", "column_" + colcubaids[i]);
                }
            }
        } catch (Exception e) {
            Logger.getLogger("CubaScrollTableWidget").log(Level.SEVERE,
                    "Unable to init cuba-ids for columns " + e.getMessage());
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.client.treetable.CubaTreeTableWidget.java

License:Apache License

@Override
public void updateColumnProperties(UIDL uidl) {
    super.updateColumnProperties(uidl);

    if (uidl.hasAttribute("colcubaids") && uidl.hasAttribute("vcolorder")) {
        try {/*from  w w  w.j  av a  2  s .c  o m*/
            String[] vcolorder = uidl.getStringArrayAttribute("vcolorder");
            String[] colcubaids = uidl.getStringArrayAttribute("colcubaids");

            Map<String, HeaderCell> headerCellMap = new HashMap<>();
            for (int i = 0; i < getHead().getVisibleCellCount(); i++) {
                HeaderCell headerCell = getHead().getHeaderCell(i);
                if (headerCell.getColKey() != null) {
                    headerCellMap.put(headerCell.getColKey(), headerCell);
                }
            }

            for (int i = 0; i < vcolorder.length; i++) {
                String key = vcolorder[i];
                HeaderCell headerCell = headerCellMap.get(key);

                if (headerCell != null) {
                    headerCell.getElement().setAttribute("cuba-id", "column_" + colcubaids[i]);
                }
            }
        } catch (Exception e) {
            Logger.getLogger("CubaTreeTableWidget").log(Level.SEVERE,
                    "Unable to init cuba-ids for columns " + e.getMessage());
        }
    }
}

From source file:com.haulmont.cuba.web.widgets.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();/*  w w  w.  java  2s. c  o  m*/
    selections.clear();

    int selectedOptions = 0;
    int availableOptions = 0;

    for (Object anUidl : uidl) {
        UIDL optionUidl = (UIDL) anUidl;

        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:com.wcs.wcslib.vaadin.widget.multifileupload.client.CustomUploadConnector.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    super.updateFromUIDL(uidl, client);
    if (uidl.hasAttribute("maxFileSize")) {
        getWidget().setMaxFileSize(uidl.getLongAttribute("maxFileSize"));
    }//from w  ww.  jav  a2s. c  o  m
    if (uidl.hasAttribute("sizeErrorMsg")) {
        getWidget().setSizeErrorMsg(uidl.getStringAttribute("sizeErrorMsg"));
    }
    if (uidl.hasAttribute("acceptFilter")) {
        getWidget().setAcceptFilter(uidl.getStringAttribute("acceptFilter"));
    }
    if (uidl.hasAttribute("mimeTypeErrorMsg")) {
        getWidget().setMimeTypeErrorMsg(uidl.getStringAttribute("mimeTypeErrorMsg"));
    }
    if (uidl.hasAttribute("acceptedMimeTypes")) {
        getWidget().setAcceptedMimeTypes(Arrays.asList(uidl.getStringArrayAttribute("acceptedMimeTypes")));
    }
}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.client.VMultiUpload.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true)) {
        return;//from ww  w  . ja  v  a  2s  .c  o m
    }
    addStyleName(CLASSNAME + "-immediate");

    this.client = client;
    paintableId = uidl.getId();
    receiverUri = client.translateVaadinUri(uidl.getStringVariable("target"));
    submitButton.setText(uidl.getStringAttribute("buttoncaption"));
    fu.setName(paintableId + "_file");

    if (uidl.hasAttribute("enabled")) {
        if (uidl.getBooleanAttribute("enabled")) {
            enableUpload();
        } else {
            disableUpload();
        }
    }

    if (uidl.hasAttribute("maxFileSize")) {
        maxFileSize = uidl.getLongAttribute("maxFileSize");
    }
    if (uidl.hasAttribute("sizeErrorMsg")) {
        sizeErrorMsg = uidl.getStringAttribute("sizeErrorMsg");
    }
    if (uidl.hasAttribute("mimeTypeErrorMsg")) {
        mimeTypeErrorMsg = uidl.getStringAttribute("mimeTypeErrorMsg");
    }
    if (uidl.hasAttribute("acceptFilter")) {
        getInput().setAccept(uidl.getStringAttribute("acceptFilter"));
    }
    if (uidl.hasAttribute("acceptedMimeTypes")) {
        acceptedMimeTypes = Arrays.asList(uidl.getStringArrayAttribute("acceptedMimeTypes"));
    }
    if (uidl.hasAttribute("interruptedFileIds")) {
        removeFromFileQueue(uidl.getIntArrayAttribute("interruptedFileIds"));
    }
    if (uidl.hasAttribute("ready")) {
        postNextFileFromQueue();
    }
}

From source file:info.magnolia.ui.vaadin.gwt.client.richtext.VMagnoliaRichTextField.java

License:Open Source License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    // Make sure external plugins are assigned before the loading command.
    if (uidl.hasAttribute(VAR_SERVERPLUGINS)) {
        customPlugins = uidl.getMapAttribute(VAR_SERVERPLUGINS);
    }/*from www.j  a  va  2  s  .co  m*/

    // list of plugin events that server is interested of handling.
    if (uidl.hasAttribute(VAR_EVENTNAMES)) {
        pluginEvents = Arrays.asList(uidl.getStringArrayAttribute(VAR_EVENTNAMES));
    }

    if (uidl.hasAttribute(ATTR_IMMEDIATE)) {
        immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE);
    }

    super.updateFromUIDL(uidl, client);

    // Server wants to send an event to a plugin, we must do this after super value update.
    if (uidl.hasAttribute(VAR_FIRE_PLUGIN_EVENT) && this.editor != null) {
        this.editor.fire(uidl.getStringAttribute(VAR_FIRE_PLUGIN_EVENT),
                uidl.getStringAttribute(VAR_FIRE_PLUGIN_EVENT_VALUE));
    }
}

From source file:org.semanticsoft.vaaclipse.widgets.client.ui.extlayout.ExtendedVerticalLayoutConnector.java

License:Open Source License

/**
 * Called whenever an update is received from the server
 *//* ww  w .j  av a2 s  .co  m*/
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    VExtendedVerticalLayout layout = getWidget();

    layout.paintableId = uidl.getId();

    if (uidl.hasAttribute(VExtendedVerticalLayout.VARIABLES)) {
        ValueMap vmap = uidl.getMapAttribute(VExtendedVerticalLayout.VARIABLES);
        Set<String> indexes = vmap.getKeySet();
        for (String index : indexes) {
            layout.variables.put(index, vmap.getString(index));
        }
    }
}