Example usage for com.vaadin.client UIDL getStringVariable

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

Introduction

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

Prototype

public String getStringVariable(String name) 

Source Link

Document

Gets the value of the named variable.

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadConnector.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (!isRealUpdate(uidl)) {
        return;//  ww w.j  a  v  a2s  .co  m
    }

    final String uploadUrl = client.translateVaadinUri(uidl.getStringVariable("uploadUrl"));

    getWidget().setUploadUrl(uploadUrl);
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.multiupload.CubaMultiUploadConnector.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (!isRealUpdate(uidl)) {
        return;/*  w ww .j ava  2 s.  co  m*/
    }

    if (!initialized) {
        initialized = true;

        String appVersion = getConnection().getConfiguration().getApplicationVersion();

        CubaMultiUploadWidget widget = getWidget();

        widget.themeName = getConnection().getUIConnector().getActiveTheme();

        widget.resourcesVersion = appVersion;
        widget.buttonImageUri = getResourceUrl(CubaMultiUploadState.BUTTON_IMAGE_KEY);
        widget.bootstrapJsUrl = getResourceUrl(CubaMultiUploadState.SWFUPLOAD_BOOTSTRAP_JS_KEY);
        widget.flashUrl = getResourceUrl(CubaMultiUploadState.SWFUPLOAD_FLASH_KEY);

        widget.targetUrl = client.translateVaadinUri(uidl.getStringVariable("action"));

        CubaMultiUploadState state = getState();

        widget.buttonCaption = state.buttonCaption;
        widget.buttonHeight = state.buttonHeight;
        widget.buttonWidth = state.buttonWidth;
        widget.buttonStyles = state.buttonStyles;
        widget.buttonDisabledStyles = state.buttonDisabledStyles;

        widget.buttonTextLeft = state.buttonTextLeft;
        widget.buttonTextTop = state.buttonTextTop;

        widget.queueSizeLimit = state.queueSizeLimit;
        widget.fileSizeLimit = state.fileSizeLimit;
        widget.queueUploadLimit = state.queueUploadLimit;

        widget.fileTypes = state.fileTypes;
        widget.fileTypesDescription = state.fileTypesDescription;
        widget.jsessionId = state.jsessionId;
        widget.buttonEnabled = state.buttonEnabled;

        widget.initComponent(getConnectorId());
    }
}

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  w  w w  .j a  v  a  2 s  .co 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:org.opennms.features.topology.ssh.internal.gwt.client.ui.VTerminal.java

License:Open Source License

/**
 * The updateFromUIDL method handles all communication from the server and passes
 * the data along to the GwtTerminal widget which updates the client side view.
 *///from w w  w .  ja  v a 2  s .  co m
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    // This call should be made first. Ensure correct implementation,
    // and let the containing layout manage caption, etc.
    if (client.updateComponent(this, uidl, true)) {
        return;
    }

    // Save reference to server connection object to be able to send
    // user interaction later
    this.client = client;

    // Save the UIDL identifier for the component
    this.uidlId = uidl.getId();

    // Check if the server wants the TermHandler to close, if so, send a
    // response back to the server that it was closed successfully
    if (uidl.getBooleanVariable("closeClient")) {
        termHandler.close();
        isClosed = true;
        sendBytes("");
    }

    // Check if the server wants the TermHandler to update manually
    if (uidl.getBooleanVariable("update"))
        update();
    if (uidl.getBooleanVariable("focus")) {
        super.focus();
        isFocused = true;
    }

    // Take the current representation of the Terminal from the server
    // and set the Inner HTML of the widget
    dump(uidl.getStringVariable("fromSSH"));
}

From source file:org.vaadin.alump.ckeditor.client.VCKEditorTextField.java

License:Apache License

