List of usage examples for com.vaadin.ui HorizontalLayout setSizeFull
@Override public void setSizeFull()
From source file:com.esofthead.mycollab.module.project.view.TimeTrackingSummaryViewImpl.java
License:Open Source License
@Override public void display() { projects = ApplicationContextUtil.getSpringBean(ProjectService.class) .getProjectsUserInvolved(AppContext.getUsername(), AppContext.getAccountId()); if (CollectionUtils.isNotEmpty(projects)) { itemTimeLoggingService = ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class); final CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.setStyleName("projectfeed-hdr-wrapper"); HorizontalLayout loggingPanel = new HorizontalLayout(); HorizontalLayout controlBtns = new HorizontalLayout(); controlBtns.setMargin(new MarginInfo(true, false, true, false)); final Label layoutHeader = new Label( ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME).getHtml() + " Time Tracking", ContentMode.HTML); layoutHeader.addStyleName("h2"); final MHorizontalLayout header = new MHorizontalLayout().withWidth("100%"); header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader); final CssLayout contentWrapper = new CssLayout(); contentWrapper.setWidth("100%"); contentWrapper.addStyleName(UIConstants.CONTENT_WRAPPER); headerWrapper.addComponent(header); this.addComponent(headerWrapper); contentWrapper.addComponent(controlBtns); MHorizontalLayout controlsPanel = new MHorizontalLayout().withWidth("100%"); contentWrapper.addComponent(controlsPanel); contentWrapper.addComponent(loggingPanel); this.addComponent(contentWrapper); final Button backBtn = new Button("Back to Workboard"); backBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w. j ava 2s. co m*/ public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null)); } }); backBtn.addStyleName(UIConstants.THEME_GREEN_LINK); backBtn.setIcon(FontAwesome.ARROW_LEFT); controlBtns.addComponent(backBtn); VerticalLayout selectionLayoutWrapper = new VerticalLayout(); selectionLayoutWrapper.setWidth("100%"); selectionLayoutWrapper.addStyleName("time-tracking-summary-search-panel"); controlsPanel.addComponent(selectionLayoutWrapper); final GridLayout selectionLayout = new GridLayout(9, 2); selectionLayout.setSpacing(true); selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT); selectionLayout.setMargin(true); selectionLayoutWrapper.addComponent(selectionLayout); Label fromLb = new Label("From:"); fromLb.setWidthUndefined(); selectionLayout.addComponent(fromLb, 0, 0); this.fromDateField = new PopupDateFieldExt(); this.fromDateField.setResolution(Resolution.DAY); this.fromDateField.setDateFormat(AppContext.getUserDateFormat()); this.fromDateField.setWidth("100px"); selectionLayout.addComponent(this.fromDateField, 1, 0); Label toLb = new Label("To:"); toLb.setWidthUndefined(); selectionLayout.addComponent(toLb, 2, 0); this.toDateField = new PopupDateFieldExt(); this.toDateField.setResolution(Resolution.DAY); this.toDateField.setDateFormat(AppContext.getUserDateFormat()); this.toDateField.setWidth("100px"); selectionLayout.addComponent(this.toDateField, 3, 0); Label groupLb = new Label("Group:"); groupLb.setWidthUndefined(); selectionLayout.addComponent(groupLb, 0, 1); this.groupField = new ValueComboBox(false, GROUPBY_PROJECT, GROUPBY_DATE, GROUPBY_USER); this.groupField.setWidth("100px"); selectionLayout.addComponent(this.groupField, 1, 1); Label sortLb = new Label("Sort:"); sortLb.setWidthUndefined(); selectionLayout.addComponent(sortLb, 2, 1); this.orderField = new ItemOrderComboBox(); this.orderField.setWidth("100px"); selectionLayout.addComponent(this.orderField, 3, 1); Label projectLb = new Label("Project:"); projectLb.setWidthUndefined(); selectionLayout.addComponent(projectLb, 4, 0); this.projectField = new UserInvolvedProjectsListSelect(); initListSelectStyle(this.projectField); selectionLayout.addComponent(this.projectField, 5, 0, 5, 1); Label userLb = new Label("User:"); userLb.setWidthUndefined(); selectionLayout.addComponent(userLb, 6, 0); this.userField = new UserInvolvedProjectsMemberListSelect(getProjectIds()); initListSelectStyle(this.userField); selectionLayout.addComponent(this.userField, 7, 0, 7, 1); final Button queryBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SUBMIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { fromDate = fromDateField.getValue(); toDate = toDateField.getValue(); searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate)); searchTimeReporting(); } }); queryBtn.setStyleName(UIConstants.THEME_GREEN_LINK); selectionLayout.addComponent(queryBtn, 8, 0); loggingPanel.setWidth("100%"); loggingPanel.setHeight("80px"); loggingPanel.setSpacing(true); totalHoursLoggingLabel = new Label("Total Hours Logging: 0 Hrs", ContentMode.HTML); totalHoursLoggingLabel.addStyleName(UIConstants.LAYOUT_LOG); totalHoursLoggingLabel.addStyleName(UIConstants.TEXT_LOG_DATE_FULL); loggingPanel.addComponent(totalHoursLoggingLabel); loggingPanel.setExpandRatio(totalHoursLoggingLabel, 1.0f); loggingPanel.setComponentAlignment(totalHoursLoggingLabel, Alignment.MIDDLE_LEFT); Button exportBtn = new Button("Export", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { exportButtonControl.setPopupVisible(true); } }); exportButtonControl = new SplitButton(exportBtn); exportButtonControl.setWidthUndefined(); exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK); exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK); VerticalLayout popupButtonsControl = new VerticalLayout(); exportButtonControl.setContent(popupButtonsControl); Button exportPdfBtn = new Button("Pdf"); FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF)); pdfDownloader.extend(exportPdfBtn); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); exportPdfBtn.setStyleName("link"); popupButtonsControl.addComponent(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL)); excelDownloader.extend(exportExcelBtn); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); exportExcelBtn.setStyleName("link"); popupButtonsControl.addComponent(exportExcelBtn); controlBtns.addComponent(exportButtonControl); controlBtns.setComponentAlignment(exportButtonControl, Alignment.TOP_RIGHT); controlBtns.setComponentAlignment(backBtn, Alignment.TOP_LEFT); controlBtns.setSizeFull(); this.timeTrackingWrapper = new VerticalLayout(); this.timeTrackingWrapper.setWidth("100%"); contentWrapper.addComponent(this.timeTrackingWrapper); Calendar date = new GregorianCalendar(); date.set(Calendar.DAY_OF_MONTH, 1); fromDate = date.getTime(); date.add(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH)); toDate = date.getTime(); fromDateField.setValue(fromDate); toDateField.setValue(toDate); searchCriteria = new ItemTimeLoggingSearchCriteria(); searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate)); } else { final Button backBtn = new Button("Back to Workboard"); backBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null)); } }); backBtn.addStyleName(UIConstants.THEME_GREEN_LINK); backBtn.setIcon(FontAwesome.ARROW_LEFT); VerticalLayout contentWrapper = new VerticalLayout(); contentWrapper.setSpacing(true); Label infoLbl = new Label("You are not involved in any project yet to track time working"); infoLbl.setWidthUndefined(); contentWrapper.setMargin(true); contentWrapper.addComponent(infoLbl); contentWrapper.setComponentAlignment(infoLbl, Alignment.MIDDLE_CENTER); contentWrapper.addComponent(backBtn); contentWrapper.setComponentAlignment(backBtn, Alignment.MIDDLE_CENTER); this.addComponent(contentWrapper); this.setComponentAlignment(contentWrapper, Alignment.MIDDLE_CENTER); } }
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/*from w ww.j av a2s . 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.esofthead.mycollab.shell.view.MainViewImpl.java
License:Open Source License
private MHorizontalLayout buildAccountMenuLayout() { accountLayout.removeAllComponents(); if (SiteConfiguration.isDemandEdition()) { // display trial box if user in trial mode SimpleBillingAccount billingAccount = AppContext.getBillingAccount(); if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) { if ("Free".equals(billingAccount.getBillingPlan().getBillingtype())) { Label informLbl = new Label( "<div class='informBlock'>FREE CHARGE<br>UPGRADE</div><div class='informBlock'>>></div>", 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//from w ww.j av a 2s. c om public void layoutClick(LayoutClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); accountLayout.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT); } else { Label informLbl = new Label("", ContentMode.HTML); informLbl.addStyleName("trialEndingNotification"); informLbl.setHeight("100%"); HorizontalLayout informBox = new HorizontalLayout(); informBox.addStyleName("trialInformBox"); informBox.setSizeFull(); informBox.setMargin(new MarginInfo(false, true, false, false)); informBox.addComponent(informLbl); 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.with(informBox).withAlign(informBox, Alignment.MIDDLE_LEFT); Duration dur = new Duration(new DateTime(billingAccount.getCreatedtime()), new DateTime()); int daysLeft = dur.toStandardDays().getDays(); if (daysLeft > 30) { informLbl.setValue( "<div class='informBlock'>Trial<br></div><div class='informBlock'>>></div>"); // AppContext.getInstance().setIsValidAccount(false); } else { informLbl.setValue(String.format("<div class='informBlock'>Trial ending<br>%d days " + "left</div><div class='informBlock'>>></div>", 30 - daysLeft)); } } } } Label accountNameLabel = new Label(AppContext.getSubDomain()); accountNameLabel.addStyleName("subdomain"); accountLayout.addComponent(accountNameLabel); if (SiteConfiguration.isCommunityEdition()) { Button buyPremiumBtn = new Button("Upgrade to Pro edition", new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new AdWindow()); } }); buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART); buyPremiumBtn.addStyleName("ad"); accountLayout.addComponent(buyPremiumBtn); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { LicenseInfo licenseInfo = licenseResolver.getLicenseInfo(); if (licenseInfo != null) { if (licenseInfo.isExpired()) { Button buyPremiumBtn = new Button(AppContext.getMessage(LicenseI18nEnum.EXPIRE_NOTIFICATION), new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow()); } }); buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART); buyPremiumBtn.addStyleName("ad"); accountLayout.addComponent(buyPremiumBtn); } else if (licenseInfo.isTrial()) { Duration dur = new Duration(new DateTime(), new DateTime(licenseInfo.getExpireDate())); int days = dur.toStandardDays().getDays(); Button buyPremiumBtn = new Button( AppContext.getMessage(LicenseI18nEnum.TRIAL_NOTIFICATION, days), new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new BuyPremiumSoftwareWindow()); } }); buyPremiumBtn.setIcon(FontAwesome.SHOPPING_CART); buyPremiumBtn.addStyleName("ad"); accountLayout.addComponent(buyPremiumBtn); } } } NotificationComponent notificationComponent = new NotificationComponent(); accountLayout.addComponent(notificationComponent); if (StringUtils.isBlank(AppContext.getUser().getAvatarid())) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification())); } if (!SiteConfiguration.isDemandEdition()) { ExtMailService mailService = AppContextUtil.getSpringBean(ExtMailService.class); if (!mailService.isMailSetupValid()) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new SmtpSetupNotification())); } SimpleUser user = AppContext.getUser(); GregorianCalendar tenDaysAgo = new GregorianCalendar(); tenDaysAgo.add(Calendar.DATE, -10); if (Boolean.TRUE.equals(user.getRequestad()) && user.getRegisteredtime().before(tenDaysAgo.getTime())) { UI.getCurrent().addWindow(new AdRequestWindow(user)); } } Resource userAvatarRes = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 24); final PopupButton accountMenu = new PopupButton(""); accountMenu.setIcon(userAvatarRes); accountMenu.setDescription(AppContext.getUserDisplayName()); OptionPopupContent accountPopupContent = new OptionPopupContent(); Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); } }); myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE)); accountPopupContent.addOption(myProfileBtn); 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.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS)); accountPopupContent.addOption(userMgtBtn); Button generalSettingBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETTING), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance().post( new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "general" })); } }); generalSettingBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.GENERAL_SETTING)); accountPopupContent.addOption(generalSettingBtn); Button themeCustomizeBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_THEME), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setting", "theme" })); } }); themeCustomizeBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.THEME_CUSTOMIZE)); accountPopupContent.addOption(themeCustomizeBtn); if (!SiteConfiguration.isDemandEdition()) { Button setupBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_SETUP), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" })); } }); setupBtn.setIcon(FontAwesome.WRENCH); accountPopupContent.addOption(setupBtn); } accountPopupContent.addSeparator(); Button helpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_HELP)); helpBtn.setIcon(FontAwesome.MORTAR_BOARD); ExternalResource helpRes = new ExternalResource("https://community.mycollab.com/meet-mycollab/"); BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes); helpOpener.extend(helpBtn); accountPopupContent.addOption(helpBtn); Button supportBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SUPPORT)); supportBtn.setIcon(FontAwesome.LIFE_SAVER); ExternalResource supportRes = new ExternalResource("http://support.mycollab.com/"); BrowserWindowOpener supportOpener = new BrowserWindowOpener(supportRes); supportOpener.extend(supportBtn); accountPopupContent.addOption(supportBtn); Button translateBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_TRANSLATE)); translateBtn.setIcon(FontAwesome.PENCIL); ExternalResource translateRes = new ExternalResource( "https://community.mycollab.com/docs/developing-mycollab/translating/"); BrowserWindowOpener translateOpener = new BrowserWindowOpener(translateRes); translateOpener.extend(translateBtn); accountPopupContent.addOption(translateBtn); if (!SiteConfiguration.isCommunityEdition()) { 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.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING)); accountPopupContent.addOption(myAccountBtn); } accountPopupContent.addSeparator(); Button aboutBtn = new Button("About MyCollab", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { accountMenu.setPopupVisible(false); Window aboutWindow = ViewManager.getCacheComponent(AbstractAboutWindow.class); UI.getCurrent().addWindow(aboutWindow); } }); aboutBtn.setIcon(FontAwesome.INFO_CIRCLE); accountPopupContent.addOption(aboutBtn); Button releaseNotesBtn = new Button("Release Notes"); ExternalResource releaseNotesRes = new ExternalResource( "https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/releases/"); BrowserWindowOpener releaseNotesOpener = new BrowserWindowOpener(releaseNotesRes); releaseNotesOpener.extend(releaseNotesBtn); releaseNotesBtn.setIcon(FontAwesome.BULLHORN); accountPopupContent.addOption(releaseNotesBtn); Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null)); } }); signoutBtn.setIcon(FontAwesome.SIGN_OUT); accountPopupContent.addSeparator(); accountPopupContent.addOption(signoutBtn); accountMenu.setContent(accountPopupContent); accountLayout.addComponent(accountMenu); return accountLayout; }
From source file:com.esspl.datagen.DataGenApplication.java
License:Open Source License
private void buildMainLayout() { log.debug("DataGenApplication - buildMainLayout() start"); VerticalLayout rootLayout = new VerticalLayout(); final Window root = new Window("DATA Gen", rootLayout); root.setStyleName("tData"); setMainWindow(root);/*from w ww . j a v a2 s . c om*/ rootLayout.setSizeFull(); rootLayout.setMargin(false, true, false, true); // Top area, containing logo and header HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); root.addComponent(top); // Create the placeholders for all the components in the top area HorizontalLayout header = new HorizontalLayout(); // Add the components and align them properly top.addComponent(header); top.setComponentAlignment(header, Alignment.TOP_LEFT); top.setStyleName("top"); top.setHeight("75px"); // Same as the background image height // header controls Embedded logo = new Embedded(); logo.setSource(DataGenConstant.LOGO); logo.setWidth("100%"); logo.setStyleName("logo"); header.addComponent(logo); header.setSpacing(false); //Show which connection profile is connected connectedString = new Label("Connected to - Oracle"); connectedString.setStyleName("connectedString"); connectedString.setWidth("500px"); connectedString.setVisible(false); top.addComponent(connectedString); //Toolbar toolbar = new ToolBar(this); top.addComponent(toolbar); top.setComponentAlignment(toolbar, Alignment.TOP_RIGHT); listing = new Table(); listing.setHeight("240px"); listing.setWidth("100%"); listing.setStyleName("dataTable"); listing.setImmediate(true); // turn on column reordering and collapsing listing.setColumnReorderingAllowed(true); listing.setColumnCollapsingAllowed(true); listing.setSortDisabled(true); // Add the table headers listing.addContainerProperty("Sl No.", Integer.class, null); listing.addContainerProperty("Column Name", TextField.class, null); listing.addContainerProperty("Data Type", Select.class, null); listing.addContainerProperty("Format", Select.class, null); listing.addContainerProperty("Examples", Label.class, null); listing.addContainerProperty("Additional Data", HorizontalLayout.class, null); listing.setColumnAlignments(new String[] { Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER }); //From the starting create 5 rows addRow(5); //Add different style for IE browser WebApplicationContext context = ((WebApplicationContext) getMainWindow().getApplication().getContext()); WebBrowser browser = context.getBrowser(); //Create a TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); if (!browser.isIE()) { tabSheet.setStyleName("tabSheet"); } //Generator Tab content start generator = new VerticalLayout(); generator.setMargin(true, true, false, true); generateTypeHl = new HorizontalLayout(); generateTypeHl.setMargin(false, false, false, true); generateTypeHl.setSpacing(true); List<String> generateTypeList = Arrays.asList(new String[] { "Sql", "Excel", "XML", "CSV" }); generateType = new OptionGroup("Generation Type", generateTypeList); generateType.setNullSelectionAllowed(false); // user can not 'unselect' generateType.select("Sql"); // select this by default generateType.setImmediate(true); // send the change to the server at once generateType.addListener(this); // react when the user selects something generateTypeHl.addComponent(generateType); //SQL Options sqlPanel = new Panel("SQL Options"); sqlPanel.setHeight("180px"); if (browser.isIE()) { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl1 = new VerticalLayout(); vl1.setMargin(false); Label lb1 = new Label("DataBase"); database = new Select(); database.addItem("Oracle"); database.addItem("Sql Server"); database.addItem("My Sql"); database.addItem("Postgress Sql"); database.addItem("H2"); database.select("Oracle"); database.setWidth("160px"); database.setNullSelectionAllowed(false); HorizontalLayout dbBar = new HorizontalLayout(); dbBar.setMargin(false, false, false, false); dbBar.setSpacing(true); dbBar.addComponent(lb1); dbBar.addComponent(database); vl1.addComponent(dbBar); Label tblLabel = new Label("Table Name"); tblName = new TextField(); tblName.setWidth("145px"); tblName.setStyleName("mandatory"); HorizontalLayout tableBar = new HorizontalLayout(); tableBar.setMargin(true, false, false, false); tableBar.setSpacing(true); tableBar.addComponent(tblLabel); tableBar.addComponent(tblName); vl1.addComponent(tableBar); createQuery = new CheckBox("Include CREATE TABLE query"); createQuery.setValue(true); HorizontalLayout createBar = new HorizontalLayout(); createBar.setMargin(true, false, false, false); createBar.addComponent(createQuery); vl1.addComponent(createBar); sqlPanel.addComponent(vl1); generateTypeHl.addComponent(sqlPanel); generator.addComponent(generateTypeHl); //CSV Option csvPanel = new Panel("CSV Options"); csvPanel.setHeight("130px"); if (browser.isIE()) { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } Label delimiter = new Label("Delimiter Character(s)"); VerticalLayout vl2 = new VerticalLayout(); vl2.setMargin(false); csvDelimiter = new TextField(); HorizontalLayout csvBar = new HorizontalLayout(); csvBar.setMargin(true, false, false, false); csvBar.setSpacing(true); csvBar.addComponent(delimiter); csvBar.addComponent(csvDelimiter); vl2.addComponent(csvBar); csvPanel.addComponent(vl2); //XML Options xmlPanel = new Panel("XML Options"); xmlPanel.setHeight("160px"); if (browser.isIE()) { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl3 = new VerticalLayout(); vl3.setMargin(false); Label lb4 = new Label("Root node name"); rootNode = new TextField(); rootNode.setWidth("125px"); rootNode.setStyleName("mandatory"); HorizontalLayout nodeBar = new HorizontalLayout(); nodeBar.setMargin(true, false, false, false); nodeBar.setSpacing(true); nodeBar.addComponent(lb4); nodeBar.addComponent(rootNode); vl3.addComponent(nodeBar); Label lb5 = new Label("Record node name"); recordNode = new TextField(); recordNode.setWidth("112px"); recordNode.setStyleName("mandatory"); HorizontalLayout recordBar = new HorizontalLayout(); recordBar.setMargin(true, false, false, false); recordBar.setSpacing(true); recordBar.addComponent(lb5); recordBar.addComponent(recordNode); vl3.addComponent(recordBar); xmlPanel.addComponent(vl3); HorizontalLayout noOfRowHl = new HorizontalLayout(); noOfRowHl.setSpacing(true); noOfRowHl.setMargin(true, false, false, true); noOfRowHl.addComponent(new Label("Number of Results")); resultNum = new TextField(); resultNum.setImmediate(true); resultNum.setNullSettingAllowed(false); resultNum.setStyleName("mandatory"); resultNum.addValidator(new IntegerValidator("Number of Results must be an Integer")); resultNum.setWidth("5em"); resultNum.setMaxLength(5); resultNum.setValue(50); noOfRowHl.addComponent(resultNum); generator.addComponent(noOfRowHl); HorizontalLayout addRowHl = new HorizontalLayout(); addRowHl.setMargin(true, false, true, true); addRowHl.setSpacing(true); addRowHl.addComponent(new Label("Add")); rowNum = new TextField(); rowNum.setImmediate(true); rowNum.setNullSettingAllowed(true); rowNum.addValidator(new IntegerValidator("Row number must be an Integer")); rowNum.setWidth("4em"); rowNum.setMaxLength(2); rowNum.setValue(1); addRowHl.addComponent(rowNum); rowsBttn = new Button("Row(s)"); rowsBttn.setIcon(DataGenConstant.ADD); rowsBttn.addListener(ClickEvent.class, this, "addRowButtonClick"); // react to clicks addRowHl.addComponent(rowsBttn); generator.addComponent(addRowHl); //Add the Grid generator.addComponent(listing); //Generate Button Button bttn = new Button("Generate"); bttn.setDescription("Generate Gata"); bttn.addListener(ClickEvent.class, this, "generateButtonClick"); // react to clicks bttn.setIcon(DataGenConstant.VIEW); bttn.setStyleName("generate"); generator.addComponent(bttn); //Generator Tab content end //Executer Tab content start - new class created to separate execution logic executor = new ExecutorView(this); //Executer Tab content end //Explorer Tab content start - new class created to separate execution logic explorer = new ExplorerView(this, databaseSessionManager); //explorer.setMargin(true); //Explorer Tab content end //About Tab content start VerticalLayout about = new VerticalLayout(); about.setMargin(true); Label aboutRichText = new Label(DataGenConstant.ABOUT_CONTENT); aboutRichText.setContentMode(Label.CONTENT_XHTML); about.addComponent(aboutRichText); //About Tab content end //Help Tab content start VerticalLayout help = new VerticalLayout(); help.setMargin(true); Label helpText = new Label(DataGenConstant.HELP_CONTENT); helpText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpText); Embedded helpScreen = new Embedded(); helpScreen.setSource(DataGenConstant.HELP_SCREEN); help.addComponent(helpScreen); Label helpStepsText = new Label(DataGenConstant.HELP_CONTENT_STEPS); helpStepsText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpStepsText); //Help Tab content end //Add the respective contents to the tab sheet tabSheet.addTab(generator, "Generator", DataGenConstant.HOME_ICON); executorTab = tabSheet.addTab(executor, "Executor", DataGenConstant.EXECUTOR_ICON); explorerTab = tabSheet.addTab(explorer, "Explorer", DataGenConstant.EXPLORER_ICON); tabSheet.addTab(about, "About", DataGenConstant.ABOUT_ICON); tabSheet.addTab(help, "Help", DataGenConstant.HELP_ICON); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); content.addComponent(tabSheet); rootLayout.addComponent(content); rootLayout.setExpandRatio(content, 1); log.debug("DataGenApplication - buildMainLayout() end"); }
From source file:com.freebox.engeneering.application.web.common.ApplicationLayout.java
License:Apache License
/** * Initializes view layout when system enters 'initView' action state. */*from w w w. j a v a2 s . c om*/ * @param event - state event. */ public void initView(@SuppressWarnings("rawtypes") StateEvent event) { final HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); content.setStyleName("main-view"); final HorizontalSplitPanel leftSplitPanel = new HorizontalSplitPanel(); leftSplitPanel.setSplitPosition(20, Sizeable.Unit.PERCENTAGE); final ComponentContainer leftSideBar = createPlaceholder(StateLayout.LEFT_SIDE_BAR); leftSideBar.setSizeFull(); content.addComponent(leftSideBar, 0); final VerticalLayout verticalLayoutContent = new VerticalLayout(); verticalLayoutContent.setStyleName("freebox-view"); verticalLayoutContent.addComponent(createPlaceholder(StateLayout.HEADER)); verticalLayoutContent.setSpacing(true); final ComponentContainer layoutContent = createPlaceholder(StateLayout.CONTENT); layoutContent.setSizeFull(); verticalLayoutContent.addComponent(layoutContent); verticalLayoutContent.setSizeFull(); //verticalLayoutContent.addComponent(createPlaceholder(StateLayout.FOOTER)); verticalLayoutContent.setExpandRatio(layoutContent, 8f); content.addComponent(verticalLayoutContent, 1); content.setExpandRatio(leftSideBar, 1.0f); content.setExpandRatio(verticalLayoutContent, 9f); setView(content); }
From source file:com.github.djabry.platform.vaadin.ui.MainUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSizeFull();//from w w w. ja v a 2s . c o m setContent(rootLayout); BannerView banner = bannerPresenter.getView(); rootLayout.addComponent(banner); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setSizeFull(); body = new VerticalLayout(); body.setSizeFull(); Navigator navigator = new Navigator(this, body); navigator.addProvider(vP); this.setNavigator(navigator); SideBarView sidebarView = sideBarPresenter.getView(); mainLayout.addComponent(sidebarView); mainLayout.addComponent(body); rootLayout.addComponent(mainLayout); rootLayout.setExpandRatio(mainLayout, 10); sidebarView.setWidth(150, Unit.PIXELS); mainLayout.setExpandRatio(body, 10); //rootLayout.setSplitPosition(150, Unit.PIXELS); navigator.navigateTo(LoginView.VIEW_NAME); eventBus.publish(EventScope.SESSION, this, Action.START); }
From source file:com.github.fbhd.AbstractSideBarUI.java
@Override protected void init(VaadinRequest vaadinRequest) { getPage().setTitle("fbhd"); final HorizontalLayout rootLayout = new HorizontalLayout(); rootLayout.setSizeFull(); setContent(rootLayout);// w w w. j a va 2s .c o m final VerticalLayout viewContainer = new VerticalLayout(); viewContainer.setSizeFull(); final Navigator navigator = new Navigator(this, viewContainer); navigator.setErrorView(new ErrorView()); navigator.addProvider(viewProvider); setNavigator(navigator); rootLayout.addComponent(getSideBar()); rootLayout.addComponent(viewContainer); rootLayout.setExpandRatio(viewContainer, 1.0f); }
From source file:com.github.moscaville.contactsdb.AbstractSideBarUI.java
License:Apache License
@Override protected void init(VaadinRequest vaadinRequest) { getPage().setTitle("ContactsDb"); final HorizontalLayout rootLayout = new HorizontalLayout(); rootLayout.setSizeFull(); setContent(rootLayout);//from w w w. j ava2 s . c om final VerticalLayout viewContainer = new VerticalLayout(); viewContainer.setSizeFull(); final Navigator navigator = new Navigator(this, viewContainer); navigator.setErrorView(new ErrorView()); navigator.addProvider(viewProvider); setNavigator(navigator); rootLayout.addComponent(getSideBar()); rootLayout.addComponent(viewContainer); rootLayout.setExpandRatio(viewContainer, 1.0f); }
From source file:com.github.peholmst.springsecuritydemo.ui.LoginView.java
License:Apache License
@SuppressWarnings("serial") protected void init() { final Panel loginPanel = new Panel(); loginPanel.setCaption(getApplication().getMessage("login.title")); ((VerticalLayout) loginPanel.getContent()).setSpacing(true); final TextField username = new TextField(getApplication().getMessage("login.username")); username.setWidth("100%"); loginPanel.addComponent(username);/* ww w . ja v a 2s . c om*/ final TextField password = new TextField(getApplication().getMessage("login.password")); password.setSecret(true); password.setWidth("100%"); loginPanel.addComponent(password); final Button loginButton = new Button(getApplication().getMessage("login.button")); loginButton.setStyleName("primary"); // TODO Make it possible to submit the form by pressing <Enter> in any // of the text fields loginPanel.addComponent(loginButton); ((VerticalLayout) loginPanel.getContent()).setComponentAlignment(loginButton, Alignment.MIDDLE_RIGHT); loginButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { final Authentication auth = new UsernamePasswordAuthenticationToken(username.getValue(), password.getValue()); try { if (logger.isDebugEnabled()) { logger.debug("Attempting authentication for user '" + auth.getName() + "'"); } Authentication returned = getAuthenticationManager().authenticate(auth); if (logger.isDebugEnabled()) { logger.debug("Authentication for user '" + auth.getName() + "' succeeded"); } fireEvent(new LoginEvent(LoginView.this, returned)); } catch (BadCredentialsException e) { if (logger.isDebugEnabled()) { logger.debug("Bad credentials for user '" + auth.getName() + "'", e); } getWindow().showNotification(getApplication().getMessage("login.badCredentials.title"), getApplication().getMessage("login.badCredentials.descr"), Notification.TYPE_WARNING_MESSAGE); } catch (DisabledException e) { if (logger.isDebugEnabled()) { logger.debug("Account disabled for user '" + auth.getName() + "'", e); } getWindow().showNotification(getApplication().getMessage("login.disabled.title"), getApplication().getMessage("login.disabled.descr"), Notification.TYPE_WARNING_MESSAGE); } catch (LockedException e) { if (logger.isDebugEnabled()) { logger.debug("Account locked for user '" + auth.getName() + "'", e); } getWindow().showNotification(getApplication().getMessage("login.locked.title"), getApplication().getMessage("login.locked.descr"), Notification.TYPE_WARNING_MESSAGE); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("Error while attempting authentication for user '" + auth.getName() + "'"); } ExceptionUtils.handleException(getWindow(), e); } } }); HorizontalLayout languages = new HorizontalLayout(); languages.setSpacing(true); final Button.ClickListener languageListener = new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Locale locale = (Locale) event.getButton().getData(); if (logger.isDebugEnabled()) { logger.debug("Changing locale to [" + locale + "] and restarting the application"); } getApplication().setLocale(locale); getApplication().close(); } }; for (Locale locale : getApplication().getSupportedLocales()) { if (!getLocale().equals(locale)) { final Button languageButton = new Button(getApplication().getLocaleDisplayName(locale)); languageButton.setStyleName(Button.STYLE_LINK); languageButton.setData(locale); languageButton.addListener(languageListener); languages.addComponent(languageButton); } } loginPanel.addComponent(languages); loginPanel.setWidth("300px"); final HorizontalLayout viewLayout = new HorizontalLayout(); viewLayout.addComponent(loginPanel); viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); viewLayout.setSizeFull(); viewLayout.setMargin(true); setCompositionRoot(viewLayout); setSizeFull(); }
From source file:com.github.tempora.view.MainView.java
License:Apache License
public MainView() { VerticalLayout vlayout = new VerticalLayout(); vlayout.addStyleName("outlined"); vlayout.addStyleName("bg"); vlayout.setSizeFull();//from ww w. j av a2 s . c o m vlayout.setMargin(true); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.addStyleName("outlined"); hlayout.setSizeFull(); setContent(vlayout); // Title Label caption = new Label("Tempora"); caption.setStyleName("logo-label", true); caption.setWidth(null); vlayout.addComponent(caption); vlayout.setExpandRatio(caption, 0.2f); vlayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); vlayout.addComponent(hlayout); vlayout.setExpandRatio(hlayout, 0.7f); // // General information about the User's mailbox // final Panel generalInfoPanel = new Panel("<center>General Information</center>"); generalInfoPanel.addStyleName("frame-bg-general-info"); generalInfoPanel.setSizeFull(); this.currentHistoryId = new Label("0"); currentHistoryId.setStyleName("general-info-count", true); currentHistoryId.setCaption("History ID"); this.messagesTotal = new Label("0"); messagesTotal.setStyleName("general-info-count", true); messagesTotal.setCaption("Messages Total"); this.threadsTotal = new Label("0"); threadsTotal.setCaption("Threads Total"); threadsTotal.setStyleName("general-info-count", true); FormLayout mailboxInfoLayout = new FormLayout(messagesTotal, currentHistoryId, threadsTotal); VerticalLayout mailboxInfoMainLayout = new VerticalLayout(mailboxInfoLayout); mailboxInfoMainLayout.setSizeFull(); mailboxInfoMainLayout.setMargin(true); generalInfoPanel.setContent(mailboxInfoMainLayout); // // Stats // final Panel statsPanel = new Panel("<center>Statistics</center>"); statsPanel.addStyleName("frame-bg-stats"); statsPanel.setSizeFull(); this.bodyAvgSize = new Label("0"); bodyAvgSize.setCaption("Body Avg. Size"); bodyAvgSize.setStyleName("stats-count", true); FormLayout statsLayout = new FormLayout(bodyAvgSize); VerticalLayout statsMainLayout = new VerticalLayout(statsLayout); statsMainLayout.setSizeFull(); statsMainLayout.setMargin(true); statsPanel.setContent(statsMainLayout); // // Top 5 // Panel top5Panel = new Panel("<center>Top 5</center>"); top5Panel.addStyleName("frame-bg-top5"); // Top 5 Senders Panel top5SendersPanel = new Panel("<center>Senders</center>"); top5SendersPanel.addStyleName("frame-bg-top5"); top5SendersPanel.setSizeFull(); this.top5Senders = new Label("NO DATA", ContentMode.PREFORMATTED); top5Senders.setSizeUndefined(); top5SendersPanel.setContent(top5Senders); // Top 5 Title Tags Panel top5TitleTagsPanel = new Panel("<center>Title Tags</center>"); top5TitleTagsPanel.addStyleName("frame-bg-top5"); top5TitleTagsPanel.setSizeFull(); this.top5TitleTags = new Label("NO DATA", ContentMode.PREFORMATTED); top5TitleTags.setSizeUndefined(); top5TitleTagsPanel.setContent(top5TitleTags); top5Panel.setSizeFull(); VerticalLayout top5MainLayout = new VerticalLayout(top5SendersPanel, top5TitleTagsPanel); top5MainLayout.setMargin(true); top5MainLayout.setSpacing(true); top5MainLayout.setSizeFull(); top5MainLayout.setComponentAlignment(top5SendersPanel, Alignment.MIDDLE_CENTER); top5MainLayout.setComponentAlignment(top5TitleTagsPanel, Alignment.MIDDLE_CENTER); top5Panel.setContent(top5MainLayout); hlayout.setSpacing(true); hlayout.addComponent(generalInfoPanel); hlayout.addComponent(statsPanel); hlayout.addComponent(top5Panel); this.currentUserEmail = new Label("-"); currentUserEmail.setCaption("Email"); Button reloadButton = new Button("\u27F3 Reload"); reloadButton.addClickListener(e -> { getSession().getSession().invalidate(); getUI().getPage().reload(); }); HorizontalLayout infoHLayout = new HorizontalLayout(); infoHLayout.addStyleName("outlined"); infoHLayout.setSizeFull(); infoHLayout.setSpacing(true); infoHLayout.setMargin(true); infoHLayout.addComponent(reloadButton); reloadButton.setWidth(null); infoHLayout.setComponentAlignment(reloadButton, Alignment.BOTTOM_LEFT); infoHLayout.addComponent(currentUserEmail); currentUserEmail.setWidth(null); infoHLayout.setComponentAlignment(currentUserEmail, Alignment.BOTTOM_RIGHT); vlayout.addComponent(infoHLayout); vlayout.setExpandRatio(infoHLayout, 0.5f); }