List of usage examples for com.vaadin.ui JavaScript getCurrent
public static JavaScript getCurrent()
From source file:annis.gui.MainToolbar.java
License:Apache License
public MainToolbar() { String bugmail = (String) VaadinSession.getCurrent().getAttribute(BUG_MAIL_KEY); if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${") && new EmailValidator("").isValid(bugmail)) { this.bugEMailAddress = bugmail; } else {/* w ww . java 2s . co m*/ this.bugEMailAddress = null; } UI ui = UI.getCurrent(); if (ui instanceof CommonUI) { ((CommonUI) ui).getSettings().addedLoadedListener(MainToolbar.this); } setWidth("100%"); setHeight("-1px"); addStyleName("toolbar"); addStyleName("border-layout"); btAboutAnnis = new Button("About ANNIS"); btAboutAnnis.addStyleName(ValoTheme.BUTTON_SMALL); btAboutAnnis.setIcon(new ThemeResource("images/annis_16.png")); btAboutAnnis.addClickListener(new AboutClickListener()); btSidebar = new Button(); btSidebar.setDisableOnClick(true); btSidebar.addStyleName(ValoTheme.BUTTON_SMALL); btSidebar.setDescription("Show and hide search sidebar"); btSidebar.setIconAlternateText(btSidebar.getDescription()); btBugReport = new Button("Report Problem"); btBugReport.addStyleName(ValoTheme.BUTTON_SMALL); btBugReport.setDisableOnClick(true); btBugReport.setIcon(FontAwesome.ENVELOPE_O); btBugReport.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { reportBug(); } }); btBugReport.setVisible(this.bugEMailAddress != null); btNavigate = new Button(); btNavigate.setVisible(false); btNavigate.setDisableOnClick(true); btNavigate.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { btNavigate.setEnabled(true); if (navigationTarget != null) { UI.getCurrent().getNavigator().navigateTo(navigationTarget.state); } } }); lblUserName = new Label("not logged in"); lblUserName.setWidth("-1px"); lblUserName.setHeight("-1px"); lblUserName.addStyleName("right-aligned-text"); btLogin = new Button("Login", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showLoginWindow(false); } }); btLogout = new Button("Logout", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // logout Helper.setUser(null); for (LoginListener l : loginListeners) { l.onLogout(); } Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION); updateUserInformation(); } }); btLogin.setSizeUndefined(); btLogin.setStyleName(ValoTheme.BUTTON_SMALL); btLogin.setIcon(FontAwesome.USER); btLogout.setSizeUndefined(); btLogout.setStyleName(ValoTheme.BUTTON_SMALL); btLogout.setIcon(FontAwesome.USER); btOpenSource = new Button("Help us to make ANNIS better!"); btOpenSource.setStyleName(BaseTheme.BUTTON_LINK); btOpenSource.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Window w = new HelpUsWindow(); w.setCaption("Help us to make ANNIS better!"); w.setModal(true); w.setResizable(true); w.setWidth("600px"); w.setHeight("500px"); UI.getCurrent().addWindow(w); w.center(); } }); addComponent(btSidebar); setComponentAlignment(btSidebar, Alignment.MIDDLE_LEFT); addComponent(btAboutAnnis); addComponent(btBugReport); addComponent(btNavigate); addComponent(btOpenSource); setSpacing(true); setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT); setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT); setComponentAlignment(btNavigate, Alignment.MIDDLE_LEFT); setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER); setExpandRatio(btOpenSource, 1.0f); addLoginButton(); btSidebar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { btSidebar.setEnabled(true); // decide new state switch (sidebarState) { case VISIBLE: if (event.isCtrlKey()) { sidebarState = SidebarState.AUTO_VISIBLE; } else { sidebarState = SidebarState.HIDDEN; } break; case HIDDEN: if (event.isCtrlKey()) { sidebarState = SidebarState.AUTO_HIDDEN; } else { sidebarState = SidebarState.VISIBLE; } break; case AUTO_VISIBLE: if (event.isCtrlKey()) { sidebarState = SidebarState.VISIBLE; } else { sidebarState = SidebarState.AUTO_HIDDEN; } break; case AUTO_HIDDEN: if (event.isCtrlKey()) { sidebarState = SidebarState.HIDDEN; } else { sidebarState = SidebarState.AUTO_VISIBLE; } break; } updateSidebarState(); } }); screenshotExtension = new ScreenshotMaker(this); JavaScript.getCurrent().addFunction("annis.gui.logincallback", new LoginCloseCallback()); updateSidebarState(); MainToolbar.this.updateUserInformation(); }
From source file:com.adonis.ui.print.PrintVehiclesUI.java
@Override protected void init(VaadinRequest request) { Table table = new Table(); table.setContainerDataSource(MainUI.getVehiclesCrudView().container); table.setVisibleColumns("vehicleNmbr", "licenseNmbr", "make", "vehicleType", "model", "year", "active", "location", "price", "priceDay", "priceWeek", "priceMonth", "status"); // Have some content to print setContent(table);/* w ww .j a va 2 s .c o m*/ // Print automatically when the window opens JavaScript.getCurrent().execute("setTimeout(function() {" + " print(); self.close();}, 0);"); }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
protected void buildInitJavascript() { JavaScript.getCurrent().addFunction("constellio_easter_egg_code", new JavaScriptFunction() { @Override//from ww w . j av a2s .co m public void call(JsonArray arguments) { ((ConstellioMenuImpl) mainMenu).getUserSettingsItem() .setIcon(new ThemeResource("images/profiles/egg.jpg")); } }); }
From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java
License:Open Source License
public NotificationComponent() { super();// w w w.ja va 2 s .com notificationItems = new ArrayList<>(); notificationContainer = new VerticalLayout(); new Restrain(notificationContainer).setMaxWidth("500px"); this.setContent(notificationContainer); this.setIcon(FontAwesome.BELL); this.setStyleName("notification-button"); addPopupVisibilityListener(this); EventBusFactory.getInstance().register(this); // Register to receive broadcasts NotificationBroadcaster.register(this); JavaScript.getCurrent().addFunction("com.mycollab.scripts.upgrade", new JavaScriptFunction() { @Override public void call(JsonArray arguments) { String version = arguments.getString(0); String installerFile = arguments.getString(1); String manualDownloadLink = arguments.getString(2); UI.getCurrent().addWindow(new UpgradeConfirmWindow(version, manualDownloadLink, installerFile)); } }); }
From source file:com.foc.business.notifier.FocNotificationEmail.java
License:Apache License
private void send_UsingLocalEmailClient() { if (getText() != null) { String text = getText().replaceAll("\n", "%0D%0A"); text = text.replace('\'', '-'); String recipients = getRecipients() != null ? getRecipients().replaceAll(" ", "") : ""; String javaScript = "var win = window.open('mailto:" + recipients + "?body=" + text + "', '_blank'); win.close();"; JavaScript.getCurrent().execute(javaScript); }/* ww w .j a v a 2 s . c o m*/ }
From source file:com.foc.vaadin.gui.components.FVEmailField.java
License:Apache License
private FVButton getEmailButton() { if (outlookButton == null) { outlookButton = new FVButton(""); outlookButton.setDescription("Send email"); outlookButton.setStyleName(BaseTheme.BUTTON_LINK); outlookButton.setIcon(FVIconFactory.getInstance().getFVIcon_24(FVIconFactory.ICON_EMAIL)); outlookButton.addClickListener(new ClickListener() { @Override//ww w. j a v a 2 s.co m public void buttonClick(ClickEvent event) { JavaScript.getCurrent().execute("window.location = 'mailto:" + getEmailText().getValue() + "'"); } }); } return outlookButton; }
From source file:com.foc.vaadin.gui.layouts.validationLayout.FVValidationLayout.java
License:Apache License
private void emailClickListener() { if (!Globals.getApp().checkSession()) { FocList focList = FocPageLinkDesc.getList(FocList.LOAD_IF_NEEDED); FocPageLink focPageLink = (FocPageLink) focList.newEmptyItem(); String randomKeyStringForURL = getUrlKey(focList); FocObject focObj = (getFocObject() != null && getFocObject() instanceof FocObject) ? (FocObject) getFocObject() : null;//from w ww . ja v a 2s .c om XMLViewKey xmlViewKey = getCentralPanel() != null ? getCentralPanel().getXMLView().getXmlViewKey() : null; String serialisation = getCentralPanel().getLinkSerialisation(); focPageLink.fill(focObj, xmlViewKey, serialisation, randomKeyStringForURL); focPageLink.validate(true); String javaScript = "var win = window.open('mailto:?body=Hello,%20%0d%0a%20%0d%0aClick on this link or copy it in you internet browser to open the document:%20%0d%0a" + Page.getCurrent().getLocation() + randomKeyStringForURL + "%20%0d%0a%20%0d%0aRegards,', '_blank'); win.close();"; Globals.logString("FVValidationLayout, Line: 897, mail line: " + Page.getCurrent().getLocation() + randomKeyStringForURL); JavaScript.getCurrent().execute(javaScript); } }
From source file:com.foc.vaadin.gui.layouts.validationLayout.PrintUI.java
License:Apache License
@Override public void init(VaadinRequest request) { super.init(request); FocCentralPanel focCentralPanel = (FocCentralPanel) getNavigationWindow(); focCentralPanel.setWidth(focCentralPanel.getPreferredWidth()); focCentralPanel.getCentralPanelWrapper().setWidth(focCentralPanel.getPreferredWidth()); //ATTENTION// w w w. ja v a2 s . c om JavaScript.getCurrent().execute("setTimeout(function() { window.print(); self.close();}, 2000);"); // JavaScript.getCurrent().execute("setTimeout(function() { window.print(); }, 2000);"); }
From source file:com.foc.vaadin.gui.xmlForm.FocXMLLayout.java
License:Apache License
public void printThisLayout2() { JavaScript.getCurrent().execute("print();"); // XMLView xmlView = getXMLView(); ////from www .ja v a 2s. c om // Window window = new Window(); //// window.setScrollable(false); // FocXMLLayout printingForm = new FocXMLLayout(); // printingForm.init((FocCentralPanel) getMainWindow(), xmlView, getFocData()); // printingForm.parseXMLAndBuildGui(); // window.setContent(printingForm); // // mWindow.open(new ExternalResource(window.getURL()), "_blank", 595, 842, // // Window.BORDER_NONE); // int prefWidth = 700; // try{ // String prefWidthStr = getPreferredPageWidth(); // // // if(prefWidthStr == null){ // prefWidthStr = "700"; // } // // // prefWidthStr = prefWidthStr.replace("px", ""); // prefWidth = Integer.parseInt(prefWidthStr); // prefWidth += FocCentralPanel.MARGIN_FOR_CENTRAL_PANEL; // }catch (Exception e){ // Globals.logException(e); // } // // window.setWidth(prefWidth+"px"); // FocWebApplication.getInstanceForThread().addWindow(window); //// Globals.showNotification("Foc Vaadin 7 compatibility", "FE54GQ", IFocEnvironment.TYPE_ERROR_MESSAGE); //// getUI().getPage().open(window.getURL(), "_blank"); //// mWindow.open(new ExternalResource(window.getURL()), "_blank", prefWidth, 842, Window.BORDER_NONE); // JavaScript.getCurrent().execute("print();"); // JavaScript.getCurrent().execute("self.close();"); /* * Change the container of the layout we want to print without re-creating * it * //---------------------------------------------------------------------- * -- * * AbstractComponentContainer container = (AbstractComponentContainer) * getParent(); container.removeComponent(this); * * FocCentralPanel centralPanel = new FocCentralPanel(); * centralPanel.fill(); centralPanel.changeCentralPanelContent(this, true); * mWindow.getApplication().addWindow(centralPanel); mWindow.open(new * ExternalResource(centralPanel.getURL()), "_blank", 595, 842, * Window.BORDER_NONE); centralPanel.executeJavaScript("print();"); // * window.executeJavaScript("self.close();"); */ }
From source file:com.foc.vaadin.gui.xmlForm.FocXMLLayout.java
License:Apache License
public void printThisLayout() { XMLView xmlView = getXMLView();//from ww w . java2 s.com Window window = new Window(); // window.setScrollable(false);//HEREHERE FocXMLLayout printingForm = new FocXMLLayout(); printingForm.init((FocCentralPanel) getMainWindow(), xmlView, getFocData()); printingForm.parseXMLAndBuildGui(); window.setContent(printingForm); FocWebApplication.getInstanceForThread().addWindow(window); // mWindow.open(new ExternalResource(window.getURL()), "_blank", 595, 842, // Window.BORDER_NONE); JavaScript.getCurrent().execute("print();"); JavaScript.getCurrent().execute("self.close();"); }