List of usage examples for com.vaadin.server Page getCurrent
public static Page getCurrent()
From source file:com.foc.vaadin.FocWebApplication.java
License:Apache License
public void initializeGUI(VaadinRequest vaadinRequest, ServletContext servletContext, HttpSession httpSession) { String path = vaadinRequest != null ? vaadinRequest.getPathInfo() : null; navigationWindow = newWindow();/*from ww w . j a v a 2s . c o m*/ if (Utils.isStringEmpty(Globals.getApp().getURL())) { if (Page.getCurrent() != null) { URI url = Page.getCurrent().getLocation(); Globals.getApp().setURL(url.toString()); } } applyUserThemeSelection(); if (Globals.isValo() && !isPrintUI()) { navigationWindow.setHeightUndefined(); navigationWindow.setHeight("100%"); FocXMLGuiComponentStatic.setCaptionMargin_Zero(navigationWindow); //PANEL // Panel bodyPanel = new Panel(); // bodyPanel.setSizeFull(); // bodyPanel.setContent(navigationWindow); //----- footerLayout = new VerticalLayout(); footerLayout.setHeight("-1px"); //footerLayout.addComponent(new Label("")); VerticalLayout mainVerticalLayout = new VerticalLayout(); mainVerticalLayout.setSizeFull();// Main Layout is set to size Full so that it fills all the height //PANEL // mainVerticalLayout.addComponent(bodyPanel); // mainVerticalLayout.setExpandRatio(bodyPanel, 1); //----- mainVerticalLayout.addComponent(navigationWindow); mainVerticalLayout.setExpandRatio(navigationWindow, 1); mainVerticalLayout.addComponent(footerLayout); setContent(mainVerticalLayout); } else { setContent(navigationWindow); footerLayout = null; } initAccountFromDataBase(); if (getNavigationWindow() != null) { INavigationWindow window = getNavigationWindow(); URI uri = Page.getCurrent().getLocation(); //Make sure the environment allows unit testing if (ConfigInfo.isUnitAllowed() && uri.getHost().equals("localhost")) { //If there are no test indexes already then we need to check the URL for test request if (!FocUnitDictionary.getInstance().hasNextTest()) { String suiteName = null; String testName = null; if (path != null && path.toLowerCase().startsWith(URL_PARAMETER_KEY_UNIT_SUITE + ":")) { suiteName = path.substring((URL_PARAMETER_KEY_UNIT_SUITE + ":").length()); if (!Utils.isStringEmpty(suiteName)) { int indexOfSuperior = suiteName.indexOf("."); if (indexOfSuperior > 0) { testName = suiteName.substring(indexOfSuperior + 1, suiteName.length()); suiteName = suiteName.substring(0, indexOfSuperior); } FocUnitDictionary.getInstance().initializeCurrentSuiteAndTest(suiteName, testName); } } } if (FocUnitDictionary.getInstance().hasNextTest()) { try { Globals.getApp().setIsUnitTest(true); FocUnitDictionary.getInstance().runSequence(); } catch (Exception e) { Globals.logException(e); } finally { // if( !FocUnitDictionary.getInstance().isPause() // && !FocUnitDictionary.getInstance().isNextTestExist() // ){ // FocUnitDictionary.getInstance().popupLogger(window); // } Globals.getApp().setIsUnitTest(false); } } } } //-------------------------------------------- }
From source file:com.foc.vaadin.FocWebEnvironment.java
License:Apache License
@Override public void showNotification(String notificationMessage, String description, int notificationType, int delay, String styleName) {/*from w ww .j a va2 s . c o m*/ try { if (Globals.getApp() != null && Globals.getApp().isUnitTest() && FocUnitDictionary.getInstance() != null) { FocUnitDictionary.getInstance().expectedNotification_Occured(notificationMessage, description, notificationType); } else { FocWebSession focWebSession = FocWebApplication.getFocWebSession_Static(); if (focWebSession == null || focWebSession.isNotificationEnabled()) { Notification.Type type = Notification.Type.ERROR_MESSAGE; if (notificationType == IFocEnvironment.TYPE_ERROR_MESSAGE) { FocLogger.getInstance().addError("Error Popup: " + notificationMessage + " " + description); } else if (notificationType == IFocEnvironment.TYPE_WARNING_MESSAGE) { FocLogger.getInstance() .addWarning("Warning Popup: " + notificationMessage + " " + description); type = Notification.Type.WARNING_MESSAGE; } else if (notificationType == IFocEnvironment.TYPE_HUMANIZED_MESSAGE) { FocLogger.getInstance().addInfo("Info Popup: " + notificationMessage + " " + description); type = Notification.Type.HUMANIZED_MESSAGE; } else if (notificationType == IFocEnvironment.TYPE_TRAY_NOTIFICATION) { FocLogger.getInstance().addInfo("Tray Popup: " + notificationMessage + " " + description); type = Notification.Type.TRAY_NOTIFICATION; } Notification notification = new Notification(notificationMessage, description, type); notification.setDelayMsec(delay); if (!Utils.isStringEmpty(styleName)) notification.setStyleName(styleName); if (Page.getCurrent() != null) { notification.show(Page.getCurrent()); } /* FancyNotifications fancyNotifications = new FancyNotifications(); fancyNotifications.setPosition(Position.BOTTOM_RIGHT); FancyNotification fancyNotification = new FancyNotification(null, notificationMessage, description); fancyNotification.getTitleLabel().setContentMode(ContentMode.HTML); fancyNotification.getDescriptionLabel().setContentMode(ContentMode.HTML); fancyNotification.addLayoutClickListener(notificationClickEvent -> Page.getCurrent().setLocation("https://github.com/alump/FancyLayouts")); fancyNotifications.showNotification(fancyNotification); */ } } } catch (Exception e) { Globals.logExceptionWithoutPopup(e); } // Notification.show(notificationMessage, description, type); }
From source file:com.foc.vaadin.gui.components.BlobResource.java
License:Apache License
public void openDownloadWindow() { // setCacheTime(0); Page.getCurrent().open(this, null, true); }
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 w w. j a va 2 s . co m 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.web.modules.admin.AdminWebModule.java
License:Apache License
public void menu_FillMenuTree(FVMenuTree menuTree, FocMenuItem fatherMenuItem) { FocMenuItem systemMenu = menuTree.pushRootMenu("System", "System"); FocMenuItem menuItem = systemMenu.pushMenu("REINDEX_ALL", "Reindex all indexes"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override/*from w ww . ja va 2 s .c o m*/ public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { OptionDialog dialog = new OptionDialog("Reindex all", "This may take a few minutes to reindex all indexes") { @Override public boolean executeOption(String optionName) { if (optionName != null && optionName.equals("ADAPT")) { Globals.getApp().getDataSource().command_AdaptDataModel_Reindex(); } return false; } }; dialog.addOption("ADAPT", "Yes Reindex"); dialog.addOption("CANCEL", "No Cancel Reindexing"); dialog.setWidth("500px"); dialog.setHeight("200px"); Globals.popupDialog(dialog); } }); menuItem = systemMenu.pushMenu("ADAPT_DATA_MODEL", "Adapt Data Model"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { OptionDialog dialog = new OptionDialog("Adapt data to model", "This may take a few minutes to adapt the database tables and fields according to the executable's version.") { @Override public boolean executeOption(String optionName) { if (optionName != null && optionName.equals("ADAPT")) { Globals.getApp().adaptDataModel(false, false); } return false; } }; dialog.addOption("ADAPT", "Yes Adapt"); dialog.addOption("CANCEL", "No Cancel Adapt"); dialog.setWidth("500px"); dialog.setHeight("200px"); Globals.popupDialog(dialog); } }); menuItem = systemMenu.pushMenu("ADAPT_DATA_MODEL_FORCED", "Adapt Data Model - Forced"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { OptionDialog dialog = new OptionDialog("Adapt data to model", "This may take a few minutes to adapt the database tables and fields according to the executable's version.") { @Override public boolean executeOption(String optionName) { if (optionName != null && optionName.equals("ADAPT")) { Globals.getApp().adaptDataModel(true, false); } return false; } }; dialog.addOption("ADAPT", "Yes Adapt"); dialog.addOption("CANCEL", "No Cancel Adapt"); dialog.setWidth("500px"); dialog.setHeight("200px"); Globals.popupDialog(dialog); } }); menuItem = systemMenu.pushMenu("DB_CONNECTION_MONITORING", "DB Connection monitoring"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { String message = ""; if (Globals.getApp() != null && Globals.getApp().getDataSource() != null) { StringBuffer buff = Globals.getApp().getDataSource().getMonitoringText(); if (buff != null) { message = buff.toString(); OptionDialog dialog = new OptionDialog("DB connection monitoring", message) { @Override public boolean executeOption(String optionName) { return false; } }; dialog.addOption("OK", "Ok"); dialog.setWidth("1000px"); dialog.setHeight("500px"); Globals.popupDialog(dialog); } } } }); menuItem = systemMenu.pushMenu("ACTIVE_USERS", "Active Users"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; if (FocWebServer.getInstance() != null) { FocWebServer.getInstance().removeApplicationsNotRunning(); } FocList list = new FocList(new FocLinkSimple(ActiveUserDesc.getInstance())); for (int i = 0; i < FocWebServer.getInstance().getApplicationCount(); i++) { FocWebApplication app = FocWebServer.getInstance().getApplicationAt(i); if (app != null && app.getFocWebSession() != null && app.getFocWebSession().getFocUser() != null && !app.isClosing()) { FocUser user = app.getFocWebSession().getFocUser(); if (user != null) { Company company = user.getCurrentCompany(); WFSite site = user.getCurrentSite(); WFTitle title = user.getCurrentTitle(); ActiveUser activeUser = (ActiveUser) list.newEmptyItem(); activeUser.setUserCompany(company); activeUser.setUser(user); activeUser.setUserSite(site); activeUser.setUserTitle(title); long lastHeartBeat = app.getLastHeartbeatTimestamp(); Date lastHeartBeatDate = new Date(lastHeartBeat); activeUser.setLastHeartBeat(lastHeartBeatDate); list.add(activeUser); } } } XMLViewKey xmlViewKey = new XMLViewKey(ActiveUserDesc.getInstance().getStorageName(), XMLViewKey.TYPE_TABLE); ICentralPanel centralPanel = XMLViewDictionary.getInstance() .newCentralPanel((FocWebVaadinWindow) mainWindow, xmlViewKey, list); centralPanel.setFocDataOwner(true); mainWindow.changeCentralPanelContent(centralPanel, true); } }); menuItem = systemMenu.pushMenu("ADMIN_CLEAR_LOGGER", "Clear Logger Tree"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { FocLogger.getInstance().dispose(); } }); menuItem = systemMenu.pushMenu("FREE_UNUSED_MEMORY", "Free unused memory"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { // INavigationWindow mainWindow = (INavigationWindow) navigationWindow; String beforeMessage = Globals.logMemory("Before freeing "); System.gc(); Globals.logMemory(""); System.gc(); Globals.logMemory(""); System.gc(); String afterMessage = Globals.logMemory("After freeing "); Globals.showNotification(beforeMessage, afterMessage, IFocEnvironment.TYPE_HUMANIZED_MESSAGE); } }); menuItem = systemMenu.pushMenu("MEMORY", "Memory"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; String message = Globals.logMemory(""); Globals.showNotification("", message, IFocEnvironment.TYPE_HUMANIZED_MESSAGE); } }); FocMenuItem mainMenu = menuTree.pushRootMenu("Admin", "Admin"); menuItem = mainMenu.pushMenu("FOC_USER", "Users"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocList focList = FocUserDesc.getList(); mainWindow.changeCentralPanelContent_ToTableForFocList(focList); } }); menuItem = mainMenu.pushMenu("DOC_RIGHTS_GROUPS", "Doc Rights Group"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocList focList = DocRightsGroupDesc.getInstance().getFocList(); mainWindow.changeCentralPanelContent_ToTableForFocList(focList); } }); menuItem = mainMenu.pushMenu("FOC_GROUP", "Groups"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocList focList = FocGroup.getList(FocList.LOAD_IF_NEEDED); mainWindow.changeCentralPanelContent_ToTableForFocList(focList); } }); menuItem = mainMenu.pushMenu("APP_CONFIG", "App Configuration"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; SaaSConfig appConfiguration = SaaSConfig.getInstance(); XMLViewKey xmlViewKey = new XMLViewKey(SaaSConfigDesc.getInstance().getStorageName(), XMLViewKey.TYPE_FORM); ICentralPanel centralPanel = XMLViewDictionary.getInstance().newCentralPanel(mainWindow, xmlViewKey, appConfiguration); mainWindow.changeCentralPanelContent(centralPanel, true); } }); menuItem = mainMenu.pushMenu("APP_CONFIGURATOR", "Adapt User Rights"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { SaaSApplicationAdaptor adapter = SaaSConfig.getInstance().getSaasApplicationAdaptor(); adapter.adaptApplication(true); adapter.adaptUserRights(); } }); menuItem = mainMenu.pushMenu("ADMIN_DOWNLOAD_USER_ACCESS", "Download user access to modules"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; UserModuleList list = new UserModuleList(); list.fill(); UserModuleAccess_ExcelExport userExport = new UserModuleAccess_ExcelExport(list); userExport.init(); userExport.dispose(); list.dispose(); } }); menuItem = mainMenu.pushMenu("FOC_MIGRATION_SOURCE", "Migration Source"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocList focList = MigrationSourceDesc.getInstance().getFocList(); mainWindow.changeCentralPanelContent_ToTableForFocList(focList); } }); menuItem = mainMenu.pushMenu("DOCUMENT_HEADER_EDIT", "Document header format"); menuItem.setExtraAction0("Reset"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { if (extraActionIndex == 0) { XMLViewKey key = XMLViewDictionary.getInstance() .newXMLViewKey_ForDocumentHeader(XMLViewKey.VIEW_DEFAULT); XMLView view = XMLViewDictionary.getInstance().get(key); FocWebApplication.getInstanceForThread().addWindow( new XMLEditor(view, "Document header", view.getXmlviewDefinition().getXML())); } else if (extraActionIndex == 1) { OptionDialog dialog = new OptionDialog("Confirmation", "Are you sure you want to reset the transaction header layout?") { public boolean executeOption(String optionName) { if (optionName.equals("YES")) { XMLViewKey key = XMLViewDictionary.getInstance() .newXMLViewKey_ForDocumentHeader(XMLViewKey.VIEW_DEFAULT); XMLView view = XMLViewDictionary.getInstance().get(key); if (view != null) { XMLViewDictionary.getInstance() .updateDocumentHearerView(view.getXmlviewDefinition()); } } return false; } }; dialog.addOption("YES", "Yes reset"); dialog.addOption("CANCEL", "No cancel"); dialog.setWidth("500px"); dialog.setHeight("200px"); Globals.popupDialog(dialog); } } }); menuItem = mainMenu.pushMenu("DOCUMENT_HEADER_PRINT_EDIT", "Document header printing format"); menuItem.setExtraAction0("Reset"); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { if (extraActionIndex == 0) { XMLViewKey key = XMLViewDictionary.getInstance() .newXMLViewKey_ForDocumentHeader(XMLViewKey.VIEW_PRINTING); XMLView view = XMLViewDictionary.getInstance().get_WithoutAdjustToLastSelection(key); FocWebApplication.getInstanceForThread().addWindow( new XMLEditor(view, "Document header", view.getXmlviewDefinition().getXML())); } else if (extraActionIndex == 1) { OptionDialog dialog = new OptionDialog("Confirmation", "Are you sure you want to reset the transaction header printing layout?") { public boolean executeOption(String optionName) { if (optionName.equals("YES")) { XMLViewKey key = XMLViewDictionary.getInstance() .newXMLViewKey_ForDocumentHeader(XMLViewKey.VIEW_PRINTING); XMLView view = XMLViewDictionary.getInstance().get(key); if (view != null) { XMLViewDictionary.getInstance() .updateDocumentHearerView_Printing(view.getXmlviewDefinition()); } } return false; } }; dialog.addOption("YES", "Yes reset"); dialog.addOption("CANCEL", "No cancel"); Globals.popupDialog(dialog); } } }); FocMenuItem countryPresetingsMenu = null; if (FocWebServer.getInstance() != null && FocWebServer.getInstance().applicationConfigurators_Size() > 0) { for (int i = 0; i < FocWebServer.getInstance().applicationConfigurators_Size(); i++) { IApplicationConfigurator config = FocWebServer.getInstance().applicationConfigurators_Get(i); if (countryPresetingsMenu == null) { countryPresetingsMenu = mainMenu.pushMenu("Country Presettings", "Country presettings"); } FocMenuItem countryMenuItem = countryPresetingsMenu.pushMenu(config.getCode(), config.getTitle()); countryMenuItem.setMenuAction(config); } } URI uri = Page.getCurrent().getLocation(); if (Globals.getApp().isUnitTest()) { menuItem = mainMenu.pushMenu(MNU_CODE_UNIT_TEST_LOG, "Unit Test Logs"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocUnitDictionary.getInstance().popupLogger(mainWindow); } }); } if (ConfigInfo.isUnitAllowed() && uri.getHost().equals("localhost")) { menuItem = mainMenu.pushMenu("UNIT_TEST_LOG", "Unit Test Logs"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocUnitDictionary.getInstance().popupLogger(mainWindow); } }); FocMenuItem unitTestingMenuList = mainMenu.pushMenu("UNIT_TEST", "Unit Tests"); FocUnitDictionary dictionary = FocUnitDictionary.getInstance(); Collection<FocUnitTestingSuite> collection = dictionary != null ? dictionary.getTestingSuiteMapValues() : null; if (collection != null) { Iterator<FocUnitTestingSuite> itr = collection.iterator(); while (itr != null && itr.hasNext()) { final FocUnitTestingSuite suite = (FocUnitTestingSuite) itr.next(); if (suite.isShowInMenu()) { menuItem = unitTestingMenuList.pushMenu(suite.getName(), suite.getName()); menuItem.setMenuAction(new IFocMenuItemAction() { public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { INavigationWindow mainWindow = (INavigationWindow) navigationWindow; FocUnitDictionary dictionary = FocUnitDictionary.getInstance(); try { dictionary.runUnitTest(suite.getName()); } catch (Exception e) { Globals.logException(e); } dictionary.popupLogger(mainWindow); } }); } } } } menuItem = mainMenu.pushMenu("MAKE_DATA_ANONIMOUS", "_Make Data Anonimous"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { OptionDialogWindow optionWindow = new OptionDialogWindow( "ARE YOU SURE YOU WANT TO LOOSE DATA NAMES!!!!! (NOT RECOMMENDED) SHOULD NEVER BE USED FOR PRODUCTION REAL DATA !!!!!!!!!!! !!!!!!!!!!!! !!!!!!!!!!!!! !!!!!!!!!!!11", null); optionWindow.setWidth("500px"); optionWindow.setHeight("200px"); optionWindow.addOption("Yes, Loose Data", new IOption() { @Override public void optionSelected(Object contextObject) { FocWebServer.getInstance().makeDataAnonymous(); } }); optionWindow.addOption("Cancel", new IOption() { @Override public void optionSelected(Object contextObject) { } }); FocWebApplication.getInstanceForThread().addWindow(optionWindow); } }); FocMenuItem autoPopulateMenu = null; Iterator<IFocDescDeclaration> focDescDeclarationIterator = Globals.getApp().getFocDescDeclarationIterator(); while (focDescDeclarationIterator != null && focDescDeclarationIterator.hasNext()) { IFocDescDeclaration focDescDeclaration = focDescDeclarationIterator.next(); if (focDescDeclaration != null) { FocDesc focDesc = focDescDeclaration.getFocDescription(); if (focDesc instanceof AutoPopulatable) { final AutoPopulatable autoPopulatable = (AutoPopulatable) focDesc; if (autoPopulateMenu == null) { autoPopulateMenu = mainMenu.pushMenu("AUTO_POPULATE", "Auto Populate"); FocMenuItem allautoPopulateMenu = autoPopulateMenu.pushMenu("ALL_AUTO_POPULATE", "All Auto Populate"); if (allautoPopulateMenu != null) { allautoPopulateMenu.setMenuAction(new AllAutoPopulateListener()); } } final String autoPopulatableTitle = autoPopulatable.getAutoPopulatableTitle(); FocMenuItem autoPopulatableMenuItem = autoPopulateMenu .pushMenu(autoPopulatableTitle.toUpperCase(), autoPopulatableTitle); autoPopulatableMenuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { OptionDialog optionDialog = new OptionDialog("Confirm Auto Populate", "This may take a few minutes to populate " + autoPopulatableTitle) { @Override public boolean executeOption(String optionName) { if (optionName.equals("OK_BUTTON")) { autoPopulatable.populate(); } return false; } }; optionDialog.addOption("OK_BUTTON", "Auto Populate"); optionDialog.addOption("CANCEL", "Cancel"); optionDialog.setWidth("500px"); optionDialog.setHeight("200px"); Globals.popupDialog(optionDialog); } }); } } } menuItem = mainMenu.pushMenu("GENERATE_MOBILE_APP_SOURCE", "_Generate Source Code For Mobile Apps"); menuItem.setMenuAction(new IFocMenuItemAction() { @Override public void actionPerformed(Object navigationWindow, FocMenuItem menuItem, int extraActionIndex) { String rootDir = "C:/eclipseworkspace_everpro/xeverpro/src/com/barmaja/everpro/mobileApp/modules"; String rootPackkage = "com.barmaja.everpro.mobileApp.modules"; TableDefinition tableDef = TableDefinition.getTableDefinitionForFocDesc(ContactDesc.getInstance()); CodeWriterSet cws = new CodeWriterSet(tableDef); CodeWriter codeWriter = null; codeWriter = cws.getCodeWriter_Proxy(); codeWriter.generateCode(); codeWriter = null; } }); }
From source file:com.foc.web.modules.admin.FocUser_Form.java
License:Apache License
public static void changePasswordForUser(FocUser focUser) { String newPassStr = focUser.resetPassword(); if (focUser != null && focUser.getContact() != null) { String email = focUser.getContact().getEMail(); if (email != null && !email.isEmpty()) { String name = focUser.getContact().getFullName(); String ENT = "%20%0d%0a"; String javaScript = "window.location = 'mailto:" + email + "?body=Dear " + name + "," + ENT + ENT; javaScript += "You can have real time follow up of your goods delivery on our online website: " + ENT + Page.getCurrent().getLocation() + ENT + ENT; javaScript += "Username: " + focUser.getName() + ENT; javaScript += "Password: " + newPassStr + ENT + ENT; javaScript += "Regards,'"; JavaScript.getCurrent().execute(javaScript); }/*from www . j a v a2 s .c o m*/ } }
From source file:com.foc.web.modules.admin.FocUser_Saas_Form.java
License:Apache License
@Override protected void resetPassword() { boolean error = getValidationLayout().commit();//In case the user is still created, the commit makes sure it gets saved with a real reference before updating the Password. if (!error) { FocUser user = (FocUser) getFocData(); String newPassword = user.resetPassword(); FocNotificationEmailTemplate template = EComConfiguration.getInstance() .getEmailTemplate_PasswordReset(); if (template != null) { FocDataDictionary dataDictionary = new FocDataDictionary(); dataDictionary.putParameter("NEW_PASSWORD", new FocDataResolver_StringConstant(newPassword)); URI url = Page.getCurrent().getLocation(); dataDictionary.putParameter("URL", new FocDataResolver_StringConstant(url.toString())); FocNotificationEmail email = EMailService.newEMail(template, dataDictionary, user); try { email.sendWithException(); } catch (Exception e) { Globals.showNotification("ERROR Sending Email", "Please check addresse email to: " + email.getRecipients(), IFocEnvironment.TYPE_ERROR_MESSAGE); // Globals.logException(e); }/* ww w .java 2 s . c o m*/ } // FocNotificationEmailTemplate template = EComConfiguration.getInstance().getEmailTemplate_PasswordReset(); // FocDataMap focDataMap = new FocDataMap(user); // focDataMap.put("NEW_PASSWORD", new REsol); // FocNotificationEmail email = template.newEmail(get) } }
From source file:com.foo01.ui.ReservationDetailView.java
@Override protected final void onBecomingVisible() { getNavigationBar().setCaption("Detail Rezervace"); //buttony pod navbarem HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setStyleName("buttonToolBarLayout"); buttonsLayout.setWidth("100%"); Button deleteButton = new Button(); deleteButton.setCaption("SMAZAT"); deleteButton.setWidth(null);//from w w w .j a v a 2 s. c o m buttonsLayout.addComponent(deleteButton); Label plug = new Label(); buttonsLayout.addComponent(plug); Button saveButton = new Button(); saveButton.setCaption("ULOIT"); saveButton.setWidth(null); buttonsLayout.addComponent(saveButton); buttonsLayout.setExpandRatio(plug, 1.0f); List<Source> sourcesList = MockSource.mockSources(); //combobox na zdroje a jmeno uzivatele HorizontalLayout sourceAndNameLayout = new HorizontalLayout(); sourceAndNameLayout.setWidth("100%"); sourceAndNameLayout.setStyleName("sourceAndNameLayout"); NativeSelect select = new NativeSelect(); select.setNullSelectionAllowed(false); System.out.println(Page.getCurrent().getBrowserWindowWidth()); String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px"; select.setWidth(width); select.addItems(sourcesList); for (Source s : sourcesList) { if (reservation.getSource().equals(s)) { select.select(s); break; } } sourceAndNameLayout.addComponent(select); Label plug2 = new Label(); sourceAndNameLayout.addComponent(plug2); Label name = new Label(reservation.getUser()); name.setWidth(null); sourceAndNameLayout.addComponent(name); sourceAndNameLayout.setExpandRatio(plug2, 1.0f); //datepickery DatePicker dateFrom = new DatePicker(); dateFrom.setStyleName("datePickerDetailView"); dateFrom.setValue(reservation.getBeginning()); dateFrom.setUseNative(true); dateFrom.setResolution(Resolution.TIME); dateFrom.setWidth("100%"); DatePicker dateTo = new DatePicker(); dateTo.setStyleName("datePickerDetailView"); dateTo.setValue(reservation.getEnding()); dateTo.setUseNative(true); dateTo.setResolution(Resolution.TIME); dateTo.setWidth("100%"); //layout pro slider a popisky HorizontalLayout sliderLayout = new HorizontalLayout(); sliderLayout.setStyleName("sliderLayout"); sliderLayout.setWidth("100%"); sliderLayout.setSpacing(true); Label sliderCaption = new Label("Po?et: "); sliderCaption.addStyleName("sliderCaption"); sliderCaption.setWidth(null); sliderLayout.addComponent(sliderCaption); final Label horvalue = new Label(); horvalue.setWidth("45px"); horvalue.setStyleName("value"); sliderLayout.addComponent(horvalue); final Slider horslider = new Slider(1, 10); horslider.setOrientation(SliderOrientation.HORIZONTAL); horslider.setValue(Double.valueOf(1)); horslider.getState(); horslider.getValue(); horslider.setImmediate(true); horslider.setWidth("100%"); sliderLayout.addComponent(horslider); sliderLayout.setExpandRatio(horslider, 1.0f); horvalue.setValue(String.valueOf(horslider.getValue().intValue())); horslider.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { int value = horslider.getValue().intValue(); horvalue.setValue(String.valueOf(value)); } }); //switch schvaleno HorizontalLayout switchLayout = new HorizontalLayout(); switchLayout.setStyleName("switchLayout"); switchLayout.addComponent(new Label("Schvleno:")); switchLayout.setSpacing(true); Switch checkbox = new Switch(null, true); switchLayout.addComponent(checkbox); //popis rezervace TextArea description = new TextArea(); description.setStyleName("descriptionDetailView"); description.setWidth("100%"); description.setImmediate(false); description.setCaption("Popis:"); description.setValue(reservation.getDescription()); //description.setRequired(true); description.setRequiredError("Popis mus bt zadn!"); description.setNullRepresentation(""); description.setReadOnly(true); //description.setRows(0); final VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); content.setStyleName(width); content.addComponent(buttonsLayout); content.addComponent(sourceAndNameLayout); content.addComponent(dateFrom); content.addComponent(dateTo); content.addComponent(sliderLayout); content.addComponent(switchLayout); content.addComponent(description); setContent(content); }
From source file:com.foo01.ui.ReservationView.java
@Override protected final void onBecomingVisible() { getNavigationBar().setCaption("Detail Rezervace"); //buttony pod navbarem // HorizontalLayout buttonsLayout = new HorizontalLayout(); // buttonsLayout.setStyleName("buttonToolBarLayout"); // buttonsLayout.setWidth("100%"); ///*from w w w . ja va 2 s. co m*/ // Button deleteButton = new Button(); // deleteButton.setCaption("SMAZAT"); // deleteButton.setWidth(null); // buttonsLayout.addComponent(deleteButton); // // Label plug = new Label(); // buttonsLayout.addComponent(plug); // // Button saveButton = new Button(); // saveButton.setCaption("ULOIT"); // saveButton.setWidth(null); // buttonsLayout.addComponent(saveButton); // buttonsLayout.setExpandRatio(plug, 1.0f); //combobox na zdroje a jmeno uzivatele List<Source> sourcesList = MockSource.mockSources(); HorizontalLayout sourceAndNameLayout = new HorizontalLayout(); sourceAndNameLayout.setWidth("100%"); sourceAndNameLayout.setStyleName("sourceAndNameLayout"); NativeSelect select = new NativeSelect(); select.setNullSelectionAllowed(false); System.out.println(Page.getCurrent().getBrowserWindowWidth()); String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px"; select.setWidth(width); select.addItems(sourcesList); for (Source s : sourcesList) { if (reservation.getSource().equals(s)) { select.select(s); break; } } sourceAndNameLayout.addComponent(select); Label plug2 = new Label(); sourceAndNameLayout.addComponent(plug2); Label name = new Label(reservation.getUser()); name.setWidth(null); sourceAndNameLayout.addComponent(name); sourceAndNameLayout.setExpandRatio(plug2, 1.0f); //datepickery DatePicker dateFrom = new DatePicker(); dateFrom.setStyleName("datePickerDetailView"); dateFrom.setValue(reservation.getBeginning()); dateFrom.setUseNative(true); dateFrom.setResolution(Resolution.TIME); dateFrom.setWidth("100%"); DatePicker dateTo = new DatePicker(); dateTo.setStyleName("datePickerDetailView"); dateTo.setValue(reservation.getEnding()); dateTo.setUseNative(true); dateTo.setResolution(Resolution.TIME); dateTo.setWidth("100%"); //layout pro slider a popisky HorizontalLayout sliderLayout = new HorizontalLayout(); sliderLayout.setStyleName("sliderLayout"); sliderLayout.setWidth("100%"); sliderLayout.setSpacing(true); Label sliderCaption = new Label("Po?et: "); sliderCaption.addStyleName("sliderCaption"); sliderCaption.setWidth(null); sliderLayout.addComponent(sliderCaption); final Label horvalue = new Label(); horvalue.setWidth("45px"); horvalue.setStyleName("value"); sliderLayout.addComponent(horvalue); final Slider horslider = new Slider(1, 10); horslider.setOrientation(SliderOrientation.HORIZONTAL); horslider.setValue(Double.valueOf(1)); horslider.getState(); horslider.getValue(); horslider.setImmediate(true); horslider.setWidth("100%"); sliderLayout.addComponent(horslider); sliderLayout.setExpandRatio(horslider, 1.0f); horvalue.setValue(String.valueOf(horslider.getValue().intValue())); horslider.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { int value = horslider.getValue().intValue(); horvalue.setValue(String.valueOf(value)); } }); //switch schvaleno HorizontalLayout switchLayout = new HorizontalLayout(); switchLayout.setStyleName("switchLayout"); switchLayout.addComponent(new Label("Schvleno:")); switchLayout.setSpacing(true); Switch checkbox = new Switch(null, true); switchLayout.addComponent(checkbox); //popis rezervace TextArea description = new TextArea(); description.setStyleName("descriptionDetailView"); description.setWidth("100%"); description.setImmediate(false); description.setCaption("Popis:"); description.setValue(reservation.getDescription()); //description.setRequired(true); description.setRequiredError("Popis mus bt zadn!"); description.setNullRepresentation(""); description.setReadOnly(true); //description.setRows(0); final VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); content.addComponent(new ButtonToolBarLayout(this)); content.addComponent(sourceAndNameLayout); content.addComponent(dateFrom); content.addComponent(dateTo); content.addComponent(sliderLayout); content.addComponent(switchLayout); content.addComponent(description); setContent(content); }
From source file:com.github.daytron.twaattin.presenter.LoginBehaviour.java
License:Open Source License
@Override public void buttonClick(Button.ClickEvent event) { try {/*from w w w.ja va 2 s. co m*/ String pin = loginField.getValue(); Principal user = new TwitterAuthenticationStrategy().authenticate(pin); VaadinSession.getCurrent().setAttribute(Principal.class, user); TimelineScreen aTimelineScreen = new TimelineScreen(); UI.getCurrent().setContent(aTimelineScreen); Notification authenticatedNotification = new Notification("You're now authenticated to Twaattin!", Notification.Type.TRAY_NOTIFICATION); authenticatedNotification.setPosition(Position.TOP_CENTER); authenticatedNotification.show(Page.getCurrent()); } catch (AuthenticationException e) { Notification errorNotification = new Notification(e.getMessage(), "Cick this box to close.", Notification.Type.ERROR_MESSAGE); errorNotification.show(Page.getCurrent()); } }