private UI getUI() { UI ui = UI.getCurrent(); if (ui == null) { throw new IllegalStateException( "There is no UI available. The UI scope is not active"); } return ui; } }
private UI getCurrentUI() { UI ui = UI.getCurrent(); if (ui == null) { throw new IllegalStateException("UI instance is not available. " + "It means that you are calling this method " + "out of a normal workflow where it's always implicitly set. " + "That may happen if you call the method from the custom thread without " + "'UI::access' or from tests without proper initialization."); } return ui; } }
private UI getCurrentUI() { UI ui = UI.getCurrent(); if (ui == null) { throw new IllegalStateException("UI instance is not available. " + "It means that you are calling this method " + "out of a normal workflow where it's always implicitly set. " + "That may happen if you call the method from the custom thread without " + "'UI::access' or from tests without proper initialization."); } return ui; }
private UI getUI() { UI ui = UI.getCurrent(); if (ui == null) { throw new IllegalStateException( "There is no UI available. The UI scope is not active"); } return ui; } }
private Locale findLocale() { Locale locale = null; if (UI.getCurrent() != null) { locale = UI.getCurrent().getLocale(); } if (locale == null) { locale = Locale.getDefault(); } return locale; }
/** * Finds an appropriate locale to be used in conversion and validation. * * @return the found locale, not null */ protected static Locale findLocale() { Locale locale = null; if (UI.getCurrent() != null) { locale = UI.getCurrent().getLocale(); } if (locale == null) { locale = Locale.getDefault(); } return locale; }
@Override public boolean isActive() { return VaadinSession.getCurrent() != null && UI.getCurrent() != null && contextualStorageManager != null; }
/** * Get the {@link DeviceInfo} for the current UI, if available. * @return Optional {@link DeviceInfo} for the current UI */ static Optional<DeviceInfo> get() { final UI ui = UI.getCurrent(); if (ui != null) { return get(ui); } return Optional.empty(); }
@Override public boolean isActive() { return VaadinSession.getCurrent() != null && UI.getCurrent() != null && contextualStorageManager != null; }
@Override public boolean isActive() { return VaadinSession.getCurrent() != null && UI.getCurrent() != null && contextualStorageManager != null; }
public ContextualStorage getContextualStorage(boolean createIfNotExist) { final Integer uiId = UI.getCurrent().getUIId(); return super.getContextualStorage(uiId, createIfNotExist); }
@Override protected ContextualStorage newContextualStorage(Integer uiId) { UI.getCurrent().addDetachListener(this::destroy); return super.newContextualStorage(uiId); }
@Override protected ContextualStorage newContextualStorage(Integer uiId) { UI.getCurrent().addDetachListener(this::destroy); return super.newContextualStorage(uiId); }
@Override protected ContextualStorage newContextualStorage(Integer uiId) { UI.getCurrent().addDetachListener(this::destroy); return super.newContextualStorage(uiId); }
public ContextualStorage getContextualStorage(boolean createIfNotExist) { final Integer uiId = UI.getCurrent().getUIId(); return super.getContextualStorage(uiId, createIfNotExist); }
public String getRoute() { if (className != null) { return UI.getCurrent().getRouter().getUrl(className); } else if (view != null) { return UI.getCurrent().getRouter().getUrl(view.getClass()); } else { return getCaption(); } }
public ContextualStorage getContextualStorage(boolean createIfNotExist) { final Integer uiId = UI.getCurrent().getUIId(); return super.getContextualStorage(uiId, createIfNotExist); }
public void navigateTo() { UI.getCurrent().navigate(getRoute()); }
public String getRoute() { if (className != null) { return UI.getCurrent().getRouter().getUrl(className); } else if (view != null) { return UI.getCurrent().getRouter().getUrl(view.getClass()); } else { return getCaption(); } }
/** * Convenience constructor to create a date picker with a pre-selected date * in current UI locale format. * * @param initialDate * the pre-selected date in the picker * @see #setValue(Object) */ public DatePicker(LocalDate initialDate) { super(initialDate, null, String.class, PARSER, FORMATTER); getElement().synchronizeProperty("invalid", "invalid-changed"); setLocale(UI.getCurrent().getLocale()); }