List of usage examples for com.vaadin.ui CustomLayout setStyleName
@Override public void setStyleName(String style)
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildLogoPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(true); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(AppContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation"); previewLayout.setStyleName("example-block"); previewLayout.setHeight("40px"); previewLayout.setWidth("520px"); Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(), 150);/*from w ww .j a va2s . c o m*/ previewLayout.addComponent(currentLogo, "mainLogo"); final ServiceMenu serviceMenu = new ServiceMenu(); Button.ClickListener clickListener = new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { Iterator<Component> iterator = serviceMenu.iterator(); while (iterator.hasNext()) { Component comp = iterator.next(); if (comp != event.getButton()) { comp.removeStyleName("selected"); } } event.getButton().addStyleName("selected"); } }; serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS, clickListener); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE, clickListener); serviceMenu.selectService(0); previewLayout.addComponent(serviceMenu, "serviceMenu"); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT); final UploadField logoUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override protected void updateDisplay() { byte[] imageData = (byte[]) this.getValue(); String mimeType = this.getLastMimeType(); if (mimeType.equals("image/jpeg")) { imageData = ImageUtil.convertJpgToPngFormat(imageData); if (imageData == null) { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { UI.getCurrent().addWindow(new LogoEditWindow(imageData)); } else { throw new UserInvalidInputException( AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; logoUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE)); logoUploadField.addStyleName("upload-field"); logoUploadField.setSizeUndefined(); logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); logoUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { BillingAccountService billingAccountService = AppContextUtil .getSpringBean(BillingAccountService.class); billingAccount.setLogopath(null); billingAccountService.updateWithSession(billingAccount, AppContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } }); resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); resetButton.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(logoUploadField, resetButton); rightPanel.with(previewLayout, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Logo", layout); this.with(formContainer); }
From source file:com.esofthead.mycollab.shell.view.MainView.java
License:Open Source License
private CustomLayout createTopMenu() { final CustomLayout layout = CustomLayoutExt.createLayout("topNavigation"); layout.setStyleName("topNavigation"); layout.setHeight("40px"); layout.setWidth("100%"); Button accountLogo = AccountLogoFactory .createAccountLogoImageComponent(ThemeManager.loadLogoPath(AppContext.getAccountId()), 150); accountLogo.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override/* w w w . j a v a 2s .c o m*/ public void buttonClick(final ClickEvent event) { final UserPreference pref = AppContext.getUserPreference(); if (pref.getLastmodulevisit() == null || ModuleNameConstants.PRJ.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)); } else if (ModuleNameConstants.CRM.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)); } else if (ModuleNameConstants.ACCOUNT.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule(this, null)); } else if (ModuleNameConstants.FILE.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null)); } } }); layout.addComponent(accountLogo, "mainLogo"); serviceMenu = new ServiceMenu(); serviceMenu.addStyleName("topNavPopup"); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM), MyCollabResource.newResource(WebResourceIds._16_customer), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)); } }); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), MyCollabResource.newResource(WebResourceIds._16_project), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (!event.isCtrlKey() && !event.isMetaKey()) { EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)); } } }); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), MyCollabResource.newResource(WebResourceIds._16_document), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null)); } }); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PEOPLE), MyCollabResource.newResource(WebResourceIds._16_account), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" })); } }); layout.addComponent(serviceMenu, "serviceMenu"); final MHorizontalLayout accountLayout = new MHorizontalLayout() .withMargin(new MarginInfo(false, true, false, false)); accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); final Label accountNameLabel = new Label(AppContext.getSubDomain()); accountNameLabel.setStyleName("subdomain"); accountLayout.addComponent(accountNameLabel); // display trial box if user in trial mode SimpleBillingAccount billingAccount = AppContext.getBillingAccount(); if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) { Label informLbl = new Label("", ContentMode.HTML); informLbl.addStyleName("trialEndingNotification"); informLbl.setHeight("100%"); HorizontalLayout informBox = new HorizontalLayout(); informBox.addStyleName("trialInformBox"); informBox.setSizeFull(); informBox.addComponent(informLbl); informBox.setMargin(new MarginInfo(false, true, false, false)); informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { private static final long serialVersionUID = 1L; @Override public void layoutClick(LayoutClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); accountLayout.addComponent(informBox); accountLayout.setSpacing(true); accountLayout.setComponentAlignment(informBox, Alignment.MIDDLE_LEFT); Date createdTime = billingAccount.getCreatedtime(); long timeDeviation = System.currentTimeMillis() - createdTime.getTime(); int daysLeft = (int) Math.floor(timeDeviation / (1000 * 60 * 60 * 24)); if (daysLeft > 30) { BillingService billingService = ApplicationContextUtil.getSpringBean(BillingService.class); BillingPlan freeBillingPlan = billingService.getFreeBillingPlan(); billingAccount.setBillingPlan(freeBillingPlan); informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + " 0 DAYS LEFT</div><div class='informBlock'>>></div>"); } else { if (AppContext.isAdmin()) { informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft) + " DAYS LEFT</div><div class='informBlock'>>></div>"); } else { informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft) + " DAYS LEFT</div><div class='informBlock'>>></div>"); } } } NotificationButton notificationButton = new NotificationButton(); accountLayout.addComponent(notificationButton); if (AppContext.getSession().getTimezone() == null) { EventBusFactory.getInstance().post(new ShellEvent.NewNotification(this, new TimezoneNotification())); } if (StringUtils.isBlank(AppContext.getSession().getAvatarid())) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification())); } if (SiteConfiguration.getDeploymentMode() != DeploymentMode.site && AppContext.isAdmin()) { try { Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target("https://api.mycollab.com/api/checkupdate"); Response response = target.request().get(); String values = response.readEntity(String.class); Gson gson = new Gson(); Properties props = gson.fromJson(values, Properties.class); String version = props.getProperty("version"); if (!MyCollabVersion.getVersion().equals(version)) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new NewUpdateNotification(props))); } } catch (Exception e) { LOG.error("Error when call remote api", e); } } UserAvatarComp userAvatar = new UserAvatarComp(); accountLayout.addComponent(userAvatar); accountLayout.setComponentAlignment(userAvatar, Alignment.MIDDLE_LEFT); final PopupButton accountMenu = new PopupButton(AppContext.getSession().getDisplayName()); final VerticalLayout accLayout = new VerticalLayout(); accLayout.setWidth("140px"); final Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); } }); myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE)); myProfileBtn.setStyleName("link"); accLayout.addComponent(myProfileBtn); final Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); myAccountBtn.setStyleName("link"); myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING)); accLayout.addComponent(myAccountBtn); final Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" })); } }); userMgtBtn.setStyleName("link"); userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS)); accLayout.addComponent(userMgtBtn); final Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AppContext.getInstance().clearSession(); EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null)); } }); signoutBtn.setStyleName("link"); signoutBtn.setIcon(FontAwesome.SIGN_OUT); accLayout.addComponent(signoutBtn); accountMenu.setContent(accLayout); accountMenu.setStyleName("accountMenu"); accountMenu.addStyleName("topNavPopup"); accountLayout.addComponent(accountMenu); layout.addComponent(accountLayout, "accountMenu"); return layout; }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.about.AboutView.java
License:Apache License
public AboutView() { CustomLayout aboutContent = new CustomLayout("aboutview"); aboutContent.setStyleName("about-content"); // you can add Vaadin components in predefined slots in the custom // layout// w w w .j a va 2s . c o m aboutContent.addComponent(new Label( FontAwesome.INFO_CIRCLE.getHtml() + " This application is using Vaadin " + Version.getFullVersion(), ContentMode.HTML), "info"); setSizeFull(); setStyleName("about-view"); addComponent(aboutContent); setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER); }
From source file:com.mycollab.module.project.view.milestone.MilestoneListViewImpl.java
License:Open Source License
private void constructBody() { CustomLayout bodyContent = CustomLayoutExt.createLayout("milestoneView"); bodyContent.setWidth("100%"); bodyContent.setStyleName("milestone-view"); MHorizontalLayout closedHeaderLayout = new MHorizontalLayout(); closedHeader = ELabel.html("").withWidthUndefined(); closedHeaderLayout.with(closedHeader).withAlign(closedHeader, Alignment.MIDDLE_CENTER); bodyContent.addComponent(closedHeaderLayout, "closed-header"); closeContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth(); bodyContent.addComponent(closeContainer, "closed-milestones"); MHorizontalLayout inProgressHeaderLayout = new MHorizontalLayout(); inProgressHeader = ELabel.html("").withWidthUndefined(); inProgressHeaderLayout.addComponent(inProgressHeader); inProgressHeaderLayout.setComponentAlignment(inProgressHeader, Alignment.MIDDLE_CENTER); bodyContent.addComponent(inProgressHeaderLayout, "in-progress-header"); inProgressContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth(); bodyContent.addComponent(this.inProgressContainer, "in-progress-milestones"); MHorizontalLayout futureHeaderLayout = new MHorizontalLayout(); futureHeader = ELabel.html("").withWidthUndefined(); futureHeaderLayout.addComponent(futureHeader); futureHeaderLayout.setComponentAlignment(futureHeader, Alignment.MIDDLE_CENTER); bodyContent.addComponent(futureHeaderLayout, "future-header"); futureContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth(); bodyContent.addComponent(this.futureContainer, "future-milestones"); this.addComponent(bodyContent); }
From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java
License:Open Source License
private void buildLogoPanel() { FormContainer formContainer = new FormContainer(); MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(true); MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false); Label logoDesc = new Label(UserUIContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION)); leftPanel.with(logoDesc).withWidth("250px"); MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false); CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation"); previewLayout.setStyleName("example-block"); previewLayout.setHeight("40px"); previewLayout.setWidth("520px"); Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(), 150);//from w ww . ja v a2 s. c om previewLayout.addComponent(currentLogo, "mainLogo"); final ServiceMenu serviceMenu = new ServiceMenu(); Button.ClickListener clickListener = new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { for (Component comp : serviceMenu) { if (comp != event.getButton()) { comp.removeStyleName("selected"); } } event.getButton().addStyleName("selected"); } }; serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS, clickListener); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE, clickListener); serviceMenu.selectService(0); previewLayout.addComponent(serviceMenu, "serviceMenu"); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, false, false)); buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT); final UploadField logoUploadField = new UploadField() { private static final long serialVersionUID = 1L; @Override protected void updateDisplay() { byte[] imageData = (byte[]) this.getValue(); String mimeType = this.getLastMimeType(); if (mimeType.equals("image/jpeg")) { imageData = ImageUtil.convertJpgToPngFormat(imageData); if (imageData == null) { throw new UserInvalidInputException( UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT)); } else { mimeType = "image/png"; } } if (mimeType.equals("image/png")) { UI.getCurrent().addWindow(new LogoEditWindow(imageData)); } else { throw new UserInvalidInputException( UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT)); } } }; logoUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE)); logoUploadField.addStyleName("upload-field"); logoUploadField.setSizeUndefined(); logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY); logoUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> { BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class); billingAccount.setLogopath(null); billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); }).withStyleName(WebThemes.BUTTON_OPTION); resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME)); buttonControls.with(resetButton, logoUploadField); rightPanel.with(previewLayout, buttonControls); layout.with(leftPanel, rightPanel).expand(rightPanel); formContainer.addSection("Logo", layout); this.with(formContainer); }
From source file:de.symeda.sormas.ui.AboutView.java
License:Open Source License
public AboutView() { CustomLayout aboutContent = new CustomLayout("aboutview"); aboutContent.setStyleName("about-content"); // Info section VerticalLayout infoLayout = new VerticalLayout(); infoLayout.setSpacing(false);/*w w w . j a v a2 s . c om*/ infoLayout.setMargin(false); aboutContent.addComponent(infoLayout, "info"); Label versionLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getCaption(Captions.aboutSormasVersion) + ": " + InfoProvider.get().getVersion(), ContentMode.HTML); infoLayout.addComponent(versionLabel); Link whatsNewLink = new Link(I18nProperties.getCaption(Captions.aboutWhatsNew), new ExternalResource( "https://github.com/hzi-braunschweig/SORMAS-Project/releases/tag/releases%2Fversion-" + InfoProvider.get().getBaseVersion())); whatsNewLink.setTargetName("_blank"); infoLayout.addComponent(whatsNewLink); Link sormasWebsiteLink = new Link(I18nProperties.getCaption(Captions.aboutSormasWebsite), new ExternalResource("https://sormasorg.helmholtz-hzi.de/")); sormasWebsiteLink.setTargetName("_blank"); infoLayout.addComponent(sormasWebsiteLink); Link sormasGithubLink = new Link("SORMAS Github", new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project")); sormasGithubLink.setTargetName("_blank"); infoLayout.addComponent(sormasGithubLink); Link changelogLink = new Link(I18nProperties.getCaption(Captions.aboutChangelog), new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project/releases")); changelogLink.setTargetName("_blank"); infoLayout.addComponent(changelogLink); // Documents section VerticalLayout documentsLayout = new VerticalLayout(); documentsLayout.setSpacing(false); documentsLayout.setMargin(false); aboutContent.addComponent(documentsLayout, "documents"); Button classificationDocumentButton = new Button( I18nProperties.getCaption(Captions.aboutCaseClassificationRules)); CssStyles.style(classificationDocumentButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT); documentsLayout.addComponent(classificationDocumentButton); try { String serverUrl = new URL(((VaadinServletRequest) VaadinService.getCurrentRequest()) .getHttpServletRequest().getRequestURL().toString()).getAuthority(); StreamResource classificationResource = DownloadUtil.createStringStreamResource( ClassificationHtmlRenderer.createHtmlForDownload(serverUrl, FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases()), "classification_rules.html", "text/html"); new FileDownloader(classificationResource).extend(classificationDocumentButton); } catch (MalformedURLException e) { } Button dataDictionaryButton = new Button(I18nProperties.getCaption(Captions.aboutDataDictionary)); CssStyles.style(dataDictionaryButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT); documentsLayout.addComponent(dataDictionaryButton); FileDownloader dataDictionaryDownloader = new FileDownloader( new ClassResource("/doc/SORMAS_Data_Dictionary.xlsx")); dataDictionaryDownloader.extend(dataDictionaryButton); Link technicalManualLink = new Link(I18nProperties.getCaption(Captions.aboutTechnicalManual), new ExternalResource( "https://github.com/hzi-braunschweig/SORMAS-Project/files/2585973/SORMAS_Technical_Manual_Webversion_20180911.pdf")); technicalManualLink.setTargetName("_blank"); documentsLayout.addComponent(technicalManualLink); setSizeFull(); setStyleName("about-view"); addComponent(aboutContent); setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER); }