/**
 * Called whenever an update is received from the server
 *///w w  w .j  av a 2 s  .  c om
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    clientToServer = client;
    paintableId = uidl.getId();
    boolean needsDataUpdate = false;
    boolean needsProtectedBodyUpdate = false;
    boolean readOnlyModeChanged = false;

    // This call should be made first.
    // It handles sizes, captions, tooltips, etc. automatically.
    // If clientToServer.updateComponent returns true there have been no changes
    // and we do not need to update anything.
    if (clientToServer.updateComponent(this, uidl, true)) {
        return;
    }

    if (!resizeListenerInPlace) {
        LayoutManager.get(client).addElementResizeListener(getElement(), new ElementResizeListener() {

            @Override
            public void onElementResize(ElementResizeEvent e) {
                doResize();
            }

        });
        resizeListenerInPlace = true;
    }

    if (uidl.hasAttribute(ATTR_IMMEDIATE)) {
        immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE);
    }
    if (uidl.hasAttribute(ATTR_READONLY)) {
        boolean newReadOnly = uidl.getBooleanAttribute(ATTR_READONLY);
        readOnlyModeChanged = newReadOnly != readOnly;
        readOnly = newReadOnly;
    }
    if (uidl.hasAttribute(ATTR_VIEW_WITHOUT_EDITOR)) {
        viewWithoutEditor = uidl.getBooleanAttribute(ATTR_VIEW_WITHOUT_EDITOR);
    }
    if (uidl.hasAttribute(ATTR_PROTECTED_BODY)) {
        boolean state = uidl.getBooleanAttribute(ATTR_PROTECTED_BODY);
        if (protectedBody != state) {
            protectedBody = state;
            needsProtectedBodyUpdate = true;
        }
    }
    if (uidl.hasVariable(VAR_TEXT)) {
        String data = uidl.getStringVariable(VAR_TEXT);
        if (ckEditor != null)
            dataBeforeEdit = ckEditor.getData();
        needsDataUpdate = !data.equals(dataBeforeEdit);
        dataBeforeEdit = data;
    }

    // Save the client side identifier (paintable id) for the widget
    if (!paintableId.equals(getElement().getId())) {
        getElement().setId(paintableId);
    }

    if (viewWithoutEditor) {
        if (ckEditor != null) {
            // may update the data and change to viewWithoutEditor at the same time 
            if (!needsDataUpdate) {
                dataBeforeEdit = ckEditor.getData();
            }
            ckEditor.destroy(true);
            ckEditorIsReady = false;
            ckEditor = null;
        }
        getElement().setInnerHTML(dataBeforeEdit);
    } else if (ckEditor == null) {
        getElement().setInnerHTML(""); // in case we put contents in there while in viewWithoutEditor mode

        final String inPageConfig = uidl.hasAttribute(ATTR_INPAGECONFIG)
                ? uidl.getStringAttribute(ATTR_INPAGECONFIG)
                : null;

        writerIndentationChars = uidl.hasAttribute(ATTR_WRITER_INDENTATIONCHARS)
                ? uidl.getStringAttribute(ATTR_WRITER_INDENTATIONCHARS)
                : null;

        if (uidl.hasAttribute(ATTR_FOCUS)) {
            setFocus(uidl.getBooleanAttribute(ATTR_FOCUS));
        }

        // See if we have any writer rules
        int i = 0;
        while (true) {
            if (!uidl.hasAttribute(ATTR_WRITERRULES_TAGNAME + i)) {
                break;
            }
            // Save the rules until our instance is ready
            String tagName = uidl.getStringAttribute(ATTR_WRITERRULES_TAGNAME + i);
            String jsRule = uidl.getStringAttribute(ATTR_WRITERRULES_JSRULE + i);
            if (writerRules == null) {
                writerRules = new HashMap<String, String>();
            }
            writerRules.put(tagName, jsRule);
            ++i;
        }

        // See if we have any keystrokes
        i = 0;
        while (true) {
            if (!uidl.hasAttribute(ATTR_KEYSTROKES_KEYSTROKE + i)) {
                break;
            }
            // Save the keystrokes until our instance is ready
            int keystroke = uidl.getIntAttribute(ATTR_KEYSTROKES_KEYSTROKE + i);
            String command = uidl.getStringAttribute(ATTR_KEYSTROKES_COMMAND + i);
            if (keystrokeMappings == null) {
                keystrokeMappings = new HashMap<Integer, String>();
            }
            keystrokeMappings.put(keystroke, command);
            ++i;
        }

        // See if we have any protected source regexs
        i = 0;
        while (true) {
            if (!uidl.hasAttribute(ATTR_PROTECTED_SOURCE + i)) {
                break;
            }
            // Save the regex until our instance is ready
            String regex = uidl.getStringAttribute(ATTR_PROTECTED_SOURCE + i);
            if (protectedSourceList == null) {
                protectedSourceList = new LinkedList<String>();
            }
            protectedSourceList.add(regex);
            ++i;
        }

        ScheduledCommand scE = new ScheduledCommand() {
            @Override
            public void execute() {
                ckEditor = (CKEditor) CKEditorService.loadEditor(paintableId, VCKEditorTextField.this,
                        inPageConfig, VCKEditorTextField.super.getOffsetWidth(),
                        VCKEditorTextField.super.getOffsetHeight());

            }
        };

        CKEditorService.loadLibrary(scE);

        // editor data and some options are set when the instance is ready....
    } else if (ckEditorIsReady) {
        if (needsDataUpdate) {
            ckEditor.setData(dataBeforeEdit);
        }

        if (needsProtectedBodyUpdate) {
            ckEditor.protectBody(protectedBody);
        }

        if (uidl.hasAttribute(ATTR_INSERT_HTML)) {
            ckEditor.insertHtml(uidl.getStringAttribute(ATTR_INSERT_HTML));
        }

        if (uidl.hasAttribute(ATTR_INSERT_TEXT)) {
            ckEditor.insertText(uidl.getStringAttribute(ATTR_INSERT_TEXT));
        }

        if (uidl.hasAttribute(ATTR_FOCUS)) {
            setFocus(uidl.getBooleanAttribute(ATTR_FOCUS));
        }

        if (readOnlyModeChanged) {
            ckEditor.setReadOnly(readOnly);
        }
    }

}