List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
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 {// w ww. j a v a 2 s .com 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 ww w .java 2s. 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.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 -> {//from w w w . j av a 2s .co 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 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 a v 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();/*from w ww .jav a 2 s . c om*/ 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 . j a v a2 s . c o m 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); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTableView.java
License:Apache License
private Layout initButtonBar() { CssLayout buttonbar = new CssLayout(); buttonbar.setStyleName("actions"); if (tableModel.isEditable()) { if (tableModel.isModeChangeable()) { editButton = new Button(getMessage("portlet.crud.button.editMode")); editButton.setEnabled(true); buttonbar.addComponent(editButton); } else if (!tableModel.isFormEditEnabled()) { saveButton = new Button(getMessage("portlet.crud.button.save")); saveButton.setVisible(false); saveButton.setEnabled(true); buttonbar.addComponent(saveButton); }//w w w. j a va 2 s . co m revertButton = new Button(getMessage("portlet.crud.button.reset")); revertButton.setVisible(false); revertButton.setEnabled(true); buttonbar.addComponent(revertButton); insertButton = new Button(getMessage("portlet.crud.button.blankRow")); insertButton.setVisible(false); insertButton.setEnabled(presenter.isInsertable()); buttonbar.addComponent(insertButton); removeButton = new Button(getMessage("portlet.crud.button.removeRow")); removeButton.setVisible(false); removeButton.setEnabled(presenter.isDeleteable()); buttonbar.addComponent(removeButton); } if (presenter.isExcelExport()) { excelExportButton = new Button("Excel"); buttonbar.addComponent(excelExportButton); } if (presenter.isCSVExport()) { csvExportButton = new Button("CSV"); buttonbar.addComponent(csvExportButton); } for (TableAction action : tableModel.getActions()) { Button actionButton = new Button(action.getTitle()); if (action.getId() != null) { actionButtons.put(action.getId(), actionButton); } else { actionButtons.put("table-action-" + tableActionDummyIdCounter++, actionButton); } buttonToTableActionMap.put(actionButton, action); buttonbar.addComponent(actionButton); } return buttonbar; }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public GroupView() { User user = UserUtils.getCurrent();/*from ww w. ja va 2 s. c o m*/ Set<Group> groups = UserUtils.getAllGroups(user); CssLayout newGroupGroup = new CssLayout(); newGroupGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); TextField textFieldNewGroupName = new TextField(); Language.setCustom(Word.GROUP_NAME, s -> textFieldNewGroupName.setPlaceholder(s)); textFieldNewGroupName.setWidth("260px"); textFieldNewGroupName.setMaxLength(255); newGroupGroup.addComponent(textFieldNewGroupName); Button buttonNewGroup = new Button(); buttonNewGroup.setIcon(VaadinIcons.PLUS); buttonNewGroup.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonNewGroup.addClickListener(e -> { TabSheet.Tab newTab = accordion.addTab(createTab(createEmptyGroup(textFieldNewGroupName.getValue())), textFieldNewGroupName.getValue()); accordion.setSelectedTab(newTab); accordion.setWidth("100%"); textFieldNewGroupName.clear(); }); newGroupGroup.addComponent(buttonNewGroup); textFieldNewGroupName .addFocusListener(f -> buttonNewGroup.setClickShortcut(ShortcutAction.KeyCode.ENTER, null)); textFieldNewGroupName.addBlurListener(f -> buttonNewGroup.removeClickShortcut()); groups.forEach(g -> { accordion.addTab(createTab(g), g.getName()); }); addComponents(newGroupGroup, accordion); //SESSIONS.put(user, this); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
private Component getProfiles(Group g) { VerticalLayout layoutRootProfiles = new VerticalLayout(); layoutRootProfiles.setMargin(false); layoutRootProfiles.setWidth("100%"); Panel panelProfiles = new Panel(Language.get(Word.PROFILES)); Language.setCustom(Word.PROFILES, s -> panelProfiles.setCaption(s)); panelProfiles.setWidth("100%"); panelProfiles.setHeight("200px"); VerticalLayout layoutProfiles = new VerticalLayout(); mapLayoutProfiles.put(g, layoutProfiles); layoutProfiles.setWidth("100%"); refreshProfiles(g, layoutProfiles);// w w w . j a v a 2s .com panelProfiles.setContent(layoutProfiles); layoutRootProfiles.addComponent(panelProfiles); if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) { CssLayout addProfileGroup = new CssLayout(); addProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); addProfileGroup.setWidth("100%"); TextField textFieldAddProfile = new TextField(); Language.setCustom(Word.PROFILE_NAME, s -> textFieldAddProfile.setPlaceholder(s)); textFieldAddProfile.setMaxLength(255); textFieldAddProfile.setWidth("35%"); addProfileGroup.addComponent(textFieldAddProfile); Button buttonAddProfile = new Button(); buttonAddProfile.setIcon(VaadinIcons.PLUS); buttonAddProfile.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddProfile.setWidth("15%"); buttonAddProfile.addClickListener(e -> { try { String name = textFieldAddProfile.getValue(); textFieldAddProfile.clear(); Runnable onClose = () -> refreshAll(g); UI.getCurrent().addWindow(GroupProfileWindow.create(g, name, true, onClose)); } catch (UserNotFoundException ex) { VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND)); } }); addProfileGroup.addComponent(buttonAddProfile); layoutRootProfiles.addComponent(addProfileGroup); } return layoutRootProfiles; }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
private Component getMembers(Group g) { VerticalLayout layoutRootMembers = new VerticalLayout(); layoutRootMembers.setMargin(false);//w w w. j av a 2 s .c o m layoutRootMembers.setWidth("100%"); Panel panelMembers = new Panel(Language.get(Word.MEMBERS)); Language.setCustom(Word.MEMBERS, s -> panelMembers.setCaption(s)); panelMembers.setWidth("100%"); panelMembers.setHeight("200px"); VerticalLayout layoutMembers = new VerticalLayout(); mapLayoutMembers.put(g, layoutMembers); layoutMembers.setWidth("100%"); refreshMembers(g, layoutMembers); panelMembers.setContent(layoutMembers); layoutRootMembers.addComponent(panelMembers); if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) { CssLayout addUserGroup = new CssLayout(); addUserGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); addUserGroup.setWidth("100%"); TextField textFieldaddUser = new TextField(); Language.setCustom(Word.USERNAME, s -> textFieldaddUser.setPlaceholder(s)); textFieldaddUser.setMaxLength(255); textFieldaddUser.setWidth("70%"); addUserGroup.addComponent(textFieldaddUser); Button buttonAddUser = new Button(); buttonAddUser.setIcon(VaadinIcons.PLUS); buttonAddUser.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddUser.setWidth("30%"); buttonAddUser.addClickListener(e -> { try { User u = UserUtils.getUser(textFieldaddUser.getValue()); textFieldaddUser.clear(); GroupUtils.addUser(g, u); refreshAll(g); } catch (UserNotFoundException ex) { VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND)); } }); addUserGroup.addComponent(buttonAddUser); layoutRootMembers.addComponent(addUserGroup); } return layoutRootMembers; }