本文整理匯總了Java中com.vaadin.server.Page.getCurrent方法的典型用法代碼示例。如果您正苦於以下問題:Java Page.getCurrent方法的具體用法?Java Page.getCurrent怎麽用?Java Page.getCurrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.server.Page
的用法示例。
在下文中一共展示了Page.getCurrent方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isEnabled
import com.vaadin.server.Page; //導入方法依賴的package包/類
public boolean isEnabled()
{
if (!enabled)
{
return false;
}
final Page page = Page.getCurrent();
if (page != null && page.getWebBrowser().isChrome())
{
logger.trace("Considering feature disabled for chome because Chrome's password manager is known to work");
return false;
}
return true;
}
示例2: notify
import com.vaadin.server.Page; //導入方法依賴的package包/類
public static void notify(String caption, String message, Throwable ex, Type type) {
Page page = Page.getCurrent();
if (page != null) {
Notification notification = new Notification(caption, contactWithLineFeed(FormatUtils.wordWrap(message, 150)),
Type.HUMANIZED_MESSAGE);
notification.setPosition(Position.MIDDLE_CENTER);
notification.setDelayMsec(-1);
String style = ValoTheme.NOTIFICATION_SUCCESS;
if (type == Type.ERROR_MESSAGE) {
style = ValoTheme.NOTIFICATION_FAILURE;
} else if (type == Type.WARNING_MESSAGE) {
style = ValoTheme.NOTIFICATION_WARNING;
}
notification.setStyleName(notification.getStyleName() + " " + ValoTheme.NOTIFICATION_CLOSABLE + " " + style);
notification.show(Page.getCurrent());
}
}
示例3: getService
import com.vaadin.server.Page; //導入方法依賴的package包/類
/**
* Gets the OAuth service singleton.
*
* @return OAuth service singleton
*/
protected OAuthService getService() {
if (service == null) {
callbackPage = Page.getCurrent();
String location = callbackPage.getLocation().toString();
Class<? extends Api> api = getApi();
ServiceBuilder builder = new ServiceBuilder();
builder.provider(api);
builder.apiKey(apiKey);
builder.apiSecret(apiSecret);
builder.callback(location);
service=builder.build();
}
return service;
}
示例4: getScreenWidth
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Override
public int getScreenWidth() {
WebBrowser browser = (Page.getCurrent() != null) ? Page.getCurrent().getWebBrowser() : null;
if (browser != null) {
return browser.getScreenWidth();
}
return -1;
}
示例5: getScreenHeight
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Override
public int getScreenHeight() {
WebBrowser browser = (Page.getCurrent() != null) ? Page.getCurrent().getWebBrowser() : null;
if (browser != null) {
return browser.getScreenHeight();
}
return -1;
}
示例6: sendError
import com.vaadin.server.Page; //導入方法依賴的package包/類
/**
* Envoi une notif d'erreur si possible
*/
private void sendError(){
try{
if (Page.getCurrent()!=null){
Notification.show("Une erreur est survenue");
}
}catch(Exception e){}
}
示例7: getCurrentPageUrl
import com.vaadin.server.Page; //導入方法依賴的package包/類
private static String getCurrentPageUrl(ServerApi server) {
String url;
if (Page.getCurrent() != null && Page.getCurrent().getLocation() != null) {
url = Page.getCurrent().getLocation().toString();
} else if (VaadinServletService.getCurrentRequest() != null) {
url = VaadinServletService.getCurrentRequest().getContextPath();
} else {
url = "https://" + server.getServerIpAddress() + "/";
}
// Workaround bug in URL generation
url = url.replace("#!", "/#!");
url = url.replace("//#!", "/#!");
return url;
}
示例8: init
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Override
protected void init(final VaadinRequest request) {
VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this));
setSizeFull();
springNavigator.addView("", mainView);
setNavigator(springNavigator);
final Page currentPage = Page.getCurrent();
final String requestUrl = currentPage.getLocation().toString();
final String language = request.getLocale().getLanguage();
final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language);
currentPage.setTitle(userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName() + ":" + userConfiguration.getLanguage().getLanguageName());
if (getSession().getUIs().isEmpty()) {
final WebBrowser webBrowser = currentPage.getWebBrowser();
final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser);
serviceRequest.setIpInformation(ipInformation);
serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication());
serviceRequest.setLocale(webBrowser.getLocale().toString());
serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser));
serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);
final ServiceResponse serviceResponse = applicationManager.service(serviceRequest);
LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT,requestUrl,language,ipInformation,webBrowser.getBrowserApplication(),serviceRequest.getSessionId(),serviceResponse.getResult().toString());
}
}
示例9: exit
import com.vaadin.server.Page; //導入方法依賴的package包/類
/**
* Exit application
*/
public static void exit() {
VaadinSession.getCurrent().getSession().removeAttribute(
HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
UI.getCurrent().close();
VaadinSession.getCurrent().close();
Page page = Page.getCurrent();
page.setLocation(VaadinService.getCurrentRequest().getContextPath() + "/logout");
}
示例10: getViewPortWidth
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Override
public int getViewPortWidth() {
return (Page.getCurrent() != null) ? Page.getCurrent().getBrowserWindowWidth() : -1;
}
示例11: getViewPortHeight
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Override
public int getViewPortHeight() {
return (Page.getCurrent() != null) ? Page.getCurrent().getBrowserWindowHeight() : -1;
}
示例12: getDeviceInfo
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Nullable
@Override
public DeviceInfo getDeviceInfo() {
// per request cache
HttpServletRequest currentServletRequest = VaadinServletService.getCurrentServletRequest();
if (currentServletRequest == null) {
return null;
}
DeviceInfo deviceInfo = (DeviceInfo) currentServletRequest.getAttribute(DeviceInfoProvider.NAME);
if (deviceInfo != null) {
return deviceInfo;
}
Page page = Page.getCurrent();
if (page == null) {
return null;
}
WebBrowser webBrowser = page.getWebBrowser();
DeviceInfo di = new DeviceInfo();
di.setAddress(webBrowser.getAddress());
di.setBrowserApplication(webBrowser.getBrowserApplication());
di.setBrowserMajorVersion(webBrowser.getBrowserMajorVersion());
di.setBrowserMinorVersion(webBrowser.getBrowserMinorVersion());
di.setChrome(webBrowser.isChrome());
di.setChromeFrame(webBrowser.isChromeFrame());
di.setChromeFrameCapable(webBrowser.isChromeFrameCapable());
di.setEdge(webBrowser.isEdge());
di.setFirefox(webBrowser.isFirefox());
di.setOpera(webBrowser.isOpera());
di.setIE(webBrowser.isIE());
if (webBrowser.isWindows()) {
di.setOperatingSystem(OperatingSystem.WINDOWS);
} else if (webBrowser.isAndroid()) {
di.setOperatingSystem(OperatingSystem.ANDROID);
} else if (webBrowser.isIOS()) {
di.setOperatingSystem(OperatingSystem.IOS);
} else if (webBrowser.isMacOSX()) {
di.setOperatingSystem(OperatingSystem.MACOSX);
} else if (webBrowser.isLinux()) {
di.setOperatingSystem(OperatingSystem.LINUX);
}
di.setIPad(webBrowser.isIPad());
di.setIPhone(webBrowser.isIPhone());
di.setWindowsPhone(webBrowser.isWindowsPhone());
di.setSecureConnection(webBrowser.isSecureConnection());
di.setLocale(webBrowser.getLocale());
di.setScreenHeight(webBrowser.getScreenHeight());
di.setScreenWidth(webBrowser.getScreenWidth());
currentServletRequest.setAttribute(DeviceInfoProvider.NAME, di);
return di;
}
示例13: onApplicationEvent
import com.vaadin.server.Page; //導入方法依賴的package包/類
@Override
public void onApplicationEvent(final AuthorizationFailureEvent authorizationFailureEvent) {
final String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();
final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
serviceRequest.setSessionId(sessionId);
serviceRequest.setEventGroup(ApplicationEventGroup.APPLICATION);
serviceRequest.setApplicationOperation(ApplicationOperationType.AUTHORIZATION);
serviceRequest.setUserId(UserContextUtil.getUserIdFromSecurityContext());
final Page currentPageIfAny = Page.getCurrent();
final String requestUrl = UserContextUtil.getRequestUrl(currentPageIfAny);
final UI currentUiIfAny = UI.getCurrent();
String methodInfo = "";
if (currentPageIfAny != null && currentUiIfAny != null && currentUiIfAny.getNavigator() != null
&& currentUiIfAny.getNavigator().getCurrentView() != null) {
serviceRequest.setPage(currentUiIfAny.getNavigator().getCurrentView().getClass().getSimpleName());
serviceRequest.setPageMode(currentPageIfAny.getUriFragment());
}
if (authorizationFailureEvent.getSource() instanceof ReflectiveMethodInvocation) {
final ReflectiveMethodInvocation methodInvocation = (ReflectiveMethodInvocation) authorizationFailureEvent
.getSource();
if (methodInvocation.getMethod() != null && methodInvocation.getThis() != null) {
methodInfo = methodInvocation.getThis().getClass().getSimpleName() + "."
+ methodInvocation.getMethod().getName();
}
}
final Collection<? extends GrantedAuthority> authorities = authorizationFailureEvent.getAuthentication().getAuthorities();
final Collection<ConfigAttribute> configAttributes = authorizationFailureEvent.getConfigAttributes();
serviceRequest.setErrorMessage(MessageFormat.format(ERROR_MESSAGE_FORMAT, requestUrl, methodInfo, AUTHORITIES, authorities,
REQUIRED_AUTHORITIES, configAttributes, authorizationFailureEvent.getSource()));
serviceRequest.setApplicationMessage(ACCESS_DENIED);
applicationManager.service(serviceRequest);
LOGGER.info(LOG_MSG_AUTHORIZATION_FAILURE_SESSION_ID_AUTHORITIES_REQUIRED_AUTHORITIES, requestUrl, methodInfo,
sessionId, authorities,
configAttributes);
}
示例14: showAtSize
import com.vaadin.server.Page; //導入方法依賴的package包/類
public void showAtSize(double percentOfBrowserSize) {
Page page = Page.getCurrent();
setWindowMode(WindowMode.NORMAL);
int pageHeight = page.getBrowserWindowHeight();
int pageWidth = page.getBrowserWindowWidth();
setHeight((int) (pageHeight * percentOfBrowserSize), Unit.PIXELS);
setWidth((int) (pageWidth * percentOfBrowserSize), Unit.PIXELS);
show();
}