Package com.vaadin.ui

Examples of com.vaadin.ui.UI


        try {
            final Class<?> type = applicationContext.getType(beanName);

            Assert.isAssignable(View.class, type, "bean did not implement View interface");

            final UI currentUI = UI.getCurrent();
            final VaadinView annotation = applicationContext.findAnnotationOnBean(beanName, VaadinView.class);

            Assert.notNull(annotation, "class did not have a VaadinView annotation");

            final Map<String, ViewProviderAccessDelegate> accessDelegates = applicationContext.getBeansOfType(ViewProviderAccessDelegate.class);
            for (ViewProviderAccessDelegate accessDelegate : accessDelegates.values()) {
                if (!accessDelegate.isAccessGranted(beanName, currentUI)) {
                    logger.debug("Access delegate [{}] denied access to view class [{}]", accessDelegate, type.getCanonicalName());
                    return false;
                }
            }

            if (annotation.ui().length == 0) {
                logger.trace("View class [{}] with view name [{}] is available for all UI subclasses", type.getCanonicalName(), annotation.name());
                return true;
            } else {
                for (Class<? extends UI> validUI : annotation.ui()) {
                    if (validUI == currentUI.getClass()) {
                        logger.trace("View class [%s] with view name [{}] is available for UI subclass [{}]", type.getCanonicalName(), annotation.name(), validUI.getCanonicalName());
                        return true;
                    }
                }
            }
View Full Code Here


    private final Logger logger = LoggerFactory.getLogger(getClass());
    private final Map<UIID, Map<String, Object>> objectMap = new ConcurrentHashMap<UIID, Map<String, Object>>();
    private final Map<UIID, Map<String, Runnable>> destructionCallbackMap = new ConcurrentHashMap<UIID, Map<String, Runnable>>();

    public UIID currentUIID() {
        final UI currentUI = UI.getCurrent();
        if (currentUI != null && currentUI.getUIId() != -1) {
            return new UIID(currentUI);
        } else {
            UIID currentIdentifier = CurrentInstance.get(UIID.class);
            Assert.notNull(currentIdentifier, String.format("Found no valid %s instance!", UIID.class.getName()));
            return currentIdentifier;
View Full Code Here

     * @return the current locale, never {@code null}.
     * @see com.vaadin.ui.UI#getLocale()
     * @see java.util.Locale#getDefault()
     */
    public Locale getLocale() {
        UI currentUI = UI.getCurrent();
        Locale locale = (currentUI == null ? null : currentUI.getLocale());
        if (locale == null) {
            locale = Locale.getDefault();
        }
        return locale;
    }
View Full Code Here

                session.unlock();
            }
        }

        private UIID getUIID() {
            final UI currentUI = UI.getCurrent();
            if (currentUI != null && currentUI.getUIId() != -1) {
                return new UIID(currentUI);
            } else {
                UIID currentIdentifier = CurrentInstance.get(UIID.class);
                Assert.notNull(currentIdentifier, String.format("Found no valid %s instance!", UIID.class.getName()));
                return currentIdentifier;
View Full Code Here

    /**
     * @deprecated As of 7.1. See #11411.
     */
    @Deprecated
    public static JsonObject encodeState(ClientConnector connector, SharedState state) {
        UI uI = connector.getUI();
        ConnectorTracker connectorTracker = uI.getConnectorTracker();
        Class<? extends SharedState> stateType = connector.getStateType();
        JsonValue diffState = connectorTracker.getDiffState(connector);
        boolean supportsDiffState = !JavaScriptConnectorState.class
                .isAssignableFrom(stateType);
        if (diffState == null && supportsDiffState) {
            // Use an empty state object as reference for full
            // repaints

            try {
                SharedState referenceState = stateType.newInstance();
                EncodeResult encodeResult = JsonCodec.encode(referenceState,
                        null, stateType, uI.getConnectorTracker());
                diffState = encodeResult.getEncodedValue();
            } catch (Exception e) {
                getLogger()
                        .log(Level.WARNING,
                                "Error creating reference object for state of type {0}",
                                stateType.getName());
            }
        }
        EncodeResult encodeResult = JsonCodec.encode(state, diffState,
                stateType, uI.getConnectorTracker());
        if (supportsDiffState) {
            connectorTracker.setDiffState(connector,
                    (JsonObject) encodeResult.getEncodedValue());
        }
        return (JsonObject) encodeResult.getDiff();
View Full Code Here

         *
         * NAME and PID from URI forms a key to fetch StreamVariable when
         * handling post
         */
        String paintableId = owner.getConnectorId();
        UI ui = owner.getUI();
        int uiId = ui.getUIId();
        String key = uiId + "/" + paintableId + "/" + name;

        ConnectorTracker connectorTracker = ui.getConnectorTracker();
        connectorTracker.addStreamVariable(paintableId, name, value);
        String seckey = connectorTracker.getSeckey(value);

        return ApplicationConstants.APP_PROTOCOL_PREFIX
                + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + seckey;
View Full Code Here

            /*
             * Reached UI and found no error handler. Try session which
             * typically has one.
             */
            UI ui = connector.getUI();
            if (ui != null) {
                errorHandler = findErrorHandler(ui.getSession());
                if (errorHandler != null) {
                    return errorHandler;
                }
            }
        }
View Full Code Here

    /* Documentation copied from interface */
    @Override
    public void markAsDirty() {
        assert getSession() == null || getSession().hasLock() : buildLockAssertMessage("markAsDirty()");
        UI uI = getUI();
        if (uI != null) {
            uI.getConnectorTracker().markDirty(this);
        }
    }
View Full Code Here

        if (null == sharedState) {
            sharedState = createState();
        }
        if (markAsDirty) {
            UI ui = getUI();
            if (ui != null && !ui.getConnectorTracker().isDirty(this)
                    && !ui.getConnectorTracker().isWritingResponse()) {
                ui.getConnectorTracker().markDirty(this);
            }
        }
        return sharedState;
    }
View Full Code Here

     * connector has not been attached, <code>null</code> is returned.
     *
     * @return The connector's session, or <code>null</code> if not attached
     */
    protected VaadinSession getSession() {
        UI uI = getUI();
        if (uI == null) {
            return null;
        } else {
            return uI.getSession();
        }
    }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.UI

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.