List of usage examples for com.vaadin.ui CssLayout CssLayout
public CssLayout()
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private CssLayout buildLoginInformation() { CssLayout loginInformation = new CssLayout(); loginInformation.setStyleName("login-information"); VerticalLayout innerLayout = new VerticalLayout(); innerLayout.setSizeFull();/*from w w w . ja v a 2s.c o m*/ Image img = new Image(null, new ThemeResource("img/sormas-logo-big.png")); img.setHeight(240, Unit.PIXELS); innerLayout.addComponent(img); innerLayout.setComponentAlignment(img, Alignment.TOP_CENTER); innerLayout.setExpandRatio(img, 0); Label loginInfoText = new Label("<h1>SORMAS</h1>" + "<h2 style='color:white'>Surveillance, Outbreak Response Management and Analysis System</h2>" + "<h3 style='color:white; text-transform:uppercase'>● Disease Prevention<br>● Disease Detection<br>● Outbreak Response</h3>", ContentMode.HTML); loginInfoText.setWidth(100, Unit.PERCENTAGE); innerLayout.addComponent(loginInfoText); innerLayout.setExpandRatio(loginInfoText, 1); Label loginInfoCopyright = new Label(" 2019 SORMAS. All Rights Reserved."); loginInfoCopyright.setWidth(100, Unit.PERCENTAGE); innerLayout.addComponent(loginInfoCopyright); innerLayout.setExpandRatio(loginInfoCopyright, 0); innerLayout.setComponentAlignment(loginInfoCopyright, Alignment.BOTTOM_LEFT); loginInformation.addComponent(innerLayout); return loginInformation; }
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private CssLayout buildLoginSidebarLayout() { CssLayout loginSidebarLayout = new CssLayout(); loginSidebarLayout.setStyleName("login-sidebar"); Label htmlLabel = new Label(); htmlLabel.setContentMode(ContentMode.HTML); Path customHtmlDirectory = Paths.get(FacadeProvider.getConfigFacade().getCustomFilesPath()); Path filePath = customHtmlDirectory.resolve("loginsidebar.html"); try {//from w w w. j av a 2 s . c om byte[] encoded = Files.readAllBytes(filePath); htmlLabel.setValue(new String(encoded, "UTF-8")); } catch (IOException e) { htmlLabel.setValue(""); } loginSidebarLayout.addComponent(htmlLabel); return loginSidebarLayout; }
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private CssLayout buildLoginDetailsLayout() { CssLayout loginDetailsLayout = new CssLayout(); loginDetailsLayout.setStyleName("login-details"); Label htmlLabel = new Label(); htmlLabel.setContentMode(ContentMode.HTML); Path customHtmlDirectory = Paths.get(FacadeProvider.getConfigFacade().getCustomFilesPath()); Path filePath = customHtmlDirectory.resolve("logindetails.html"); try {/*from w w w .j av a2 s . com*/ byte[] encoded = Files.readAllBytes(filePath); htmlLabel.setValue(new String(encoded, "UTF-8")); } catch (IOException e) { htmlLabel.setValue(""); } loginDetailsLayout.addComponent(htmlLabel); return loginDetailsLayout; }
From source file:de.symeda.sormas.ui.MainScreen.java
License:Open Source License
public MainScreen(SormasUI ui) { CssLayout viewContainer = new CssLayout(); viewContainer.setSizeFull();/*from w ww . j a v a 2s .com*/ viewContainer.addStyleName("sormas-content"); final Navigator navigator = new Navigator(ui, viewContainer); navigator.setErrorProvider(new ViewProvider() { @Override public String getViewName(String viewAndParameters) { return viewAndParameters; } @Override public View getView(String viewName) { try { // Add new views to this clause to make sure that the right error page is shown if (viewName.equals(SurveillanceDashboardView.VIEW_NAME) || viewName.equals(ContactsDashboardView.VIEW_NAME) || viewName.equals(TasksView.VIEW_NAME) || viewName.equals(CasesView.VIEW_NAME) || viewName.equals(ContactsView.VIEW_NAME) || viewName.equals(EventsView.VIEW_NAME) || viewName.equals(SamplesView.VIEW_NAME) || viewName.equals(ReportsView.VIEW_NAME) || viewName.equals(StatisticsView.VIEW_NAME) || viewName.equals(UsersView.VIEW_NAME) || viewName.equals(OutbreaksView.VIEW_NAME) || viewName.equals(RegionsView.VIEW_NAME) || viewName.equals(DistrictsView.VIEW_NAME) || viewName.equals(CommunitiesView.VIEW_NAME) || viewName.equals(HealthFacilitiesView.VIEW_NAME) || viewName.equals(LaboratoriesView.VIEW_NAME) || viewName.equals(PointsOfEntryView.VIEW_NAME) || viewName.equals(UserRightsView.VIEW_NAME)) { return AccessDeniedView.class.newInstance(); } else { return ErrorView.class.newInstance(); } } catch (Exception e) { throw new RuntimeException(e); } } }); menu = new Menu(navigator); if (UserProvider.getCurrent().hasUserRight(UserRight.DASHBOARD_VIEW)) { ControllerProvider.getDashboardController().registerViews(navigator); } if (UserProvider.getCurrent().hasUserRight(UserRight.DASHBOARD_SURVEILLANCE_ACCESS)) { menu.addView(SurveillanceDashboardView.class, AbstractDashboardView.ROOT_VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuDashboard), VaadinIcons.DASHBOARD); } else if (UserProvider.getCurrent().hasUserRight(UserRight.DASHBOARD_CONTACT_ACCESS)) { menu.addView(ContactsDashboardView.class, AbstractDashboardView.ROOT_VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuDashboard), VaadinIcons.DASHBOARD); } if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_VIEW)) { menu.addView(TasksView.class, TasksView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuTasks), VaadinIcons.TASKS); } if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) { ControllerProvider.getCaseController().registerViews(navigator); menu.addView(CasesView.class, CasesView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuCases), VaadinIcons.EDIT); } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) { ControllerProvider.getContactController().registerViews(navigator); menu.addView(ContactsView.class, ContactsView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuContacts), VaadinIcons.HAND); } if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW)) { ControllerProvider.getEventController().registerViews(navigator); menu.addView(EventsView.class, EventsView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuEvents), VaadinIcons.PHONE); } if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_VIEW)) { ControllerProvider.getSampleController().registerViews(navigator); menu.addView(SamplesView.class, SamplesView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuSamples), VaadinIcons.DATABASE); } if (UserProvider.getCurrent().hasUserRight(UserRight.WEEKLYREPORT_VIEW)) { menu.addView(ReportsView.class, ReportsView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuReports), VaadinIcons.FILE_TEXT); } if (UserProvider.getCurrent().hasUserRight(UserRight.STATISTICS_ACCESS)) { ControllerProvider.getStatisticsController().registerViews(navigator); menu.addView(StatisticsView.class, AbstractStatisticsView.ROOT_VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuStatistics), VaadinIcons.BAR_CHART); } if (UserProvider.getCurrent().hasUserRight(UserRight.USER_VIEW)) { menu.addView(UsersView.class, UsersView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuUsers), VaadinIcons.USERS); } if (UserProvider.getCurrent().hasUserRight(UserRight.CONFIGURATION_ACCESS)) { AbstractConfigurationView.registerViews(navigator); menu.addView(OutbreaksView.class, AbstractConfigurationView.ROOT_VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuConfiguration), VaadinIcons.COGS); } menu.addView(AboutView.class, AboutView.VIEW_NAME, I18nProperties.getCaption(Captions.mainMenuAbout), VaadinIcons.INFO_CIRCLE); navigator.addViewChangeListener(viewChangeListener); ui.setNavigator(navigator); addComponent(menu); addComponent(viewContainer); setExpandRatio(viewContainer, 1); setSpacing(false); setMargin(false); setSizeFull(); }
From source file:de.symeda.sormas.ui.Menu.java
License:Open Source License
public Menu(Navigator navigator) { this.navigator = navigator; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.setDefaultComponentAlignment(Alignment.TOP_CENTER); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);//from w w w. j a v a 2 s .c o m Label title = new Label("SORMAS"); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/sormas-logo.png")); CssStyles.style(image, ValoTheme.MENU_LOGO, ValoTheme.BUTTON_LINK); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { SormasUI.get().getNavigator().navigateTo(SurveillanceDashboardView.VIEW_NAME); } }); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item MenuBar logoutMenu = new MenuBar(); logoutMenu.addItem(I18nProperties.getCaption(Captions.actionLogout) + " (" + UserProvider.getCurrent().getUserName() + ")", VaadinIcons.SIGN_OUT, new Command() { @Override public void menuSelected(MenuItem selectedItem) { LoginHelper.logout(); } }); logoutMenu.addStyleName("user-menu"); menuPart.addComponent(logoutMenu); // button for toggling the visibility of the menu when on a small screen final Button showMenu = new Button(I18nProperties.getCaption(Captions.menu), new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(VALO_MENU_TOGGLE); showMenu.setIcon(VaadinIcons.MENU); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); }
From source file:de.symeda.sormas.ui.samples.SampleEditForm.java
License:Open Source License
private void initializeRequestedTests() { // Yes/No fields for requesting pathogen/additional tests OptionGroup pathogenTestingRequestedField = addField(SampleDto.PATHOGEN_TESTING_REQUESTED, OptionGroup.class); CssStyles.style(pathogenTestingRequestedField, CssStyles.OPTIONGROUP_CAPTION_AREA_INLINE); pathogenTestingRequestedField.setWidthUndefined(); OptionGroup additionalTestingRequestedField = addField(SampleDto.ADDITIONAL_TESTING_REQUESTED, OptionGroup.class); CssStyles.style(additionalTestingRequestedField, CssStyles.OPTIONGROUP_CAPTION_AREA_INLINE); additionalTestingRequestedField.setWidthUndefined(); // CheckBox groups to select the requested pathogen/additional tests OptionGroup requestedPathogenTestsField = addField(SampleDto.REQUESTED_PATHOGEN_TESTS, OptionGroup.class); CssStyles.style(requestedPathogenTestsField, CssStyles.OPTIONGROUP_CHECKBOXES_HORIZONTAL); requestedPathogenTestsField.setMultiSelect(true); requestedPathogenTestsField.addItems((Object[]) PathogenTestType.values()); requestedPathogenTestsField.removeItem(PathogenTestType.OTHER); requestedPathogenTestsField.setCaption(null); OptionGroup requestedAdditionalTestsField = addField(SampleDto.REQUESTED_ADDITIONAL_TESTS, OptionGroup.class); CssStyles.style(requestedAdditionalTestsField, CssStyles.OPTIONGROUP_CHECKBOXES_HORIZONTAL); requestedAdditionalTestsField.setMultiSelect(true); requestedAdditionalTestsField.addItems((Object[]) AdditionalTestType.values()); requestedAdditionalTestsField.setCaption(null); // Text fields to type in other tests TextField requestedOtherPathogenTests = addField(SampleDto.REQUESTED_OTHER_PATHOGEN_TESTS, TextField.class); TextField requestedOtherAdditionalTests = addField(SampleDto.REQUESTED_OTHER_ADDITIONAL_TESTS, TextField.class); // The code below relies on getValue() to return the sample of the form and therefore has to be delayed until the sample is set addValueChangeListener(e -> {//ww w .j av a2s . c o m if (!requestedTestsInitialized) { if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EDIT_NOT_OWNED) || UserProvider.getCurrent().getUuid().equals(getValue().getReportingUser().getUuid())) { // Information texts for users that can edit the requested tests Label requestedPathogenInfoLabel = new Label( I18nProperties.getString(Strings.infoSamplePathogenTesting)); getContent().addComponent(requestedPathogenInfoLabel, PATHOGEN_TESTING_INFO_LOC); Label requestedAdditionalInfoLabel = new Label( I18nProperties.getString(Strings.infoSampleAdditionalTesting)); getContent().addComponent(requestedAdditionalInfoLabel, ADDITIONAL_TESTING_INFO_LOC); // Set initial visibility requestedPathogenTestsField .setVisible(Boolean.TRUE.equals(getValue().getPathogenTestingRequested())); requestedPathogenInfoLabel .setVisible(Boolean.TRUE.equals(getValue().getPathogenTestingRequested())); requestedOtherPathogenTests .setVisible(Boolean.TRUE.equals(getValue().getPathogenTestingRequested())); // CheckBoxes should be hidden when no tests are requested pathogenTestingRequestedField.addValueChangeListener(f -> { requestedPathogenInfoLabel.setVisible(f.getProperty().getValue().equals(Boolean.TRUE)); requestedPathogenTestsField.setVisible(f.getProperty().getValue().equals(Boolean.TRUE)); requestedOtherPathogenTests.setVisible(f.getProperty().getValue().equals(Boolean.TRUE)); }); if (!UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW)) { // Hide additional testing fields when user is not allowed to see them additionalTestingRequestedField.setVisible(false); requestedAdditionalTestsField.setVisible(false); requestedAdditionalInfoLabel.setVisible(false); requestedOtherAdditionalTests.setVisible(false); } else { requestedAdditionalTestsField .setVisible(Boolean.TRUE.equals(getValue().getAdditionalTestingRequested())); requestedAdditionalInfoLabel .setVisible(Boolean.TRUE.equals(getValue().getAdditionalTestingRequested())); requestedOtherAdditionalTests .setVisible(Boolean.TRUE.equals(getValue().getAdditionalTestingRequested())); additionalTestingRequestedField.addValueChangeListener(f -> { requestedAdditionalInfoLabel .setVisible(f.getProperty().getValue().equals(Boolean.TRUE)); requestedAdditionalTestsField .setVisible(f.getProperty().getValue().equals(Boolean.TRUE)); requestedOtherAdditionalTests .setVisible(f.getProperty().getValue().equals(Boolean.TRUE)); }); } } else { // If the user can't edit the sample, they see a read-only list of requested tests setVisible(false, SampleDto.PATHOGEN_TESTING_REQUESTED, SampleDto.ADDITIONAL_TESTING_REQUESTED, SampleDto.REQUESTED_PATHOGEN_TESTS, SampleDto.REQUESTED_ADDITIONAL_TESTS); // Display a label for every requested pathogen test or hide the whole section if no tests have been requested if (Boolean.TRUE.equals(getValue().getPathogenTestingRequested()) && !getValue().getRequestedPathogenTests().isEmpty()) { Label pathogenTestsHeading = new Label( I18nProperties.getString(Strings.headingRequestedPathogenTests)); CssStyles.style(pathogenTestsHeading, CssStyles.LABEL_BOLD, CssStyles.LABEL_SECONDARY, CssStyles.VSPACE_4); getContent().addComponent(pathogenTestsHeading, PATHOGEN_TESTING_READ_HEADLINE_LOC); CssLayout requestedPathogenTestsLayout = new CssLayout(); CssStyles.style(requestedPathogenTestsLayout, CssStyles.VSPACE_3); for (PathogenTestType testType : getValue().getRequestedPathogenTests()) { Label testLabel = new Label(testType.toString()); testLabel.setWidthUndefined(); CssStyles.style(testLabel, CssStyles.LABEL_ROUNDED_CORNERS, CssStyles.LABEL_BACKGROUND_FOCUS_LIGHT, CssStyles.VSPACE_4, CssStyles.HSPACE_RIGHT_4); requestedPathogenTestsLayout.addComponent(testLabel); } getContent().addComponent(requestedPathogenTestsLayout, REQUESTED_PATHOGEN_TESTS_READ_LOC); } // If the user can view additional tests, display a label for every requested additional test // or hide the whole section if no tests have been requested if (UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW) && Boolean.TRUE.equals(getValue().getAdditionalTestingRequested()) && !getValue().getRequestedAdditionalTests().isEmpty()) { Label additionalTestsHeading = new Label( I18nProperties.getString(Strings.headingRequestedAdditionalTests)); CssStyles.style(additionalTestsHeading, CssStyles.LABEL_BOLD, CssStyles.LABEL_SECONDARY, CssStyles.VSPACE_4); getContent().addComponent(additionalTestsHeading, ADDITIONAL_TESTING_READ_HEADLINE_LOC); CssLayout requestedAdditionalTestsLayout = new CssLayout(); CssStyles.style(requestedAdditionalTestsLayout, CssStyles.VSPACE_3); for (AdditionalTestType testType : getValue().getRequestedAdditionalTests()) { Label testLabel = new Label(testType.toString()); testLabel.setWidthUndefined(); CssStyles.style(testLabel, CssStyles.LABEL_ROUNDED_CORNERS, CssStyles.LABEL_BACKGROUND_FOCUS_LIGHT, CssStyles.VSPACE_4, CssStyles.HSPACE_RIGHT_4); requestedAdditionalTestsLayout.addComponent(testLabel); } getContent().addComponent(requestedAdditionalTestsLayout, REQUESTED_ADDITIONAL_TESTS_READ_LOC); } } } requestedTestsInitialized = true; }); }
From source file:de.symeda.sormas.ui.SubMenu.java
License:Open Source License
public SubMenu() { setWidth(100, Unit.PERCENTAGE);/* w ww . jav a 2 s. c om*/ setHeightUndefined(); setPrimaryStyleName("v-tabsheet"); menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName("v-tabsheet-tabcontainer"); menuItemsLayout.setWidth(100, Unit.PERCENTAGE); menuItemsLayout.setHeightUndefined(); addComponent(menuItemsLayout); }
From source file:de.symeda.sormas.ui.SubMenu.java
License:Open Source License
public void addView(final String name, String caption, String params, boolean isBackNavigation) { String target = "#!" + name + (params != null ? "/" + params : ""); CssLayout tabItemCell = new CssLayout(); tabItemCell.setSizeUndefined();//w w w .j av a 2 s. c o m tabItemCell.setPrimaryStyleName("v-tabsheet-tabitemcell"); CssLayout tabItem = new CssLayout(); tabItem.setSizeUndefined(); tabItem.setPrimaryStyleName("v-tabsheet-tabitem"); if (isBackNavigation) { tabItem.addStyleName("back"); } tabItemCell.addComponent(tabItem); Link link = new Link(caption, new ExternalResource(target)); link.addStyleName("v-caption"); if (isBackNavigation) link.setIcon(VaadinIcons.ARROW_CIRCLE_LEFT); tabItem.addComponent(link); menuItemsLayout.addComponent(tabItemCell); viewMenuItemMap.put(name, tabItem); }
From source file:de.symeda.sormas.ui.SubMenu.java
License:Open Source License
public void addView(final String name, String caption, LayoutClickListener onClick) { CssLayout tabItemCell = new CssLayout(); tabItemCell.setSizeUndefined();// w w w. j a v a2s . c o m tabItemCell.setPrimaryStyleName("v-tabsheet-tabitemcell"); CssLayout tabItem = new CssLayout(); tabItem.setSizeUndefined(); tabItem.setPrimaryStyleName("v-tabsheet-tabitem"); tabItemCell.addComponent(tabItem); Link link = new Link(caption, null); link.addStyleName("v-caption"); tabItem.addComponent(link); tabItem.addLayoutClickListener(onClick); tabItem.addLayoutClickListener((e) -> { this.setActiveView(name); }); menuItemsLayout.addComponent(tabItemCell); viewMenuItemMap.put(name, tabItem); }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultFormView.java
License:Apache License
@SuppressWarnings("serial") private void createFooterAndPopulateActions(FormActions actions) { CssLayout buttons = new CssLayout(); buttons.setStyleName("actions"); boolean allHidden = true; for (final FormAction action : actions) { final Button button = new Button(action.getTitle()); button.setDisableOnClick(true);//from w w w . ja va2 s . c om button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { presenter.executeAction(action); } finally { button.setEnabled(true); } } }); if (action.getActionHandler() instanceof SearchFormAction) { if (searchAction == null) { searchAction = action; // button.setClickShortcut(KeyCode.ENTER); } } if (action.isHidden()) { button.setVisible(false); } else { allHidden = false; } buttons.addComponent(button); } if (!allHidden) { rootLayout.addComponent(buttons); } }