本文整理汇总了Java中com.vaadin.ui.UI.getCurrent方法的典型用法代码示例。如果您正苦于以下问题:Java UI.getCurrent方法的具体用法?Java UI.getCurrent怎么用?Java UI.getCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vaadin.ui.UI
的用法示例。
在下文中一共展示了UI.getCurrent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteCandidat
import com.vaadin.ui.UI; //导入方法依赖的package包/类
public void deleteCandidat() {
SecurityUserCandidat cand = userController.getSecurityUserCandidat();
if (cand != null) {
CompteMinima cpt = compteMinimaRepository.findOne(cand.getIdCptMin());
if (cpt != null) {
logger.debug("Delete compte NoDossier = " + cpt.getNumDossierOpiCptMin());
compteMinimaRepository.delete(cpt);
uiController.unregisterUiCandidat(MainUI.getCurrent());
SecurityContext context = SecurityContextHolder.createEmptyContext();
SecurityContextHolder.setContext(context);
UI.getCurrent().getSession().getSession()
.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, context);
MainUI current = (MainUI) UI.getCurrent();
uiController.registerUiCandidat(current);
current.navigateToAccueilView();
}
}
}
示例2: changeLangueUI
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Change la langue de l'UI
*
* @param codeLangue
* le code langage de la locale
* @param forceToReloadMenu
* si le menu doit être forcé à être rechargé-->cas du candidat en
* connexion interne
* @return true si la langue a été& changée
*/
private Boolean changeLangueUI(String codeLangue, Boolean forceToReloadMenu) {
if (codeLangue == null || UI.getCurrent() == null) {
return false;
}
Locale locale = UI.getCurrent().getLocale();
if (forceToReloadMenu || locale == null || locale.getLanguage() == null
|| (codeLangue != null && !codeLangue.equals(locale.getLanguage()))) {
SecurityUserCandidat user = userController.getSecurityUserCandidat();
if (user != null) {
user.setCodLangue(codeLangue);
}
((MainUI) UI.getCurrent()).setLocale(new Locale(codeLangue));
((MainUI) UI.getCurrent()).configReconnectDialogMessages();
((MainUI) UI.getCurrent()).constructMainMenu();
return true;
}
return false;
}
示例3: handleConnectorRequest
import com.vaadin.ui.UI; //导入方法依赖的package包/类
@Override
public boolean handleConnectorRequest(VaadinRequest request,
VaadinResponse response, String path) throws IOException {
final BusyIndicatorWindow busyIndicatorWindow = new BusyIndicatorWindow();
final UI ui = UI.getCurrent();
ui.access(() -> ui.addWindow(busyIndicatorWindow));
try {
//on charge le fichier
getStreamSource().loadOndemandFile();
if (getStreamSource().getStream()==null){
return true;
}
getResource().setFilename(getStreamSource().getFileName());
return super.handleConnectorRequest(request, response, path);
}catch(Exception e){
return true;
}
finally {
busyIndicatorWindow.close();
}
}
示例4: handleConnectorRequest
import com.vaadin.ui.UI; //导入方法依赖的package包/类
@Override
public boolean handleConnectorRequest(VaadinRequest request,
VaadinResponse response, String path) throws IOException {
final BusyIndicatorWindow busyIndicatorWindow = new BusyIndicatorWindow();
final UI ui = UI.getCurrent();
ui.access(() -> ui.addWindow(busyIndicatorWindow));
try {
getStreamSource().loadOndemandFile();
if (getStreamSource().getStream()==null){
return true;
}
getDownloadStreamSource().setMIMEType("application/pdf");
getDownloadStreamSource().getStream().setParameter(
"Content-Disposition",
"attachment; filename="+getStreamSource().getFileName());
return super.handleConnectorRequest(request, response, path);
}catch(Exception e){
return true;
}finally {
busyIndicatorWindow.close();
}
}
示例5: getCurrentUIViewNavigator
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Try to obtain ViewNavigator from current thread-bound {@link UI}
* @return If current {@link UI} is available and has a ViewNavigator setted, this one is retuned. Null otherwise.
*/
public static ViewNavigator getCurrentUIViewNavigator() {
UI ui = UI.getCurrent();
if (ui != null) {
Navigator navigator = ui.getNavigator();
if (navigator instanceof ViewNavigator) {
return (ViewNavigator) navigator;
}
}
return null;
}
示例6: getViewInstance
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Get View instance from view class with consistent stateful views handling
* @param viewClass View class
* @return View instance
* @throws ViewConfigurationException Failed to create view instance
*/
protected View getViewInstance(Class<? extends View> viewClass) throws ViewConfigurationException {
synchronized (statefulViews) {
View view = null;
final UI ui = UI.getCurrent();
// check stateful
boolean stateful = isStatefulView(viewClass);
if (stateful) {
view = getStatefulViewInstance(ui, viewClass);
}
// create instance
if (view == null) {
try {
view = viewClass.newInstance();
if (stateful) {
// retain instance
Map<Class<? extends View>, WeakReference<View>> views = statefulViews.get(ui);
if (views == null) {
views = new HashMap<>(8);
statefulViews.put(ui, views);
}
views.put(viewClass, new WeakReference<>(view));
}
} catch (Exception e) {
throw new ViewConfigurationException("Failed to istantiate view class " + viewClass.getName(), e);
}
}
return view;
}
}
示例7: createMenuButtonForNotification
import com.vaadin.ui.UI; //导入方法依赖的package包/类
private Button createMenuButtonForNotification(VaadinIcons icon, String caption, String message) {
final Button button
= new Button(caption,
(e) -> {
UI ui = UI.getCurrent();
ConfirmDialog.show(
ui,
message, // ToDo extract in Executor
(ConfirmDialog.Listener) dialog -> {
if (dialog.isConfirmed()) {
VaadinSession vaadinSession = ui.getSession();
vaadinSession.setAttribute(SESSION_ATTRIBUTE_USER, null);
vaadinSession.close();
ui.getPage().setLocation("/");
}
else {
// User did not confirm
// CANCEL STUFF
}
});
});
button.setIcon(icon);
button.addStyleName(ValoTheme.BUTTON_HUGE);
button.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
button.addStyleName(ValoTheme.MENU_ITEM);
button.setWidth("100%");
button.setId(buttonID().apply(MainView.class, caption));
return button;
}
示例8: findLocale
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Get the most suitable {@link Locale} to use.
* @return the field, UI or {@link LocalizationContext} locale
*/
protected Locale findLocale() {
Locale locale = getLocale();
if (locale == null && UI.getCurrent() != null) {
locale = UI.getCurrent().getLocale();
}
if (locale == null) {
locale = LocalizationContext.getCurrent().filter(l -> l.isLocalized()).flatMap(l -> l.getLocale())
.orElse(Locale.getDefault());
}
return locale;
}
示例9: getUIId
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* @return l'id de l'ui de l'utilisateur
*/
private String getUIId() {
MainUI ui = (MainUI) UI.getCurrent();
if (ui == null) {
return null;
} else {
return ui.getUiId();
}
}
示例10: getSecurityContextFromSession
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Récupère le securityContext dans la session.
*
* @return securityContext associé à la session
*/
public SecurityContext getSecurityContextFromSession() {
if (UI.getCurrent() != null && UI.getCurrent().getSession() != null
&& UI.getCurrent().getSession().getSession() != null) {
return (SecurityContext) UI.getCurrent().getSession().getSession()
.getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
}
return null;
}
示例11: getLock
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Verrouille une ressource pour l'UI courante
* @param obj la ressource à verrouiller
* @return true si la ressource est bien verrouillée pour l'UI courante, false sinon
*/
private boolean getLock(Object obj) {
Assert.notNull(obj, applicationContext.getMessage("assert.notNull", null, UI.getCurrent().getLocale()));
UI lockUI = locks.get(obj);
if (lockUI instanceof UI && lockUI != UI.getCurrent() && uiController.isUIStillActive(lockUI)) {
return false;
}
locks.put(obj, UI.getCurrent());
return true;
}
示例12: Canvas
import com.vaadin.ui.UI; //导入方法依赖的package包/类
public Canvas(ItemContainer items) {
this.items = items;
ui = UI.getCurrent();
registerRpc(new CanvasServerRpc() {
@Override
public void imagesLoaded() {
fireImagesLoaded();
}
@Override
public void addItem(Item item){
items.addItem(listener, item);
}
});
listener = new CanvasUpdateListener(ui){
@Override
public void addedItem(Item item){
getUi().accessSynchronously(() -> getRpcProxy(CanvasClientRpc.class).addItem(item));
}
//TODO
@Override
public void deletedItem(Item item){
}
//TODO
@Override
public void changedItem(Item item){
//getUi().accessSynchronously(() -> getRpcProxy(CanvasClientRpc.class).changeItem(items, item));
}
};
items.addListener(ui.getId(), listener);
ui.addDetachListener((e) -> {Canvas.this.items.removeListener(ui.getId(), listener);});
}
示例13: createMenuButtonForNotification
import com.vaadin.ui.UI; //导入方法依赖的package包/类
private Pair<String, Button> createMenuButtonForNotification(VaadinIcons icon, String caption, String message) {
final Button button
= new Button(caption,
(e) -> {
UI ui = UI.getCurrent();
ConfirmDialog.show(
ui,
message, // ToDo extract in Executor
(ConfirmDialog.Listener) dialog -> {
if (dialog.isConfirmed()) {
getSubject().logout(); //removes all identifying information and invalidates their session too.
VaadinSession vaadinSession = ui.getSession();
vaadinSession.setAttribute(SESSION_ATTRIBUTE_USER, null);
vaadinSession.close();
ui.getPage().setLocation("/");
}
else {
// User did not confirm
// CANCEL STUFF
}
});
});
button.setIcon(icon);
button.addStyleName(ValoTheme.BUTTON_HUGE);
button.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
button.addStyleName(ValoTheme.MENU_ITEM);
button.setWidth("100%");
button.setId(buttonID().apply(MainView.class, caption));
return new Pair<>(mapToShiroRole(caption), button);
}
示例14: getCurrent
import com.vaadin.ui.UI; //导入方法依赖的package包/类
public static TripMap getCurrent() {
// Fetch from a session attribute as a workaround for not missing UI
// scope support
UI ui = UI.getCurrent();
VaadinSession session = ui.getSession();
String attributeName = TripMap.class.getName() + ui.getUIId();
TripMap directionSearch = (TripMap) session
.getAttribute(attributeName);
if (directionSearch == null) {
directionSearch = new TripMap();
ui.getSession().setAttribute(attributeName, directionSearch);
}
return directionSearch;
}
示例15: releaseLock
import com.vaadin.ui.UI; //导入方法依赖的package包/类
/**
* Rend un verrou, après avoir vérifié qu'il appartient à l'UI courante
* @param obj
*/
public void releaseLock(Object obj) {
if (locks.get(obj) == UI.getCurrent()) {
removeLock(obj);
}
}