List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:org.vaadin.alump.masonry.demo.MainMenuView.java
License:Open Source License
@Override public void enter(ViewChangeListener.ViewChangeEvent event) { Page.getCurrent().setTitle("MasonryLayout Demo Menu"); }
From source file:org.vaadin.presentation.views.ScheduleListView.java
@PostConstruct private void init() { /*//from w w w.j ava 2 s.co m * Add value change listener to table that opens the selected customer into * an editor. */ scheduleTable.addMValueChangeListener(new MValueChangeListener<ScheduleHeader>() { @Override public void valueChange(MValueChangeEvent<ScheduleHeader> event) { editSchedule(event.getValue()); } }); /* * Configure the filter input and hook to text change events to * repopulate the table based on given filter. Text change * events are sent to the server when e.g. user holds a tiny pause * while typing or hits enter. * */ filter.setInputPrompt("Filter schedules..."); filter.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent textChangeEvent) { listSchedules(textChangeEvent.getText()); } }); /* "Responsive Web Design" can be done with plain Java as well. Here we * e.g. do selective layouting and configure visible columns in * table based on available width */ layout(); adjustTableColumns(); /* If you wish the UI to adapt on window resize/page orientation * change, hook to BrowserWindowResizeEvent */ UI.getCurrent().setResizeLazy(true); Page.getCurrent().addBrowserWindowResizeListener(new Page.BrowserWindowResizeListener() { @Override public void browserWindowResized(Page.BrowserWindowResizeEvent browserWindowResizeEvent) { adjustTableColumns(); layout(); } }); listSchedules(); }
From source file:org.vaadin.spring.security.internal.VaadinManagedSecurity.java
License:Apache License
@Override public void logout() { VaadinSession.getCurrent().close(); Page.getCurrent().reload(); }
From source file:org.vaadin.spring.security.managed.DefaultVaadinManagedSecurity.java
License:Apache License
@Override public void logout(String logoutUrl) { VaadinSession.getCurrent().close(); Page.getCurrent().setLocation(logoutUrl); }
From source file:org.vaadin.tori.component.AuthoringComponent.java
License:Apache License
private AbstractField<String> buildEditor() { AbstractField<String> result = null; if (Page.getCurrent().getWebBrowser().isAndroid()) { result = new TextArea(); } else {/*from w w w .ja va 2 s .co m*/ result = new BBCodeWysiwygEditor(true, true); result.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { if (!ignoreInputChanges) { listener.inputValueChanged(editor.getValue()); } } }); ((BBCodeWysiwygEditor) result).addBlurListener(new BlurListener() { @Override public void blur(final BlurEvent event) { UI.getCurrent().setPollInterval(ToriUI.DEFAULT_POLL_INTERVAL); } }); ((BBCodeWysiwygEditor) result).addFocusListener(new FocusListener() { @Override public void focus(final FocusEvent event) { UI.getCurrent().setPollInterval(3000); } }); } result.setSizeFull(); return result; }
From source file:org.vaadin.tori.component.BBCodeWysiwygEditor.java
License:Apache License
private void configurePlugins(final CKEditorConfig config, final boolean autoGrow, final boolean bbcode) { if (bbcode) { config.addToExtraPlugins("custombbcode"); }/*from w ww . j a v a 2 s. c o m*/ config.addToExtraPlugins("codebutton"); config.addToRemovePlugins("magicline"); WebBrowser browser = Page.getCurrent().getWebBrowser(); boolean disableResizer = true; if (autoGrow) { if (browser.isChrome() || browser.isSafari() || browser.isOpera()) { config.addToExtraPlugins("autogrow"); } else { disableResizer = false; } } if (disableResizer) { config.disableResizeEditor(); } }
From source file:org.vaadin.tori.component.DebugControlPanel.java
License:Apache License
public DebugControlPanel(final DebugAuthorizationService authorizationService) { Page.getCurrent().getStyles() .add(".v-popupview-popup { background: #fff; } .v-popupview-popup .v-widget { font-size: 12px; }"); addStyleName("debugcontrolpanel"); this.authorizationService = authorizationService; ToriNavigator.getCurrent().addViewChangeListener(new ViewChangeListener() { @Override/*from w w w . j a v a2 s . com*/ public void afterViewChange(final ViewChangeEvent event) { currentView = event.getNewView(); } @Override public boolean beforeViewChange(final ViewChangeEvent event) { return true; } }); final PopupView popupButton = new PopupView("Debug Control Panel", new Panel()); popupButton.setHideOnMouseOut(false); popupButton.addStyleName("v-button"); popupButton.addPopupVisibilityListener(this); setCompositionRoot(popupButton); setSizeUndefined(); }
From source file:org.vaadin.tori.ToriApiLoader.java
License:Apache License
private static String getToriThemeImagesURL(final VaadinRequest request) throws MalformedURLException { URL url = Page.getCurrent().getLocation().toURL(); int port = url.getPort(); if (url.getProtocol().equals("http") && port == 80) { port = -1;//from w w w.j a v a 2 s. c o m } else if (url.getProtocol().equals("https") && port == 443) { port = -1; } URL serverURL = new URL(url.getProtocol(), url.getHost(), port, ""); String contextPath = request.getContextPath(); String imagesPath = "/VAADIN/themes/tori/images/"; return serverURL + contextPath + imagesPath; }
From source file:org.vaadin.tori.ToriNavigator.java
License:Apache License
private void updatePageTitle(final String title) { String prefix = configuration.getPageTitlePrefix(); StringBuilder sb = new StringBuilder(); if (prefix != null) { sb.append(prefix);//from www .j a va 2s .co m } if (title != null && !title.isEmpty()) { if (!sb.toString().isEmpty()) { sb.append(" > "); } sb.append(title); } String pageTitle = sb.toString(); Page.getCurrent().setTitle(pageTitle); // Liferay session.js resets the document.title after every request // (when logged in). // This hack is a workaround for the issue. JavaScript.eval( // @formatter:off //Liferay 6.0 "try {" + "Liferay.Session._originalTitle = '" + pageTitle + "';" + "} catch(err){}" + //Liferay 6.2 "try {" + "Liferay.Session.display._state.data.pageTitle.initValue = '" + pageTitle + "';" + "Liferay.Session.display._state.data.pageTitle.lazy.value = '" + pageTitle + "';" + "} catch(err){}"); // @formatter:on }
From source file:org.vaadin.tori.ToriUI.java
License:Apache License
private void checkUrl() { UrlConverter uc = apiLoader.getUrlConverter(); if (uc != null) { String currentUrl = Page.getCurrent().getLocation().toString(); String convertedUrl = uc.convertUrlToToriForm(currentUrl); if (!currentUrl.equals(convertedUrl)) { Page.getCurrent().setLocation(convertedUrl); }// w ww . jav a 2 s .co m } }