Example usage for com.vaadin.client UIDL getStringAttribute

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

Introduction

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

Prototype

public String getStringAttribute(String name) 

Source Link

Document

Gets the named attribute as a String.

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();// www  .  j  a  v  a2 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.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();/*  www.ja v  a 2  s  . com*/
    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  ww  w .  j  av a 2s.  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;/*  w  w w  .  j av  a  2  s. 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.grid.VMagnoliaTreeTable.java

License:Open Source License

@Override
protected String buildCaptionHtmlSnippet(UIDL uidl) {
    return (uidl.getTag().equals("column")) ? super.buildCaptionHtmlSnippet(uidl)
            : uidl.getStringAttribute("caption");
}

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  ww w . j a  v a  2s. c o 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:it.zero11.vaadin.asyncfiltercombobox.client.AsyncFilterComboBoxConnector.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    getWidget().filterChangeEventMode = uidl
            .getStringAttribute(AsyncFilterComboBoxConstants.ATTR_FILTERCHANGE_EVENTMODE);
    getWidget().filterChangeEventTimeout = uidl
            .getIntAttribute(AsyncFilterComboBoxConstants.ATTR_FILTERCHANGE_TIMEOUT);
    super.updateFromUIDL(uidl, client);
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ItemIdClientCriterion.java

License:Open Source License

@Override
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
protected boolean accept(VDragEvent drag, UIDL configuration) {
    try {/*from   w w w  . j a  v a  2  s .co m*/

        String component = drag.getTransferable().getDragSource().getWidget().getElement().getId();
        int c = configuration.getIntAttribute(COMPONENT_COUNT);
        String mode = configuration.getStringAttribute(MODE);
        for (int dragSourceIndex = 0; dragSourceIndex < c; dragSourceIndex++) {
            String requiredPid = configuration.getStringAttribute(COMPONENT + dragSourceIndex);
            if ((STRICT_MODE.equals(mode) && component.equals(requiredPid))
                    || (PREFIX_MODE.equals(mode) && component.startsWith(requiredPid))) {
                return true;
            }

        }
    } catch (Exception e) {
        // log and continue
        LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage());
    }
    return false;
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.java

License:Open Source License

private static VAcceptCriterion getCriteria(final UIDL configuration, final int i) {
    final UIDL childUIDL = configuration.getChildUIDL(i);
    return VAcceptCriteria.get(childUIDL.getStringAttribute("name"));
}

From source file:org.eclipse.hawkbit.ui.dd.client.criteria.ViewClientCriterion.java

License:Open Source License

@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/*from   www .  j a v  a 2  s.c o m*/
            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);
}