本文整理匯總了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);
}
}