Package com.vaadin.terminal

Examples of com.vaadin.terminal.VariableOwner


        StreamVariable streamVariable = pidToNameToStreamVariable.get(
                paintableId).get(variableName);
        String secKey = streamVariableToSeckey.get(streamVariable);
        if (secKey.equals(parts[2])) {

            VariableOwner source = getVariableOwner(paintableId);
            String contentType = request.getContentType();
            if (request.getContentType().contains("boundary")) {
                // Multipart requests contain boundary string
                doHandleSimpleMultipartFileUpload(
                        new HttpServletRequestWrapper(request),
View Full Code Here


                    String[] variable = variableRecords[i];
                    String[] nextVariable = null;
                    if (i + 1 < variableRecords.length) {
                        nextVariable = variableRecords[i + 1];
                    }
                    final VariableOwner owner = getVariableOwner(variable[VAR_PID]);
                    if (owner != null && owner.isEnabled()) {
                        // TODO this should be Map<String, Object>, but the
                        // VariableOwner API does not guarantee the key is a
                        // string
                        Map<String, Object> m;
                        if (nextVariable != null
                                && variable[VAR_PID]
                                        .equals(nextVariable[VAR_PID])) {
                            // we have more than one value changes in row for
                            // one variable owner, collect em in HashMap
                            m = new HashMap<String, Object>();
                            m.put(variable[VAR_NAME],
                                    convertVariableValue(
                                            variable[VAR_TYPE].charAt(0),
                                            variable[VAR_VALUE]));
                        } else {
                            // use optimized single value map
                            m = Collections.singletonMap(
                                    variable[VAR_NAME],
                                    convertVariableValue(
                                            variable[VAR_TYPE].charAt(0),
                                            variable[VAR_VALUE]));
                        }

                        // collect following variable changes for this owner
                        while (nextVariable != null
                                && variable[VAR_PID]
                                        .equals(nextVariable[VAR_PID])) {
                            i++;
                            variable = nextVariable;
                            if (i + 1 < variableRecords.length) {
                                nextVariable = variableRecords[i + 1];
                            } else {
                                nextVariable = null;
                            }
                            m.put(variable[VAR_NAME],
                                    convertVariableValue(
                                            variable[VAR_TYPE].charAt(0),
                                            variable[VAR_VALUE]));
                        }
                        try {
                            owner.changeVariables(request, m);

                            // Special-case of closing browser-level windows:
                            // track browser-windows currently open in client
                            if (owner instanceof Window
                                    && ((Window) owner).getParent() == null) {
                                final Boolean close = (Boolean) m.get("close");
                                if (close != null && close.booleanValue()) {
                                    closingWindowName = ((Window) owner)
                                            .getName();
                                }
                            }
                        } catch (Exception e) {
                            if (owner instanceof Component) {
                                handleChangeVariablesError(application2,
                                        (Component) owner, e, m);
                            } else {
                                // TODO DragDropService error handling
                                throw new RuntimeException(e);
                            }
                        }
                    } else {

                        // Handle special case where window-close is called
                        // after the window has been removed from the
                        // application or the application has closed
                        if ("close".equals(variable[VAR_NAME])
                                && "true".equals(variable[VAR_VALUE])) {
                            // Silently ignore this
                            continue;
                        }

                        // Ignore variable change
                        String msg = "Warning: Ignoring variable change for ";
                        if (owner != null) {
                            msg += "disabled component " + owner.getClass();
                            String caption = ((Component) owner).getCaption();
                            if (caption != null) {
                                msg += ", caption=" + caption;
                            }
                        } else {
View Full Code Here

        }
        return success;
    }

    private VariableOwner getVariableOwner(String string) {
        VariableOwner owner = (VariableOwner) idPaintableMap.get(string);
        if (owner == null && string.startsWith("DD")) {
            return getDragAndDropService();
        }
        return owner;
    }
View Full Code Here

    public void handleFileUpload(ResourceRequest request,
            ResourceResponse response) throws IOException {
        String contentType = request.getContentType();
        String name = request.getParameter("name");
        String ownerId = request.getParameter("rec-owner");
        VariableOwner variableOwner = getVariableOwner(ownerId);
        StreamVariable streamVariable = ownerToNameToStreamVariable.get(
                variableOwner).get(name);

        if (contentType.contains("boundary")) {
            doHandleSimpleMultipartFileUpload(
View Full Code Here

        StreamVariable streamVariable = getStreamVariable(paintableId,
                variableName);
        String secKey = streamVariableToSeckey.get(streamVariable);
        if (secKey.equals(parts[2])) {

            VariableOwner source = getVariableOwner(paintableId);
            String contentType = request.getContentType();
            if (request.getContentType().contains("boundary")) {
                // Multipart requests contain boundary string
                doHandleSimpleMultipartFileUpload(
                        new HttpServletRequestWrapper(request),
View Full Code Here

            String[] variable = variableRecords[i];
            String[] nextVariable = null;
            if (i + 1 < variableRecords.length) {
                nextVariable = variableRecords[i + 1];
            }
            final VariableOwner owner = getVariableOwner(variable[VAR_PID]);
            if (owner != null && owner.isEnabled()) {
                Map<String, Object> m;
                if (nextVariable != null
                        && variable[VAR_PID].equals(nextVariable[VAR_PID])) {
                    // we have more than one value changes in row for
                    // one variable owner, collect them in HashMap
                    m = new HashMap<String, Object>();
                    m.put(variable[VAR_NAME], decodeVariable(variable));
                } else {
                    // use optimized single value map
                    m = Collections.singletonMap(variable[VAR_NAME],
                            decodeVariable(variable));
                }

                // collect following variable changes for this owner
                while (nextVariable != null
                        && variable[VAR_PID].equals(nextVariable[VAR_PID])) {
                    i++;
                    variable = nextVariable;
                    if (i + 1 < variableRecords.length) {
                        nextVariable = variableRecords[i + 1];
                    } else {
                        nextVariable = null;
                    }
                    m.put(variable[VAR_NAME], decodeVariable(variable));
                }
                try {
                    changeVariables(source, owner, m);

                    // Special-case of closing browser-level windows:
                    // track browser-windows currently open in client
                    if (owner instanceof Window
                            && ((Window) owner).getParent() == null) {
                        final Boolean close = (Boolean) m.get("close");
                        if (close != null && close.booleanValue()) {
                            closingWindowName = ((Window) owner).getName();
                        }
                    }
                } catch (Exception e) {
                    Component errorComponent = null;
                    if (owner instanceof Component) {
                        errorComponent = (Component) owner;
                    } else if (owner instanceof DragAndDropService) {
                        if (m.get("dhowner") instanceof Component) {
                            errorComponent = (Component) m.get("dhowner");
                        }
                    }

                    handleChangeVariablesError(app, errorComponent, e, m);
                }
            } else {

                // Handle special case where window-close is called
                // after the window has been removed from the
                // application or the application has closed
                if ("close".equals(variable[VAR_NAME])
                        && "true".equals(variable[VAR_VALUE])) {
                    // Silently ignore this
                    continue;
                }

                // Ignore variable change
                String msg = "Warning: Ignoring variable change for ";
                if (owner != null) {
                    msg += "disabled component " + owner.getClass();
                    String caption = ((Component) owner).getCaption();
                    if (caption != null) {
                        msg += ", caption=" + caption;
                    }
                } else {
View Full Code Here

            Map<String, Object> m) {
        owner.changeVariables(source, m);
    }

    protected VariableOwner getVariableOwner(String string) {
        VariableOwner owner = (VariableOwner) idPaintableMap.get(string);
        if (owner == null && string.startsWith("DD")) {
            return getDragAndDropService();
        }
        return owner;
    }
View Full Code Here

        try {
            return convertVariableValue(variable[VAR_TYPE].charAt(0),
                    variable[VAR_VALUE]);
        } catch (Exception e) {
            String pid = variable[VAR_PID];
            VariableOwner variableOwner = getVariableOwner(pid);
            String targetType = variableOwner == null ? "unknown VariableOwner"
                    : variableOwner.getClass().getName();
            throw new RuntimeException("Could not convert variable \""
                    + variable[VAR_NAME] + "\" for " + targetType + " (" + pid
                    + ")", e);
        }
    }
View Full Code Here

    public void handleFileUpload(ResourceRequest request,
            ResourceResponse response) throws IOException {
        String contentType = request.getContentType();
        String name = request.getParameter("name");
        String ownerId = request.getParameter("rec-owner");
        VariableOwner variableOwner = getVariableOwner(ownerId);
        StreamVariable streamVariable = ownerToNameToStreamVariable.get(
                variableOwner).get(name);

        if (contentType.contains("boundary")) {
            doHandleSimpleMultipartFileUpload(
View Full Code Here

            String[] variable = variableRecords[i];
            String[] nextVariable = null;
            if (i + 1 < variableRecords.length) {
                nextVariable = variableRecords[i + 1];
            }
            final VariableOwner owner = getVariableOwner(variable[VAR_PID]);
            if (owner != null && owner.isEnabled()) {
                Map<String, Object> m;
                if (nextVariable != null
                        && variable[VAR_PID].equals(nextVariable[VAR_PID])) {
                    // we have more than one value changes in row for
                    // one variable owner, collect em in HashMap
                    m = new HashMap<String, Object>();
                    m.put(variable[VAR_NAME],
                            convertVariableValue(variable[VAR_TYPE].charAt(0),
                                    variable[VAR_VALUE]));
                } else {
                    // use optimized single value map
                    m = Collections.singletonMap(
                            variable[VAR_NAME],
                            convertVariableValue(variable[VAR_TYPE].charAt(0),
                                    variable[VAR_VALUE]));
                }

                // collect following variable changes for this owner
                while (nextVariable != null
                        && variable[VAR_PID].equals(nextVariable[VAR_PID])) {
                    i++;
                    variable = nextVariable;
                    if (i + 1 < variableRecords.length) {
                        nextVariable = variableRecords[i + 1];
                    } else {
                        nextVariable = null;
                    }
                    m.put(variable[VAR_NAME],
                            convertVariableValue(variable[VAR_TYPE].charAt(0),
                                    variable[VAR_VALUE]));
                }
                try {
                    owner.changeVariables(source, m);

                    // Special-case of closing browser-level windows:
                    // track browser-windows currently open in client
                    if (owner instanceof Window
                            && ((Window) owner).getParent() == null) {
                        final Boolean close = (Boolean) m.get("close");
                        if (close != null && close.booleanValue()) {
                            closingWindowName = ((Window) owner).getName();
                        }
                    }
                } catch (Exception e) {
                    if (owner instanceof Component) {
                        handleChangeVariablesError(app, (Component) owner, e, m);
                    } else {
                        // TODO DragDropService error handling
                        throw new RuntimeException(e);
                    }
                }
            } else {

                // Handle special case where window-close is called
                // after the window has been removed from the
                // application or the application has closed
                if ("close".equals(variable[VAR_NAME])
                        && "true".equals(variable[VAR_VALUE])) {
                    // Silently ignore this
                    continue;
                }

                // Ignore variable change
                String msg = "Warning: Ignoring variable change for ";
                if (owner != null) {
                    msg += "disabled component " + owner.getClass();
                    String caption = ((Component) owner).getCaption();
                    if (caption != null) {
                        msg += ", caption=" + caption;
                    }
                } else {
View Full Code Here

TOP

Related Classes of com.vaadin.terminal.VariableOwner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.