本文整理匯總了Java中com.vaadin.server.Page類的典型用法代碼示例。如果您正苦於以下問題:Java Page類的具體用法?Java Page怎麽用?Java Page使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Page類屬於com.vaadin.server包,在下文中一共展示了Page類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initElectronApi
import com.vaadin.server.Page; //導入依賴的package包/類
private void initElectronApi() {
JavaScript js = getPage().getJavaScript();
js.addFunction("appMenuItemTriggered", arguments -> {
if (arguments.length() == 1 && arguments.get(0) instanceof JsonString) {
String menuId = arguments.get(0).asString();
if ("About".equals(menuId)) {
onMenuAbout();
} else if ("Exit".equals(menuId)) {
onWindowExit();
}
}
});
js.addFunction("appWindowExit", arguments -> onWindowExit());
Page.Styles styles = getPage().getStyles();
try {
InputStream resource = MainUI.class.getResourceAsStream(
"/org/strangeway/electronvaadin/resources/electron.css");
styles.add(IOUtils.toString(resource, StandardCharsets.UTF_8));
} catch (IOException ignored) {
}
}
示例2: 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;
}
示例3: downloadExport
import com.vaadin.server.Page; //導入依賴的package包/類
protected void downloadExport(final String export, String filename) {
StreamSource ss = new StreamSource() {
private static final long serialVersionUID = 1L;
public InputStream getStream() {
try {
return new ByteArrayInputStream(export.getBytes(Charset.forName("utf-8")));
} catch (Exception e) {
log.error("Failed to export configuration", e);
CommonUiUtils.notify("Failed to export configuration.", Type.ERROR_MESSAGE);
return null;
}
}
};
String datetime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
StreamResource resource = new StreamResource(ss,
String.format("%s-config-%s.json", filename, datetime));
final String KEY = "export";
setResource(KEY, resource);
Page.getCurrent().open(ResourceReference.create(resource, this, KEY).getURL(), null);
}
示例4: onAuthenticationFailed
import com.vaadin.server.Page; //導入依賴的package包/類
/**
* Invoked when authentication is missing or failed using {@link AuthContext} during {@link Authenticate} annotation
* processing.
* @param authc Authenticate annotation
* @param navigationState Navigation state
* @throws ViewNavigationException If cannot be performed any redirection using {@link Authenticate#redirectURI()}
*/
protected void onAuthenticationFailed(final Authenticate authc, final String navigationState)
throws ViewNavigationException {
// redirect
String redirectURI = AnnotationUtils.getStringValue(authc.redirectURI());
if (redirectURI != null) {
// check view scheme
String viewNavigationState = getViewNavigationState(redirectURI);
if (viewNavigationState != null) {
try {
suspendAuthenticationCheck = true;
navigator.navigateTo(viewNavigationState);
} finally {
suspendAuthenticationCheck = false;
}
} else {
// try to open the URI as an URL
Page.getCurrent().open(redirectURI, null);
}
} else {
throw new ViewNavigationException(navigationState, "Authentication required");
}
}
示例5: validationStatusChange
import com.vaadin.server.Page; //導入依賴的package包/類
@Override
public void validationStatusChange(ValidationStatusEvent<?> statusChangeEvent) {
if (statusChangeEvent.isInvalid()) {
String error = showAllErrors
? statusChangeEvent.getErrorMessages().stream().collect(Collectors.joining("<br/>"))
: statusChangeEvent.getErrorMessage();
if (error == null || error.trim().equals("")) {
error = "Validation error";
}
if (notification != null) {
notification.setCaption(error);
notification.show(Page.getCurrent());
} else {
Notification.show(error, Type.ERROR_MESSAGE);
}
}
}
示例6: switchToUser
import com.vaadin.server.Page; //導入依賴的package包/類
/**
* Change le rôle de l'utilisateur courant
*
* @param username
* le nom de l'utilisateur a prendre
*/
public void switchToUser(String username) {
Assert.hasText(username, applicationContext.getMessage("assert.hasText", null, UI.getCurrent().getLocale()));
/* Vérifie que l'utilisateur existe */
try {
UserDetails details = userDetailsService.loadUserByUsername(username);
if (details == null || details.getAuthorities() == null || details.getAuthorities().size() == 0) {
Notification.show(applicationContext.getMessage("admin.switchUser.usernameNotFound",
new Object[] { username }, UI.getCurrent().getLocale()), Notification.Type.WARNING_MESSAGE);
return;
}
} catch (UsernameNotFoundException unfe) {
Notification.show(applicationContext.getMessage("admin.switchUser.usernameNotFound",
new Object[] { username }, UI.getCurrent().getLocale()), Notification.Type.WARNING_MESSAGE);
return;
}
String switchToUserUrl = MethodUtils.formatSecurityPath(loadBalancingController.getApplicationPath(false),
ConstanteUtils.SECURITY_SWITCH_PATH) + "?" + SwitchUserFilter.SPRING_SECURITY_SWITCH_USERNAME_KEY + "="
+ username;
Page.getCurrent().open(switchToUserUrl, null);
}
示例7: buildMainView
import com.vaadin.server.Page; //導入依賴的package包/類
private void buildMainView() {
buildHeader();
buildMainLayout();
this.root.setExpandRatio(this.mainLayout, 1);
this.registration = this.ctx.registerService(BroadcastListener.class, this, null);
// adding view change listener to navigator
addViewChangeListener();
String uriFragment = Page.getCurrent().getUriFragment();
if (StringUtils.isBlank(uriFragment)) {
uriFragment = VIEW_FRAGMENT_ALERTS;
}
String sanitizedFragment = StringUtils.remove(uriFragment, '!').replace('+', ' ');
this.nav.navigateTo(sanitizedFragment);
}
示例8: showJobNotification
import com.vaadin.server.Page; //導入依賴的package包/類
public static void showJobNotification(Long jobId, ServerApi server) {
HashMap<String, Object> paramMap = null;
if (jobId != null) {
paramMap = new HashMap<>();
paramMap.put(JOB_ID_PARAM_KEY, jobId);
}
String jobLinkUrl = createInternalUrl(MainUI.VIEW_FRAGMENT_JOBS, paramMap, server);
if (jobLinkUrl != null) {
if (jobId == null) {
new Notification("Info", "<a href=\"" + jobLinkUrl + "\">" + " Go To Job View" + "</a>",
Notification.Type.TRAY_NOTIFICATION, true).show(Page.getCurrent());
} else {
new Notification("Info", "Job <a href=\"" + jobLinkUrl + "\">" + jobId + "</a> started.",
Notification.Type.TRAY_NOTIFICATION, true).show(Page.getCurrent());
}
} else {
new Notification("Info", "Job started.", Notification.Type.TRAY_NOTIFICATION, true).show(Page.getCurrent());
}
}
示例9: init
import com.vaadin.server.Page; //導入依賴的package包/類
@Override
protected void init(VaadinRequest vaadinRequest) {
VaadinSession.getCurrent().getSession().setMaxInactiveInterval(-1);
Page.getCurrent().setTitle("Tiny Pounder (" + VERSION + ")");
setupLayout();
addKitControls();
updateKitControls();
initVoltronConfigLayout();
initVoltronControlLayout();
initRuntimeLayout();
addExitCloseTab();
updateServerGrid();
// refresh consoles if any
consoleRefresher = scheduledExecutorService.scheduleWithFixedDelay(
() -> access(() -> runningServers.values().forEach(RunningServer::refreshConsole)),
2, 2, TimeUnit.SECONDS);
}
示例10: init
import com.vaadin.server.Page; //導入依賴的package包/類
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout contentArea = new VerticalLayout();
contentArea.setMargin(false);
setContent(contentArea);
final Navigator navigator = new Navigator(this, contentArea);
navigator.addProvider(viewProvider);
navigator.setErrorView(InaccessibleErrorView.class);
String defaultView = Page.getCurrent().getUriFragment();
if (defaultView == null || defaultView.trim().isEmpty()) {
defaultView = SecureView.VIEW_NAME;
}
if (isUserAuthenticated(vaadinRequest)) {
navigator.navigateTo(defaultView);
} else {
navigator.navigateTo(LoginView.VIEW_NAME + "/" + defaultView);
}
}
示例11: testSetNavigator
import com.vaadin.server.Page; //導入依賴的package包/類
@Test
public void testSetNavigator()
{
navigationStateManager.setNavigator(null);
Mockito.verifyZeroInteractions(popStateListenerRegistration);
Mockito.verifyZeroInteractions(page);
Mockito.when(page.addPopStateListener(ArgumentMatchers.any(Page.PopStateListener.class)))
.thenReturn(popStateListenerRegistration);
navigationStateManager.setNavigator(navigator);
Mockito.verify(page)
.addPopStateListener(ArgumentMatchers.any(Page.PopStateListener.class));
navigationStateManager.setNavigator(null);
Mockito.verify(popStateListenerRegistration).remove();
}
示例12: LanguageComboBox
import com.vaadin.server.Page; //導入依賴的package包/類
public LanguageComboBox(Locale locale) {
super(I18n.t("language"));
setStyleName("languages");
setContainerDataSource(createDataSource());
setItemCaptionPropertyId("caption");
setItemIconPropertyId("icon");
setImmediate(true);
setNullSelectionAllowed(false);
setInitialValue(locale);
addValueChangeListener(event -> {
BBPlay.setLanguage(((Locale) event.getProperty().getValue()).getLanguage());
Page.getCurrent().reload();
});
}
示例13: receiveUpload
import com.vaadin.server.Page; //導入依賴的package包/類
@Override
public OutputStream receiveUpload(String filename, String mimeType) {
imageCounter++;
savePath = "../uploads/" + filename;
imageName = filename;
FileOutputStream fos = null; // Stream to write to
try {
// Open the file for writing.
file = new File(savePath);
fos = new FileOutputStream(file);
} catch (final java.io.FileNotFoundException e) {
new Notification("Could not open file",
e.getMessage(),
Notification.Type.ERROR_MESSAGE).show(Page.getCurrent());
return null;
}
return fos; // Return the output stream to write to
}
示例14: injectMovieCoverStyles
import com.vaadin.server.Page; //導入依賴的package包/類
private void injectMovieCoverStyles() {
// Add all movie cover images as classes to CSSInject
String styles = "";
// for (Movie m : DashboardUI.getDataProvider().getMovies()) {
// WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
//
// String bg = "url(VAADIN/themes/" + UI.getCurrent().getTheme()
// + "/img/event-title-bg.png), url(" + m.getThumbUrl() + ")";
//
// // IE8 doesn't support multiple background images
// if (webBrowser.isIE() && webBrowser.getBrowserMajorVersion() == 8) {
// bg = "url(" + m.getThumbUrl() + ")";
// }
//
// styles += ".v-calendar-event-" + m.getId()
// + " .v-calendar-event-content {background-image:" + bg
// + ";}";
// }
Page.getCurrent().getStyles().add(styles);
}
示例15: init
import com.vaadin.server.Page; //導入依賴的package包/類
@Override
protected void init(final VaadinRequest request) {
setLocale(Locale.US);
DashboardEventBus.register(this);
Responsive.makeResponsive(this);
addStyleName(ValoTheme.UI_WITH_MENU);
updateContent();
// Some views need to be aware of browser resize events so a
// BrowserResizeEvent gets fired to the event bus on every occasion.
Page.getCurrent().addBrowserWindowResizeListener(
new BrowserWindowResizeListener() {
@Override
public void browserWindowResized(
final BrowserWindowResizeEvent event) {
DashboardEventBus.post(new BrowserResizeEvent());
}
});
}